]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Fix channel switch to a DFS channel
authorRajat Soni <quic_rajson@quicinc.com>
Thu, 4 Apr 2024 09:20:50 +0000 (14:50 +0530)
committerJouni Malinen <j@w1.fi>
Mon, 15 Apr 2024 08:56:41 +0000 (11:56 +0300)
When we are configuring automatic channel selection, we are not able to
switch to a given DFS channel because when we are trying to move to a
DFS channel, the interface is disabled and enabled again. When the
interface is disabled and enabled we are setting iface's freq and
channel to 0 in setup_interface2() in case ACS is enabled, and now we
don't know to which channel we were trying to move. Now ACS will run and
the interface will be up in the channel that is suitable.

To fix this issue add a flag named is_ch_switch_dfs to check if the
channel switch request is for a DFS channel and we can use this in
setup_interface2() to decide whther we have to set iface's freq and
channel to 0 or not. This way iface's freq and channel will retain the
values while channel switching to a DFS channel when ACS is enabled.

Signed-off-by: Rajat Soni <quic_rajson@quicinc.com>
hostapd/ctrl_iface.c
src/ap/hostapd.c
src/ap/hostapd.h

index 10cb186f142d50ceb946236b5ff444e7cb573558..23cc52a2878215c260951ed9f74bc2f4cdf81eef 100644 (file)
@@ -2715,6 +2715,7 @@ static int hostapd_ctrl_iface_chan_switch(struct hostapd_iface *iface,
                           settings.freq_params.center_freq1);
 
                /* Perform CAC and switch channel */
+               iface->is_ch_switch_dfs = true;
                hostapd_switch_channel_fallback(iface, &settings.freq_params);
                return 0;
        }
index f8cb6432d00756670fb7046490cf4d952a2f5ab6..07bbf29dea6ca7cfde99aa4aeec09adcbd1f5c44 100644 (file)
@@ -2074,10 +2074,11 @@ static int setup_interface2(struct hostapd_iface *iface)
        } else {
                int ret;
 
-               if (iface->conf->acs) {
+               if (iface->conf->acs && !iface->is_ch_switch_dfs) {
                        iface->freq = 0;
                        iface->conf->channel = 0;
                }
+               iface->is_ch_switch_dfs = false;
 
                ret = configured_fixed_chan_to_freq(iface);
                if (ret < 0)
@@ -3140,6 +3141,7 @@ struct hostapd_iface * hostapd_init(struct hapd_interfaces *interfaces,
                hostapd_bss_setup_multi_link(hapd, interfaces);
        }
 
+       hapd_iface->is_ch_switch_dfs = false;
        return hapd_iface;
 
 fail:
index 0c38bb53df5a1c2b500cb1fa3204a9b1b3ab18b6..85f8975fa9590d3f5c6c677647e8072999f00106 100644 (file)
@@ -705,6 +705,8 @@ struct hostapd_iface {
 
        /* Configured freq of interface is NO_IR */
        bool is_no_ir;
+
+       bool is_ch_switch_dfs; /* Channel switch from ACS to DFS */
 };
 
 /* hostapd.c */