]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Restore permanent MAC address on the FLUSH command
authorJouni Malinen <j@w1.fi>
Sun, 21 Feb 2021 15:22:37 +0000 (17:22 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 21 Feb 2021 15:22:37 +0000 (17:22 +0200)
Clear previously used random MAC address on the FLUSH command if
mac_addr setting has been disabled.

Signed-off-by: Jouni Malinen <j@w1.fi>
wpa_supplicant/ctrl_iface.c
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index 2dce086f16cf45c688fbad07d9a91c975a3c7db6..0d4c2bc8f0bb3291fe4449657badbcbbdb1f361e 100644 (file)
@@ -8572,6 +8572,8 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s)
        wpas_pasn_auth_stop(wpa_s);
 #endif /* CONFIG_PASN */
 
+       if (wpa_s->mac_addr_changed && wpa_s->conf->mac_addr == 0)
+               wpas_restore_permanent_mac_addr(wpa_s);
 }
 
 
index 8384cce7536ed6635d6a38a443a0f6273ae883fe..e1497e1f5a07f1fbb12ab3562490ed71f0195993 100644 (file)
@@ -2145,6 +2145,24 @@ static void wpa_s_clear_sae_rejected(struct wpa_supplicant *wpa_s)
 }
 
 
+int wpas_restore_permanent_mac_addr(struct wpa_supplicant *wpa_s)
+{
+       if (wpa_drv_set_mac_addr(wpa_s, NULL) < 0) {
+               wpa_msg(wpa_s, MSG_INFO,
+                       "Could not restore permanent MAC address");
+               return -1;
+       }
+       wpa_s->mac_addr_changed = 0;
+       if (wpa_supplicant_update_mac_addr(wpa_s) < 0) {
+               wpa_msg(wpa_s, MSG_INFO,
+                       "Could not update MAC address information");
+               return -1;
+       }
+       wpa_msg(wpa_s, MSG_DEBUG, "Using permanent MAC address");
+       return 0;
+}
+
+
 static void wpas_start_assoc_cb(struct wpa_radio_work *work, int deinit);
 
 /**
@@ -2205,18 +2223,8 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
                        return;
                wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
        } else if (rand_style == 0 && wpa_s->mac_addr_changed) {
-               if (wpa_drv_set_mac_addr(wpa_s, NULL) < 0) {
-                       wpa_msg(wpa_s, MSG_INFO,
-                               "Could not restore permanent MAC address");
+               if (wpas_restore_permanent_mac_addr(wpa_s) < 0)
                        return;
-               }
-               wpa_s->mac_addr_changed = 0;
-               if (wpa_supplicant_update_mac_addr(wpa_s) < 0) {
-                       wpa_msg(wpa_s, MSG_INFO,
-                               "Could not update MAC address information");
-                       return;
-               }
-               wpa_msg(wpa_s, MSG_DEBUG, "Using permanent MAC address");
        }
        wpa_s->last_ssid = ssid;
 
index f192bf8a226fb0a9f119fecae7752d894163ecb5..7d14b627d89afc73b0b56cf70ea96518e35058b9 100644 (file)
@@ -1425,6 +1425,7 @@ int wpa_supplicant_update_bridge_ifname(struct wpa_supplicant *wpa_s,
 int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
                              struct wpa_bss *bss, struct wpa_ssid *ssid,
                              u8 *wpa_ie, size_t *wpa_ie_len);
+int wpas_restore_permanent_mac_addr(struct wpa_supplicant *wpa_s);
 void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
                              struct wpa_bss *bss,
                              struct wpa_ssid *ssid);