Authentication fails if already authenticated.

Blaise Gassend blaise
Fri Jul 30 16:49:46 PDT 2010


Doing associate-unassociate cycle tests, I discovered a problem with how
the SME handles authentication problems in 0.7.2. Here is the scenario:

1) mac80211 is already authenticated with the AP
2) you try to associate to the AP
3) wpa_driver_nl80211_authenticate tries to authenticate
4) the first authentication request fails with EALREADY wpa_driver_nl80211_authenticate sends a deauthentication request and then tries to authenticate again
5) the deauthenticate response arrives and cancels the association attempt
6) the authenticate response arrives, but nobody is listening anymore.

The following patch fixes the problem, but is a bit hokey as I do not know if we are guaranteed to get a deauthenticate event. It might be preferable to wait for the deauthenticate to complete before retrying the authenticate attempt. It is a bit more involved so I'm curious for feedback from this list before I try this more involved solution.


Index: wpa_supplicant/src/drivers/driver_nl80211.c
===================================================================
--- wpa_supplicant/src/drivers/driver_nl80211.c (revision 31464)
+++ wpa_supplicant/src/drivers/driver_nl80211.c (working copy)
@@ -113,6 +113,8 @@
 
        struct i802_bss first_bss;
 
+        int deauth_before_reauth;
+
 #ifdef HOSTAPD
        int eapol_sock; /* socket for EAPOL frames */
 
@@ -719,6 +721,19 @@
                                    MAC2STR(bssid));
                         return;
                 }
+                
+                if (drv->deauth_before_reauth) {
+                        /*
+                         * Authentication returned EAGAIN so we are doing a
+                         * deauthenticate followed by reauthenticate. We
+                         * can ignore this event.
+                         */
+                        drv->deauth_before_reauth = 0;
+                        wpa_printf(MSG_DEBUG, "nl80211: Deauth received "
+                                   "as expected (from " MACSTR ") -- ignoring",
+                                   MAC2STR(bssid));
+                        return;
+                }
         }
 
        drv->associated = 0;
@@ -2472,6 +2487,7 @@
                         * authentication if we are already authenticated. As a
                         * workaround, force deauthentication and try again.
                         */
+                        drv->deauth_before_reauth = 1;
                        wpa_printf(MSG_DEBUG, "nl80211: Retry authentication "
                                   "after forced deauthentication");
                        wpa_driver_nl80211_deauthenticate(





More information about the Hostap mailing list