Skip to content

Commit 294196a

Browse files
Luis R. Rodriguezlinvjw
authored andcommitted
cfg80211: check allowed channel type upon userspace requests
Thanks to nl80211 userspace can be very specific upon device configuration. Before processing the request for the new HT40 channel types (HT40- or HT40+) we need to ensure we can use them regulatory-wise. This wasn't required with wireless extensions as specifying the channel type wasn't not available and configuration was done towards the end implicitly upon association or reception of beacons from the AP. For the new nl80211 we have to check this when configuring the interfaces explicitly. Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 768777e commit 294196a

1 file changed

Lines changed: 17 additions & 22 deletions

File tree

‎net/wireless/nl80211.c‎

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
492492
enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT;
493493
struct ieee80211_channel *chan;
494494
struct ieee80211_sta_ht_cap *ht_cap;
495-
u32 freq, sec_freq;
495+
u32 freq;
496496

497497
if (!rdev->ops->set_channel) {
498498
result = -EOPNOTSUPP;
@@ -518,33 +518,28 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
518518
if (!chan || chan->flags & IEEE80211_CHAN_DISABLED)
519519
goto bad_res;
520520

521-
if (channel_type == NL80211_CHAN_HT40MINUS)
522-
sec_freq = freq - 20;
523-
else if (channel_type == NL80211_CHAN_HT40PLUS)
524-
sec_freq = freq + 20;
525-
else
526-
sec_freq = 0;
527-
528-
ht_cap = &rdev->wiphy.bands[chan->band]->ht_cap;
529-
530-
/* no HT capabilities */
531-
if (channel_type != NL80211_CHAN_NO_HT &&
532-
!ht_cap->ht_supported)
521+
if (channel_type == NL80211_CHAN_HT40MINUS &&
522+
(chan->flags & IEEE80211_CHAN_NO_HT40MINUS))
523+
goto bad_res;
524+
else if (channel_type == NL80211_CHAN_HT40PLUS &&
525+
(chan->flags & IEEE80211_CHAN_NO_HT40PLUS))
533526
goto bad_res;
534527

535-
if (sec_freq) {
536-
struct ieee80211_channel *schan;
528+
/*
529+
* At this point we know if that if HT40 was requested
530+
* we are allowed to use it and the extension channel
531+
* exists.
532+
*/
537533

538-
/* no 40 MHz capabilities */
534+
ht_cap = &rdev->wiphy.bands[chan->band]->ht_cap;
535+
536+
/* no HT capabilities or intolerant */
537+
if (channel_type != NL80211_CHAN_NO_HT) {
538+
if (!ht_cap->ht_supported)
539+
goto bad_res;
539540
if (!(ht_cap->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) ||
540541
(ht_cap->cap & IEEE80211_HT_CAP_40MHZ_INTOLERANT))
541542
goto bad_res;
542-
543-
schan = ieee80211_get_channel(&rdev->wiphy, sec_freq);
544-
545-
/* Secondary channel not allowed */
546-
if (!schan || schan->flags & IEEE80211_CHAN_DISABLED)
547-
goto bad_res;
548543
}
549544

550545
result = rdev->ops->set_channel(&rdev->wiphy, chan,

0 commit comments

Comments
 (0)