]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DFS offload: Use hostapd_is_dfs_required() to check if DFS required
authorHu Wang <huw@codeaurora.org>
Tue, 27 Apr 2021 08:41:13 +0000 (16:41 +0800)
committerJouni Malinen <j@w1.fi>
Mon, 7 Jun 2021 14:42:56 +0000 (17:42 +0300)
hostapd_handle_dfs_offload() is the DFS handler for the offloaded case,
in which ieee80211_is_dfs() is used to check if the configured frequency
requires DFS or not.

When the configured channel width is not 20 (e.g., 160),
ieee80211_is_dfs() will not checked adjacent freqs, so it possibly makes
wrong conclusion for whether DFS is required.

hostapd_is_dfs_required() does similar thing with ieee80211_is_dfs()
except it supports checking whether the configured frequency and its
adjacent frequencies require DFS. So hostapd_is_dfs_required() is a more
robust and better option than ieee80211_is_dfs() to check DFS.

The issue is hostapd_is_dfs_required() is for non-offload case due to
the check of the configuration parameter ieee80211h. Add a check for
WPA_DRIVER_FLAGS_DFS_OFFLOAD to make it support the DFS offload case
(i.e., ieee80211h=0) as well.

For example, configuring the AP to start at freq=5240 with channel width
160:
- Existing hostapd checks freq=5240 is non-DFS, hence skip DFS CAC and
  transition to AP-Enabled which volatiles DFS-RADAR detection.

  LOG: "hostapd : hostapd_handle_dfs_offload: freq 5240 MHz does not
        require DFS. Continue channel/AP setup"

- This commit checks freq=5240 and its adjacent freqs are DFS required,
  hence remains in DFS state until DFS CAC completed.

  LOG: "hostapd : hostapd_handle_dfs_offload: freq 5240 MHz requires
        DFS for 4 chans"

Signed-off-by: Hu Wang <huw@codeaurora.org>
src/ap/dfs.c

index b990fb3423887c9b3589ad710032313531574a0e..03c99b175215ca352c98dcb2030122fce688b675 100644 (file)
@@ -1228,7 +1228,9 @@ int hostapd_is_dfs_required(struct hostapd_iface *iface)
 {
        int n_chans, n_chans1, start_chan_idx, start_chan_idx1, res;
 
-       if (!iface->conf->ieee80211h || !iface->current_mode ||
+       if ((!(iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD) &&
+            !iface->conf->ieee80211h) ||
+           !iface->current_mode ||
            iface->current_mode->mode != HOSTAPD_MODE_IEEE80211A)
                return 0;
 
@@ -1279,6 +1281,8 @@ int hostapd_dfs_start_cac(struct hostapd_iface *iface, int freq,
  */
 int hostapd_handle_dfs_offload(struct hostapd_iface *iface)
 {
+       int dfs_res;
+
        wpa_printf(MSG_DEBUG, "%s: iface->cac_started: %d",
                   __func__, iface->cac_started);
 
@@ -1294,10 +1298,11 @@ int hostapd_handle_dfs_offload(struct hostapd_iface *iface)
                return 1;
        }
 
-       if (ieee80211_is_dfs(iface->freq, iface->hw_features,
-                            iface->num_hw_features)) {
-               wpa_printf(MSG_DEBUG, "%s: freq %d MHz requires DFS",
-                          __func__, iface->freq);
+       dfs_res = hostapd_is_dfs_required(iface);
+       if (dfs_res > 0) {
+               wpa_printf(MSG_DEBUG,
+                          "%s: freq %d MHz requires DFS for %d chans",
+                          __func__, iface->freq, dfs_res);
                return 0;
        }