[PATCH 4/6] wpa_supplicant: Do not propagate bad scan results to siblings.
Ben Greear
greearb
Fri Dec 3 16:55:03 PST 2010
This decreases useless work and re-scans by siblings when a
device gets a scan failure.
Signed-off-by: Ben Greear <greearb at candelatech.com>
---
:100644 100644 28babd1... 0481b35... M wpa_supplicant/events.c
wpa_supplicant/events.c | 32 ++++++++++++++++++++------------
1 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 28babd1..0481b35 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -827,9 +827,10 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s,
return 1;
}
-
-static void _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
- union wpa_event_data *data)
+/** Return < 0 if scan results are a failure.
+ */
+static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
+ union wpa_event_data *data)
{
struct wpa_bss *selected;
struct wpa_ssid *ssid = NULL;
@@ -848,11 +849,11 @@ static void _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
NULL, 1);
if (scan_res == NULL) {
if (wpa_s->conf->ap_scan == 2 || ap)
- return;
+ return -1;
wpa_msg(wpa_s, MSG_DEBUG, "Failed to get scan results - try "
"scanning again");
wpa_supplicant_req_new_scan(wpa_s, 1, 0);
- return;
+ return -1;
}
#ifndef CONFIG_NO_RANDOM_POOL
@@ -876,13 +877,13 @@ static void _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
wpa_s->scan_res_handler(wpa_s, scan_res);
wpa_s->scan_res_handler = NULL;
wpa_scan_results_free(scan_res);
- return;
+ return 0;
}
if (ap) {
wpa_msg(wpa_s, MSG_DEBUG, "Ignore scan results in AP mode");
wpa_scan_results_free(scan_res);
- return;
+ return 0;
}
wpa_msg(wpa_s, MSG_DEBUG, "%s: New scan results available", wpa_s->ifname);
@@ -893,18 +894,18 @@ static void _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
if ((wpa_s->conf->ap_scan == 2 && !wpas_wps_searching(wpa_s))) {
wpa_scan_results_free(scan_res);
- return;
+ return 0;
}
if (wpa_s->disconnected) {
wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
wpa_scan_results_free(scan_res);
- return;
+ return 0;
}
if (bgscan_notify_scan(wpa_s, scan_res) == 1) {
wpa_scan_results_free(scan_res);
- return;
+ return 0;
}
wpa_supplicant_rsn_preauth_scan_results(wpa_s, scan_res);
@@ -917,7 +918,7 @@ static void _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
scan_res);
wpa_scan_results_free(scan_res);
if (skip)
- return;
+ return 0;
wpa_supplicant_connect(wpa_s, selected, ssid);
} else {
wpa_scan_results_free(scan_res);
@@ -943,6 +944,7 @@ static void _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
timeout_usec);
}
}
+ return 0;
}
@@ -952,7 +954,13 @@ static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
const char *rn, *rn2;
struct wpa_supplicant *ifs;
- _wpa_supplicant_event_scan_results(wpa_s, data);
+ if (_wpa_supplicant_event_scan_results(wpa_s, data) < 0) {
+ /* If the scan results were a failure, then no need to
+ * notify those interfaces that did not actually request
+ * this scan.
+ */
+ return;
+ }
/*
* Check other interfaces to see if they have the same radio-name. If
--
1.7.2.3
More information about the Hostap
mailing list