Skip to content

Commit

Permalink
nl80211: Disallow setting of HT for channel 14
Browse files Browse the repository at this point in the history
This patch disables setting of HT20 and more for channel 14 because
the channel is only for IEEE 802.11b.

The patch for net/wireless/util.c was unit-tested.

The patch for net/wireless/chan.c was tested with iw command.

Before this patch.
$ sudo iw dev <ifname> set channel 14 HT20
$

After this patch.
$ sudo iw dev <ifname> set channel 14 HT20
kernel reports: invalid channel definition
command failed: Invalid argument (-22)
$

Signed-off-by: Masashi Honma <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[clean up the code, use != instead of equivalent >]
Signed-off-by: Johannes Berg <[email protected]>
  • Loading branch information
masap authored and jmberg-intel committed Oct 30, 2019
1 parent 6f74a55 commit ec649fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions net/wireless/chan.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef)
return false;
}

/* channel 14 is only for IEEE 802.11b */
if (chandef->center_freq1 == 2484 &&
chandef->width != NL80211_CHAN_WIDTH_20_NOHT)
return false;

if (cfg80211_chandef_is_edmg(chandef) &&
!cfg80211_edmg_chandef_valid(chandef))
return false;
Expand Down
3 changes: 2 additions & 1 deletion net/wireless/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,8 @@ bool ieee80211_chandef_to_operating_class(struct cfg80211_chan_def *chandef,
}

if (freq == 2484) {
if (chandef->width > NL80211_CHAN_WIDTH_40)
/* channel 14 is only for IEEE 802.11b */
if (chandef->width != NL80211_CHAN_WIDTH_20_NOHT)
return false;

*op_class = 82; /* channel 14 */
Expand Down

0 comments on commit ec649fe

Please sign in to comment.