From f86d282f4326fac4a945094bd8f06c9ee1f3087e Mon Sep 17 00:00:00 2001 From: Jithu Jance Date: Thu, 17 Oct 2013 11:56:02 +0530 Subject: [PATCH] Handle legacy scan interruption of sched_scan/PNO While starting from PNO start context, the scheduled scan was not setting the flag wpa_s->scanning. This was resulting in the subsequent SCAN command to proceed further and send command to nl80211/cfg80211. The expected behavior of cancelling sched_scan was not happening here. While sched_scan is in progress and a legacy scan comes on the cli/socket, the sched_scan is cancelled and normal scan is allowed to continue. However, sometimes sched_scan cancelled event comes a bit delayed and we will send out the scan command before the wpa_s->scanning is cleared. Instead, reschedule the incoming scan req if the wpa_s->scanning shows that it is still in progress. Signed-hostap: Jithu Jance --- wpa_supplicant/ctrl_iface.c | 4 ++-- wpa_supplicant/scan.c | 19 ++++++++++++++----- wpa_supplicant/scan.h | 4 ++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 280441ed7..6472f4f5c 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -117,7 +117,7 @@ static int pno_start(struct wpa_supplicant *wpa_s) interval = wpa_s->conf->sched_scan_interval ? wpa_s->conf->sched_scan_interval : 10; - ret = wpa_drv_sched_scan(wpa_s, ¶ms, interval * 1000); + ret = wpa_supplicant_start_sched_scan(wpa_s, ¶ms, interval); os_free(params.filter_ssids); if (ret == 0) wpa_s->pno = 1; @@ -131,7 +131,7 @@ static int pno_stop(struct wpa_supplicant *wpa_s) if (wpa_s->pno) { wpa_s->pno = 0; - ret = wpa_drv_stop_sched_scan(wpa_s); + ret = wpa_supplicant_stop_sched_scan(wpa_s); } if (wpa_s->wpa_state == WPA_SCANNING) diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index 6d679d2c4..7baacaa6f 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -261,10 +261,9 @@ wpa_supplicant_sched_scan_timeout(void *eloop_ctx, void *timeout_ctx) } -static int -wpa_supplicant_start_sched_scan(struct wpa_supplicant *wpa_s, - struct wpa_driver_scan_params *params, - int interval) +int wpa_supplicant_start_sched_scan(struct wpa_supplicant *wpa_s, + struct wpa_driver_scan_params *params, + int interval) { int ret; @@ -279,7 +278,7 @@ wpa_supplicant_start_sched_scan(struct wpa_supplicant *wpa_s, } -static int wpa_supplicant_stop_sched_scan(struct wpa_supplicant *wpa_s) +int wpa_supplicant_stop_sched_scan(struct wpa_supplicant *wpa_s) { int ret; @@ -567,6 +566,16 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) return; } + if (wpa_s->scanning) { + /* + * If we are already in scanning state, we shall reschedule the + * the incoming scan request. + */ + wpa_dbg(wpa_s, MSG_DEBUG, "Already scanning - Reschedule the incoming scan req"); + wpa_supplicant_req_scan(wpa_s, 1, 0); + return; + } + if (!wpa_supplicant_enabled_networks(wpa_s) && wpa_s->scan_req == NORMAL_SCAN_REQ) { wpa_dbg(wpa_s, MSG_DEBUG, "No enabled networks - do not scan"); diff --git a/wpa_supplicant/scan.h b/wpa_supplicant/scan.h index 66581a9db..b6fe070e2 100644 --- a/wpa_supplicant/scan.h +++ b/wpa_supplicant/scan.h @@ -39,5 +39,9 @@ void wpa_supplicant_update_scan_int(struct wpa_supplicant *wpa_s, int sec); void scan_only_handler(struct wpa_supplicant *wpa_s, struct wpa_scan_results *scan_res); int wpas_scan_scheduled(struct wpa_supplicant *wpa_s); +int wpa_supplicant_start_sched_scan(struct wpa_supplicant *wpa_s, + struct wpa_driver_scan_params *params, + int interval); +int wpa_supplicant_stop_sched_scan(struct wpa_supplicant *wpa_s); #endif /* SCAN_H */