]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpa_supplicant: Add option to explicitly set 4addr mode
authorKonstantinos Natsakis <infradead.org@aleph-0.net>
Wed, 1 Feb 2023 00:16:18 +0000 (02:16 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 20 Feb 2023 22:00:07 +0000 (00:00 +0200)
Add a new network profile option enable_4addr_mode=1 that puts an
interface in 4addr mode, for interfaces meant to be added to a bridge.

Signed-off-by: Konstantinos Natsakis <infradead.org@aleph-0.net>
wpa_supplicant/config.c
wpa_supplicant/config_file.c
wpa_supplicant/config_ssid.h
wpa_supplicant/events.c

index 9477ad4721b001fc18caaba0ffadfbc5b5c1cd29..277a896450cfbb2a52d52ad6d3310b6c53d89aa1 100644 (file)
@@ -2710,6 +2710,7 @@ static const struct parse_data ssid_fields[] = {
        { INT_RANGE(transition_disable, 0, 255) },
        { INT_RANGE(sae_pk, 0, 2) },
        { INT_RANGE(disable_eht, 0, 1)},
+       { INT_RANGE(enable_4addr_mode, 0, 1)},
 };
 
 #undef OFFSET
index 2e4b081e9a5d9e85ce219e96b03711e249cc8246..b5d114ebd08292bc2ecc3a8cad7dffb00d965a38 100644 (file)
@@ -890,6 +890,7 @@ static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid)
        INT(disable_he);
 #endif /* CONFIG_HE_OVERRIDES */
        INT(disable_eht);
+       INT(enable_4addr_mode);
 
 #undef STR
 #undef INT
index 4d89e04b91a950ac3f31284745bc5d11b66c34fb..383e948ee9cd5c9d34e700b33f838c6f21df328f 100644 (file)
@@ -1240,6 +1240,17 @@ struct wpa_ssid {
         * to 1 to have it disabled.
         */
        int disable_eht;
+
+       /**
+        * enable_4addr_mode - Set 4addr mode after association
+        * 0 = Do not attempt to set 4addr mode
+        * 1 = Try to set 4addr mode after association
+        *
+        * Linux requires that an interface is set to 4addr mode before it can
+        * be added to a bridge. Set this to 1 for networks where you intent
+        * to use the interface in a bridge.
+        */
+       int enable_4addr_mode;
 };
 
 #endif /* CONFIG_SSID_H */
index edc392e737913267e6ba3ee5246f80d53ab2a7b3..c3f0e744e2255ef79c09ff6ef7d871e2fe905096 100644 (file)
@@ -2705,6 +2705,26 @@ static void interworking_process_assoc_resp(struct wpa_supplicant *wpa_s,
 #endif /* CONFIG_INTERWORKING */
 
 
+static void wpa_supplicant_set_4addr_mode(struct wpa_supplicant *wpa_s)
+{
+       if (wpa_s->enabled_4addr_mode) {
+               wpa_printf(MSG_DEBUG, "4addr mode already set");
+               return;
+       }
+
+       if (wpa_drv_set_4addr_mode(wpa_s, 1) < 0) {
+               wpa_msg(wpa_s, MSG_ERROR, "Failed to set 4addr mode");
+               goto fail;
+       }
+       wpa_s->enabled_4addr_mode = 1;
+       wpa_msg(wpa_s, MSG_INFO, "Successfully set 4addr mode");
+       return;
+
+fail:
+       wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING);
+}
+
+
 static void multi_ap_process_assoc_resp(struct wpa_supplicant *wpa_s,
                                        const u8 *ies, size_t ies_len)
 {
@@ -2757,11 +2777,7 @@ static void multi_ap_set_4addr_mode(struct wpa_supplicant *wpa_s)
                goto fail;
        }
 
-       if (wpa_drv_set_4addr_mode(wpa_s, 1) < 0) {
-               wpa_printf(MSG_ERROR, "Failed to set 4addr mode");
-               goto fail;
-       }
-       wpa_s->enabled_4addr_mode = 1;
+       wpa_supplicant_set_4addr_mode(wpa_s);
        return;
 
 fail:
@@ -3849,6 +3865,9 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
 #ifdef CONFIG_DPP2
        wpa_s->dpp_pfs_fallback = 0;
 #endif /* CONFIG_DPP2 */
+
+       if (wpa_s->current_ssid && wpa_s->current_ssid->enable_4addr_mode)
+               wpa_supplicant_set_4addr_mode(wpa_s);
 }