[PATCH 2/2] wpa_supplicant: dont exit scanning state on config reload

Michal Kazior kazikcz at gmail.com
Fri Feb 12 08:27:54 EST 2021

From: Michal Kazior <michal at plume.com>

There's a chance that prior to config reload being
requested a scan work was started. As such forcing
wpa_s to WPA_DISCONNECTED was removing any hints
that the actual driver is busy with work. That led
to wpa_s reporting "Failed to initialize AP scan"
over and over again for a few seconds (depending
on driver/capabilities) until the untracked scan

Cancelling a scan isn't really a solution because
there's a bunch of scanning state bits sprinkled
across wpa_s structure and they get updated as
driver events actually flow in in async manner.

As far as I can tell this is only preventing
unnecessary warning messages. This doesn't seem
like it was crippling any logic per se.

Signed-off-by: Michal Kazior <michal at plume.com>
 wpa_supplicant/wpa_supplicant.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index db99d9597..8e6b232ea 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -1099,13 +1099,19 @@ static void wpa_supplicant_terminate(int sig, void *signal_ctx)
 void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s)
 	enum wpa_states old_state = wpa_s->wpa_state;
+	enum wpa_states new_state;
+	if (old_state == WPA_SCANNING)
+		new_state = WPA_SCANNING;
+	else
+		new_state = WPA_DISCONNECTED;
 	wpa_s->pairwise_cipher = 0;
 	wpa_s->group_cipher = 0;
 	wpa_s->mgmt_group_cipher = 0;
 	wpa_s->key_mgmt = 0;
 	if (wpa_s->wpa_state != WPA_INTERFACE_DISABLED)
-		wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
+		wpa_supplicant_set_state(wpa_s, new_state);
 	if (wpa_s->wpa_state != old_state)
 		wpas_notify_state_changed(wpa_s, wpa_s->wpa_state, old_state);

More information about the Hostap mailing list