P2P: Recover p2p_find operation in case of failure to fetch scan results

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>
This commit is contained in:
Sunil Dutt 2020-12-08 11:48:13 +05:30 committed by Jouni Malinen
parent 74818ca63f
commit f39d6aacbb
3 changed files with 32 additions and 3 deletions

View file

@ -2091,9 +2091,18 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
return -1; return -1;
if (data && data->scan_info.external_scan) if (data && data->scan_info.external_scan)
return -1; return -1;
wpa_dbg(wpa_s, MSG_DEBUG, "Failed to get scan results - try " if (wpa_s->scan_res_fail_handler) {
"scanning again"); void (*handler)(struct wpa_supplicant *wpa_s);
wpa_supplicant_req_new_scan(wpa_s, 1, 0);
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; ret = -1;
goto scan_work_done; goto scan_work_done;
} }

View 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) static void wpas_p2p_trigger_scan_cb(struct wpa_radio_work *work, int deinit)
{ {
struct wpa_supplicant *wpa_s = work->wpa_s; 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); p2p_notify_scan_trigger_status(wpa_s->global->p2p, ret);
os_get_reltime(&wpa_s->scan_trigger_time); os_get_reltime(&wpa_s->scan_trigger_time);
wpa_s->scan_res_handler = wpas_p2p_scan_res_handler; 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->own_scan_requested = 1;
wpa_s->clear_driver_scan_cache = 0; wpa_s->clear_driver_scan_cache = 0;
wpa_s->p2p_scan_work = work; wpa_s->p2p_scan_work = work;

View file

@ -619,6 +619,7 @@ struct wpa_supplicant {
void (*scan_res_handler)(struct wpa_supplicant *wpa_s, void (*scan_res_handler)(struct wpa_supplicant *wpa_s,
struct wpa_scan_results *scan_res); 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; /* struct wpa_bss::list */
struct dl_list bss_id; /* struct wpa_bss::list_id */ struct dl_list bss_id; /* struct wpa_bss::list_id */
size_t num_bss; size_t num_bss;