From patchwork Fri Apr 6 23:04:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 151282 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 3DAB3B702E for ; Sat, 7 Apr 2012 09:05:09 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 132649C1CE; Fri, 6 Apr 2012 19:05:06 -0400 (EDT) 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 Pn-8+PjwgRQ0; Fri, 6 Apr 2012 19:05:05 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 0AB099C1D4; Fri, 6 Apr 2012 19:05:01 -0400 (EDT) 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 DC9E717C01C for ; Fri, 6 Apr 2012 19:04:58 -0400 (EDT) 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 JvF6UZrHXZ5L for ; Fri, 6 Apr 2012 19:04:54 -0400 (EDT) Received: from ns3.lanforge.com (mail.candelatech.com [208.74.158.172]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 81C0B17C01B for ; Fri, 6 Apr 2012 19:04:48 -0400 (EDT) Received: from fs3.candelatech.com (firewall.candelatech.com [70.89.124.249]) by ns3.lanforge.com (8.14.2/8.14.2) with ESMTP id q36N4ZCv027852 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 6 Apr 2012 16:04:43 -0700 From: greearb@candelatech.com To: hostap@lists.shmoo.com Subject: [PATCH 2/3] wpa_supplicant: Support minimum interval between scan attempts. Date: Fri, 6 Apr 2012 16:04:13 -0700 Message-Id: <1333753454-21306-2-git-send-email-greearb@candelatech.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1333753454-21306-1-git-send-email-greearb@candelatech.com> References: <1333753454-21306-1-git-send-email-greearb@candelatech.com> Cc: Ben Greear 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 From: Ben Greear When running lots of vifs, they can all end up wanting to scan right after the other. This leaves too little time for useful work to happen. Allow users to configure a minimum timer interval (in seconds) between scans. Default is zero, which is current behaviour. Signed-hostap: Ben Greear --- :100644 100644 2a166c7... bf838b1... M wpa_supplicant/config.c :100644 100644 9bdc29e... c15f02b... M wpa_supplicant/config.h :100644 100644 8fdc544... cce57c2... M wpa_supplicant/events.c :100644 100644 eec5c7b... 1374aca... M wpa_supplicant/scan.c :100644 100644 8c83a42... 61e0510... M wpa_supplicant/scan.h :100644 100644 a494c49... 47b22c3... M wpa_supplicant/wpa_supplicant_i.h wpa_supplicant/config.c | 2 ++ wpa_supplicant/config.h | 4 ++++ wpa_supplicant/events.c | 14 ++++++++++++++ wpa_supplicant/scan.c | 20 +++++++++++++++++++- wpa_supplicant/scan.h | 1 + wpa_supplicant/wpa_supplicant_i.h | 1 + 6 files changed, 41 insertions(+), 1 deletions(-) diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index 2a166c7..bf838b1 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -2492,6 +2492,7 @@ struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface, config->bss_expiration_scan_count = DEFAULT_BSS_EXPIRATION_SCAN_COUNT; config->max_num_sta = DEFAULT_MAX_NUM_STA; config->access_network_type = DEFAULT_ACCESS_NETWORK_TYPE; + config->min_scan_gap = DEFAULT_MIN_SCAN_GAP; if (ctrl_interface) config->ctrl_interface = os_strdup(ctrl_interface); @@ -2832,6 +2833,7 @@ static const struct global_parse_data global_fields[] = { { INT(dot11RSNAConfigPMKLifetime), 0 }, { INT(dot11RSNAConfigPMKReauthThreshold), 0 }, { INT(dot11RSNAConfigSATimeout), 0 }, + { INT(min_scan_gap), 0 }, #ifndef CONFIG_NO_CONFIG_WRITE { INT(update_config), 0 }, #endif /* CONFIG_NO_CONFIG_WRITE */ diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h index 9bdc29e..c15f02b 100644 --- a/wpa_supplicant/config.h +++ b/wpa_supplicant/config.h @@ -23,6 +23,7 @@ #define DEFAULT_BSS_EXPIRATION_SCAN_COUNT 2 #define DEFAULT_MAX_NUM_STA 128 #define DEFAULT_ACCESS_NETWORK_TYPE 15 +#define DEFAULT_MIN_SCAN_GAP 0 #include "config_ssid.h" #include "wps/wps.h" @@ -577,6 +578,9 @@ struct wpa_config { */ int disassoc_low_ack; + /* Minimum interval between scan requests, in seconds */ + int min_scan_gap; + /** * interworking - Whether Interworking (IEEE 802.11u) is enabled */ diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 8fdc544..cce57c2 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1000,6 +1000,7 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid = NULL; struct wpa_scan_results *scan_res; int ap = 0; + struct os_time t; #ifdef CONFIG_AP if (wpa_s->ap_iface) @@ -1071,6 +1072,19 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, return 0; } + os_get_time(&t); + wpa_s->last_scan_rx_sec = t.sec; + /* Now, *if* we have (another) scan scheduled, and a min-scan-gap + * configured, make sure it happens after the minimum time. Since + * one STA's scan results can be propagated to other STA on the + * same radio, this is actually a common case. + */ + if (wpa_s->conf->min_scan_gap && + eloop_is_timeout_registered(wpa_supplicant_scan, wpa_s, NULL)) { + /* Min gap will be applied as needed */ + wpa_supplicant_req_scan(wpa_s, 1, 0); + } + wpa_dbg(wpa_s, MSG_DEBUG, "New scan results available"); wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS); wpas_notify_scan_results(wpa_s); diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index eec5c7b..1374aca 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -426,7 +426,7 @@ wpa_supplicant_extra_ies(struct wpa_supplicant *wpa_s, } -static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) +void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) { struct wpa_supplicant *wpa_s = eloop_ctx; struct wpa_ssid *ssid; @@ -700,6 +700,24 @@ void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec) } } + /* With lots of VIFS, we can end up trying to scan very often. + * This can cause us to not be able to associate due to missing + * EAPOL key messages and such. So, allow a minimum time between + * scans. + */ + if (wpa_s->conf->min_scan_gap) { + int mingap; + struct os_time t; + os_get_time(&t); + + mingap = wpa_s->conf->min_scan_gap + - (t.sec - wpa_s->last_scan_rx_sec); + if (mingap > wpa_s->conf->min_scan_gap) + mingap = wpa_s->conf->min_scan_gap; + if (mingap > sec) + sec = mingap; + } + wpa_dbg(wpa_s, MSG_DEBUG, "Setting scan request: %d sec %d usec", sec, usec); eloop_cancel_timeout(wpa_supplicant_scan, wpa_s, NULL); diff --git a/wpa_supplicant/scan.h b/wpa_supplicant/scan.h index 8c83a42..61e0510 100644 --- a/wpa_supplicant/scan.h +++ b/wpa_supplicant/scan.h @@ -10,6 +10,7 @@ #define SCAN_H int wpa_supplicant_enabled_networks(struct wpa_config *conf); +void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx); void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec); int wpa_supplicant_delayed_sched_scan(struct wpa_supplicant *wpa_s, int sec, int usec); diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index a494c49..47b22c3 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -292,6 +292,7 @@ struct wpa_supplicant { int key_mgmt; int wpa_proto; int mgmt_group_cipher; + int last_scan_rx_sec; void *drv_priv; /* private data used by driver_ops */ void *global_drv_priv;