[PATCH] Handle disconnect event while scanning for WPS

Jouni Malinen j
Sat Sep 27 12:41:12 PDT 2014


On Sat, Sep 27, 2014 at 10:33:30PM +0300, Jouni Malinen wrote:
> Would you be able to share a debug log showing a case where this is
> triggered? I'd assume this is with "STA_AUTOCONNECT 0" since that would
> be needed to get wpa_s->disconnected set to 1 on deauthentication event.
> However, when I tested trying to force that, I saw wpa_s->disconnected
> getting cleared immediately in wpas_wps_reassoc() and the following
> disconnection event getting ignored, so wpa_s->disconnected did not get
> set to 1 again.
> 
> Do you have commit d6a36f3956cc49c77376eceaef2e14548ca0bf30
> ('nl80211: Mask out deauth even after own deauth request') included in
> the version that you are testing with?

If I break that mechanism and disable autoconnect, I can reproduce the
issue. I'm not sure how exactly this would happen with that deauth event
ignoring case in place. Or well, maybe there is a driver that ends up
generating multiple disconnection events that somehow is able to bypass
that.

> The autoconnect disabled case is already trying to skip the part of
> setting wpa_s->disconnected through "wpa_s->key_mgmt ==
> WPA_KEY_MGMT_WPS", but maybe that has been broken by some of the newer
> changes. As such, more appropriate fix would likely be to add this
> wpas_wps_searching(wpa_s) as a condition there in
> wpa_supplicant_event_disassoc_finish() for setting disconnected=1 rather
> than in this scan event handling case.

It looks like this is safe to do, so I'm planning on applying following
instead of the proposed change in scan result event processing.


diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -2159,10 +2159,12 @@ static void wpa_supplicant_event_disassoc_finish(struct wpa_supplicant *wpa_s,
 	}
 	if (!wpa_s->disconnected &&
 	    (!wpa_s->auto_reconnect_disabled ||
-	     wpa_s->key_mgmt == WPA_KEY_MGMT_WPS)) {
+	     wpa_s->key_mgmt == WPA_KEY_MGMT_WPS ||
+	     wpas_wps_searching(wpa_s))) {
 		wpa_dbg(wpa_s, MSG_DEBUG, "Auto connect enabled: try to "
-			"reconnect (wps=%d wpa_state=%d)",
+			"reconnect (wps=%d/%d wpa_state=%d)",
 			wpa_s->key_mgmt == WPA_KEY_MGMT_WPS,
+			wpas_wps_searching(wpa_s),
 			wpa_s->wpa_state);
 		if (wpa_s->wpa_state == WPA_COMPLETED &&
 		    wpa_s->current_ssid &&
 
-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the Hostap mailing list