fix(wpa_supplicant): Clear bssid flag and channel in supplicant disconnect handler

- Clear the bssid set flag and channel in supplicant disconnect handler as this
  can cause the station to recursively connect to the wrong AP in case
  roaming through BTM mechanisms fails.
- Fix issue with incorrect blocking time calculation when blocking scan
  issued for a single channel.
This commit is contained in:
jgujarathi 2023-09-29 11:32:55 +05:30 committed by BOT
parent ff622e4428
commit 84d7ab5c0c
3 changed files with 13 additions and 6 deletions

View File

@ -162,7 +162,7 @@ static void btm_rrm_task(void *pvParameters)
} }
#endif /* CONFIG_SUPPLICANT_TASK */ #endif /* CONFIG_SUPPLICANT_TASK */
static void clear_bssid_flag(struct wpa_supplicant *wpa_s) static void clear_bssid_flag_and_channel(struct wpa_supplicant *wpa_s)
{ {
wifi_config_t *config; wifi_config_t *config;
@ -178,7 +178,8 @@ static void clear_bssid_flag(struct wpa_supplicant *wpa_s)
} }
esp_wifi_get_config(WIFI_IF_STA, config); esp_wifi_get_config(WIFI_IF_STA, config);
if (config->sta.bssid_set) { if (config->sta.bssid_set || config->sta.channel) {
config->sta.channel = 0;
config->sta.bssid_set = 0; config->sta.bssid_set = 0;
esp_wifi_set_config(WIFI_IF_STA, config); esp_wifi_set_config(WIFI_IF_STA, config);
} }
@ -439,11 +440,11 @@ void supplicant_sta_conn_handler(uint8_t *bssid)
/* Register for mgmt frames */ /* Register for mgmt frames */
register_mgmt_frames(wpa_s); register_mgmt_frames(wpa_s);
/* clear set bssid flag */ /* clear set bssid flag */
clear_bssid_flag(wpa_s); clear_bssid_flag_and_channel(wpa_s);
#endif /* defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) */ #endif /* defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) */
} }
void supplicant_sta_disconn_handler(void) void supplicant_sta_disconn_handler(uint8_t reason_code)
{ {
#if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) #if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R)
struct wpa_supplicant *wpa_s = &g_wpa_supp; struct wpa_supplicant *wpa_s = &g_wpa_supp;
@ -451,6 +452,12 @@ void supplicant_sta_disconn_handler(void)
#ifdef CONFIG_IEEE80211KV #ifdef CONFIG_IEEE80211KV
wpas_rrm_reset(wpa_s); wpas_rrm_reset(wpa_s);
wpas_clear_beacon_rep_data(wpa_s); wpas_clear_beacon_rep_data(wpa_s);
/* Not clearing in case of roaming disconnect as BTM induced connection
* itself sets a specific bssid and channel to connect to before disconnection.
* Subsequent connections or disconnections will clear this flag */
if (reason_code != WIFI_REASON_ROAMING) {
clear_bssid_flag_and_channel(wpa_s);
}
#endif /* CONFIG_IEEE80211KV */ #endif /* CONFIG_IEEE80211KV */
if (wpa_s->current_bss) { if (wpa_s->current_bss) {
wpa_s->current_bss = NULL; wpa_s->current_bss = NULL;

View File

@ -46,5 +46,5 @@ void esp_supplicant_unset_all_appie(void);
void esp_set_scan_ie(void); void esp_set_scan_ie(void);
void esp_set_assoc_ie(uint8_t *bssid, const u8 *ies, size_t ies_len, bool add_mdie); void esp_set_assoc_ie(uint8_t *bssid, const u8 *ies, size_t ies_len, bool add_mdie);
void supplicant_sta_conn_handler(uint8_t* bssid); void supplicant_sta_conn_handler(uint8_t* bssid);
void supplicant_sta_disconn_handler(void); void supplicant_sta_disconn_handler(uint8_t reason_code);
#endif #endif

View File

@ -301,7 +301,7 @@ static void wpa_sta_disconnected_cb(uint8_t reason_code)
owe_deinit(); owe_deinit();
#endif /* CONFIG_OWE_STA */ #endif /* CONFIG_OWE_STA */
supplicant_sta_disconn_handler(); supplicant_sta_disconn_handler(reason_code);
} }
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT #ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT