As link_id isn't always available. Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@xxxxxxxxx> --- src/drivers/driver_nl80211.c | 2 +- src/drivers/driver_nl80211.h | 1 + src/drivers/driver_nl80211_event.c | 30 +++++++++++++++++++++++++----- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 7bacdd3f50..8bb1c3f0d7 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -4116,7 +4116,7 @@ int wpa_driver_nl80211_authenticate_retry(struct wpa_driver_nl80211_data *drv) } -static struct i802_link *nl80211_get_link(struct i802_bss *bss, s8 link_id) +struct i802_link *nl80211_get_link(struct i802_bss *bss, s8 link_id) { unsigned int i; diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h index ed6293bd3b..b38cd7f53a 100644 --- a/src/drivers/driver_nl80211.h +++ b/src/drivers/driver_nl80211.h @@ -319,6 +319,7 @@ int process_bss_event(struct nl_msg *msg, void *arg); const char * nl80211_iftype_str(enum nl80211_iftype mode); void nl80211_restore_ap_mode(struct i802_bss *bss); +struct i802_link *nl80211_get_link(struct i802_bss *bss, s8 link_id); #ifdef ANDROID int android_nl_socket_set_nonblocking(struct nl_sock *handle); diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c index a6f8c97ca2..838afabcc7 100644 --- a/src/drivers/driver_nl80211_event.c +++ b/src/drivers/driver_nl80211_event.c @@ -1406,6 +1406,20 @@ static void mlme_event_unprot_beacon(struct wpa_driver_nl80211_data *drv, } +static struct i802_link *nl80211_get_mld_link_by_freq(struct i802_bss *bss, u32 freq) +{ + unsigned int i; + + for (i = 0; i < bss->n_links; i++) { + if ((u32)bss->links[i].freq == freq && + bss->links[i].link_id != -1) + return &bss->links[i]; + } + + return NULL; +} + + static void mlme_event(struct i802_bss *bss, enum nl80211_commands cmd, struct nlattr *frame, struct nlattr *addr, struct nlattr *timed_out, @@ -1418,7 +1432,8 @@ static void mlme_event(struct i802_bss *bss, u16 stype = 0, auth_type = 0; const u8 *data; size_t len; - int link_id; + int link_id = -1; + struct i802_link *mld_link = NULL; if (timed_out && addr) { mlme_timeout_event(drv, cmd, addr); @@ -1432,10 +1447,14 @@ static void mlme_event(struct i802_bss *bss, return; } + /* get the mld link either by link id or freq */ if (link) - link_id = nla_get_u8(link); - else - link_id = -1; + mld_link = nl80211_get_link(bss, nla_get_u8(link)); + else if (freq) + mld_link = nl80211_get_mld_link_by_freq(bss, nla_get_u32(freq)); + + if (mld_link) + link_id = mld_link->link_id; data = nla_data(frame); len = nla_len(frame); @@ -1478,7 +1497,8 @@ static void mlme_event(struct i802_bss *bss, os_memcmp(bss->addr, data + 4 + ETH_ALEN, ETH_ALEN) != 0 && (is_zero_ether_addr(drv->first_bss->prev_addr) || os_memcmp(bss->prev_addr, data + 4 + ETH_ALEN, - ETH_ALEN) != 0)) { + ETH_ALEN) != 0) && + (!mld_link || os_memcmp(mld_link->addr, data + 4, ETH_ALEN) != 0)) { wpa_printf(MSG_MSGDUMP, "nl80211: %s: Ignore MLME frame event " "for foreign address", bss->ifname); return; -- 2.38.1 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap