From patchwork Thu Jan 5 15:09:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [NOT-WORKING] wpa_supplicant: reinit peer sm in case of reconnection Date: Thu, 05 Jan 2012 05:09:05 -0000 From: Antonio Quartulli X-Patchwork-Id: 134491 Message-Id: <1325776145-5057-1-git-send-email-ordex@autistici.org> To: hostap@lists.shmoo.com In case of a node sending a new EAPOL message while the state is WPA_COMPLETED, the state machine has to be reinitialised and the keys have to be reset to permit a new renegotiation Signed-off-by: Antonio Quartulli --- To permit key renegotiation I actually deinit/reinit the ibss_rsn_peer structure associated with a "rebooting" peer. However with this patch, the rebooted node does not receive any EAPOL packet sent by the old one (the opposite works). Any clue about this problem? wpa_supplicant/ibss_rsn.c | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/wpa_supplicant/ibss_rsn.c b/wpa_supplicant/ibss_rsn.c index d4fa39d..ef91068 100644 --- a/wpa_supplicant/ibss_rsn.c +++ b/wpa_supplicant/ibss_rsn.c @@ -17,8 +17,10 @@ #include "common.h" #include "l2_packet/l2_packet.h" #include "rsn_supp/wpa.h" +#include "rsn_supp/wpa_i.h" #include "rsn_supp/wpa_ie.h" #include "ap/wpa_auth.h" +#include "ap/wpa_auth_i.h" #include "wpa_supplicant_i.h" #include "driver_i.h" #include "ibss_rsn.h" @@ -547,6 +549,7 @@ static int ibss_rsn_process_rx_eapol(struct ibss_rsn *ibss_rsn, { int supp; u8 *tmp; + u8 peermac[ETH_ALEN]; supp = ibss_rsn_eapol_dst_supp(buf, len); if (supp < 0) @@ -557,6 +560,26 @@ static int ibss_rsn_process_rx_eapol(struct ibss_rsn *ibss_rsn, return -1; os_memcpy(tmp, buf, len); if (supp) { + if (wpa_sm_get_state(peer->supp) == WPA_COMPLETED) { + memcpy(peermac, peer->addr, ETH_ALEN); + wpa_printf(MSG_DEBUG, "************* RESETTING! %pM\n", peermac); + ibss_rsn_stop(ibss_rsn, peermac); + + wpa_clear_keys(ibss_rsn->wpa_s, peermac); + + ibss_rsn_start(ibss_rsn, peermac); + + for (peer = ibss_rsn->peers; peer; peer = peer->next) { + if (os_memcmp(peermac, peer->addr, ETH_ALEN) == 0) + break; + } + + if (!peer) { + wpa_printf(MSG_DEBUG, "recreated peer not found!\n"); + return -1; + } + } + wpa_printf(MSG_DEBUG, "RSN: IBSS RX EAPOL for Supplicant"); wpa_sm_rx_eapol(peer->supp, peer->addr, tmp, len); } else {