From d924be3bd06ae7b167df7c28d7e807319c817990 Mon Sep 17 00:00:00 2001 From: Andrei Otcheretianski Date: Mon, 22 May 2023 22:33:44 +0300 Subject: [PATCH] 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 --- src/ap/ieee802_11.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index 03ce0b5b4..175f3ed02 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -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)