]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Reject 40 MHz channel config if regulatory rules do not allow it
authorHu Wang <huw@codeaurora.org>
Tue, 1 Jun 2021 09:52:40 +0000 (17:52 +0800)
committerJouni Malinen <j@w1.fi>
Tue, 1 Jun 2021 21:06:20 +0000 (00:06 +0300)
When regulatory rules are configured not to support 40 MHz channels on
the 2.4 GHz band, hostapd_is_usable_chans() still allowed 40 MHz
channels (i.e., 1-9) to be used with ht_capab=[HT40+][HT40-].

Looking into hostapd_is_usable_chans():
1) Validate primary channel using hostapd_is_usable_chan()
2) Try to pick a default secondary channel if hostapd_is_usable_chan()
3) Try to pick a valid secondary channel if both HT40+/HT40- set, and
   further validate primary channel's allowed bandwidth mask.
4) Return channel not usable.

For example, for the 2.4 GHz channel 9 in Japan, its default secondary
channel is 13, which is valid per hostapd_is_usable_chan(), so step (2)
returns channel usable.

Add a more strict check to step (2) to clearly reject 40 MHz channel
configuration if regulatory rules do not allow the 40 MHz bandwidth,
which is similarly done in commit ce6d9ce15b07 ("hostapd: Add supported
channel bandwidth checking infrastructure").

Signed-off-by: Hu Wang <huw@codeaurora.org>
src/ap/hw_features.c

index 7849be181c212d6fb68c14d25a149e8f432ac892..bb5404fa7dd4df6664d94a69e7f5f24d59f3aa84 100644 (file)
@@ -917,8 +917,14 @@ static int hostapd_is_usable_chans(struct hostapd_iface *iface)
                return 1;
 
        if (hostapd_is_usable_chan(iface, iface->freq +
-                                  iface->conf->secondary_channel * 20, 0))
-               return 1;
+                                  iface->conf->secondary_channel * 20, 0)) {
+               if (iface->conf->secondary_channel == 1 &&
+                   (pri_chan->allowed_bw & HOSTAPD_CHAN_WIDTH_40P))
+                       return 1;
+               if (iface->conf->secondary_channel == -1 &&
+                   (pri_chan->allowed_bw & HOSTAPD_CHAN_WIDTH_40M))
+                       return 1;
+       }
        if (!iface->conf->ht40_plus_minus_allowed)
                return 0;