[PATCH 4/8] wpa_supplicant: Disconnect before trying to switch to a different network

Ilan Peer ilan.peer at intel.com
Thu Dec 10 02:56:05 PST 2015


From: Ayala Beker <ayala.beker at intel.com>

Currently, when wpa_supplicant receives bgscan results
with a preferred netwrok, it connects to that network without
disconnecting from the previous one. This might result in an
inconsistent state of upper layers.

Fix this by disconnecting from the current AP before connecting to
the new one.

Signed-off-by: Ayala Beker <ayala.beker at intel.com>
---
 wpa_supplicant/events.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index a7b053d..192b666 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -1574,6 +1574,13 @@ static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s,
 			return 0;
 		}
 
+		if (ssid != wpa_s->current_ssid &&
+		    wpa_s->wpa_state >= WPA_AUTHENTICATING) {
+			wpa_s->own_disconnect_req = 1;
+			wpa_supplicant_deauthenticate(wpa_s,
+						      WLAN_REASON_DEAUTH_LEAVING);
+		}
+
 		if (wpa_supplicant_connect(wpa_s, selected, ssid) < 0) {
 			wpa_dbg(wpa_s, MSG_DEBUG, "Connect failed");
 			return -1;
-- 
1.9.1




More information about the Hostap mailing list