]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
AP: AID allocation for MLD
authorAndrei Otcheretianski <andrei.otcheretianski@intel.com>
Mon, 22 May 2023 19:33:44 +0000 (22:33 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 8 Jun 2023 15:20:04 +0000 (18:20 +0300)
Find an AID that is unused on all the affiliated links when assigning an
AID to a non-AP MLD.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
src/ap/ieee802_11.c

index 03ce0b5b4540637d9be715b69d8e012d2d03488e..175f3ed027c24ce7451a05dfacff3b90a5be801a 100644 (file)
@@ -3256,6 +3256,42 @@ static u8 hostapd_max_bssid_indicator(struct hostapd_data *hapd)
 }
 
 
+static u32 hostapd_get_aid_word(struct hostapd_data *hapd,
+                               struct sta_info *sta, int i)
+{
+#ifdef CONFIG_IEEE80211BE
+       u32 aid_word = 0;
+
+       /* Do not assign an AID that is in use on any of the affiliated links
+        * when finding an AID for a non-AP MLD. */
+       if (hapd->conf->mld_ap) {
+               int j;
+
+               for (j = 0; j < MAX_NUM_MLD_LINKS; j++) {
+                       struct hostapd_data *link_bss;
+
+                       if (!sta->mld_info.links[j].valid)
+                               continue;
+
+                       link_bss = hostapd_mld_get_link_bss(hapd, j);
+                       if (!link_bss) {
+                               /* This shouldn't happen, just skip */
+                               wpa_printf(MSG_ERROR,
+                                          "MLD: Failed to get link BSS for AID");
+                               continue;
+                       }
+
+                       aid_word |= link_bss->sta_aid[i];
+               }
+
+               return aid_word;
+       }
+#endif /* CONFIG_IEEE80211BE */
+
+       return hapd->sta_aid[i];
+}
+
+
 int hostapd_get_aid(struct hostapd_data *hapd, struct sta_info *sta)
 {
        int i, j = 32, aid;
@@ -3270,10 +3306,12 @@ int hostapd_get_aid(struct hostapd_data *hapd, struct sta_info *sta)
                return -1;
 
        for (i = 0; i < AID_WORDS; i++) {
-               if (hapd->sta_aid[i] == (u32) -1)
+               u32 aid_word = hostapd_get_aid_word(hapd, sta, i);
+
+               if (aid_word == (u32) -1)
                        continue;
                for (j = 0; j < 32; j++) {
-                       if (!(hapd->sta_aid[i] & BIT(j)))
+                       if (!(aid_word & BIT(j)))
                                break;
                }
                if (j < 32)