From 92f1ceb3cea8c0ca1a9070d449f25666f05e5640 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Wed, 27 Jun 2018 14:08:24 -0700 Subject: [PATCH] netdev/eapol: removed eapol deauthenticate This removes the need for the eapol/netdev deauthenticate function. netdev_handshake_failed was exposed so device.c could issue the disconnect. --- src/device.c | 5 ++++- src/eapol.c | 11 ----------- src/eapol.h | 5 ----- src/netdev.c | 12 ++---------- src/netdev.h | 2 ++ 5 files changed, 8 insertions(+), 27 deletions(-) diff --git a/src/device.c b/src/device.c index 2bed2efc..56ddfeff 100644 --- a/src/device.c +++ b/src/device.c @@ -657,8 +657,11 @@ static void device_handshake_event(struct handshake_state *hs, /* If we got here, then our PSK works. Save if required */ network_sync_psk(network); break; - case HANDSHAKE_EVENT_COMPLETE: case HANDSHAKE_EVENT_FAILED: + netdev_handshake_failed(device_get_netdev(device), + l_get_u16(event_data)); + break; + case HANDSHAKE_EVENT_COMPLETE: /* * currently we dont care about any other events. The * netdev_connect_cb will notify us when the connection is diff --git a/src/eapol.c b/src/eapol.c index 1de911a9..70722269 100644 --- a/src/eapol.c +++ b/src/eapol.c @@ -42,7 +42,6 @@ struct l_queue *preauths; struct watchlist frame_watches; static uint32_t eapol_4way_handshake_time = 2; -eapol_deauthenticate_func_t deauthenticate = NULL; eapol_rekey_offload_func_t rekey_offload = NULL; eapol_tx_packet_func_t tx_packet = NULL; @@ -756,11 +755,6 @@ static inline void handshake_failed(struct eapol_sm *sm, uint16_t reason_code) { handshake_event(sm->handshake, HANDSHAKE_EVENT_FAILED, &reason_code); - if (deauthenticate) - deauthenticate(sm->handshake->ifindex, - sm->handshake->aa, sm->handshake->spa, - reason_code, sm->user_data); - eapol_sm_free(sm); } @@ -2000,11 +1994,6 @@ void __eapol_set_tx_user_data(void *user_data) tx_user_data = user_data; } -void __eapol_set_deauthenticate_func(eapol_deauthenticate_func_t func) -{ - deauthenticate = func; -} - void __eapol_set_rekey_offload_func(eapol_rekey_offload_func_t func) { rekey_offload = func; diff --git a/src/eapol.h b/src/eapol.h index 2c8a9447..ab557b64 100644 --- a/src/eapol.h +++ b/src/eapol.h @@ -120,10 +120,6 @@ typedef void (*eapol_rekey_offload_func_t)(uint32_t ifindex, typedef void (*eapol_sm_event_func_t)(unsigned int event, const void *event_data, void *user_data); -typedef void (*eapol_deauthenticate_func_t)(uint32_t ifindex, const uint8_t *aa, - const uint8_t *spa, - uint16_t reason_code, - void *user_data); typedef void (*eapol_preauth_cb_t)(const uint8_t *pmk, void *user_data); typedef void (*eapol_preauth_destroy_func_t)(void *user_data); typedef void (*eapol_frame_watch_func_t)(uint16_t proto, const uint8_t *from, @@ -183,7 +179,6 @@ void __eapol_tx_packet(uint32_t ifindex, const uint8_t *dst, uint16_t proto, void __eapol_set_tx_packet_func(eapol_tx_packet_func_t func); void __eapol_set_tx_user_data(void *user_data); -void __eapol_set_deauthenticate_func(eapol_deauthenticate_func_t func); void __eapol_set_rekey_offload_func(eapol_rekey_offload_func_t func); void __eapol_update_replay_counter(uint32_t ifindex, const uint8_t *spa, const uint8_t *aa, uint64_t replay_counter); diff --git a/src/netdev.c b/src/netdev.c index 2b2e25b0..9e669ac4 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -1276,19 +1276,12 @@ invalid_key: netdev_setting_keys_failed(nhs, rc); } -static void netdev_handshake_failed(uint32_t ifindex, - const uint8_t *aa, const uint8_t *spa, - uint16_t reason_code, void *user_data) +void netdev_handshake_failed(struct netdev *netdev, uint16_t reason_code) { struct l_genl_msg *msg; - struct netdev *netdev; - - netdev = netdev_find(ifindex); - if (!netdev) - return; l_error("4-Way handshake failed for ifindex: %d, reason: %u", - ifindex, reason_code); + netdev->index, reason_code); netdev->sm = NULL; @@ -4140,7 +4133,6 @@ bool netdev_init(struct l_genl_family *in, __handshake_set_install_gtk_func(netdev_set_gtk); __handshake_set_install_igtk_func(netdev_set_igtk); - __eapol_set_deauthenticate_func(netdev_handshake_failed); __eapol_set_rekey_offload_func(netdev_set_rekey_offload); __eapol_set_tx_packet_func(netdev_control_port_frame); diff --git a/src/netdev.h b/src/netdev.h index 938dac96..8cc0655f 100644 --- a/src/netdev.h +++ b/src/netdev.h @@ -145,6 +145,8 @@ uint32_t netdev_frame_watch_add(struct netdev *netdev, uint16_t frame_type, void *user_data); bool netdev_frame_watch_remove(struct netdev *netdev, uint32_t id); +void netdev_handshake_failed(struct netdev *netdev, uint16_t reason_code); + struct netdev *netdev_find(int ifindex); uint32_t netdev_watch_add(struct netdev *netdev, netdev_watch_func_t func,