From e66bcedd3ea62c1fa72f95cea918483ec5cb84a5 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 10 Jun 2015 15:40:35 +0300 Subject: [PATCH] Do not set own_disconnect_req flag if not connected This fixes some issues where a disconnection event may get ignored if an earlier operation to remove or disable a network resulted in an attempt to disconnect event though no connection was in place. wpa_s->current_ssid != NULL alone is not sufficient to determine that there will be a driver event notifying completion of such disconnection request. Set own_disconnect_req to 1 only if wpa_s->wpa_state is also indicating that there is a connection or an attempt to complete one. This showed up in a failure, e.g., when running the hwsim test case scan_int followed by ap_vlan_wpa2_psk_radius_required where the latter ended up not processing a connection failure event and getting stuck not trying to run a new scan and connection attempt. Signed-off-by: Jouni Malinen --- wpa_supplicant/ctrl_iface.c | 6 ++++-- wpa_supplicant/wpa_supplicant.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index faf683c9c..f32b7c927 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -2876,7 +2876,8 @@ static int wpa_supplicant_ctrl_iface_remove_network( #endif /* CONFIG_SME */ wpa_sm_set_config(wpa_s->wpa, NULL); eapol_sm_notify_config(wpa_s->eapol, NULL, NULL); - wpa_s->own_disconnect_req = 1; + if (wpa_s->wpa_state >= WPA_AUTHENTICATING) + wpa_s->own_disconnect_req = 1; wpa_supplicant_deauthenticate( wpa_s, WLAN_REASON_DEAUTH_LEAVING); } @@ -2923,7 +2924,8 @@ static int wpa_supplicant_ctrl_iface_remove_network( wpa_sm_set_config(wpa_s->wpa, NULL); eapol_sm_notify_config(wpa_s->eapol, NULL, NULL); - wpa_s->own_disconnect_req = 1; + if (wpa_s->wpa_state >= WPA_AUTHENTICATING) + wpa_s->own_disconnect_req = 1; wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING); } diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 11ac73550..05f480896 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -873,7 +873,8 @@ int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s) eapol_sm_invalidate_cached_session(wpa_s->eapol); if (wpa_s->current_ssid) { - wpa_s->own_disconnect_req = 1; + if (wpa_s->wpa_state >= WPA_AUTHENTICATING) + wpa_s->own_disconnect_req = 1; wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING); } @@ -2604,7 +2605,8 @@ void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s, int disconnected = 0; if (ssid && ssid != wpa_s->current_ssid && wpa_s->current_ssid) { - wpa_s->own_disconnect_req = 1; + if (wpa_s->wpa_state >= WPA_AUTHENTICATING) + wpa_s->own_disconnect_req = 1; wpa_supplicant_deauthenticate( wpa_s, WLAN_REASON_DEAUTH_LEAVING); disconnected = 1;