Skip to content

Commit 818965d

Browse files
jmalinenjmberg-intel
authored andcommitted
cfg80211: Allow a scan request for a specific BSSID
This allows scans for a specific BSSID to be optimized by the user space application by requesting the driver to set the Probe Request frame BSSID field (Address 3) to the specified BSSID instead of the wildcard BSSID. This prevents other APs from replying which reduces airtime need and latency in getting the response from the target AP through. This is an optimization and as such, it is acceptable for some of the drivers not to support the mechanism. If not supported, the wildcard BSSID will be used and more responses may be received. Signed-off-by: Jouni Malinen <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent 5c05803 commit 818965d

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

include/net/cfg80211.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,7 @@ struct cfg80211_ssid {
14551455
* @mac_addr_mask: MAC address mask used with randomisation, bits that
14561456
* are 0 in the mask should be randomised, bits that are 1 should
14571457
* be taken from the @mac_addr
1458+
* @bssid: BSSID to scan for (most commonly, the wildcard BSSID)
14581459
*/
14591460
struct cfg80211_scan_request {
14601461
struct cfg80211_ssid *ssids;
@@ -1471,6 +1472,7 @@ struct cfg80211_scan_request {
14711472

14721473
u8 mac_addr[ETH_ALEN] __aligned(2);
14731474
u8 mac_addr_mask[ETH_ALEN] __aligned(2);
1475+
u8 bssid[ETH_ALEN] __aligned(2);
14741476

14751477
/* internal */
14761478
struct wiphy *wiphy;

include/uapi/linux/nl80211.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,9 @@
322322
* @NL80211_CMD_GET_SCAN: get scan results
323323
* @NL80211_CMD_TRIGGER_SCAN: trigger a new scan with the given parameters
324324
* %NL80211_ATTR_TX_NO_CCK_RATE is used to decide whether to send the
325-
* probe requests at CCK rate or not.
325+
* probe requests at CCK rate or not. %NL80211_ATTR_MAC can be used to
326+
* specify a BSSID to scan for; if not included, the wildcard BSSID will
327+
* be used.
326328
* @NL80211_CMD_NEW_SCAN_RESULTS: scan notification (as a reply to
327329
* NL80211_CMD_GET_SCAN and on the "scan" multicast group)
328330
* @NL80211_CMD_SCAN_ABORTED: scan was aborted, for unspecified reasons,

net/wireless/nl80211.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5996,6 +5996,12 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
59965996
request->no_cck =
59975997
nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]);
59985998

5999+
if (info->attrs[NL80211_ATTR_MAC])
6000+
memcpy(request->bssid, nla_data(info->attrs[NL80211_ATTR_MAC]),
6001+
ETH_ALEN);
6002+
else
6003+
eth_broadcast_addr(request->bssid);
6004+
59996005
request->wdev = wdev;
60006006
request->wiphy = &rdev->wiphy;
60016007
request->scan_start = jiffies;

net/wireless/scan.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,8 @@ int cfg80211_wext_siwscan(struct net_device *dev,
12931293
if (wiphy->bands[i])
12941294
creq->rates[i] = (1 << wiphy->bands[i]->n_bitrates) - 1;
12951295

1296+
eth_broadcast_addr(creq->bssid);
1297+
12961298
rdev->scan_req = creq;
12971299
err = rdev_scan(rdev, creq);
12981300
if (err) {

net/wireless/sme.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ static int cfg80211_conn_scan(struct wireless_dev *wdev)
119119
wdev->conn->params.ssid_len);
120120
request->ssids[0].ssid_len = wdev->conn->params.ssid_len;
121121

122+
eth_broadcast_addr(request->bssid);
123+
122124
request->wdev = wdev;
123125
request->wiphy = &rdev->wiphy;
124126
request->scan_start = jiffies;

0 commit comments

Comments
 (0)