From patchwork Fri Mar 1 05:21:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masashi Honma X-Patchwork-Id: 224227 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 598992C029A for ; Fri, 1 Mar 2013 16:21:54 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 38EE99D225; Fri, 1 Mar 2013 00:21:51 -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 60rz9N6I3tsp; Fri, 1 Mar 2013 00:21:51 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id CE5269D227; Fri, 1 Mar 2013 00:21:46 -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 744059D225 for ; Fri, 1 Mar 2013 00:21:45 -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 xxQUElB3FXnG for ; Fri, 1 Mar 2013 00:21:40 -0500 (EST) Received: from mail-oa0-f54.google.com (mail-oa0-f54.google.com [209.85.219.54]) (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 5F08C9D227 for ; Fri, 1 Mar 2013 00:21:40 -0500 (EST) Received: by mail-oa0-f54.google.com with SMTP id n12so5087456oag.13 for ; Thu, 28 Feb 2013 21:21:38 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.182.109.70 with SMTP id hq6mr7753589obb.4.1362115297658; Thu, 28 Feb 2013 21:21:37 -0800 (PST) Received: by 10.76.33.38 with HTTP; Thu, 28 Feb 2013 21:21:37 -0800 (PST) In-Reply-To: <20130228143703.GB25770@w1.fi> References: <20130228143703.GB25770@w1.fi> Date: Fri, 1 Mar 2013 14:21:37 +0900 Message-ID: Subject: Re: [PATCH] Use BSS expiration age as fast association threshold From: Masashi Honma To: hostap@lists.shmoo.com 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: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com 2013/2/28 Jouni Malinen wrote: > On Tue, Feb 26, 2013 at 10:36:00PM +0900, Masashi Honma wrote: > > diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c > > @@ -1344,7 +1344,7 @@ int wpa_supplicant_fast_associate(struct > > > - if (now.sec - wpa_s->last_scan.sec > 5) { > > + if (now.sec - wpa_s->last_scan.sec > wpa_s->conf->bss_expiration_age) { > > wpa_printf(MSG_DEBUG, "Fast associate: Old scan results"); > > This would change the default behavior to use up to 180 seconds old scan > results to avoid the new scan. I don't think I want to go that far as > the default behavior.. Scan results may have changed considerably and > BSS or even network selection is not really going to be ideal if the > device has moved. I see. My purpose is only making it configurable. So I modified the patch. [PATCH] Make scan results expiration age configurable Signed-hostap: Masashi Honma int debug_show_keys); Regards, Masashi Honma. diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 06efd2c..a2c6bf7 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -3386,6 +3386,15 @@ static int wpa_supplicant_ctrl_iface_scan_interval( } +static int wpa_supplicant_ctrl_iface_last_scan_expiration_age( + struct wpa_supplicant *wpa_s, char *cmd) +{ + int expiration_age = atoi(cmd); + return wpa_supplicant_set_last_scan_expiration_age(wpa_s, + expiration_age); +} + + static int wpa_supplicant_ctrl_iface_bss_expire_age( struct wpa_supplicant *wpa_s, char *cmd) { @@ -5332,6 +5341,10 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, } else if (os_strncmp(buf, "SCAN_INTERVAL ", 14) == 0) { if (wpa_supplicant_ctrl_iface_scan_interval(wpa_s, buf + 14)) reply_len = -1; + } else if (os_strncmp(buf, "LAST_SCAN_EXPIRATION_AGE ", 25) == 0) { + if (wpa_supplicant_ctrl_iface_last_scan_expiration_age( + wpa_s, buf + 25)) + reply_len = -1; } else if (os_strcmp(buf, "INTERFACE_LIST") == 0) { reply_len = wpa_supplicant_global_iface_list( wpa_s->global, reply, reply_size); diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 6c8ab6c..6813ff6 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1343,10 +1343,14 @@ int wpa_supplicant_fast_associate(struct wpa_supplicant *wpa_s) 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; + if (wpa_s->last_scan_expiration_age > 0) { + os_get_time(&now); + if (now.sec - wpa_s->last_scan.sec > + wpa_s->last_scan_expiration_age) { + wpa_printf(MSG_DEBUG, "Fast associate: Old scan " + "results"); + return -1; + } } return wpas_select_network_from_last_scan(wpa_s); diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index 133a077..f6f283c 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -658,6 +658,13 @@ static int wpa_cli_cmd_scan_interval(struct wpa_ctrl *ctrl, int argc, } +static int wpa_cli_cmd_last_scan_expiration_age(struct wpa_ctrl *ctrl, int argc, + char *argv[]) +{ + return wpa_cli_cmd(ctrl, "LAST_SCAN_EXPIRATION_AGE", 1, argc, argv); +} + + static int wpa_cli_cmd_bss_expire_age(struct wpa_ctrl *ctrl, int argc, char *argv[]) { @@ -2464,6 +2471,9 @@ static struct wpa_cli_cmd wpa_cli_commands[] = { { "scan_interval", wpa_cli_cmd_scan_interval, NULL, cli_cmd_flag_none, " = set scan_interval parameter (in seconds)" }, + { "last_scan_expiration_age", wpa_cli_cmd_last_scan_expiration_age, + NULL, cli_cmd_flag_none, + " = set last_scan_expiration_age parameter (in seconds)" }, { "bss_expire_age", wpa_cli_cmd_bss_expire_age, NULL, cli_cmd_flag_none, " = set BSS expiration age parameter" }, diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index fc3a84b..9fe7c60 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -1993,6 +1993,29 @@ int wpa_supplicant_set_scan_interval(struct wpa_supplicant *wpa_s, /** + * wpa_supplicant_set_last_scan_expiration_age - Set last scan expiration age + * @wpa_s: wpa_supplicant structure for a network interface + * @expiration_age: expiration age in seconds + * Returns: 0 if succeed or -1 if expiration_age has an invalid value + * + */ +int wpa_supplicant_set_last_scan_expiration_age(struct wpa_supplicant *wpa_s, + int expiration_age) +{ + if (expiration_age < 0) { + wpa_msg(wpa_s, MSG_ERROR, "Invalid expiration age %d", + expiration_age); + return -1; + } + wpa_msg(wpa_s, MSG_DEBUG, "Setting expiration age: %d sec", + expiration_age); + wpa_s->last_scan_expiration_age = expiration_age; + + return 0; +} + + +/** * wpa_supplicant_set_debug_params - Set global debug params * @global: wpa_global structure * @debug_level: debug level @@ -2417,6 +2440,7 @@ static struct wpa_supplicant * wpa_supplicant_alloc(void) return NULL; wpa_s->scan_req = INITIAL_SCAN_REQ; wpa_s->scan_interval = 5; + wpa_s->last_scan_expiration_age = 5; wpa_s->new_connection = 1; wpa_s->parent = wpa_s; wpa_s->sched_scanning = 0; diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 0f51f8e..c637f68 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -371,6 +371,7 @@ struct wpa_supplicant { unsigned int last_scan_res_used; unsigned int last_scan_res_size; int last_scan_full; + int last_scan_expiration_age; struct os_time last_scan; struct wpa_driver_ops *driver; @@ -724,6 +725,8 @@ int wpa_supplicant_set_bss_expiration_count(struct wpa_supplicant *wpa_s, unsigned int expire_count); int wpa_supplicant_set_scan_interval(struct wpa_supplicant *wpa_s, int scan_interval); +int wpa_supplicant_set_last_scan_expiration_age(struct wpa_supplicant *wpa_s, + int expiration_age); int wpa_supplicant_set_debug_params(struct wpa_global *global, int debug_level, int debug_timestamp,