]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Multi-AP: Set 4-address mode after network selection
authorGurumoorthi Gnanasambandhan <gguru@codeaurora.org>
Wed, 11 Mar 2020 10:41:54 +0000 (16:11 +0530)
committerJouni Malinen <j@w1.fi>
Fri, 13 Mar 2020 15:00:19 +0000 (17:00 +0200)
Split multi_ap_process_assoc_resp() to set 4-address mode after network
selection. Previously, wpa_s->current_ssid might have been NULL in some
cases and that would have resulted in 4-address mode not getting enabled
properly.

Signed-off-by: Gurumoorthi Gnanasambandhan <gguru@codeaurora.org>
wpa_supplicant/events.c
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index 06c4229686bdfda8bf91161a1dade7e67f85a3ce..15f7ae82e5667beae6ac3e2a1203bd7ed5c462f6 100644 (file)
@@ -2465,28 +2465,41 @@ static void multi_ap_process_assoc_resp(struct wpa_supplicant *wpa_s,
        const u8 *map_sub_elem, *pos;
        size_t len;
 
-       if (!wpa_s->current_ssid ||
-           !wpa_s->current_ssid->multi_ap_backhaul_sta ||
-           !ies ||
-           ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed)
-               return;
+       wpa_s->multi_ap_ie = 0;
 
-       if (!elems.multi_ap || elems.multi_ap_len < 7) {
-               wpa_printf(MSG_INFO, "AP doesn't support Multi-AP protocol");
-               goto fail;
-       }
+       if (!ies ||
+           ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed ||
+           !elems.multi_ap || elems.multi_ap_len < 7)
+               return;
 
        pos = elems.multi_ap + 4;
        len = elems.multi_ap_len - 4;
 
        map_sub_elem = get_ie(pos, len, MULTI_AP_SUB_ELEM_TYPE);
-       if (!map_sub_elem || map_sub_elem[1] < 1) {
-               wpa_printf(MSG_INFO, "invalid Multi-AP sub elem type");
+       if (!map_sub_elem || map_sub_elem[1] < 1)
+               return;
+
+       wpa_s->multi_ap_backhaul = !!(map_sub_elem[2] & MULTI_AP_BACKHAUL_BSS);
+       wpa_s->multi_ap_fronthaul = !!(map_sub_elem[2] &
+                                      MULTI_AP_FRONTHAUL_BSS);
+       wpa_s->multi_ap_ie = 1;
+}
+
+
+static void multi_ap_set_4addr_mode(struct wpa_supplicant *wpa_s)
+{
+       if (!wpa_s->current_ssid ||
+           !wpa_s->current_ssid->multi_ap_backhaul_sta)
+               return;
+
+       if (!wpa_s->multi_ap_ie) {
+               wpa_printf(MSG_INFO,
+                          "AP does not include valid Multi-AP element");
                goto fail;
        }
 
-       if (!(map_sub_elem[2] & MULTI_AP_BACKHAUL_BSS)) {
-               if ((map_sub_elem[2] & MULTI_AP_FRONTHAUL_BSS) &&
+       if (!wpa_s->multi_ap_backhaul) {
+               if (wpa_s->multi_ap_fronthaul &&
                    wpa_s->current_ssid->key_mgmt & WPA_KEY_MGMT_WPS) {
                        wpa_printf(MSG_INFO,
                                   "WPS active, accepting fronthaul-only BSS");
@@ -2988,6 +3001,8 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
                }
        }
 
+       multi_ap_set_4addr_mode(wpa_s);
+
        if (wpa_s->conf->ap_scan == 1 &&
            wpa_s->drv_flags & WPA_DRIVER_FLAGS_BSS_SELECTION) {
                if (wpa_supplicant_assoc_update_ie(wpa_s) < 0 && new_bss)
index 584ca3b912a6d5f85ecc93452244b8c70c85eebc..44c34f041bf89646178686d2b9232f3adf76ab3d 100644 (file)
@@ -2091,6 +2091,7 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
        else
                rand_style = ssid->mac_addr;
 
+       wpa_s->multi_ap_ie = 0;
        wmm_ac_clear_saved_tspecs(wpa_s);
        wpa_s->reassoc_same_bss = 0;
        wpa_s->reassoc_same_ess = 0;
index 383bf8e69ae1c95fe34bdad23401d5cb8843ed65..a6ec3f37efc52ca23c68bf0f722fe5ececb89bdf 100644 (file)
@@ -1287,6 +1287,9 @@ struct wpa_supplicant {
        unsigned int enabled_4addr_mode:1;
        unsigned int multi_bss_support:1;
        unsigned int drv_authorized_port:1;
+       unsigned int multi_ap_ie:1;
+       unsigned int multi_ap_backhaul:1;
+       unsigned int multi_ap_fronthaul:1;
 };