From 3a995cb5a9f5748f49ed3d86615e4e3619e9cc7a Mon Sep 17 00:00:00 2001 From: Xinyue Ling Date: Wed, 7 Jun 2023 16:13:34 +0800 Subject: [PATCH] Determine current hw mode before channel switch There are two hw modes (5 GHz and 6 GHz) with HOSTAPD_MODE_IEEE80211A and the current hw mode may be wrong after one channel switch to 6 GHz. This will cause hostapd_set_freq_params() to return -1 when saving previous state and the second channel switch to fail. Fix this by adding hostapd_determine_mode() before every channel switch. Signed-off-by: Jouni Malinen --- src/ap/hostapd.c | 2 ++ src/ap/hw_features.c | 2 +- src/ap/hw_features.h | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index a8ba207de..99d10bea9 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -55,6 +55,7 @@ #include "hs20.h" #include "airtime_policy.h" #include "wpa_auth_kay.h" +#include "hw_features.h" static int hostapd_flush_old_stations(struct hostapd_data *hapd, u16 reason); @@ -3775,6 +3776,7 @@ static int hostapd_change_config_freq(struct hostapd_data *hapd, if (!channel) return -1; + hostapd_determine_mode(hapd->iface); mode = hapd->iface->current_mode; /* if a pointer to old_params is provided we save previous state */ diff --git a/src/ap/hw_features.c b/src/ap/hw_features.c index 26f8974ba..7d899f50d 100644 --- a/src/ap/hw_features.c +++ b/src/ap/hw_features.c @@ -1040,7 +1040,7 @@ static bool skip_mode(struct hostapd_iface *iface, } -static void hostapd_determine_mode(struct hostapd_iface *iface) +void hostapd_determine_mode(struct hostapd_iface *iface) { int i; enum hostapd_hw_mode target_mode; diff --git a/src/ap/hw_features.h b/src/ap/hw_features.h index ad0ddf7ff..092941f77 100644 --- a/src/ap/hw_features.h +++ b/src/ap/hw_features.h @@ -28,6 +28,7 @@ int hostapd_prepare_rates(struct hostapd_iface *iface, void hostapd_stop_setup_timers(struct hostapd_iface *iface); int hostapd_hw_skip_mode(struct hostapd_iface *iface, struct hostapd_hw_modes *mode); +void hostapd_determine_mode(struct hostapd_iface *iface); #else /* NEED_AP_MLME */ static inline void hostapd_free_hw_features(struct hostapd_hw_modes *hw_features, @@ -91,6 +92,10 @@ static inline int hostapd_check_he_6ghz_capab(struct hostapd_iface *iface) return 0; } +static inline void hostapd_determine_mode(struct hostapd_iface *iface) +{ +} + #endif /* NEED_AP_MLME */ #endif /* HW_FEATURES_H */