Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nl80211: Disallow setting of HT for channel 14

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 <masashi.honma@gmail.com>
Link: https://lore.kernel.org/r/20191021075045.2719-1-masashi.honma@gmail.com
[clean up the code, use != instead of equivalent >]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Masashi Honma and committed by
Johannes Berg
ec649fed 6f74a55d

+7 -1
+5
net/wireless/chan.c
··· 204 204 return false; 205 205 } 206 206 207 + /* channel 14 is only for IEEE 802.11b */ 208 + if (chandef->center_freq1 == 2484 && 209 + chandef->width != NL80211_CHAN_WIDTH_20_NOHT) 210 + return false; 211 + 207 212 if (cfg80211_chandef_is_edmg(chandef) && 208 213 !cfg80211_edmg_chandef_valid(chandef)) 209 214 return false;
+2 -1
net/wireless/util.c
··· 1559 1559 } 1560 1560 1561 1561 if (freq == 2484) { 1562 - if (chandef->width > NL80211_CHAN_WIDTH_40) 1562 + /* channel 14 is only for IEEE 802.11b */ 1563 + if (chandef->width != NL80211_CHAN_WIDTH_20_NOHT) 1563 1564 return false; 1564 1565 1565 1566 *op_class = 82; /* channel 14 */