]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
ACS: Stop before scan if no channels in chanlist are available
authorNeo Jou <neojou@gmail.com>
Wed, 18 Sep 2019 07:39:50 +0000 (15:39 +0800)
committerJouni Malinen <j@w1.fi>
Thu, 19 Sep 2019 09:09:47 +0000 (12:09 +0300)
When we set "channel=0" in hostapd.conf to enable ACS function, and set
a wrong channel list, e.g., chanlist=222-999 on purpose, hostapd would
still start ACS process to compute the ideal channel, even when there
are no available channels with such configuration.

Though there is no problem since hostapd fails to initialize interface,
it spends time going through the scan and the debug log entries may make
it more difficult to tell what was behind the failure.

Thus, check if there are any available channels in acs_request_scan(),
and return -1 if no available channel, then it will fail at acs_init(),
without doing ACS computation. It will show the following in the log:
    Could not select hw_mode and channel. (-3)
    wlan0: interface state UNINITIALIZED->DISABLED

Then we can know the setting is incorrect already in
hostapd_select_hw_mode(), instead of waiting for scan callback function
to know if the setting is ok for ACS or not. This can save time and help
to tell if the setting is correct at the initial function at the first.
This will also allow the ENABLE control interface command to return FAIL
when adding an interface dynamically.

Signed-off-by: Neo Jou <neojou@gmail.com>
src/ap/acs.c

index 11178a1f047c9a853880c8acb0458477578e9f84..f12539fcd6b80d49bb6bfa6503f11fbd8b6046e7 100644 (file)
@@ -942,6 +942,12 @@ static int acs_request_scan(struct hostapd_iface *iface)
        }
        *freq = 0;
 
+       if (params.freqs == freq) {
+               wpa_printf(MSG_ERROR, "ACS: No available channels found");
+               os_free(params.freqs);
+               return -1;
+       }
+
        iface->scan_cb = acs_scan_complete;
 
        wpa_printf(MSG_DEBUG, "ACS: Scanning %d / %d",