Handle both HT40+ and HT40- allowed consistently in channel check

Return the result from the first hostapd_is_usable_chan() call instead
of the following attempts in case of ht40_plus_minus_allowed to have
consistent behavior with the case where only one option is specified.
This allows the fallback to 20 MHz to work in additional cases.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
This commit is contained in:
Jouni Malinen 2024-02-02 17:50:40 +02:00 committed by Jouni Malinen
parent 06edbdf4da
commit d3d59967af

View file

@ -1001,7 +1001,7 @@ static int hostapd_is_usable_chans(struct hostapd_iface *iface)
{ {
int secondary_freq; int secondary_freq;
struct hostapd_channel_data *pri_chan; struct hostapd_channel_data *pri_chan;
int err; int err, err2;
if (!iface->current_mode) if (!iface->current_mode)
return 0; return 0;
@ -1044,15 +1044,15 @@ static int hostapd_is_usable_chans(struct hostapd_iface *iface)
/* Both HT40+ and HT40- are set, pick a valid secondary channel */ /* Both HT40+ and HT40- are set, pick a valid secondary channel */
secondary_freq = iface->freq + 20; secondary_freq = iface->freq + 20;
err = hostapd_is_usable_chan(iface, secondary_freq, 0); err2 = hostapd_is_usable_chan(iface, secondary_freq, 0);
if (err > 0 && (pri_chan->allowed_bw & HOSTAPD_CHAN_WIDTH_40P)) { if (err2 > 0 && (pri_chan->allowed_bw & HOSTAPD_CHAN_WIDTH_40P)) {
iface->conf->secondary_channel = 1; iface->conf->secondary_channel = 1;
return 1; return 1;
} }
secondary_freq = iface->freq - 20; secondary_freq = iface->freq - 20;
err = hostapd_is_usable_chan(iface, secondary_freq, 0); err2 = hostapd_is_usable_chan(iface, secondary_freq, 0);
if (err > 0 && (pri_chan->allowed_bw & HOSTAPD_CHAN_WIDTH_40M)) { if (err2 > 0 && (pri_chan->allowed_bw & HOSTAPD_CHAN_WIDTH_40M)) {
iface->conf->secondary_channel = -1; iface->conf->secondary_channel = -1;
return 1; return 1;
} }