From 1ee555100401d71239bf5eb895f0222548432b4b Mon Sep 17 00:00:00 2001 From: Kapil Gupta Date: Tue, 4 Mar 2025 20:25:18 +0530 Subject: [PATCH] fix(esp_wifi): Prevent flushing of FT data mistakenly --- .../wpa_supplicant/esp_supplicant/src/esp_common.c | 13 +++---------- .../esp_supplicant/src/esp_common_i.h | 1 + .../esp_supplicant/src/esp_wpa_main.c | 4 ++++ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_common.c b/components/wpa_supplicant/esp_supplicant/src/esp_common.c index 2344d570ee..39c0bded1f 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_common.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_common.c @@ -178,7 +178,7 @@ static int handle_assoc_frame(u8 *frame, size_t len, return 0; } -static void wpa_sta_clear_ft_auth_ie(void) +void wpa_sta_clear_ft_auth_ie(void) { struct wpa_sm *sm = &gWpaSm; wpa_printf(MSG_DEBUG, "Clearing all FT IE parameters and keys"); @@ -341,8 +341,7 @@ void supplicant_sta_conn_handler(uint8_t *bssid) void supplicant_sta_disconn_handler(uint8_t reason_code) { -#if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) - struct wpa_sm *sm = &gWpaSm; +#if defined(CONFIG_IEEE80211KV) struct wpa_supplicant *wpa_s = &g_wpa_supp; #if defined(CONFIG_RRM) @@ -358,13 +357,7 @@ void supplicant_sta_disconn_handler(uint8_t reason_code) if (wpa_s->current_bss) { wpa_s->current_bss = NULL; } -#if defined(CONFIG_IEEE80211R) - if (!sm->cur_pmksa) { - /* clear all ft auth related IEs so that next will be open auth */ - wpa_sta_clear_ft_auth_ie(); - } -#endif -#endif /* defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) */ +#endif /* defined(CONFIG_IEEE80211KV) */ } #if defined(CONFIG_RRM) diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h b/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h index 0e9581b057..699d2f8d59 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h +++ b/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h @@ -34,3 +34,4 @@ void esp_set_assoc_ie(uint8_t *bssid, const u8 *ies, size_t ies_len, bool add_md void supplicant_sta_conn_handler(uint8_t* bssid); void supplicant_sta_disconn_handler(uint8_t reason_code); #endif +void wpa_sta_clear_ft_auth_ie(void); diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c b/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c index 0e23f41a1d..d837571b90 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c @@ -297,6 +297,10 @@ static void wpa_sta_disconnected_cb(uint8_t reason_code) case WIFI_REASON_INVALID_FTE: wpa_sta_clear_curr_pmksa(); wpa_sm_notify_disassoc(&gWpaSm); +#if defined(CONFIG_IEEE80211R) + /* clear all ft auth related IEs so that next will be open auth */ + wpa_sta_clear_ft_auth_ie(); +#endif break; default: if (g_wpa_pmk_caching_disabled) {