From 3bc01a901803ce17dac04ca37bacbaad7e0418ba Mon Sep 17 00:00:00 2001 From: Hariharan Basuthkar Date: Wed, 8 Oct 2025 03:03:34 +0530 Subject: [PATCH] Update conf->op_class in hostapd_change_config_freq() Some cases of channel switching, e.g., when changing from a 320 MHz channel to a 80 MHz channel in the 6 GHz band, has been observed to cause disconnections due to non-AP MLDs getting confused with inaccurate information. On the AP side, the new target channel's ccfs0 and ccfs1 have incorrect values in the EHT Operating Information element. This is because, in hostapd_eid_eht_operation(), the ch_width is calculated based on conf->op_class and during the channel switch, hostapd_change_config_freq() does not assign the target channel's op_class to conf->op_class during the construction of the Beacon frame template. Fix this issue by assigning conf->op_class in hostapd_change_config_freq(). Also, change the datatype of channel in hostapd_change_config_freq() from int to u8, as IEEE 802.11 channel numbers are represented with 8 bits, and can only be between 1 to 255. Signed-off-by: Hariharan Basuthkar --- src/ap/hostapd.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index fe815119f..ed644a06f 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -4471,8 +4471,7 @@ int hostapd_change_config_freq(struct hostapd_data *hapd, struct hostapd_freq_params *params, struct hostapd_freq_params *old_params) { - int channel; - u8 seg0 = 0, seg1 = 0; + u8 channel, op_class, seg0 = 0, seg1 = 0; struct hostapd_hw_modes *mode; if (!params->channel) { @@ -4557,6 +4556,14 @@ int hostapd_change_config_freq(struct hostapd_data *hapd, ieee80211_freq_to_chan(params->center_freq2, &seg1) == NUM_HOSTAPD_MODES) return -1; + if (ieee80211_freq_to_channel_ext(params->freq, + conf->secondary_channel, + hostapd_get_oper_chwidth(hapd->iconf), + &op_class, &channel) == + NUM_HOSTAPD_MODES) + return -1; + + conf->op_class = op_class; hostapd_set_oper_centr_freq_seg0_idx(conf, seg0); hostapd_set_oper_centr_freq_seg1_idx(conf, seg1); -- 2.47.3