Patchwork [PATCHv3] wpa_supplicant: Implement fast-associate on SelectNetwork

login
register
mail settings
Submitter Paul Stewart
Date Jan. 16, 2013, 2:28 a.m.
Message ID <20130116174523.A780A2004B6@clearcreek.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/212880/
State Accepted
Commit cecdddc18419048dfe30866eb02c305c752a39c2
Headers show

Comments

Paul Stewart - Jan. 16, 2013, 2:28 a.m.
If scan results are available when we perform a SelectNetwork, use
them to make an associate decision.  This can save an entire scan
interval-worth of time in situations where something external to
wpa_supplicant (like a connection manager) has just previously
requested a scan before calling SelectNetwork.

Signed-hostap: Paul Stewart <pstew@chromium.org>
---
 wpa_supplicant/events.c           |   20 ++++++++++++++++++++
 wpa_supplicant/interworking.c     |   12 ++----------
 wpa_supplicant/wpa_supplicant.c   |    4 +++-
 wpa_supplicant/wpa_supplicant_i.h |    1 +
 4 files changed, 26 insertions(+), 11 deletions(-)
Jouni Malinen - Feb. 3, 2013, 7:10 p.m.
On Tue, Jan 15, 2013 at 06:28:09PM -0800, Paul Stewart wrote:
> If scan results are available when we perform a SelectNetwork, use
> them to make an associate decision.  This can save an entire scan
> interval-worth of time in situations where something external to
> wpa_supplicant (like a connection manager) has just previously
> requested a scan before calling SelectNetwork.

Thanks, applied.

Patch

diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 983f670..a54385f 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -1308,6 +1308,26 @@  static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
 #endif /* CONFIG_NO_SCAN_PROCESSING */
 
 
+int wpa_supplicant_fast_associate(struct wpa_supplicant *wpa_s)
+{
+#ifdef CONFIG_NO_SCAN_PROCESSING
+	return -1;
+#else /* CONFIG_NO_SCAN_PROCESSING */
+	struct os_time now;
+
+	if (wpa_s->last_scan_res_used <= 0)
+		return -1;
+
+	os_get_time(&now);
+	if (now.sec - wpa_s->last_scan.sec > 5) {
+		wpa_printf(MSG_DEBUG, "Fast associate: Old scan results");
+		return -1;
+	}
+
+	return wpas_select_network_from_last_scan(wpa_s);
+#endif /* CONFIG_NO_SCAN_PROCESSING */
+}
+
 #ifdef CONFIG_WNM
 
 static void wnm_bss_keep_alive(void *eloop_ctx, void *sock_ctx)
diff --git a/wpa_supplicant/interworking.c b/wpa_supplicant/interworking.c
index b8a8bb2..e1f58a6 100644
--- a/wpa_supplicant/interworking.c
+++ b/wpa_supplicant/interworking.c
@@ -54,16 +54,8 @@  static void interworking_reconnect(struct wpa_supplicant *wpa_s)
 	wpa_s->disconnected = 0;
 	wpa_s->reassociate = 1;
 
-	if (wpa_s->last_scan_res_used > 0) {
-		struct os_time now;
-		os_get_time(&now);
-		if (now.sec - wpa_s->last_scan.sec <= 5) {
-			wpa_printf(MSG_DEBUG, "Interworking: Old scan results "
-				   "are fresh - connect without new scan");
-			if (wpas_select_network_from_last_scan(wpa_s) >= 0)
-				return;
-		}
-	}
+	if (wpa_supplicant_fast_associate(wpa_s) >= 0)
+		return;
 
 	wpa_supplicant_req_scan(wpa_s, 0, 0);
 }
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 64f5c1b..47caa37 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -1875,7 +1875,9 @@  void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s,
 	wpa_s->connect_without_scan = NULL;
 	wpa_s->disconnected = 0;
 	wpa_s->reassociate = 1;
-	wpa_supplicant_req_scan(wpa_s, 0, disconnected ? 100000 : 0);
+
+	if (wpa_supplicant_fast_associate(wpa_s) != 1)
+		wpa_supplicant_req_scan(wpa_s, 0, disconnected ? 100000 : 0);
 
 	if (ssid)
 		wpas_notify_network_selected(wpa_s, ssid);
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index ecbdedf..807c7cd 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -786,6 +786,7 @@  void wpa_supplicant_stop_countermeasures(void *eloop_ctx, void *sock_ctx);
 void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx, void *sock_ctx);
 void wnm_bss_keep_alive_deinit(struct wpa_supplicant *wpa_s);
 int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s);
+int wpa_supplicant_fast_associate(struct wpa_supplicant *wpa_s);
 
 /* eap_register.c */
 int eap_register_methods(void);