aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2014-06-12 15:39:05 -0400
committerJohannes Berg <johannes.berg@intel.com>2014-11-19 12:45:52 -0500
commitad2b26abc157460ca6fac1a53a2bfeade283adfa (patch)
tree81f73219cf0132dca99028fe1a8f4a26805d5247 /include
parentff5db4392c75e005882dd93641b2caa436437dd6 (diff)
cfg80211: allow drivers to support random MAC addresses for scan
Add the necessary feature flags and a scan flag to support using random MAC addresses for scan while unassociated. The configuration for this supports an arbitrary MAC address value and mask, so that any kind of configuration (e.g. fixed OUI or full 46-bit random) can be requested. Full 46-bit random is the default when no other configuration is passed. Also add a small helper function to use the addr/mask correctly. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'include')
-rw-r--r--include/net/cfg80211.h25
-rw-r--r--include/uapi/linux/nl80211.h29
2 files changed, 54 insertions, 0 deletions
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 05aae22e92a5..bb748c4da5af 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1437,6 +1437,10 @@ struct cfg80211_ssid {
1437 * @aborted: (internal) scan request was notified as aborted 1437 * @aborted: (internal) scan request was notified as aborted
1438 * @notified: (internal) scan request was notified as done or aborted 1438 * @notified: (internal) scan request was notified as done or aborted
1439 * @no_cck: used to send probe requests at non CCK rate in 2GHz band 1439 * @no_cck: used to send probe requests at non CCK rate in 2GHz band
1440 * @mac_addr: MAC address used with randomisation
1441 * @mac_addr_mask: MAC address mask used with randomisation, bits that
1442 * are 0 in the mask should be randomised, bits that are 1 should
1443 * be taken from the @mac_addr
1440 */ 1444 */
1441struct cfg80211_scan_request { 1445struct cfg80211_scan_request {
1442 struct cfg80211_ssid *ssids; 1446 struct cfg80211_ssid *ssids;
@@ -1451,6 +1455,9 @@ struct cfg80211_scan_request {
1451 1455
1452 struct wireless_dev *wdev; 1456 struct wireless_dev *wdev;
1453 1457
1458 u8 mac_addr[ETH_ALEN] __aligned(2);
1459 u8 mac_addr_mask[ETH_ALEN] __aligned(2);
1460
1454 /* internal */ 1461 /* internal */
1455 struct wiphy *wiphy; 1462 struct wiphy *wiphy;
1456 unsigned long scan_start; 1463 unsigned long scan_start;
@@ -1461,6 +1468,17 @@ struct cfg80211_scan_request {
1461 struct ieee80211_channel *channels[0]; 1468 struct ieee80211_channel *channels[0];
1462}; 1469};
1463 1470
1471static inline void get_random_mask_addr(u8 *buf, const u8 *addr, const u8 *mask)
1472{
1473 int i;
1474
1475 get_random_bytes(buf, ETH_ALEN);
1476 for (i = 0; i < ETH_ALEN; i++) {
1477 buf[i] &= ~mask[i];
1478 buf[i] |= addr[i] & mask[i];
1479 }
1480}
1481
1464/** 1482/**
1465 * struct cfg80211_match_set - sets of attributes to match 1483 * struct cfg80211_match_set - sets of attributes to match
1466 * 1484 *
@@ -1494,6 +1512,10 @@ struct cfg80211_match_set {
1494 * @channels: channels to scan 1512 * @channels: channels to scan
1495 * @min_rssi_thold: for drivers only supporting a single threshold, this 1513 * @min_rssi_thold: for drivers only supporting a single threshold, this
1496 * contains the minimum over all matchsets 1514 * contains the minimum over all matchsets
1515 * @mac_addr: MAC address used with randomisation
1516 * @mac_addr_mask: MAC address mask used with randomisation, bits that
1517 * are 0 in the mask should be randomised, bits that are 1 should
1518 * be taken from the @mac_addr
1497 */ 1519 */
1498struct cfg80211_sched_scan_request { 1520struct cfg80211_sched_scan_request {
1499 struct cfg80211_ssid *ssids; 1521 struct cfg80211_ssid *ssids;
@@ -1508,6 +1530,9 @@ struct cfg80211_sched_scan_request {
1508 int n_match_sets; 1530 int n_match_sets;
1509 s32 min_rssi_thold; 1531 s32 min_rssi_thold;
1510 1532
1533 u8 mac_addr[ETH_ALEN] __aligned(2);
1534 u8 mac_addr_mask[ETH_ALEN] __aligned(2);
1535
1511 /* internal */ 1536 /* internal */
1512 struct wiphy *wiphy; 1537 struct wiphy *wiphy;
1513 struct net_device *dev; 1538 struct net_device *dev;
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index d23208194e3c..a99081efc2d4 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1686,6 +1686,8 @@ enum nl80211_commands {
1686 * 1686 *
1687 * @NL80211_ATTR_OPER_CLASS: operating class 1687 * @NL80211_ATTR_OPER_CLASS: operating class
1688 * 1688 *
1689 * @NL80211_ATTR_MAC_MASK: MAC address mask
1690 *
1689 * @NUM_NL80211_ATTR: total number of nl80211_attrs available 1691 * @NUM_NL80211_ATTR: total number of nl80211_attrs available
1690 * @NL80211_ATTR_MAX: highest attribute number currently defined 1692 * @NL80211_ATTR_MAX: highest attribute number currently defined
1691 * @__NL80211_ATTR_AFTER_LAST: internal use 1693 * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2041,6 +2043,8 @@ enum nl80211_attrs {
2041 2043
2042 NL80211_ATTR_OPER_CLASS, 2044 NL80211_ATTR_OPER_CLASS,
2043 2045
2046 NL80211_ATTR_MAC_MASK,
2047
2044 /* add attributes here, update the policy in nl80211.c */ 2048 /* add attributes here, update the policy in nl80211.c */
2045 2049
2046 __NL80211_ATTR_AFTER_LAST, 2050 __NL80211_ATTR_AFTER_LAST,
@@ -4139,6 +4143,18 @@ enum nl80211_ap_sme_features {
4139 * See 'macaddr' field in the vif_params (cfg80211.h). 4143 * See 'macaddr' field in the vif_params (cfg80211.h).
4140 * @NL80211_FEATURE_TDLS_CHANNEL_SWITCH: Driver supports channel switching when 4144 * @NL80211_FEATURE_TDLS_CHANNEL_SWITCH: Driver supports channel switching when
4141 * operating as a TDLS peer. 4145 * operating as a TDLS peer.
4146 * @NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR: This device/driver supports using a
4147 * random MAC address during scan (if the device is unassociated); the
4148 * %NL80211_SCAN_FLAG_RANDOM_ADDR flag may be set for scans and the MAC
4149 * address mask/value will be used.
4150 * @NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR: This device/driver supports
4151 * using a random MAC address for every scan iteration during scheduled
4152 * scan (while not associated), the %NL80211_SCAN_FLAG_RANDOM_ADDR may
4153 * be set for scheduled scan and the MAC address mask/value will be used.
4154 * @NL80211_FEATURE_ND_RANDOM_MAC_ADDR: This device/driver supports using a
4155 * random MAC address for every scan iteration during "net detect", i.e.
4156 * scan in unassociated WoWLAN, the %NL80211_SCAN_FLAG_RANDOM_ADDR may
4157 * be set for scheduled scan and the MAC address mask/value will be used.
4142 */ 4158 */
4143enum nl80211_feature_flags { 4159enum nl80211_feature_flags {
4144 NL80211_FEATURE_SK_TX_STATUS = 1 << 0, 4160 NL80211_FEATURE_SK_TX_STATUS = 1 << 0,
@@ -4170,6 +4186,9 @@ enum nl80211_feature_flags {
4170 NL80211_FEATURE_SUPPORTS_WMM_ADMISSION = 1 << 26, 4186 NL80211_FEATURE_SUPPORTS_WMM_ADMISSION = 1 << 26,
4171 NL80211_FEATURE_MAC_ON_CREATE = 1 << 27, 4187 NL80211_FEATURE_MAC_ON_CREATE = 1 << 27,
4172 NL80211_FEATURE_TDLS_CHANNEL_SWITCH = 1 << 28, 4188 NL80211_FEATURE_TDLS_CHANNEL_SWITCH = 1 << 28,
4189 NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR = 1 << 29,
4190 NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR = 1 << 30,
4191 NL80211_FEATURE_ND_RANDOM_MAC_ADDR = 1 << 31,
4173}; 4192};
4174 4193
4175/** 4194/**
@@ -4218,11 +4237,21 @@ enum nl80211_connect_failed_reason {
4218 * dangerous because will destroy stations performance as a lot of frames 4237 * dangerous because will destroy stations performance as a lot of frames
4219 * will be lost while scanning off-channel, therefore it must be used only 4238 * will be lost while scanning off-channel, therefore it must be used only
4220 * when really needed 4239 * when really needed
4240 * @NL80211_SCAN_FLAG_RANDOM_ADDR: use a random MAC address for this scan (or
4241 * for scheduled scan: a different one for every scan iteration). When the
4242 * flag is set, depending on device capabilities the @NL80211_ATTR_MAC and
4243 * @NL80211_ATTR_MAC_MASK attributes may also be given in which case only
4244 * the masked bits will be preserved from the MAC address and the remainder
4245 * randomised. If the attributes are not given full randomisation (46 bits,
4246 * locally administered 1, multicast 0) is assumed.
4247 * This flag must not be requested when the feature isn't supported, check
4248 * the nl80211 feature flags for the device.
4221 */ 4249 */
4222enum nl80211_scan_flags { 4250enum nl80211_scan_flags {
4223 NL80211_SCAN_FLAG_LOW_PRIORITY = 1<<0, 4251 NL80211_SCAN_FLAG_LOW_PRIORITY = 1<<0,
4224 NL80211_SCAN_FLAG_FLUSH = 1<<1, 4252 NL80211_SCAN_FLAG_FLUSH = 1<<1,
4225 NL80211_SCAN_FLAG_AP = 1<<2, 4253 NL80211_SCAN_FLAG_AP = 1<<2,
4254 NL80211_SCAN_FLAG_RANDOM_ADDR = 1<<3,
4226}; 4255};
4227 4256
4228/** 4257/**