From de796327bc6e2866436ff8351225aed9e3018155 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Tue, 20 Oct 2026 13:41:27 +0200 Subject: [PATCH] hostapd: ucode: fix the width and the result of switch_channel switch_channel() takes the width from oper_chwidth and falls back to the current width of the interface. freq_info() did not return it, so a config change of the width alone made a channel switch with the old width and the new centre frequency, which the kernel refuses, and the radio restarted instead. Return oper_chwidth from freq_info(). start() reads the same field, so a start with a frequency from wpa_supplicant now also takes the width of the config, which matches the centre frequency that freq_info() computes for it. switch_channel() also returned the result of the last BSS only. mac80211 does not finalise a channel switch that only part of the BSSes of a radio take part in, so stop at the first BSS that fails and let the caller restart the radio. Signed-off-by: John Crispin Signed-off-by: Felix Fietkau --- package/network/services/hostapd/src/src/ap/ucode.c | 4 +++- package/network/services/hostapd/src/src/utils/ucode.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/package/network/services/hostapd/src/src/ap/ucode.c b/package/network/services/hostapd/src/src/ap/ucode.c index 419b650a06a..30a800f62fc 100644 --- a/package/network/services/hostapd/src/src/ap/ucode.c +++ b/package/network/services/hostapd/src/src/ap/ucode.c @@ -911,7 +911,9 @@ uc_hostapd_iface_switch_channel(uc_vm_t *vm, size_t nargs) if ((intval = ucv_int64_get(ucv_object_get(info, "center_freq2", NULL))) && !errno) csa.freq_params.center_freq2 = intval; - for (i = 0; i < iface->num_bss; i++) + /* mac80211 completes the switch only if every BSS of the radio + * takes part */ + for (i = 0; i < iface->num_bss && !ret; i++) ret = hostapd_switch_channel(iface->bss[i], &csa); return ucv_boolean_new(!ret); diff --git a/package/network/services/hostapd/src/src/utils/ucode.c b/package/network/services/hostapd/src/src/utils/ucode.c index 32edaeb75ac..1ea026b0923 100644 --- a/package/network/services/hostapd/src/src/utils/ucode.c +++ b/package/network/services/hostapd/src/src/utils/ucode.c @@ -172,6 +172,7 @@ uc_value_t *uc_wpa_freq_info(uc_vm_t *vm, size_t nargs) ucv_object_add(ret, "hw_mode_str", ucv_string_new(modestr)); ucv_object_add(ret, "sec_channel", ucv_int64_new(sec_channel)); ucv_object_add(ret, "frequency", ucv_int64_new(freq_val)); + ucv_object_add(ret, "oper_chwidth", ucv_int64_new(chanwidth)); if (!sec_channel) return ret;