diff mbox series

ACS: to improve the checking of available ACS channel list

Message ID 1568792390-8232-1-git-send-email-neojou@gmail.com
State Accepted
Headers show
Series ACS: to improve the checking of available ACS channel list | expand

Commit Message

Neo Jou Sept. 18, 2019, 7:39 a.m. UTC
From: Neo Jou <neojou@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@gmail.com>
---
 src/ap/acs.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Jouni Malinen Sept. 21, 2019, 12:47 p.m. UTC | #1
On Wed, Sep 18, 2019 at 03:39:50PM +0800, neojou@gmail.com wrote:
> 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.

Thanks, applied.
diff mbox series

Patch

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",