diff mbox series

[v2] hostapd: Downgrade to 802.11b on channel 14 in hostapd_acs_completed()

Message ID 20261104080918.1117-1-chao.meng@unisoc.com
State New
Headers show
Series [v2] hostapd: Downgrade to 802.11b on channel 14 in hostapd_acs_completed() | expand

Commit Message

Chao Meng Nov. 4, 2026, 8:09 a.m. UTC
From: "chao.meng" <chao.meng@unisoc.com>

The channel 14 downgrade (force IEEE 802.11b mode and disable HT, VHT,
HE, and EHT) is done only in hostapd_select_hw_mode(). In the ACS
offload case, the selected channel is applied through
hostapd_acs_channel_selected() and hostapd_acs_completed() without
calling hostapd_select_hw_mode(), so channel 14 (2484 MHz) gets
configured with HT/VHT/HE enabled. The kernel rejects that since
channel 14 is allowed only for IEEE 802.11b without HT
(NL80211_CHAN_WIDTH_20_NOHT), and AP setup fails with -EINVAL.

Apply the same channel 14 downgrade in hostapd_acs_completed() before
validating the selected channels, and reselect current_mode based on
the downgraded mode so that the rate set and ERP information element
are generated for IEEE 802.11b. This is idempotent for the internal
ACS and fixed channel cases where hostapd_select_hw_mode() has already
applied the same downgrade.

Signed-off-by: chao.meng <chao.meng@unisoc.com>
---
 src/ap/hw_features.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

--
2.43.0.windows.1
diff mbox series

Patch

diff --git a/src/ap/hw_features.c b/src/ap/hw_features.c
index 2af3d3b57..5f93e1093 100644
--- a/src/ap/hw_features.c
+++ b/src/ap/hw_features.c
@@ -1383,10 +1383,43 @@  static void hostapd_notify_bad_chans(struct hostapd_iface *iface)
 int hostapd_acs_completed(struct hostapd_iface *iface, int err)
 {
        int ret = -1;
+       int i;

        if (err)
                goto out;

+       if ((iface->conf->hw_mode == HOSTAPD_MODE_IEEE80211G ||
+            iface->conf->ieee80211n || iface->conf->ieee80211ac ||
+            iface->conf->ieee80211ax || iface->conf->ieee80211be) &&
+           iface->conf->channel == 14) {
+               wpa_printf(MSG_INFO, "Disable OFDM/HT/VHT/HE/EHT on channel 14");
+               iface->conf->hw_mode = HOSTAPD_MODE_IEEE80211B;
+               iface->conf->ieee80211n = 0;
+               iface->conf->ieee80211ac = 0;
+               iface->conf->ieee80211ax = 0;
+               iface->conf->ieee80211be = 0;
+
+               iface->current_mode = NULL;
+               for (i = 0; i < iface->num_hw_features; i++) {
+                       struct hostapd_hw_modes *mode = &iface->hw_features[i];
+
+                       if (mode->mode == iface->conf->hw_mode) {
+                               if (skip_mode(iface, mode))
+                                       continue;
+
+                               iface->current_mode = mode;
+                               break;
+                       }
+               }
+
+               if (!iface->current_mode) {
+                       wpa_printf(MSG_ERROR, "No hw mode available for channel 14");
+                       wpa_msg(iface->bss[0]->msg_ctx, MSG_ERROR, ACS_EVENT_FAILED);
+                       hostapd_notify_bad_chans(iface);
+                       goto out;
+               }
+       }
+
        switch (hostapd_check_chans(iface)) {
        case HOSTAPD_CHAN_VALID:
                iface->is_no_ir = false;