]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl80211: Use frequency to determine MLD link for MLME events
authorAndrei Otcheretianski <andrei.otcheretianski@intel.com>
Mon, 22 May 2023 19:33:57 +0000 (22:33 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 12 Jun 2023 20:13:21 +0000 (23:13 +0300)
This is needed since link_id is not always available. In addition,
recognize the link address as a known address.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
src/drivers/driver_nl80211.c
src/drivers/driver_nl80211.h
src/drivers/driver_nl80211_event.c

index dc512c8565d1ebb0307196c334b08f2eaca12112..b15c9e419159a521df7619018423cd09c3329aef 100644 (file)
@@ -4118,7 +4118,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;
 
index cd883e44b3b7cfc06dfc6c8df154b7b97bbc4fc6..7586e0809d1f4fa014071c070380934aa454656a 100644 (file)
@@ -323,6 +323,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);
index bc1dd4371354835e0bb524cfe09d4b4858104802..82525da72a60690ecc726d0bf3e4e579261eaa8a 100644 (file)
@@ -1611,6 +1611,21 @@ 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, unsigned int freq)
+{
+       unsigned int i;
+
+       for (i = 0; i < bss->n_links; i++) {
+               if ((unsigned int) 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,
@@ -1623,7 +1638,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);
@@ -1637,10 +1653,15 @@ static void mlme_event(struct i802_bss *bss,
                return;
        }
 
+       /* Determine the MLD link either by an explicitly provided link id or
+        * finding a match based on the frequency. */
        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);
@@ -1683,7 +1704,9 @@ 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;