]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl80211: Use attribute NL80211_ATTR_BSSID to scan for specific BSSID
authorVinayak Yadawad <vinayak.yadawad@broadcom.com>
Fri, 8 Dec 2023 16:20:23 +0000 (21:50 +0530)
committerJouni Malinen <j@w1.fi>
Sat, 9 Dec 2023 08:56:20 +0000 (10:56 +0200)
With changes to optimize scan for specific BSSID, there arises a
scenario where in nl80211_trigger_scan() is called with a scan
randomization enabled. A combination of NL80211_ATTR_MAC for BSSID and
scan randomization, which uses NL80211_ATTR_MAC for a different purpose,
results in invalid error for the scan request. To fix the issue use
attribute NL80211_ATTR_BSSID instead of NL80211_ATTR_MAC.

NL80211_ATTR_BSSID was introduced in kernel commit 2fa436b3a2a7
("nl80211: Use different attrs for BSSID and random MAC addr in scan
req") in 2016. Prior to that, only NL80211_ATTR_MAC could be used for
specifying the target BSSID. For backwards compatibility, add the
NL80211_ATTR_MAC attribute as well when not using a random MAC address.

Signed-off-by: Vinayak Yadawad <vinayak.yadawad@broadcom.com>
src/drivers/driver_nl80211_scan.c

index 736db6406357303dbd9f29150007688d1e200231..530d50c7f1cb913b2c336fd24486bdf71a561cd3 100644 (file)
@@ -385,7 +385,15 @@ int wpa_driver_nl80211_scan(struct i802_bss *bss,
        if (params->bssid) {
                wpa_printf(MSG_DEBUG, "nl80211: Scan for a specific BSSID: "
                           MACSTR, MAC2STR(params->bssid));
-               if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, params->bssid))
+               if (nla_put(msg, NL80211_ATTR_BSSID, ETH_ALEN, params->bssid))
+                       goto fail;
+               /* NL80211_ATTR_MAC was used for this purpose initially and the
+                * NL80211_ATTR_BSSID was added in 2016 when MAC address
+                * randomization was added. For compatibility with older kernel
+                * versions, add the NL80211_ATTR_MAC attribute as well when
+                * the conflicting functionality is not in use. */
+               if (!params->mac_addr_rand &&
+                   nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, params->bssid))
                        goto fail;
        }