Skip to content

Commit ee2aca3

Browse files
committed
cfg80211: add ability to override VHT capabilities
For testing it's sometimes useful to be able to override certain VHT capability advertisement, add the ability to do that in cfg80211. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent c8bb93f commit ee2aca3

6 files changed

Lines changed: 103 additions & 8 deletions

File tree

‎include/net/cfg80211.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,9 +1430,11 @@ struct cfg80211_auth_request {
14301430
* enum cfg80211_assoc_req_flags - Over-ride default behaviour in association.
14311431
*
14321432
* @ASSOC_REQ_DISABLE_HT: Disable HT (802.11n)
1433+
* @ASSOC_REQ_DISABLE_VHT: Disable VHT
14331434
*/
14341435
enum cfg80211_assoc_req_flags {
14351436
ASSOC_REQ_DISABLE_HT = BIT(0),
1437+
ASSOC_REQ_DISABLE_VHT = BIT(1),
14361438
};
14371439

14381440
/**
@@ -1454,6 +1456,8 @@ enum cfg80211_assoc_req_flags {
14541456
* @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
14551457
* will be used in ht_capa. Un-supported values will be ignored.
14561458
* @ht_capa_mask: The bits of ht_capa which are to be used.
1459+
* @vht_capa: VHT capability override
1460+
* @vht_capa_mask: VHT capability mask indicating which fields to use
14571461
*/
14581462
struct cfg80211_assoc_request {
14591463
struct cfg80211_bss *bss;
@@ -1464,6 +1468,7 @@ struct cfg80211_assoc_request {
14641468
u32 flags;
14651469
struct ieee80211_ht_cap ht_capa;
14661470
struct ieee80211_ht_cap ht_capa_mask;
1471+
struct ieee80211_vht_cap vht_capa, vht_capa_mask;
14671472
};
14681473

14691474
/**
@@ -1574,6 +1579,8 @@ struct cfg80211_ibss_params {
15741579
* @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
15751580
* will be used in ht_capa. Un-supported values will be ignored.
15761581
* @ht_capa_mask: The bits of ht_capa which are to be used.
1582+
* @vht_capa: VHT Capability overrides
1583+
* @vht_capa_mask: The bits of vht_capa which are to be used.
15771584
*/
15781585
struct cfg80211_connect_params {
15791586
struct ieee80211_channel *channel;
@@ -1592,6 +1599,8 @@ struct cfg80211_connect_params {
15921599
int bg_scan_period;
15931600
struct ieee80211_ht_cap ht_capa;
15941601
struct ieee80211_ht_cap ht_capa_mask;
1602+
struct ieee80211_vht_cap vht_capa;
1603+
struct ieee80211_vht_cap vht_capa_mask;
15951604
};
15961605

15971606
/**
@@ -2516,6 +2525,8 @@ struct wiphy_wowlan_support {
25162525
* @ap_sme_capa: AP SME capabilities, flags from &enum nl80211_ap_sme_features.
25172526
* @ht_capa_mod_mask: Specify what ht_cap values can be over-ridden.
25182527
* If null, then none can be over-ridden.
2528+
* @vht_capa_mod_mask: Specify what VHT capabilities can be over-ridden.
2529+
* If null, then none can be over-ridden.
25192530
*
25202531
* @max_acl_mac_addrs: Maximum number of MAC addresses that the device
25212532
* supports for ACL.
@@ -2624,6 +2635,7 @@ struct wiphy {
26242635
struct dentry *debugfsdir;
26252636

26262637
const struct ieee80211_ht_cap *ht_capa_mod_mask;
2638+
const struct ieee80211_vht_cap *vht_capa_mod_mask;
26272639

26282640
#ifdef CONFIG_NET_NS
26292641
/* the network namespace this phy lives in currently */

‎include/uapi/linux/nl80211.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,9 @@ enum nl80211_attrs {
16851685
NL80211_ATTR_PROTOCOL_FEATURES,
16861686
NL80211_ATTR_SPLIT_WIPHY_DUMP,
16871687

1688+
NL80211_ATTR_DISABLE_VHT,
1689+
NL80211_ATTR_VHT_CAPABILITY_MASK,
1690+
16881691
/* add attributes here, update the policy in nl80211.c */
16891692

16901693
__NL80211_ATTR_AFTER_LAST,

‎net/wireless/core.h‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,15 +335,19 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
335335
const u8 *ie, int ie_len, bool use_mfp,
336336
struct cfg80211_crypto_settings *crypt,
337337
u32 assoc_flags, struct ieee80211_ht_cap *ht_capa,
338-
struct ieee80211_ht_cap *ht_capa_mask);
338+
struct ieee80211_ht_cap *ht_capa_mask,
339+
struct ieee80211_vht_cap *vht_capa,
340+
struct ieee80211_vht_cap *vht_capa_mask);
339341
int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
340342
struct net_device *dev, struct ieee80211_channel *chan,
341343
const u8 *bssid, const u8 *prev_bssid,
342344
const u8 *ssid, int ssid_len,
343345
const u8 *ie, int ie_len, bool use_mfp,
344346
struct cfg80211_crypto_settings *crypt,
345347
u32 assoc_flags, struct ieee80211_ht_cap *ht_capa,
346-
struct ieee80211_ht_cap *ht_capa_mask);
348+
struct ieee80211_ht_cap *ht_capa_mask,
349+
struct ieee80211_vht_cap *vht_capa,
350+
struct ieee80211_vht_cap *vht_capa_mask);
347351
int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
348352
struct net_device *dev, const u8 *bssid,
349353
const u8 *ie, int ie_len, u16 reason,
@@ -375,6 +379,8 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
375379
bool no_cck, bool dont_wait_for_ack, u64 *cookie);
376380
void cfg80211_oper_and_ht_capa(struct ieee80211_ht_cap *ht_capa,
377381
const struct ieee80211_ht_cap *ht_capa_mask);
382+
void cfg80211_oper_and_vht_capa(struct ieee80211_vht_cap *vht_capa,
383+
const struct ieee80211_vht_cap *vht_capa_mask);
378384

379385
/* SME */
380386
int __cfg80211_connect(struct cfg80211_registered_device *rdev,

‎net/wireless/mlme.c‎

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,23 @@ void cfg80211_oper_and_ht_capa(struct ieee80211_ht_cap *ht_capa,
343343
p1[i] &= p2[i];
344344
}
345345

346+
/* Do a logical ht_capa &= ht_capa_mask. */
347+
void cfg80211_oper_and_vht_capa(struct ieee80211_vht_cap *vht_capa,
348+
const struct ieee80211_vht_cap *vht_capa_mask)
349+
{
350+
int i;
351+
u8 *p1, *p2;
352+
if (!vht_capa_mask) {
353+
memset(vht_capa, 0, sizeof(*vht_capa));
354+
return;
355+
}
356+
357+
p1 = (u8*)(vht_capa);
358+
p2 = (u8*)(vht_capa_mask);
359+
for (i = 0; i < sizeof(*vht_capa); i++)
360+
p1[i] &= p2[i];
361+
}
362+
346363
int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
347364
struct net_device *dev,
348365
struct ieee80211_channel *chan,
@@ -351,7 +368,9 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
351368
const u8 *ie, int ie_len, bool use_mfp,
352369
struct cfg80211_crypto_settings *crypt,
353370
u32 assoc_flags, struct ieee80211_ht_cap *ht_capa,
354-
struct ieee80211_ht_cap *ht_capa_mask)
371+
struct ieee80211_ht_cap *ht_capa_mask,
372+
struct ieee80211_vht_cap *vht_capa,
373+
struct ieee80211_vht_cap *vht_capa_mask)
355374
{
356375
struct wireless_dev *wdev = dev->ieee80211_ptr;
357376
struct cfg80211_assoc_request req;
@@ -388,6 +407,13 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
388407
sizeof(req.ht_capa_mask));
389408
cfg80211_oper_and_ht_capa(&req.ht_capa_mask,
390409
rdev->wiphy.ht_capa_mod_mask);
410+
if (vht_capa)
411+
memcpy(&req.vht_capa, vht_capa, sizeof(req.vht_capa));
412+
if (vht_capa_mask)
413+
memcpy(&req.vht_capa_mask, vht_capa_mask,
414+
sizeof(req.vht_capa_mask));
415+
cfg80211_oper_and_vht_capa(&req.vht_capa_mask,
416+
rdev->wiphy.vht_capa_mod_mask);
391417

392418
req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len,
393419
WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
@@ -422,7 +448,9 @@ int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
422448
const u8 *ie, int ie_len, bool use_mfp,
423449
struct cfg80211_crypto_settings *crypt,
424450
u32 assoc_flags, struct ieee80211_ht_cap *ht_capa,
425-
struct ieee80211_ht_cap *ht_capa_mask)
451+
struct ieee80211_ht_cap *ht_capa_mask,
452+
struct ieee80211_vht_cap *vht_capa,
453+
struct ieee80211_vht_cap *vht_capa_mask)
426454
{
427455
struct wireless_dev *wdev = dev->ieee80211_ptr;
428456
int err;
@@ -431,7 +459,8 @@ int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
431459
wdev_lock(wdev);
432460
err = __cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid,
433461
ssid, ssid_len, ie, ie_len, use_mfp, crypt,
434-
assoc_flags, ht_capa, ht_capa_mask);
462+
assoc_flags, ht_capa, ht_capa_mask,
463+
vht_capa, vht_capa_mask);
435464
wdev_unlock(wdev);
436465
mutex_unlock(&rdev->devlist_mtx);
437466

‎net/wireless/nl80211.c‎

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,10 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = {
371371
[NL80211_ATTR_STA_CAPABILITY] = { .type = NLA_U16 },
372372
[NL80211_ATTR_STA_EXT_CAPABILITY] = { .type = NLA_BINARY, },
373373
[NL80211_ATTR_SPLIT_WIPHY_DUMP] = { .type = NLA_FLAG, },
374+
[NL80211_ATTR_DISABLE_VHT] = { .type = NLA_FLAG },
375+
[NL80211_ATTR_VHT_CAPABILITY_MASK] = {
376+
.len = NL80211_VHT_CAPABILITY_LEN,
377+
},
374378
};
375379

376380
/* policy for the key attributes */
@@ -1522,6 +1526,12 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *dev,
15221526
dev->wiphy.extended_capabilities_mask)))
15231527
goto nla_put_failure;
15241528

1529+
if (dev->wiphy.vht_capa_mod_mask &&
1530+
nla_put(msg, NL80211_ATTR_VHT_CAPABILITY_MASK,
1531+
sizeof(*dev->wiphy.vht_capa_mod_mask),
1532+
dev->wiphy.vht_capa_mod_mask))
1533+
goto nla_put_failure;
1534+
15251535
/* done */
15261536
*split_start = 0;
15271537
break;
@@ -5982,6 +5992,8 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info)
59825992
u32 flags = 0;
59835993
struct ieee80211_ht_cap *ht_capa = NULL;
59845994
struct ieee80211_ht_cap *ht_capa_mask = NULL;
5995+
struct ieee80211_vht_cap *vht_capa = NULL;
5996+
struct ieee80211_vht_cap *vht_capa_mask = NULL;
59855997

59865998
if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
59875999
return -EINVAL;
@@ -6038,12 +6050,25 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info)
60386050
ht_capa = nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]);
60396051
}
60406052

6053+
if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_VHT]))
6054+
flags |= ASSOC_REQ_DISABLE_VHT;
6055+
6056+
if (info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK])
6057+
vht_capa_mask =
6058+
nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]);
6059+
6060+
if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) {
6061+
if (!vht_capa_mask)
6062+
return -EINVAL;
6063+
vht_capa = nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]);
6064+
}
6065+
60416066
err = nl80211_crypto_settings(rdev, info, &crypto, 1);
60426067
if (!err)
60436068
err = cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid,
60446069
ssid, ssid_len, ie, ie_len, use_mfp,
6045-
&crypto, flags, ht_capa,
6046-
ht_capa_mask);
6070+
&crypto, flags, ht_capa, ht_capa_mask,
6071+
vht_capa, vht_capa_mask);
60476072

60486073
return err;
60496074
}
@@ -6623,6 +6648,24 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info)
66236648
sizeof(connect.ht_capa));
66246649
}
66256650

6651+
if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_VHT]))
6652+
connect.flags |= ASSOC_REQ_DISABLE_VHT;
6653+
6654+
if (info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK])
6655+
memcpy(&connect.vht_capa_mask,
6656+
nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]),
6657+
sizeof(connect.vht_capa_mask));
6658+
6659+
if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) {
6660+
if (!info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]) {
6661+
kfree(connkeys);
6662+
return -EINVAL;
6663+
}
6664+
memcpy(&connect.vht_capa,
6665+
nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]),
6666+
sizeof(connect.vht_capa));
6667+
}
6668+
66266669
err = cfg80211_connect(rdev, dev, &connect, connkeys);
66276670
if (err)
66286671
kfree(connkeys);

‎net/wireless/sme.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev)
195195
params->mfp != NL80211_MFP_NO,
196196
&params->crypto,
197197
params->flags, &params->ht_capa,
198-
&params->ht_capa_mask);
198+
&params->ht_capa_mask,
199+
&params->vht_capa,
200+
&params->vht_capa_mask);
199201
if (err)
200202
__cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
201203
NULL, 0,

0 commit comments

Comments
 (0)