From: Vinayak Yadawad Date: Fri, 8 Dec 2023 16:20:23 +0000 (+0530) Subject: nl80211: Use attribute NL80211_ATTR_BSSID to scan for specific BSSID X-Git-Tag: hostap_2_11~702 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ee7b046a995d1977a178fe9a688a2007cd4ce3f;p=thirdparty%2Fhostap.git nl80211: Use attribute NL80211_ATTR_BSSID to scan for specific BSSID 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 --- diff --git a/src/drivers/driver_nl80211_scan.c b/src/drivers/driver_nl80211_scan.c index 736db6406..530d50c7f 100644 --- a/src/drivers/driver_nl80211_scan.c +++ b/src/drivers/driver_nl80211_scan.c @@ -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; }