AP/MLO: Forward received EAPOL frames to correct BSS

In case of MLO AP and legacy client, make sure received EAPOL frames are
processed on the correct BSS.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
This commit is contained in:
Andrei Otcheretianski 2023-05-22 22:34:10 +03:00 committed by Jouni Malinen
parent 5c6cad01fd
commit 5199cff4c7

View file

@ -1623,25 +1623,76 @@ static int hostapd_event_new_sta(struct hostapd_data *hapd, const u8 *addr)
} }
static struct hostapd_data * hostapd_find_by_sta(struct hostapd_iface *iface,
const u8 *src)
{
struct sta_info *sta;
unsigned int j;
for (j = 0; j < iface->num_bss; j++) {
sta = ap_get_sta(iface->bss[j], src);
if (sta && sta->flags & WLAN_STA_ASSOC)
return iface->bss[j];
}
return NULL;
}
static void hostapd_event_eapol_rx(struct hostapd_data *hapd, const u8 *src, static void hostapd_event_eapol_rx(struct hostapd_data *hapd, const u8 *src,
const u8 *data, size_t data_len, const u8 *data, size_t data_len,
enum frame_encryption encrypted, enum frame_encryption encrypted,
int link_id) int link_id)
{ {
struct hostapd_iface *iface; struct hostapd_data *orig_hapd = hapd;
struct sta_info *sta;
size_t j; #ifdef CONFIG_IEEE80211BE
if (link_id != -1) {
struct hostapd_data *h_hapd;
hapd = switch_link_hapd(hapd, link_id); hapd = switch_link_hapd(hapd, link_id);
iface = hapd->iface; h_hapd = hostapd_find_by_sta(hapd->iface, src);
if (!h_hapd)
h_hapd = hostapd_find_by_sta(orig_hapd->iface, src);
if (h_hapd)
hapd = h_hapd;
} else if (hapd->conf->mld_ap) {
unsigned int i;
for (j = 0; j < iface->num_bss; j++) { /* Search for STA on other MLO BSSs */
sta = ap_get_sta(iface->bss[j], src); for (i = 0; i < hapd->iface->interfaces->count; i++) {
if (sta && sta->flags & WLAN_STA_ASSOC) { struct hostapd_iface *h =
hapd = iface->bss[j]; hapd->iface->interfaces->iface[i];
struct hostapd_data *h_hapd = h->bss[0];
struct hostapd_bss_config *hconf = h_hapd->conf;
if (!hconf->mld_ap ||
hconf->mld_id != hapd->conf->mld_id)
continue;
h_hapd = hostapd_find_by_sta(h, src);
if (h_hapd) {
hapd = h_hapd;
break; break;
} }
} }
} else {
hapd = hostapd_find_by_sta(hapd->iface, src);
}
#else /* CONFIG_IEEE80211BE */
hapd = hostapd_find_by_sta(hapd->iface, src);
#endif /* CONFIG_IEEE80211BE */
if (!hapd) {
/* WLAN cases need to have an existing association, but non-WLAN
* cases (mainly, wired IEEE 802.1X) need to be able to process
* EAPOL frames from new devices that do not yet have a STA
* entry and as such, do not get a match in
* hostapd_find_by_sta(). */
wpa_printf(MSG_DEBUG,
"No STA-specific hostapd instance for EAPOL RX found - fall back to initial context");
hapd = orig_hapd;
}
ieee802_1x_receive(hapd, src, data, data_len, encrypted); ieee802_1x_receive(hapd, src, data, data_len, encrypted);
} }