From patchwork Wed Jan 16 02:28:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Stewart X-Patchwork-Id: 212880 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) by ozlabs.org (Postfix) with ESMTP id 1CE292C0126 for ; Thu, 17 Jan 2013 04:45:35 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id A42439C124; Wed, 16 Jan 2013 12:45:33 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 87vCzMoSyIpM; Wed, 16 Jan 2013 12:45:33 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 5AACA9C14B; Wed, 16 Jan 2013 12:45:29 -0500 (EST) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 968D79C14B for ; Wed, 16 Jan 2013 12:45:28 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XZyEfWWiK6oH for ; Wed, 16 Jan 2013 12:45:24 -0500 (EST) Received: from mail-qc0-f202.google.com (mail-qc0-f202.google.com [209.85.216.202]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id BE3739C124 for ; Wed, 16 Jan 2013 12:45:24 -0500 (EST) Received: by mail-qc0-f202.google.com with SMTP id s25so189458qcq.3 for ; Wed, 16 Jan 2013 09:45:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:in-reply-to:references:from:date:subject:to:message-id :x-gm-message-state; bh=xwbIUtkwOlhvJS1Yv5Ah67k1WuwsuS3aePKFAlqSVpI=; b=X2IZVqsHbnFzlCwirxqyKLO5tWtgqpwiWWJnXpNdBgRAyax1bnmb7YuiaFof7B68ue DDeJckSu0G1hygSqcmfU0BVal2scuav+T+YmkcKtjwWwQdJMHozIBwgrOgYol60w5IHe 9yTE4iTFZzFEz4+S/8YydwLAoeTEKgDVDj7p6sZcmAfYVb3cK4uix65+SUESkWbj2I7U UJs1+f2aEoZ65POGjMFLnD/L9Ik6KiyorV4xXSuXUBbGadhtiNeSaRCVgcxBioMcVPeh 9IIijzDERIZ4mFxsFi/kqQul3O+qU/caL/wroAFMcEFm4cFoMZJ5XLoXNCh9oXzb6+uq 6Hag== X-Received: by 10.236.135.236 with SMTP id u72mr841415yhi.21.1358358324331; Wed, 16 Jan 2013 09:45:24 -0800 (PST) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id p19si1069027yhi.1.2013.01.16.09.45.24 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Wed, 16 Jan 2013 09:45:24 -0800 (PST) Received: from clearcreek.mtv.corp.google.com (clearcreek.mtv.corp.google.com [172.22.73.104]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 124495A4256 for ; Wed, 16 Jan 2013 09:45:24 -0800 (PST) Received: by clearcreek.mtv.corp.google.com (Postfix, from userid 110058) id A780A2004B6; Wed, 16 Jan 2013 09:45:23 -0800 (PST) In-Reply-To: References: From: Paul Stewart Date: Tue, 15 Jan 2013 18:28:09 -0800 Subject: [PATCHv3] wpa_supplicant: Implement fast-associate on SelectNetwork To: hostap@lists.shmoo.com Message-Id: <20130116174523.A780A2004B6@clearcreek.mtv.corp.google.com> X-Gm-Message-State: ALoCoQl8bhrfCRH8iaCemNeW7F/7fV5lwVLiBvrmyMm7ZdT4CiMa6KnUcc/TIuMRxThPEONUlXc+jDeYpzUqpjo3YFX5sJ7zsaWRmMD5g911XO2wsbNx5BDFFffxsfrG8zTGFDliFnL60xZk4ffyfYrav/FkH8eEkVt8Xo9hz6wM16oPh3bFOu/ZRG9ZJejdWuaOBXHyKLcdzchPQ0IxjPz7goIbJXQs4g== X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com 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 --- 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(-) 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);