[PATCH] ACS: to improve the checking of available ACS channel list

neojou at gmail.com neojou at gmail.com
Wed Sep 18 00:39:50 PDT 2019

From: Neo Jou <neojou at gmail.com>

When we set "channel=0" in hostapd.conf to enable ACS function,
and set the wrong channel list, e.g. chanlist=222-999 on purpose,
hostapd will still start ACS process to compute ideal channel,
even there is no available channel in this setting.

Though there is no problem since hostapd fails to initialize
interface, it spends time and may cause some problem to tell if
the setting is correct at the first.

Thus would like to suggest the following patch, we can check if
there is any available channels in the function acs_request_scan()
at the first, 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 at the first at
hostapd_select_hw_mode(), instead of waiting for scan callback
function to know if the setting is ok for ACS or not. It can save
time and help to tell if the setting is correct at the initial
function at the first.

Signed-off-by: Neo Jou <neojou at gmail.com>
 src/ap/acs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/ap/acs.c b/src/ap/acs.c
index 11178a1..e1e196d 100644
--- a/src/ap/acs.c
+++ b/src/ap/acs.c
@@ -942,6 +942,10 @@ static int acs_request_scan(struct hostapd_iface *iface)
 	*freq = 0;
+	if (params.freqs == freq) { /* No available channel */
+		return -1;
+	}
 	iface->scan_cb = acs_scan_complete;
 	wpa_printf(MSG_DEBUG, "ACS: Scanning %d / %d",

More information about the Hostap mailing list