History

cfg80211: add checks for beacon rate, extend to mesh

The previous commit added support for specifying the beacon rate for AP mode. Add features checks to this, and extend it to also support the rate configuration for mesh networks. For IBSS it's not as simple due to joining etc., so that's not yet supported.

Johannes Berg committed 10 years ago

Commit 8564e381 parent a7c7fbf3 files · +54 −13Browse files

Unified · Split

3 files
  1. include/net/cfg80211.h +3 −1
  2. include/uapi/linux/nl80211.h +16 −1
  3. net/wireless/nl80211.c +35 −11
include/net/cfg80211.h+3−1
@@ -712,7 +712,7 @@ struct cfg80211_bitrate_mask { · 711 unmodified lines
712712 * MAC address based access control
713713 * @pbss: If set, start as a PCP instead of AP. Relevant for DMG
714714 * networks.
715− * @beacon_rate: masks for setting user configured beacon tx rate.
715+ * @beacon_rate: bitrate to be used for beacons
716716 */
717717 struct cfg80211_ap_settings {
718718 struct cfg80211_chan_def chandef;
@@ -1365,6 +1365,7 @@ struct mesh_config { · 646 unmodified lines
13651365 * @beacon_interval: beacon interval to use
13661366 * @mcast_rate: multicat rate for Mesh Node [6Mbps is the default for 802.11a]
13671367 * @basic_rates: basic rates to use when creating the mesh
1368+ * @beacon_rate: bitrate to be used for beacons
13681369 *
13691370 * These parameters are fixed when the mesh is created.
13701371 */
@@ -1385,6 +1386,7 @@ struct mesh_setup { · 14 unmodified lines
13851386 u16 beacon_interval;
13861387 int mcast_rate[NUM_NL80211_BANDS];
13871388 u32 basic_rates;
1389+ struct cfg80211_bitrate_mask beacon_rate;
13881390 };
13891391
13901392 /**
include/uapi/linux/nl80211.h+16−1
@@ -1343,7 +1343,13 @@ enum nl80211_commands { · 1342 unmodified lines
13431343 * enum nl80211_band value is used as the index (nla_type() of the nested
13441344 * data. If a band is not included, it will be configured to allow all
13451345 * rates based on negotiated supported rates information. This attribute
1346− * is used with %NL80211_CMD_SET_TX_BITRATE_MASK.
1346+ * is used with %NL80211_CMD_SET_TX_BITRATE_MASK and with starting AP,
1347+ * and joining mesh networks (not IBSS yet). In the later case, it must
1348+ * specify just a single bitrate, which is to be used for the beacon.
1349+ * The driver must also specify support for this with the extended
1350+ * features NL80211_EXT_FEATURE_BEACON_RATE_LEGACY,
1351+ * NL80211_EXT_FEATURE_BEACON_RATE_HT and
1352+ * NL80211_EXT_FEATURE_BEACON_RATE_VHT.
13471353 *
13481354 * @NL80211_ATTR_FRAME_MATCH: A binary attribute which typically must contain
13491355 * at least one byte, currently used with @NL80211_CMD_REGISTER_FRAME.
@@ -4551,6 +4557,12 @@ enum nl80211_feature_flags { · 3201 unmodified lines
45514557 * (if available).
45524558 * @NL80211_EXT_FEATURE_SET_SCAN_DWELL: This driver supports configuration of
45534559 * channel dwell time.
4560+ * @NL80211_EXT_FEATURE_BEACON_RATE_LEGACY: Driver supports beacon rate
4561+ * configuration (AP/mesh), supporting a legacy (non HT/VHT) rate.
4562+ * @NL80211_EXT_FEATURE_BEACON_RATE_HT: Driver supports beacon rate
4563+ * configuration (AP/mesh) with HT rates.
4564+ * @NL80211_EXT_FEATURE_BEACON_RATE_VHT: Driver supports beacon rate
4565+ * configuration (AP/mesh) with VHT rates.
45544566 *
45554567 * @NUM_NL80211_EXT_FEATURES: number of extended features.
45564568 * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
@@ -4562,6 +4574,9 @@ enum nl80211_ext_feature_index { · 5 unmodified lines
45624574 NL80211_EXT_FEATURE_SCAN_START_TIME,
45634575 NL80211_EXT_FEATURE_BSS_PARENT_TSF,
45644576 NL80211_EXT_FEATURE_SET_SCAN_DWELL,
4577+ NL80211_EXT_FEATURE_BEACON_RATE_LEGACY,
4578+ NL80211_EXT_FEATURE_BEACON_RATE_HT,
4579+ NL80211_EXT_FEATURE_BEACON_RATE_VHT,
45654580
45664581 /* add new features before the definition below */
45674582 NUM_NL80211_EXT_FEATURES,
net/wireless/nl80211.c+35−11
@@ -3569,13 +3569,12 @@ out: · 3568 unmodified lines
35693569 return 0;
35703570 }
35713571
3572−static int validate_beacon_tx_rate(struct cfg80211_ap_settings *params)
3572+static int validate_beacon_tx_rate(struct cfg80211_registered_device *rdev,
3573+ enum nl80211_band band,
3574+ struct cfg80211_bitrate_mask *beacon_rate)
35733575 {
3574− u32 rate, count_ht, count_vht, i;
3575− enum nl80211_band band;
3576−
3577− band = params->chandef.chan->band;
3578− rate = params->beacon_rate.control[band].legacy;
3576+ u32 count_ht, count_vht, i;
3577+ u32 rate = beacon_rate->control[band].legacy;
35793578
35803579 /* Allow only one rate */
35813580 if (hweight32(rate) > 1)
@@ -3583,9 +3582,9 @@ static int validate_beacon_tx_rate(struct cfg80211_ap_settings *params) · 1 unmodified line
35833582
35843583 count_ht = 0;
35853584 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++) {
3586− if (hweight8(params->beacon_rate.control[band].ht_mcs[i]) > 1) {
3585+ if (hweight8(beacon_rate->control[band].ht_mcs[i]) > 1) {
35873586 return -EINVAL;
3588− } else if (params->beacon_rate.control[band].ht_mcs[i]) {
3587+ } else if (beacon_rate->control[band].ht_mcs[i]) {
35893588 count_ht++;
35903589 if (count_ht > 1)
35913590 return -EINVAL;
@@ -3596,9 +3595,9 @@ static int validate_beacon_tx_rate(struct cfg80211_ap_settings *params) · 4 unmodified lines
35963595
35973596 count_vht = 0;
35983597 for (i = 0; i < NL80211_VHT_NSS_MAX; i++) {
3599− if (hweight16(params->beacon_rate.control[band].vht_mcs[i]) > 1) {
3598+ if (hweight16(beacon_rate->control[band].vht_mcs[i]) > 1) {
36003599 return -EINVAL;
3601− } else if (params->beacon_rate.control[band].vht_mcs[i]) {
3600+ } else if (beacon_rate->control[band].vht_mcs[i]) {
36023601 count_vht++;
36033602 if (count_vht > 1)
36043603 return -EINVAL;
@@ -3610,6 +3609,19 @@ static int validate_beacon_tx_rate(struct cfg80211_ap_settings *params) · 5 unmodified lines
36103609 if ((count_ht && count_vht) || (!rate && !count_ht && !count_vht))
36113610 return -EINVAL;
36123611
3612+ if (rate &&
3613+ !wiphy_ext_feature_isset(&rdev->wiphy,
3614+ NL80211_EXT_FEATURE_BEACON_RATE_LEGACY))
3615+ return -EINVAL;
3616+ if (count_ht &&
3617+ !wiphy_ext_feature_isset(&rdev->wiphy,
3618+ NL80211_EXT_FEATURE_BEACON_RATE_HT))
3619+ return -EINVAL;
3620+ if (count_vht &&
3621+ !wiphy_ext_feature_isset(&rdev->wiphy,
3622+ NL80211_EXT_FEATURE_BEACON_RATE_VHT))
3623+ return -EINVAL;
3624+
36133625 return 0;
36143626 }
36153627
@@ -3847,7 +3859,8 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) · 231 unmodified lines
38473859 if (err)
38483860 return err;
38493861
3850− err = validate_beacon_tx_rate(&params);
3862+ err = validate_beacon_tx_rate(rdev, params.chandef.chan->band,
3863+ &params.beacon_rate);
38513864 if (err)
38523865 return err;
38533866 }
@@ -9406,6 +9419,17 @@ static int nl80211_join_mesh(struct sk_buff *skb, struct genl_info *info) · 5552 unmodified lines
94069419 return err;
94079420 }
94089421
9422+ if (info->attrs[NL80211_ATTR_TX_RATES]) {
9423+ err = nl80211_parse_tx_bitrate_mask(info, &setup.beacon_rate);
9424+ if (err)
9425+ return err;
9426+
9427+ err = validate_beacon_tx_rate(rdev, setup.chandef.chan->band,
9428+ &setup.beacon_rate);
9429+ if (err)
9430+ return err;
9431+ }
9432+
94099433 return cfg80211_join_mesh(rdev, dev, &setup, &cfg);
94109434 }
94119435

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t