AP MLD: Use a helper function to check if a STA is a non-AP MLD

This makes it easier to change the struct sta_info design for MLD by
reducing the number of direct references.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2024-01-21 18:45:28 +02:00
parent ee9375fb3b
commit 6bda0aca8b
10 changed files with 41 additions and 29 deletions

View file

@ -269,7 +269,7 @@ static bool hostapd_sta_is_link_sta(struct hostapd_data *hapd,
struct sta_info *sta)
{
#ifdef CONFIG_IEEE80211BE
if (hapd->conf->mld_ap && sta->mld_info.mld_sta &&
if (ap_sta_is_mld(hapd, sta) &&
sta->mld_assoc_link_id != hapd->mld_link_id)
return true;
#endif /* CONFIG_IEEE80211BE */
@ -839,7 +839,7 @@ int hostapd_drv_sta_deauth(struct hostapd_data *hapd,
struct sta_info *sta = ap_get_sta(hapd, addr);
link_id = hapd->mld_link_id;
if (sta && sta->mld_info.mld_sta)
if (ap_sta_is_mld(hapd, sta))
own_addr = hapd->mld_addr;
}
#endif /* CONFIG_IEEE80211BE */
@ -860,7 +860,7 @@ int hostapd_drv_sta_disassoc(struct hostapd_data *hapd,
if (hapd->conf->mld_ap) {
struct sta_info *sta = ap_get_sta(hapd, addr);
if (sta && sta->mld_info.mld_sta)
if (ap_sta_is_mld(hapd, sta))
own_addr = hapd->mld_addr;
}
#endif /* CONFIG_IEEE80211BE */
@ -918,7 +918,7 @@ static int hapd_drv_send_action(struct hostapd_data *hapd, unsigned int freq,
} else if (hapd->conf->mld_ap) {
sta = ap_get_sta(hapd, dst);
if (sta && sta->mld_info.mld_sta) {
if (ap_sta_is_mld(hapd, sta)) {
own_addr = hapd->mld_addr;
bssid = own_addr;
}

View file

@ -513,7 +513,7 @@ int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
return -1;
}
#ifdef CONFIG_IEEE80211BE
if (sta->mld_info.mld_sta) {
if (ap_sta_is_mld(hapd, sta)) {
wpa_printf(MSG_DEBUG,
"MLD: Set ML info in RSN Authenticator");
wpa_auth_set_ml_info(sta->wpa_sm, hapd->mld_addr,

View file

@ -3599,7 +3599,7 @@ void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
}
#ifdef CONFIG_IEEE80211BE
if (hapd->conf->mld_ap && sta->mld_info.mld_sta &&
if (ap_sta_is_mld(hapd, sta) &&
sta->mld_assoc_link_id != hapd->mld_link_id)
return;
#endif /* CONFIG_IEEE80211BE */

View file

@ -407,7 +407,7 @@ static int send_auth_reply(struct hostapd_data *hapd, struct sta_info *sta,
* the MLD MAC address. Thus, use the MLD address instead of translating
* the addresses.
*/
if (hapd->conf->mld_ap && sta && sta->mld_info.mld_sta) {
if (ap_sta_is_mld(hapd, sta)) {
sa = hapd->mld_addr;
ml_resp = hostapd_ml_auth_resp(hapd);
@ -608,7 +608,7 @@ static struct wpabuf * auth_build_sae_commit(struct hostapd_data *hapd,
const u8 *own_addr = hapd->own_addr;
#ifdef CONFIG_IEEE80211BE
if (hapd->conf->mld_ap && sta->mld_info.mld_sta)
if (ap_sta_is_mld(hapd, sta))
own_addr = hapd->mld_addr;
#endif /* CONFIG_IEEE80211BE */
@ -877,7 +877,7 @@ static void sae_sme_send_external_auth_status(struct hostapd_data *hapd,
params.status = status;
#ifdef CONFIG_IEEE80211BE
if (sta->mld_info.mld_sta)
if (ap_sta_is_mld(hapd, sta))
params.bssid =
sta->mld_info.links[sta->mld_assoc_link_id].peer_addr;
#endif /* CONFIG_IEEE80211BE */
@ -3246,7 +3246,7 @@ static void handle_auth(struct hostapd_data *hapd,
* the MLD MAC address. It is the responsibility of the driver to
* handle the translations.
*/
if (hapd->conf->mld_ap && sta && sta->mld_info.mld_sta) {
if (ap_sta_is_mld(hapd, sta)) {
dst = sta->addr;
bssid = hapd->mld_addr;
}
@ -3737,7 +3737,7 @@ u16 owe_process_rsn_ie(struct hostapd_data *hapd,
goto end;
}
#ifdef CONFIG_IEEE80211BE
if (sta->mld_info.mld_sta)
if (ap_sta_is_mld(hapd, sta))
wpa_auth_set_ml_info(sta->wpa_sm, hapd->mld_addr,
sta->mld_assoc_link_id, &sta->mld_info);
#endif /* CONFIG_IEEE80211BE */
@ -4019,7 +4019,7 @@ static int __check_assoc_ies(struct hostapd_data *hapd, struct sta_info *sta,
}
#ifdef CONFIG_IEEE80211BE
if (info->mld_sta) {
if (ap_sta_is_mld(hapd, sta)) {
wpa_printf(MSG_DEBUG,
"MLD: Set ML info in RSN Authenticator");
wpa_auth_set_ml_info(sta->wpa_sm,
@ -4608,7 +4608,7 @@ static int add_associated_sta(struct hostapd_data *hapd,
bool mld_link_sta = false;
#ifdef CONFIG_IEEE80211BE
if (hapd->conf->mld_ap && sta->mld_info.mld_sta) {
if (ap_sta_is_mld(hapd, sta)) {
u8 mld_link_id = hapd->mld_link_id;
mld_link_sta = sta->mld_assoc_link_id != mld_link_id;
@ -4769,8 +4769,7 @@ static u16 send_assoc_resp(struct hostapd_data *hapd, struct sta_info *sta,
* Once a non-AP MLD is added to the driver, the addressing should use
* MLD MAC address.
*/
if (hapd->conf->mld_ap && sta && sta->mld_info.mld_sta &&
allow_mld_addr_trans)
if (ap_sta_is_mld(hapd, sta) && allow_mld_addr_trans)
sa = hapd->mld_addr;
#endif /* CONFIG_IEEE80211BE */
@ -6440,7 +6439,7 @@ static void handle_assoc_cb(struct hostapd_data *hapd,
}
#ifdef CONFIG_IEEE80211BE
if (hapd->conf->mld_ap && sta->mld_info.mld_sta &&
if (ap_sta_is_mld(hapd, sta) &&
hapd->mld_link_id != sta->mld_assoc_link_id) {
/* See ieee80211_ml_link_sta_assoc_cb() for the MLD case */
wpa_printf(MSG_DEBUG,

View file

@ -779,7 +779,7 @@ u8 * hostapd_eid_eht_ml_beacon(struct hostapd_data *hapd,
u8 * hostapd_eid_eht_ml_assoc(struct hostapd_data *hapd, struct sta_info *info,
u8 *eid)
{
if (!info || !info->mld_info.mld_sta)
if (!ap_sta_is_mld(hapd, info))
return eid;
eid = hostapd_eid_eht_basic_ml_common(hapd, eid, &info->mld_info,
@ -1012,11 +1012,12 @@ const u8 * hostapd_process_ml_auth(struct hostapd_data *hapd,
static int hostapd_mld_validate_assoc_info(struct hostapd_data *hapd,
struct mld_info *info)
struct sta_info *sta)
{
u8 i, link_id;
struct mld_info *info = &sta->mld_info;
if (!info->mld_sta) {
if (!ap_sta_is_mld(hapd, sta)) {
wpa_printf(MSG_DEBUG, "MLD: Not a non-AP MLD");
return 0;
}
@ -1390,7 +1391,7 @@ u16 hostapd_process_ml_assoc_req(struct hostapd_data *hapd,
goto out;
}
ret = hostapd_mld_validate_assoc_info(hapd, info);
ret = hostapd_mld_validate_assoc_info(hapd, sta);
out:
wpabuf_free(mlbuf);
if (ret) {

View file

@ -120,7 +120,7 @@ void ieee802_11_send_sa_query_req(struct hostapd_data *hapd,
}
#ifdef CONFIG_IEEE80211BE
if (hapd->conf->mld_ap && sta && sta->mld_info.mld_sta)
if (ap_sta_is_mld(hapd, sta))
own_addr = hapd->mld_addr;
#endif /* CONFIG_IEEE80211BE */
@ -218,7 +218,7 @@ static void ieee802_11_send_sa_query_resp(struct hostapd_data *hapd,
MACSTR, MAC2STR(sa));
#ifdef CONFIG_IEEE80211BE
if (hapd->conf->mld_ap && sta->mld_info.mld_sta)
if (ap_sta_is_mld(hapd, sta))
own_addr = hapd->mld_addr;
#endif /* CONFIG_IEEE80211BE */
@ -1169,7 +1169,7 @@ struct sta_info * hostapd_ml_get_assoc_sta(struct hostapd_data *hapd,
struct hostapd_data *other_hapd = NULL;
struct sta_info *tmp_sta;
if (!sta->mld_info.mld_sta)
if (!ap_sta_is_mld(hapd, sta))
return NULL;
*assoc_hapd = hapd;

View file

@ -303,7 +303,7 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
ieee802_1x_free_station(hapd, sta);
#ifdef CONFIG_IEEE80211BE
if (!hapd->conf->mld_ap || !sta->mld_info.mld_sta ||
if (!ap_sta_is_mld(hapd, sta) ||
hapd->mld_link_id == sta->mld_assoc_link_id)
wpa_auth_sta_deinit(sta->wpa_sm);
#else
@ -1400,7 +1400,7 @@ bool ap_sta_set_authorized_flag(struct hostapd_data *hapd, struct sta_info *sta,
int mld_assoc_link_id = -1;
#ifdef CONFIG_IEEE80211BE
if (hapd->conf->mld_ap && sta->mld_info.mld_sta) {
if (ap_sta_is_mld(hapd, sta)) {
if (sta->mld_assoc_link_id == hapd->mld_link_id)
mld_assoc_link_id = sta->mld_assoc_link_id;
else
@ -1757,7 +1757,7 @@ int ap_sta_re_add(struct hostapd_data *hapd, struct sta_info *sta)
*/
#ifdef CONFIG_IEEE80211BE
if (hapd->conf->mld_ap && sta->mld_info.mld_sta) {
if (ap_sta_is_mld(hapd, sta)) {
u8 mld_link_id = hapd->mld_link_id;
mld_link_sta = sta->mld_assoc_link_id != mld_link_id;

View file

@ -17,6 +17,7 @@
#include "common/sae.h"
#include "crypto/sha384.h"
#include "pasn/pasn_common.h"
#include "hostapd.h"
/* STA flags */
#define WLAN_STA_AUTH BIT(0)
@ -419,4 +420,14 @@ int ap_sta_re_add(struct hostapd_data *hapd, struct sta_info *sta);
void ap_free_sta_pasn(struct hostapd_data *hapd, struct sta_info *sta);
static inline bool ap_sta_is_mld(struct hostapd_data *hapd,
struct sta_info *sta)
{
#ifdef CONFIG_IEEE80211BE
return hapd->conf->mld_ap && sta && sta->mld_info.mld_sta;
#else /* CONFIG_IEEE80211BE */
return false;
#endif /* CONFIG_IEEE80211BE */
}
#endif /* STA_INFO_H */

View file

@ -50,7 +50,7 @@ static const u8 * wnm_ap_get_own_addr(struct hostapd_data *hapd,
const u8 *own_addr = hapd->own_addr;
#ifdef CONFIG_IEEE80211BE
if (hapd->conf->mld_ap && (!sta || sta->mld_info.mld_sta))
if (hapd->conf->mld_ap && (!sta || ap_sta_is_mld(hapd, sta)))
own_addr = hapd->mld_addr;
#endif /* CONFIG_IEEE80211BE */
@ -1030,7 +1030,7 @@ int wnm_send_bss_tm_req(struct hostapd_data *hapd, struct sta_info *sta,
if (disassoc_timer) {
#ifdef CONFIG_IEEE80211BE
if (hapd->conf->mld_ap && sta->mld_info.mld_sta) {
if (ap_sta_is_mld(hapd, sta)) {
int i;
unsigned int links = 0;

View file

@ -560,7 +560,8 @@ int hostapd_wpa_auth_send_eapol(void *ctx, const u8 *addr,
if (sta) {
flags = hostapd_sta_flags_to_drv(sta->flags);
#ifdef CONFIG_IEEE80211BE
if (sta->mld_info.mld_sta && (sta->flags & WLAN_STA_AUTHORIZED))
if (ap_sta_is_mld(hapd, sta) &&
(sta->flags & WLAN_STA_AUTHORIZED))
link_id = -1;
#endif /* CONFIG_IEEE80211BE */
}