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 <john@phrozen.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
John Crispin authored and Felix Fietkau committed 2026-10-28 16:29:45 +01:00
1 parent 9f0bbefb03
commit de796327bc
2 files changed
+4 -1

No files matched your search

@@ -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);
@@ -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;