From e9ccfc38fd0cf319919994adf93098b632be11d9 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 4 Jan 2016 23:37:43 +0200 Subject: [PATCH] Clear wpa_supplicant state to DISCONNECTED on FLUSH command It was possible for the FLUSH command to trigger auto connect mechanism to schedule a new scan in 100 ms. This is not desired since all the network profiles will be removed immediately and the scan or an attempt to reconnect would not be of any benefit here. Such a scan in 100 ms can cause issues for cases where multiple test sequences are run back to back, so prevent this by clearing wpa_supplicant state to DISCONNECTED (which avoids scheduling of the 100 ms scan trigger on disconnection) if the state was AUTHENTICATING or higher when the FLUSH command was issued. Signed-off-by: Jouni Malinen --- wpa_supplicant/ctrl_iface.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 10d86f555..848f323f0 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -6973,6 +6973,14 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s) wpas_abort_ongoing_scan(wpa_s); + if (wpa_s->wpa_state >= WPA_AUTHENTICATING) { + /* + * Avoid possible auto connect re-connection on getting + * disconnected due to state flush. + */ + wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED); + } + #ifdef CONFIG_P2P wpas_p2p_cancel(p2p_wpa_s); p2p_ctrl_flush(p2p_wpa_s);