blob: 293384f5ef90b9da55c1d2236b2ea19e04afe2ee [file] [log] [blame]
From 89cea0c904dfce8fca45a3d721f2871c32402e05 Mon Sep 17 00:00:00 2001
From: Peter Chiu <chui-hao.chiu@mediatek.com>
Date: Tue, 16 Jan 2024 16:22:17 +0800
Subject: [PATCH 070/126] mtk: hostapd: add wds mlo support
1. Add mld_assoc_sta to get the primary sta_info.
2. Find hapd according to mld address.
The latest get_hapd_bssid return hapd only if link id is matched.
However,the hostapd_rx_from_unknown_sta does not have link
information so it cannot get hapd.
Modify get_hapd_bssid to ignore link id when link id is -1.
Without this patch, wds mode cannot work and the AP would not be
aware that station is using 4 address.
Transmit correct hapd by i802_bss->ctx to EVENT_RX_FROM_UNKNOWN handler.
Without this patch, AP cannot setup AP_VLAN interface in mlo + legacy case.
In mlo + legacy case, if wds null is sent to legacy AP, it cannot get correct
hapd according drv->ctx because drv->ctx and legacy AP's hapd may not under
the same hostapd_iface.
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
---
src/ap/drv_callbacks.c | 7 ++++---
src/ap/ieee802_11.c | 8 ++++++++
src/ap/sta_info.c | 6 +++++-
src/ap/sta_info.h | 1 +
src/drivers/driver.h | 3 +++
src/drivers/driver_nl80211.c | 14 ++++++++++++++
src/drivers/driver_nl80211_event.c | 2 +-
7 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c
index 1fa27bf80..1107fd70e 100644
--- a/src/ap/drv_callbacks.c
+++ b/src/ap/drv_callbacks.c
@@ -1798,6 +1798,7 @@ switch_link_scan(struct hostapd_data *hapd, u64 scan_cookie)
static struct hostapd_data * get_hapd_bssid(struct hostapd_iface *iface,
const u8 *bssid, int link_id)
{
+ struct hostapd_data *ret = NULL;
size_t i;
if (bssid == NULL)
@@ -1820,7 +1821,7 @@ static struct hostapd_data * get_hapd_bssid(struct hostapd_iface *iface,
if (ether_addr_equal(bssid, hapd->own_addr) ||
(hapd->conf->mld_ap &&
ether_addr_equal(bssid, hapd->mld->mld_addr) &&
- link_id == hapd->mld_link_id))
+ (link_id == hapd->mld_link_id || link_id == -1)))
return hapd;
if (!hapd->conf->mld_ap)
@@ -1832,13 +1833,13 @@ static struct hostapd_data * get_hapd_bssid(struct hostapd_iface *iface,
if (ether_addr_equal(bssid, p_hapd->own_addr) ||
(ether_addr_equal(bssid, p_hapd->mld->mld_addr) &&
- link_id == p_hapd->mld_link_id))
+ (link_id == p_hapd->mld_link_id || link_id == -1)))
return p_hapd;
}
#endif /* CONFIG_IEEE80211BE */
}
- return NULL;
+ return ret;
}
diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index c6676b754..d26b50031 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -3183,6 +3183,7 @@ static void handle_auth(struct hostapd_data *hapd,
ap_sta_set_mld(sta, true);
sta->mld_assoc_link_id = link_id;
+ sta->mld_assoc_sta = sta;
/*
* Set the MLD address as the station address and the
@@ -4572,6 +4573,7 @@ static int ieee80211_ml_process_link(struct hostapd_data *hapd,
sta->flags |= origin_sta->flags | WLAN_STA_ASSOC_REQ_OK;
sta->mld_assoc_link_id = origin_sta->mld_assoc_link_id;
+ sta->mld_assoc_sta = origin_sta;
status = __check_assoc_ies(hapd, sta, NULL, 0, &elems, reassoc, true);
if (status != WLAN_STATUS_SUCCESS) {
@@ -7037,6 +7039,12 @@ void ieee802_11_rx_from_unknown(struct hostapd_data *hapd, const u8 *src,
struct sta_info *sta;
sta = ap_get_sta(hapd, src);
+
+#ifdef CONFIG_IEEE80211BE
+ if (sta && sta->mld_info.mld_sta)
+ sta = sta->mld_assoc_sta;
+#endif
+
if (sta &&
((sta->flags & WLAN_STA_ASSOC) ||
((sta->flags & WLAN_STA_ASSOC_REQ_OK) && wds))) {
diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c
index d4f4eb913..ea34d347f 100644
--- a/src/ap/sta_info.c
+++ b/src/ap/sta_info.c
@@ -74,6 +74,7 @@ struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta)
while (s != NULL && os_memcmp(s->addr, sta, 6) != 0)
s = s->hnext;
+#ifdef CONFIG_IEEE80211BE
if (hapd->conf->mld_ap && !s) {
u8 link_id;
@@ -84,10 +85,13 @@ struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta)
continue;
for (s = h->sta_list; s; s = s->next)
- if (!os_memcmp(s->setup_link_addr, sta, 6))
+ if ((!os_memcmp(s->setup_link_addr, sta, 6) ||
+ !os_memcmp(s->addr, sta, 6)) &&
+ s->flags & WLAN_STA_ASSOC)
return s;
}
}
+#endif
return s;
}
diff --git a/src/ap/sta_info.h b/src/ap/sta_info.h
index 6b88799e2..67b97671a 100644
--- a/src/ap/sta_info.h
+++ b/src/ap/sta_info.h
@@ -328,6 +328,7 @@ struct sta_info {
#ifdef CONFIG_IEEE80211BE
struct mld_info mld_info;
u8 mld_assoc_link_id;
+ struct sta_info *mld_assoc_sta;
#endif /* CONFIG_IEEE80211BE */
u16 max_idle_period; /* if nonzero, the granted BSS max idle period in
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 47f4f56c0..ec00c36e4 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -5366,6 +5366,9 @@ struct wpa_driver_ops {
* @pp_mode: Value is defined in enum pp_mode
*/
int (*pp_mode_set)(void *priv, const u8 pp_mode);
+#ifdef CONFIG_IEEE80211BE
+ int (*get_mld_addr)(void *priv, u8 *addr);
+#endif
};
/**
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index dec358fba..8f7215d62 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -15209,6 +15209,17 @@ fail:
return -ENOBUFS;
}
+#ifdef CONFIG_IEEE80211BE
+static int nl80211_get_mld_addr(void *priv, u8 *addr)
+{
+ struct i802_bss *bss = priv;
+
+ os_memcpy(addr, bss->addr, ETH_ALEN);
+
+ return 0;
+}
+#endif
+
const struct wpa_driver_ops wpa_driver_nl80211_ops = {
.name = "nl80211",
.desc = "Linux nl80211/cfg80211",
@@ -15389,4 +15400,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
.amnt_dump = nl80211_amnt_dump,
.background_radar_mode = nl80211_background_radar_mode,
.pp_mode_set = nl80211_pp_mode_set,
+#ifdef CONFIG_IEEE80211BE
+ .get_mld_addr = nl80211_get_mld_addr,
+#endif
};
diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c
index 7f5a3d892..07af6be77 100644
--- a/src/drivers/driver_nl80211_event.c
+++ b/src/drivers/driver_nl80211_event.c
@@ -2575,7 +2575,7 @@ static void nl80211_spurious_frame(struct i802_bss *bss, struct nlattr **tb,
event.rx_from_unknown.addr = nla_data(tb[NL80211_ATTR_MAC]);
event.rx_from_unknown.wds = wds;
- wpa_supplicant_event(drv->ctx, EVENT_RX_FROM_UNKNOWN, &event);
+ wpa_supplicant_event(bss->ctx, EVENT_RX_FROM_UNKNOWN, &event);
}
--
2.18.0