]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Select 6 GHz mode correctly for ACS cases
authorJouni Malinen <quic_jouni@quicinc.com>
Tue, 25 Apr 2023 14:29:46 +0000 (17:29 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 25 Apr 2023 14:29:46 +0000 (17:29 +0300)
Use the op_class configuration to determine whether to select the 5 GHz
or 6 GHz mode for ACS. Without this, the first mode (5 GHz in most
cases) would have been selected regardless of the op_class value.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
src/ap/hw_features.c

index 154449068c14a0ceca2d368886989e2a0e5c6287..f836be488eb96623b06f8b2ef3aa93840231ee73 100644 (file)
@@ -1001,9 +1001,27 @@ static int hostapd_is_usable_chans(struct hostapd_iface *iface)
 }
 
 
+static bool skip_mode(struct hostapd_iface *iface,
+                     struct hostapd_hw_modes *mode)
+{
+       int chan;
+
+       if (iface->freq > 0 && !hw_mode_get_channel(mode, iface->freq, &chan))
+               return true;
+
+       if (is_6ghz_op_class(iface->conf->op_class) && iface->freq == 0 &&
+           (mode->mode != HOSTAPD_MODE_IEEE80211A ||
+            mode->num_channels == 0 ||
+            !is_6ghz_freq(mode->channels[0].freq)))
+               return true;
+
+       return false;
+}
+
+
 static void hostapd_determine_mode(struct hostapd_iface *iface)
 {
-       int i, chan;
+       int i;
        enum hostapd_hw_mode target_mode;
 
        if (iface->current_mode ||
@@ -1022,8 +1040,7 @@ static void hostapd_determine_mode(struct hostapd_iface *iface)
 
                mode = &iface->hw_features[i];
                if (mode->mode == target_mode) {
-                       if (iface->freq > 0 &&
-                           !hw_mode_get_channel(mode, iface->freq, &chan))
+                       if (skip_mode(iface, mode))
                                continue;
 
                        iface->current_mode = mode;
@@ -1156,11 +1173,9 @@ int hostapd_select_hw_mode(struct hostapd_iface *iface)
        iface->current_mode = NULL;
        for (i = 0; i < iface->num_hw_features; i++) {
                struct hostapd_hw_modes *mode = &iface->hw_features[i];
-               int chan;
 
                if (mode->mode == iface->conf->hw_mode) {
-                       if (iface->freq > 0 &&
-                           !hw_mode_get_channel(mode, iface->freq, &chan))
+                       if (skip_mode(iface, mode))
                                continue;
 
                        iface->current_mode = mode;