]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Recover p2p_find operation in case of failure to fetch scan results
authorSunil Dutt <usdutt@codeaurora.org>
Tue, 8 Dec 2020 06:18:13 +0000 (11:48 +0530)
committerJouni Malinen <j@w1.fi>
Mon, 21 Dec 2020 21:04:54 +0000 (23:04 +0200)
Add a handler to notify failures to fetch the scan results and provide
an option to override default behavior of requesting a new scan in one
second in such an error condition. Use this new handler mechanism to
continue the p2p_find operation (by invoking p2p_scan_res_handled) for
an interim scenario where the p2p_scan attempt fails to get the scan
results from the driver which can happen, e.g., if there are parallel
updates to the cfg80211 scan results.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
wpa_supplicant/events.c
wpa_supplicant/p2p_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index fa8f5e1c0ea6991ce614d1cec06a4154dc322a74..d9ecbefc0ba9ec225d8df57e584eaa064c66631f 100644 (file)
@@ -2091,9 +2091,18 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
                        return -1;
                if (data && data->scan_info.external_scan)
                        return -1;
-               wpa_dbg(wpa_s, MSG_DEBUG, "Failed to get scan results - try "
-                       "scanning again");
-               wpa_supplicant_req_new_scan(wpa_s, 1, 0);
+               if (wpa_s->scan_res_fail_handler) {
+                       void (*handler)(struct wpa_supplicant *wpa_s);
+
+                       handler = wpa_s->scan_res_fail_handler;
+                       wpa_s->scan_res_fail_handler = NULL;
+                       handler(wpa_s);
+               } else {
+                       wpa_dbg(wpa_s, MSG_DEBUG,
+                               "Failed to get scan results - try scanning again");
+                       wpa_supplicant_req_new_scan(wpa_s, 1, 0);
+               }
+
                ret = -1;
                goto scan_work_done;
        }
index 867874dd98797fe1b360b3135f1d4099c7b2f442..8c8a834dac85d597fec59423dd373fcb988fd963 100644 (file)
@@ -291,6 +291,24 @@ static void wpas_p2p_scan_res_handler(struct wpa_supplicant *wpa_s,
 }
 
 
+static void wpas_p2p_scan_res_fail_handler(struct wpa_supplicant *wpa_s)
+{
+       if (wpa_s->p2p_scan_work) {
+               struct wpa_radio_work *work = wpa_s->p2p_scan_work;
+
+               wpa_s->p2p_scan_work = NULL;
+               radio_work_done(work);
+       }
+
+       if (wpa_s->global->p2p_disabled || !wpa_s->global->p2p)
+               return;
+
+       wpa_dbg(wpa_s, MSG_DEBUG,
+               "P2P: Failed to get scan results - try to continue");
+       p2p_scan_res_handled(wpa_s->global->p2p);
+}
+
+
 static void wpas_p2p_trigger_scan_cb(struct wpa_radio_work *work, int deinit)
 {
        struct wpa_supplicant *wpa_s = work->wpa_s;
@@ -335,6 +353,7 @@ static void wpas_p2p_trigger_scan_cb(struct wpa_radio_work *work, int deinit)
        p2p_notify_scan_trigger_status(wpa_s->global->p2p, ret);
        os_get_reltime(&wpa_s->scan_trigger_time);
        wpa_s->scan_res_handler = wpas_p2p_scan_res_handler;
+       wpa_s->scan_res_fail_handler = wpas_p2p_scan_res_fail_handler;
        wpa_s->own_scan_requested = 1;
        wpa_s->clear_driver_scan_cache = 0;
        wpa_s->p2p_scan_work = work;
index 568e383b1e352530052bdf728ab731836176866c..51fa00702513af68e0838acfd94ae3438c9fb4a2 100644 (file)
@@ -619,6 +619,7 @@ struct wpa_supplicant {
 
        void (*scan_res_handler)(struct wpa_supplicant *wpa_s,
                                 struct wpa_scan_results *scan_res);
+       void (*scan_res_fail_handler)(struct wpa_supplicant *wpa_s);
        struct dl_list bss; /* struct wpa_bss::list */
        struct dl_list bss_id; /* struct wpa_bss::list_id */
        size_t num_bss;