]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DPP2: Fix channel 6 inclusion for chirping with non-2 GHz interfaces
authorDisha Das <dishad@codeaurora.org>
Tue, 20 Jul 2021 09:45:18 +0000 (15:15 +0530)
committerJouni Malinen <j@w1.fi>
Thu, 29 Jul 2021 17:07:52 +0000 (20:07 +0300)
When the driver provides a list of supported modes, hostapd ended up
adding channel 6 even if the 2.4 GHz mode was not included. This
resulted in incorrect behavior of trying to transmit on a not supported
channel in case of 5 GHz only radios.

Fix this by adding the channel 6 by default only if the driver does not
provide a list of supported modes. Whenever the supported modes are
available, only add this channel if it is explicitly listed as an
enabled channel.

This is similar to an earlier wpa_supplicant change in commit
8e5739c3ac31 ("DPP2: Check channel 6 validity before adding it to chirp
channel list").

Signed-off-by: Disha Das <dishad@codeaurora.org>
src/ap/dpp_hostapd.c

index 93ffd8cf7c3623eef44b336cae2b0c246ce38250..013022a87802354f2e13dd4274a72687911d462b 100644 (file)
@@ -2387,6 +2387,7 @@ hostapd_dpp_chirp_scan_res_handler(struct hostapd_iface *iface)
        unsigned int i;
        struct hostapd_hw_modes *mode;
        int c;
+       bool chan6 = hapd->iface->hw_features == NULL;
 
        if (!bi)
                return;
@@ -2406,7 +2407,21 @@ hostapd_dpp_chirp_scan_res_handler(struct hostapd_iface *iface)
        }
 
        /* Preferred chirping channels */
-       int_array_add_unique(&hapd->dpp_chirp_freqs, 2437);
+       mode = dpp_get_mode(hapd, HOSTAPD_MODE_IEEE80211G);
+       if (mode) {
+               for (c = 0; c < mode->num_channels; c++) {
+                       struct hostapd_channel_data *chan = &mode->channels[c];
+
+                       if (chan->flag & (HOSTAPD_CHAN_DISABLED |
+                                         HOSTAPD_CHAN_RADAR) ||
+                           chan->freq != 2437)
+                               continue;
+                       chan6 = true;
+                       break;
+               }
+       }
+       if (chan6)
+               int_array_add_unique(&hapd->dpp_chirp_freqs, 2437);
 
        mode = dpp_get_mode(hapd, HOSTAPD_MODE_IEEE80211A);
        if (mode) {