From: Hu Wang Date: Tue, 1 Jun 2021 09:52:40 +0000 (+0800) Subject: hostapd: Reject 40 MHz channel config if regulatory rules do not allow it X-Git-Tag: hostap_2_10~258 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c25b50306ed420a07d23aacfbe35fca1e2fbb447;p=thirdparty%2Fhostap.git hostapd: Reject 40 MHz channel config if regulatory rules do not allow it 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 --- diff --git a/src/ap/hw_features.c b/src/ap/hw_features.c index 7849be181..bb5404fa7 100644 --- a/src/ap/hw_features.c +++ b/src/ap/hw_features.c @@ -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;