]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpa_supplicant: Configurable fast-associate timer threshold
authorMikael Kanstrup <mikael.kanstrup@sony.com>
Wed, 4 Nov 2020 09:30:27 +0000 (10:30 +0100)
committerJouni Malinen <j@w1.fi>
Sat, 6 Feb 2021 14:56:30 +0000 (16:56 +0200)
For Android the default value of 5 seconds is usually too short for
scan results from last scan initiated from settings app to be
considered for fast-associate. Make the fast-associate timer value
configurable so that a suitable value can be set based on a systems
regular scan interval.

Signed-off-by: Mikael Kanstrup <mikael.kanstrup@sony.com>
wpa_supplicant/config.c
wpa_supplicant/config.h
wpa_supplicant/config_file.c
wpa_supplicant/events.c
wpa_supplicant/wpa_cli.c
wpa_supplicant/wpa_supplicant.conf
wpa_supplicant/wpa_supplicant_i.h

index 60129cf4830ccce3b98006acb9fd348ac7942b44..bc3d8ffd6df19b7af6056ad959bfb21c62bd375e 100644 (file)
@@ -4309,6 +4309,7 @@ struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface,
        config->ap_isolate = DEFAULT_AP_ISOLATE;
        config->access_network_type = DEFAULT_ACCESS_NETWORK_TYPE;
        config->scan_cur_freq = DEFAULT_SCAN_CUR_FREQ;
+       config->scan_res_valid_for_connect = DEFAULT_SCAN_RES_VALID_FOR_CONNECT;
        config->wmm_ac_params[0] = ac_be;
        config->wmm_ac_params[1] = ac_bk;
        config->wmm_ac_params[2] = ac_vi;
@@ -5105,6 +5106,7 @@ static const struct global_parse_data global_fields[] = {
        { FUNC(freq_list), 0 },
        { FUNC(initial_freq_list), 0},
        { INT(scan_cur_freq), 0 },
+       { INT(scan_res_valid_for_connect), 0},
        { INT(sched_scan_interval), 0 },
        { INT(sched_scan_start_delay), 0 },
        { INT(tdls_external_control), 0},
index c902ffbfa93b367744012591957c03f4fca9adf5..aac4a9dffb18ebd166a6f3860cad8298e6edf141 100644 (file)
@@ -45,6 +45,7 @@
 #define DEFAULT_DISASSOC_IMMINENT_RSSI_THRESHOLD -75
 #define DEFAULT_OCE_SUPPORT OCE_STA
 #define DEFAULT_EXTENDED_KEY_ID 0
+#define DEFAULT_SCAN_RES_VALID_FOR_CONNECT 5
 
 #include "config_ssid.h"
 #include "wps/wps.h"
@@ -937,6 +938,15 @@ struct wpa_config {
         */
        int scan_cur_freq;
 
+       /**
+        * scan_res_valid_for_connect - Seconds scans are valid for association
+        *
+        * This configures the number of seconds old scan results are considered
+        * valid for association. When scan results are older than this value
+        * a new scan is triggered prior to the association.
+        */
+       int scan_res_valid_for_connect;
+
        /**
         * changed_parameters - Bitmap of changed parameters since last update
         */
index 9ddd9ecfdc2c7ae7751c5421af6831ef0119bed7..6f02ad32fc0b8466882dd143364ab42d00ca6c0b 100644 (file)
@@ -1487,6 +1487,11 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
        if (config->scan_cur_freq != DEFAULT_SCAN_CUR_FREQ)
                fprintf(f, "scan_cur_freq=%d\n", config->scan_cur_freq);
 
+       if (config->scan_res_valid_for_connect !=
+           DEFAULT_SCAN_RES_VALID_FOR_CONNECT)
+               fprintf(f, "scan_res_valid_for_connect=%d\n",
+                       config->scan_res_valid_for_connect);
+
        if (config->sched_scan_interval)
                fprintf(f, "sched_scan_interval=%u\n",
                        config->sched_scan_interval);
index 7bacc203e617faf4797727579590bc43e1b97305..aadb05409dd015740a8d6cdc255f28b0fd1b93a7 100644 (file)
@@ -2449,7 +2449,7 @@ int wpa_supplicant_fast_associate(struct wpa_supplicant *wpa_s)
 
        os_get_reltime(&now);
        if (os_reltime_expired(&now, &wpa_s->last_scan,
-                              SCAN_RES_VALID_FOR_CONNECT)) {
+                              wpa_s->conf->scan_res_valid_for_connect)) {
                wpa_printf(MSG_DEBUG, "Fast associate: Old scan results");
                return -1;
        }
@@ -5313,13 +5313,13 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                }
                wpa_supplicant_mark_disassoc(wpa_s);
                os_reltime_age(&wpa_s->last_scan, &age);
-               if (age.sec >= SCAN_RES_VALID_FOR_CONNECT) {
-                       clear_at.sec = SCAN_RES_VALID_FOR_CONNECT;
+               if (age.sec >= wpa_s->conf->scan_res_valid_for_connect) {
+                       clear_at.sec = wpa_s->conf->scan_res_valid_for_connect;
                        clear_at.usec = 0;
                } else {
                        struct os_reltime tmp;
 
-                       tmp.sec = SCAN_RES_VALID_FOR_CONNECT;
+                       tmp.sec = wpa_s->conf->scan_res_valid_for_connect;
                        tmp.usec = 0;
                        os_reltime_sub(&tmp, &age, &clear_at);
                }
index ec2eeb1cc457467531999d22cd5dea9943c5c262..a5f7ef3537d1df8d33f5f83eacaeda41bb3bdb08 100644 (file)
@@ -493,7 +493,8 @@ static char ** wpa_cli_complete_set(const char *str, int pos)
                "p2p_go_max_inactivity", "auto_interworking", "okc", "pmf",
                "sae_groups", "dtim_period", "beacon_int",
                "ap_vendor_elements", "ignore_old_scan_res", "freq_list",
-               "scan_cur_freq", "sched_scan_interval",
+               "scan_cur_freq", "scan_res_valid_for_connect",
+               "sched_scan_interval",
                "tdls_external_control", "osu_dir", "wowlan_triggers",
                "p2p_search_delay", "mac_addr", "rand_addr_lifetime",
                "preassoc_mac_addr", "key_mgmt_offload", "passive_scan",
@@ -589,7 +590,8 @@ static char ** wpa_cli_complete_get(const char *str, int pos)
                "wps_nfc_dev_pw_id", "ext_password_backend",
                "p2p_go_max_inactivity", "auto_interworking", "okc", "pmf",
                "dtim_period", "beacon_int", "ignore_old_scan_res",
-               "scan_cur_freq", "sched_scan_interval",
+               "scan_cur_freq", "scan_res_valid_for_connect",
+               "sched_scan_interval",
                "sched_scan_start_delay",
                "tdls_external_control", "osu_dir", "wowlan_triggers",
                "p2p_search_delay", "mac_addr", "rand_addr_lifetime",
index 46f78755d48775f4ced13a5473e8cfa46b28a21b..7a9eac1394a855b1605259cd1f98532c75fbc6e0 100644 (file)
@@ -458,6 +458,9 @@ fast_reauth=1
 # 1:  Scan current operating frequency if another VIF on the same radio
 #     is already associated.
 
+# Seconds to consider old scan results valid for association (default: 5)
+#scan_res_valid_for_connect=5
+
 # MAC address policy default
 # 0 = use permanent MAC address
 # 1 = use random MAC address for each ESS connection
index f70f3c853700a42f454d8833142409baa4c8f14c..dc37f5f262ce4d735022123940403d82af179098 100644 (file)
@@ -49,9 +49,6 @@ struct ctrl_iface_global_priv;
 struct wpas_dbus_priv;
 struct wpas_binder_priv;
 
-/* How many seconds to consider old scan results valid for association. */
-#define SCAN_RES_VALID_FOR_CONNECT 5
-
 /**
  * struct wpa_interface - Parameters for wpa_supplicant_add_iface()
  */