]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DFS: Add supported channel bandwidth checking
authorDmitry Lebed <dlebed@quantenna.com>
Thu, 1 Mar 2018 11:49:29 +0000 (14:49 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 6 Jan 2019 10:09:21 +0000 (12:09 +0200)
While selecting a new channel as a reaction to radar event we need to
take into account supported bandwidth for each channel provided via
nl80211. Without this modification hostapd might select an unsupported
channel that would fail during AP startup.

Signed-off-by: Dmitry Lebed <dlebed@quantenna.com>
src/ap/dfs.c

index 993dd19c2cb07df9f838467f92a2f47d4c321ec8..79cd00f44a780c9a6e1a9b254a0b66e581cf1e30 100644 (file)
@@ -142,18 +142,30 @@ static int dfs_chan_range_available(struct hostapd_hw_modes *mode,
 {
        struct hostapd_channel_data *first_chan, *chan;
        int i;
+       u32 bw = num_chan_to_bw(num_chans);
 
        if (first_chan_idx + num_chans > mode->num_channels)
                return 0;
 
        first_chan = &mode->channels[first_chan_idx];
 
+       /* hostapd DFS implementation assumes the first channel as primary.
+        * If it's not allowed to use the first channel as primary, decline the
+        * whole channel range. */
+       if (!chan_pri_allowed(first_chan))
+               return 0;
+
        for (i = 0; i < num_chans; i++) {
                chan = dfs_get_chan_data(mode, first_chan->freq + i * 20,
                                         first_chan_idx);
                if (!chan)
                        return 0;
 
+               /* HT 40 MHz secondary channel availability checked only for
+                * primary channel */
+               if (!chan_bw_allowed(chan, bw, 1, !i))
+                       return 0;
+
                if (!dfs_channel_available(chan, skip_radar))
                        return 0;
        }
@@ -197,7 +209,8 @@ static int dfs_find_channel(struct hostapd_iface *iface,
                /* Skip HT40/VHT incompatible channels */
                if (iface->conf->ieee80211n &&
                    iface->conf->secondary_channel &&
-                   !dfs_is_chan_allowed(chan, n_chans))
+                   (!dfs_is_chan_allowed(chan, n_chans) ||
+                    !(chan->allowed_bw & HOSTAPD_CHAN_WIDTH_40P)))
                        continue;
 
                /* Skip incompatible chandefs */