AP: AID allocation for MLD

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>
This commit is contained in:
Andrei Otcheretianski 2023-05-22 22:33:44 +03:00 committed by Jouni Malinen
parent 11a607d121
commit d924be3bd0

View 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)