Skip to content

Commit

Permalink
supplicant: Assume external scans complete within 30 seconds.
Browse files Browse the repository at this point in the history
When testing relatively buggy ath10k driver and firmware,
I saw cases where supplicant thought external scans were
active when in fact none were.  This effectively hangs supplicant
because it will never again scan to start the association logic.

This patch times out external scans after 30 seconds and continues
on as if the external scan had completed.

Signed-off-by: Ben Greear <greearb@candelatech.com>
  • Loading branch information
greearb committed Feb 22, 2016
1 parent e4a128f commit 913f01e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions wpa_supplicant/events.c
Expand Up @@ -3432,6 +3432,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
} else {
wpa_dbg(wpa_s, MSG_DEBUG, "External program started a scan");
wpa_s->radio->external_scan_running = 1;
os_get_reltime(&wpa_s->external_scan_start_time);
wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_STARTED);
}
break;
Expand Down
17 changes: 15 additions & 2 deletions wpa_supplicant/wpa_supplicant.c
Expand Up @@ -4246,8 +4246,21 @@ static void radio_start_next_work(void *eloop_ctx, void *timeout_ctx)
return; /* already started and still in progress */

if (wpa_s && wpa_s->radio->external_scan_running) {
wpa_printf(MSG_DEBUG, "Delay radio work start until externally triggered scan completes");
return;
/* If external scan has been running too long, then continue with our own,
* we must have missed the scan-completed event somehow..or buggy os/driver
* did not deliver it.
*/
struct os_reltime now, diff;
os_get_reltime(&now);
os_reltime_sub(&now, &wpa_s->external_scan_start_time, &diff);
if (diff.sec > 30) {
wpa_msg(wpa_s, MSG_INFO, "External scan took too long: %ld.%06ld seconds, will assume it is completed.",
diff.sec, diff.usec);
wpa_s->radio->external_scan_running = 0;
} else {
wpa_msg(wpa_s, MSG_DEBUG, "Delay radio work start until externally triggered scan completes");
return;
}
}
} else {
work = NULL;
Expand Down
1 change: 1 addition & 0 deletions wpa_supplicant/wpa_supplicant_i.h
Expand Up @@ -617,6 +617,7 @@ struct wpa_supplicant {
struct os_reltime scan_trigger_time, scan_start_time;
/* Minimum freshness requirement for connection purposes */
struct os_reltime scan_min_time;
struct os_reltime external_scan_start_time;
int scan_runs; /* number of scan runs since WPS was started */
int *next_scan_freqs;
int *manual_scan_freqs;
Expand Down

0 comments on commit 913f01e

Please sign in to comment.