]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Allow bgscan parameters to be reconfigured
authorMatthew Wang <matthewmwang@chromium.org>
Thu, 16 Jul 2020 00:17:42 +0000 (17:17 -0700)
committerJouni Malinen <j@w1.fi>
Fri, 9 Oct 2020 13:50:36 +0000 (16:50 +0300)
Teach wpa_supplicant to {de,}initialize bgscans when bgscan parameters
are set after initial connection.

Signed-off-by: Matthew Wang <matthewmwang@chromium.org>
wpa_supplicant/config.c
wpa_supplicant/config.h
wpa_supplicant/ctrl_iface.c
wpa_supplicant/dbus/dbus_new_handlers.c
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index 0cbd09c863e2debedad18b2d37c5bdf425672905..b828b599fabb6f6cff9f2907ff6e5fb206082321 100644 (file)
@@ -4963,7 +4963,7 @@ static const struct global_parse_data global_fields[] = {
        { INT_RANGE(eapol_version, 1, 2), 0 },
 #endif /* CONFIG_MACSEC */
        { INT(ap_scan), 0 },
-       { FUNC(bgscan), 0 },
+       { FUNC(bgscan), CFG_CHANGED_BGSCAN },
 #ifdef CONFIG_MESH
        { INT(user_mpm), 0 },
        { INT_RANGE(max_peer_links, 0, 255), 0 },
index 3c38e1e5772c47c00af24e39db1f4a813a255604..2a2ad8722f3c9a8f295faa095facf395d7203b56 100644 (file)
@@ -376,6 +376,7 @@ struct wpa_cred {
 #define CFG_CHANGED_SCHED_SCAN_PLANS BIT(17)
 #define CFG_CHANGED_WOWLAN_TRIGGERS BIT(18)
 #define CFG_CHANGED_DISABLE_BTM BIT(19)
+#define CFG_CHANGED_BGSCAN BIT(20)
 
 /**
  * struct wpa_config - wpa_supplicant configuration data
index 127b5fe0bcdce90dce6354db00ac0ce360e274fc..7df7ba0d136568ddb47e1d76aea73c5c98c492c3 100644 (file)
@@ -3547,6 +3547,20 @@ static int wpa_supplicant_ctrl_iface_update_network(
        if (ret == 1)
                return 0; /* No change to the previously configured value */
 
+#ifdef CONFIG_BGSCAN
+       if (os_strcmp(name, "bgscan") == 0) {
+               /*
+                * Reset the bgscan parameters for the current network and
+                * return. There's no need to flush caches for bgscan parameter
+                * changes.
+                */
+               if (wpa_s->current_ssid == ssid &&
+                   wpa_s->wpa_state == WPA_COMPLETED)
+                       wpa_supplicant_reset_bgscan(wpa_s);
+               return 0;
+       }
+#endif /* CONFIG_BGSCAN */
+
        if (os_strcmp(name, "bssid") != 0 &&
            os_strcmp(name, "bssid_hint") != 0 &&
            os_strcmp(name, "priority") != 0) {
index defb9d405642180d7d834eab13bc96f55d603068..53e869488e24e6bd2d9e84d5e7137e7eb8cd24d6 100644 (file)
@@ -274,6 +274,23 @@ dbus_bool_t set_network_properties(struct wpa_supplicant *wpa_s,
                if (ret == 1)
                        goto skip_update;
 
+#ifdef CONFIG_BGSCAN
+               if (os_strcmp(entry.key, "bgscan") == 0) {
+                       /*
+                        * Reset the bgscan parameters for the current network
+                        * and continue. There's no need to flush caches for
+                        * bgscan parameter changes.
+                        */
+                       if (wpa_s->current_ssid == ssid &&
+                           wpa_s->wpa_state == WPA_COMPLETED)
+                               wpa_supplicant_reset_bgscan(wpa_s);
+                       os_free(value);
+                       value = NULL;
+                       wpa_dbus_dict_entry_clear(&entry);
+                       continue;
+               }
+#endif /* CONFIG_BGSCAN */
+
                if (os_strcmp(entry.key, "bssid") != 0 &&
                    os_strcmp(entry.key, "priority") != 0)
                        wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
index a7e9e459ee038dcec325a7ceaebad433f6994736..cb243f2f88ddf92701e05a38c94aa7b56ff7c2be 100644 (file)
@@ -803,7 +803,22 @@ const char * wpa_supplicant_state_txt(enum wpa_states state)
 
 #ifdef CONFIG_BGSCAN
 
-static void wpa_supplicant_start_bgscan(struct wpa_supplicant *wpa_s)
+static void wpa_supplicant_stop_bgscan(struct wpa_supplicant *wpa_s)
+{
+       if (wpa_s->bgscan_ssid) {
+               bgscan_deinit(wpa_s);
+               wpa_s->bgscan_ssid = NULL;
+       }
+}
+
+
+/**
+ * wpa_supplicant_reset_bgscan - Reset the bgscan for the current SSID.
+ * @wpa_s: Pointer to the wpa_supplicant data
+ *
+ * Stop, start, or reconfigure the scan parameters depending on the method.
+ */
+void wpa_supplicant_reset_bgscan(struct wpa_supplicant *wpa_s)
 {
        const char *name;
 
@@ -811,12 +826,12 @@ static void wpa_supplicant_start_bgscan(struct wpa_supplicant *wpa_s)
                name = wpa_s->current_ssid->bgscan;
        else
                name = wpa_s->conf->bgscan;
-       if (name == NULL || name[0] == '\0')
+       if (!name || name[0] == '\0') {
+               wpa_supplicant_stop_bgscan(wpa_s);
                return;
+       }
        if (wpas_driver_bss_selection(wpa_s))
                return;
-       if (wpa_s->current_ssid == wpa_s->bgscan_ssid)
-               return;
 #ifdef CONFIG_P2P
        if (wpa_s->p2p_group_interface != NOT_P2P_GROUP_INTERFACE)
                return;
@@ -846,15 +861,6 @@ static void wpa_supplicant_start_bgscan(struct wpa_supplicant *wpa_s)
                wpa_s->bgscan_ssid = NULL;
 }
 
-
-static void wpa_supplicant_stop_bgscan(struct wpa_supplicant *wpa_s)
-{
-       if (wpa_s->bgscan_ssid != NULL) {
-               bgscan_deinit(wpa_s);
-               wpa_s->bgscan_ssid = NULL;
-       }
-}
-
 #endif /* CONFIG_BGSCAN */
 
 
@@ -1011,8 +1017,8 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
        wpa_s->wpa_state = state;
 
 #ifdef CONFIG_BGSCAN
-       if (state == WPA_COMPLETED)
-               wpa_supplicant_start_bgscan(wpa_s);
+       if (state == WPA_COMPLETED && wpa_s->current_ssid != wpa_s->bgscan_ssid)
+               wpa_supplicant_reset_bgscan(wpa_s);
        else if (state < WPA_ASSOCIATED)
                wpa_supplicant_stop_bgscan(wpa_s);
 #endif /* CONFIG_BGSCAN */
@@ -7255,6 +7261,18 @@ void wpa_supplicant_update_config(struct wpa_supplicant *wpa_s)
        if (wpa_s->conf->changed_parameters & CFG_CHANGED_DISABLE_BTM)
                wpa_supplicant_set_default_scan_ies(wpa_s);
 
+#ifdef CONFIG_BGSCAN
+       /*
+        * We default to global bgscan parameters only when per-network bgscan
+        * parameters aren't set. Only bother resetting bgscan parameters if
+        * this is the case.
+        */
+       if ((wpa_s->conf->changed_parameters & CFG_CHANGED_BGSCAN) &&
+           wpa_s->current_ssid && !wpa_s->current_ssid->bgscan &&
+           wpa_s->wpa_state == WPA_COMPLETED)
+               wpa_supplicant_reset_bgscan(wpa_s);
+#endif /* CONFIG_BGSCAN */
+
 #ifdef CONFIG_WPS
        wpas_wps_update_config(wpa_s);
 #endif /* CONFIG_WPS */
index eac3491cc0956ed5bf4da047137617467ec91c09..5d99fcccd97057af8f3903c985dc9d571ae60dc2 100644 (file)
@@ -1465,6 +1465,7 @@ int wpas_beacon_rep_scan_process(struct wpa_supplicant *wpa_s,
 void wpas_clear_beacon_rep_data(struct wpa_supplicant *wpa_s);
 void wpas_flush_fils_hlp_req(struct wpa_supplicant *wpa_s);
 void wpas_clear_disabled_interface(void *eloop_ctx, void *timeout_ctx);
+void wpa_supplicant_reset_bgscan(struct wpa_supplicant *wpa_s);
 
 
 /* MBO functions */