]> git.ipfire.org Git - thirdparty/hostap.git/blobdiff - wpa_supplicant/events.c
MBO/OCE: Work around misbehaving MBO/OCE APs that use RSN without PMF
[thirdparty/hostap.git] / wpa_supplicant / events.c
index fb77f1dbd23e988435c79d35875ef5ce1d9b2106..ba9a5ac2e432d434e9522871bf9e687b16964b35 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * WPA Supplicant - Driver event processing
- * Copyright (c) 2003-2017, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2003-2019, Jouni Malinen <j@w1.fi>
  *
  * This software may be distributed under the terms of the BSD license.
  * See README for more details.
@@ -29,6 +29,7 @@
 #include "common/ieee802_11_defs.h"
 #include "common/ieee802_11_common.h"
 #include "common/gas_server.h"
+#include "common/dpp.h"
 #include "crypto/random.h"
 #include "blacklist.h"
 #include "wpas_glue.h"
@@ -50,6 +51,9 @@
 #include "dpp_supplicant.h"
 
 
+#define MAX_OWE_TRANSITION_BSS_SELECT_COUNT 5
+
+
 #ifndef CONFIG_NO_SCAN_PROCESSING
 static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s,
                                              int new_scan, int own_request);
@@ -290,6 +294,13 @@ void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
        if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
                return;
 
+       if (os_reltime_initialized(&wpa_s->session_start)) {
+               os_reltime_age(&wpa_s->session_start, &wpa_s->session_length);
+               wpa_s->session_start.sec = 0;
+               wpa_s->session_start.usec = 0;
+               wpas_notify_session_length(wpa_s);
+       }
+
        wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
        bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
        os_memset(wpa_s->bssid, 0, ETH_ALEN);
@@ -305,8 +316,9 @@ void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
        eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
        if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) ||
            wpa_s->key_mgmt == WPA_KEY_MGMT_OWE ||
-           wpa_s->key_mgmt == WPA_KEY_MGMT_DPP)
+           wpa_s->key_mgmt == WPA_KEY_MGMT_DPP || wpa_s->drv_authorized_port)
                eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
+       wpa_s->drv_authorized_port = 0;
        wpa_s->ap_ies_from_associnfo = 0;
        wpa_s->current_ssid = NULL;
        eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
@@ -314,12 +326,17 @@ void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
 
        wpas_rrm_reset(wpa_s);
        wpa_s->wnmsleep_used = 0;
+       wnm_clear_coloc_intf_reporting(wpa_s);
+       wpa_s->disable_mbo_oce = 0;
 
 #ifdef CONFIG_TESTING_OPTIONS
        wpa_s->last_tk_alg = WPA_ALG_NONE;
        os_memset(wpa_s->last_tk, 0, sizeof(wpa_s->last_tk));
 #endif /* CONFIG_TESTING_OPTIONS */
        wpa_s->ieee80211ac = 0;
+
+       if (wpa_s->enabled_4addr_mode && wpa_drv_set_4addr_mode(wpa_s, 0) == 0)
+               wpa_s->enabled_4addr_mode = 0;
 }
 
 
@@ -545,6 +562,10 @@ static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s,
                                        "   skip RSN IE - parse failed");
                        break;
                }
+               if (!ie.has_pairwise)
+                       ie.pairwise_cipher = wpa_default_rsn_cipher(bss->freq);
+               if (!ie.has_group)
+                       ie.group_cipher = wpa_default_rsn_cipher(bss->freq);
 
                if (wep_ok &&
                    (ie.group_cipher & (WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104)))
@@ -592,7 +613,6 @@ static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s,
                        break;
                }
 
-#ifdef CONFIG_IEEE80211W
                if (!(ie.capabilities & WPA_CAPABILITY_MFPC) &&
                    wpas_get_ssid_pmf(wpa_s, ssid) ==
                    MGMT_FRAME_PROTECTION_REQUIRED) {
@@ -601,7 +621,6 @@ static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s,
                                        "   skip RSN IE - no mgmt frame protection");
                        break;
                }
-#endif /* CONFIG_IEEE80211W */
                if ((ie.capabilities & WPA_CAPABILITY_MFPR) &&
                    wpas_get_ssid_pmf(wpa_s, ssid) ==
                    NO_MGMT_FRAME_PROTECTION) {
@@ -610,17 +629,6 @@ static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s,
                                        "   skip RSN IE - no mgmt frame protection enabled but AP requires it");
                        break;
                }
-#ifdef CONFIG_MBO
-               if (!(ie.capabilities & WPA_CAPABILITY_MFPC) &&
-                   wpas_mbo_get_bss_attr(bss, MBO_ATTR_ID_AP_CAPA_IND) &&
-                   wpas_get_ssid_pmf(wpa_s, ssid) !=
-                   NO_MGMT_FRAME_PROTECTION) {
-                       if (debug_print)
-                               wpa_dbg(wpa_s, MSG_DEBUG,
-                                       "   skip RSN IE - no mgmt frame protection enabled on MBO AP");
-                       break;
-               }
-#endif /* CONFIG_MBO */
 
                if (debug_print)
                        wpa_dbg(wpa_s, MSG_DEBUG,
@@ -628,7 +636,6 @@ static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s,
                return 1;
        }
 
-#ifdef CONFIG_IEEE80211W
        if (wpas_get_ssid_pmf(wpa_s, ssid) == MGMT_FRAME_PROTECTION_REQUIRED &&
            (!(ssid->key_mgmt & WPA_KEY_MGMT_OWE) || ssid->owe_only)) {
                if (debug_print)
@@ -636,7 +643,6 @@ static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s,
                                "   skip - MFP Required but network not MFP Capable");
                return 0;
        }
-#endif /* CONFIG_IEEE80211W */
 
        wpa_ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
        while ((ssid->proto & WPA_PROTO_WPA) && wpa_ie) {
@@ -703,6 +709,19 @@ static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s,
 #ifdef CONFIG_OWE
        if ((ssid->key_mgmt & WPA_KEY_MGMT_OWE) && !ssid->owe_only &&
            !wpa_ie && !rsn_ie) {
+               if (wpa_s->owe_transition_select &&
+                   wpa_bss_get_vendor_ie(bss, OWE_IE_VENDOR_TYPE) &&
+                   ssid->owe_transition_bss_select_count + 1 <=
+                   MAX_OWE_TRANSITION_BSS_SELECT_COUNT) {
+                       ssid->owe_transition_bss_select_count++;
+                       if (debug_print)
+                               wpa_dbg(wpa_s, MSG_DEBUG,
+                                       "   skip OWE transition BSS (selection count %d does not exceed %d)",
+                                       ssid->owe_transition_bss_select_count,
+                                       MAX_OWE_TRANSITION_BSS_SELECT_COUNT);
+                       wpa_s->owe_transition_search = 1;
+                       return 0;
+               }
                if (debug_print)
                        wpa_dbg(wpa_s, MSG_DEBUG,
                                "   allow in OWE transition mode");
@@ -1190,7 +1209,7 @@ struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
                        continue;
                }
 
-               if (ssid->mode != IEEE80211_MODE_MESH && !bss_is_ess(bss) &&
+               if (ssid->mode != WPAS_MODE_MESH && !bss_is_ess(bss) &&
                    !bss_is_pbss(bss)) {
                        if (debug_print)
                                wpa_dbg(wpa_s, MSG_DEBUG,
@@ -1214,7 +1233,7 @@ struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
                }
 
 #ifdef CONFIG_MESH
-               if (ssid->mode == IEEE80211_MODE_MESH && ssid->frequency > 0 &&
+               if (ssid->mode == WPAS_MODE_MESH && ssid->frequency > 0 &&
                    ssid->frequency != bss->freq) {
                        if (debug_print)
                                wpa_dbg(wpa_s, MSG_DEBUG,
@@ -1318,10 +1337,10 @@ struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s,
                        continue;
                }
 
-               if (wpa_is_bss_tmp_disallowed(wpa_s, bss->bssid)) {
+               if (wpa_is_bss_tmp_disallowed(wpa_s, bss)) {
                        if (debug_print)
                                wpa_dbg(wpa_s, MSG_DEBUG,
-                                       "   skip - MBO retry delay has not passed yet");
+                                       "   skip - AP temporarily disallowed");
                        continue;
                }
 #ifdef CONFIG_TESTING_OPTIONS
@@ -1387,8 +1406,11 @@ wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s,
 
        for (i = 0; i < wpa_s->last_scan_res_used; i++) {
                struct wpa_bss *bss = wpa_s->last_scan_res[i];
+
+               wpa_s->owe_transition_select = 1;
                *selected_ssid = wpa_scan_res_match(wpa_s, i, bss, group,
                                                    only_first_ssid, 1);
+               wpa_s->owe_transition_select = 0;
                if (!*selected_ssid)
                        continue;
                wpa_dbg(wpa_s, MSG_DEBUG, "   selected BSS " MACSTR
@@ -1580,9 +1602,9 @@ wpa_supplicant_pick_new_network(struct wpa_supplicant *wpa_s)
                                continue;
                        }
 #endif /* !CONFIG_IBSS_RSN */
-                       if (ssid->mode == IEEE80211_MODE_IBSS ||
-                           ssid->mode == IEEE80211_MODE_AP ||
-                           ssid->mode == IEEE80211_MODE_MESH)
+                       if (ssid->mode == WPAS_MODE_IBSS ||
+                           ssid->mode == WPAS_MODE_AP ||
+                           ssid->mode == WPAS_MODE_MESH)
                                return ssid;
                }
        }
@@ -1869,7 +1891,7 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
        if (sme_proc_obss_scan(wpa_s) > 0)
                goto scan_work_done;
 
-       if (own_request &&
+       if (own_request && data &&
            wpas_beacon_rep_scan_process(wpa_s, scan_res, &data->scan_info) > 0)
                goto scan_work_done;
 
@@ -1902,6 +1924,21 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
                radio_work_done(work);
        }
 
+       os_free(wpa_s->last_scan_freqs);
+       wpa_s->last_scan_freqs = NULL;
+       wpa_s->num_last_scan_freqs = 0;
+       if (own_request && data &&
+           data->scan_info.freqs && data->scan_info.num_freqs) {
+               wpa_s->last_scan_freqs = os_malloc(sizeof(int) *
+                                                  data->scan_info.num_freqs);
+               if (wpa_s->last_scan_freqs) {
+                       os_memcpy(wpa_s->last_scan_freqs,
+                                 data->scan_info.freqs,
+                                 sizeof(int) * data->scan_info.num_freqs);
+                       wpa_s->num_last_scan_freqs = data->scan_info.num_freqs;
+               }
+       }
+
        return wpas_select_network_from_last_scan(wpa_s, 1, own_request);
 
 scan_work_done:
@@ -1935,6 +1972,7 @@ static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s,
        if (wpa_s->p2p_mgmt)
                return 0; /* no normal connection on p2p_mgmt interface */
 
+       wpa_s->owe_transition_search = 0;
        selected = wpa_supplicant_pick_network(wpa_s, &ssid);
 
 #ifdef CONFIG_MESH
@@ -1954,6 +1992,8 @@ static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s,
                        return 0;
                }
 
+               wpa_s->suitable_network++;
+
                if (ssid != wpa_s->current_ssid &&
                    wpa_s->wpa_state >= WPA_AUTHENTICATING) {
                        wpa_s->own_disconnect_req = 1;
@@ -1974,6 +2014,7 @@ static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s,
                 */
                return 1;
        } else {
+               wpa_s->no_suitable_network++;
                wpa_dbg(wpa_s, MSG_DEBUG, "No suitable network found");
                ssid = wpa_supplicant_pick_new_network(wpa_s);
                if (ssid) {
@@ -2036,6 +2077,17 @@ static int wpas_select_network_from_last_scan(struct wpa_supplicant *wpa_s,
                                return 0;
                        }
 #endif /* CONFIG_WPS */
+#ifdef CONFIG_OWE
+                       if (wpa_s->owe_transition_search) {
+                               wpa_dbg(wpa_s, MSG_DEBUG,
+                                       "OWE: Use shorter wait during transition mode search");
+                               timeout_sec = 0;
+                               timeout_usec = 500000;
+                               wpa_supplicant_req_new_scan(wpa_s, timeout_sec,
+                                                           timeout_usec);
+                               return 0;
+                       }
+#endif /* CONFIG_OWE */
                        if (wpa_supplicant_req_sched_scan(wpa_s))
                                wpa_supplicant_req_new_scan(wpa_s, timeout_sec,
                                                            timeout_usec);
@@ -2235,6 +2287,57 @@ static void interworking_process_assoc_resp(struct wpa_supplicant *wpa_s,
 #endif /* CONFIG_INTERWORKING */
 
 
+static void multi_ap_process_assoc_resp(struct wpa_supplicant *wpa_s,
+                                       const u8 *ies, size_t ies_len)
+{
+       struct ieee802_11_elems elems;
+       const u8 *map_sub_elem, *pos;
+       size_t len;
+
+       if (!wpa_s->current_ssid ||
+           !wpa_s->current_ssid->multi_ap_backhaul_sta ||
+           !ies ||
+           ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed)
+               return;
+
+       if (!elems.multi_ap || elems.multi_ap_len < 7) {
+               wpa_printf(MSG_INFO, "AP doesn't support Multi-AP protocol");
+               goto fail;
+       }
+
+       pos = elems.multi_ap + 4;
+       len = elems.multi_ap_len - 4;
+
+       map_sub_elem = get_ie(pos, len, MULTI_AP_SUB_ELEM_TYPE);
+       if (!map_sub_elem || map_sub_elem[1] < 1) {
+               wpa_printf(MSG_INFO, "invalid Multi-AP sub elem type");
+               goto fail;
+       }
+
+       if (!(map_sub_elem[2] & MULTI_AP_BACKHAUL_BSS)) {
+               if ((map_sub_elem[2] & MULTI_AP_FRONTHAUL_BSS) &&
+                   wpa_s->current_ssid->key_mgmt & WPA_KEY_MGMT_WPS) {
+                       wpa_printf(MSG_INFO,
+                                  "WPS active, accepting fronthaul-only BSS");
+                       /* Don't set 4addr mode in this case, so just return */
+                       return;
+               }
+               wpa_printf(MSG_INFO, "AP doesn't support backhaul BSS");
+               goto fail;
+       }
+
+       if (wpa_drv_set_4addr_mode(wpa_s, 1) < 0) {
+               wpa_printf(MSG_ERROR, "Failed to set 4addr mode");
+               goto fail;
+       }
+       wpa_s->enabled_4addr_mode = 1;
+       return;
+
+fail:
+       wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING);
+}
+
+
 #ifdef CONFIG_FST
 static int wpas_fst_update_mbie(struct wpa_supplicant *wpa_s,
                                const u8 *ie, size_t ie_len)
@@ -2311,6 +2414,9 @@ static int wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s,
                    get_ie(data->assoc_info.resp_ies,
                           data->assoc_info.resp_ies_len, WLAN_EID_VHT_CAP))
                        wpa_s->ieee80211ac = 1;
+
+               multi_ap_process_assoc_resp(wpa_s, data->assoc_info.resp_ies,
+                                           data->assoc_info.resp_ies_len);
        }
        if (data->assoc_info.beacon_ies)
                wpa_hexdump(MSG_DEBUG, "beacon_ies",
@@ -2320,6 +2426,26 @@ static int wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s,
                wpa_dbg(wpa_s, MSG_DEBUG, "freq=%u MHz",
                        data->assoc_info.freq);
 
+       wpa_s->connection_set = 0;
+       if (data->assoc_info.req_ies && data->assoc_info.resp_ies) {
+               struct ieee802_11_elems req_elems, resp_elems;
+
+               if (ieee802_11_parse_elems(data->assoc_info.req_ies,
+                                          data->assoc_info.req_ies_len,
+                                          &req_elems, 0) != ParseFailed &&
+                   ieee802_11_parse_elems(data->assoc_info.resp_ies,
+                                          data->assoc_info.resp_ies_len,
+                                          &resp_elems, 0) != ParseFailed) {
+                       wpa_s->connection_set = 1;
+                       wpa_s->connection_ht = req_elems.ht_capabilities &&
+                               resp_elems.ht_capabilities;
+                       wpa_s->connection_vht = req_elems.vht_capabilities &&
+                               resp_elems.vht_capabilities;
+                       wpa_s->connection_he = req_elems.he_capabilities &&
+                               resp_elems.he_capabilities;
+               }
+       }
+
        p = data->assoc_info.req_ies;
        l = data->assoc_info.req_ies_len;
 
@@ -2378,6 +2504,28 @@ static int wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s,
        }
 #endif /* CONFIG_OWE */
 
+#ifdef CONFIG_DPP2
+       wpa_sm_set_dpp_z(wpa_s->wpa, NULL);
+       if (wpa_s->key_mgmt == WPA_KEY_MGMT_DPP && wpa_s->dpp_pfs) {
+               struct ieee802_11_elems elems;
+
+               if (ieee802_11_parse_elems(data->assoc_info.resp_ies,
+                                          data->assoc_info.resp_ies_len,
+                                          &elems, 0) == ParseFailed ||
+                   !elems.owe_dh)
+                       goto no_pfs;
+               if (dpp_pfs_process(wpa_s->dpp_pfs, elems.owe_dh,
+                                   elems.owe_dh_len) < 0) {
+                       wpa_supplicant_deauthenticate(wpa_s,
+                                                     WLAN_REASON_UNSPECIFIED);
+                       return -1;
+               }
+
+               wpa_sm_set_dpp_z(wpa_s->wpa, wpa_s->dpp_pfs->secret);
+       }
+no_pfs:
+#endif /* CONFIG_DPP2 */
+
 #ifdef CONFIG_IEEE80211R
 #ifdef CONFIG_SME
        if (wpa_s->sme.auth_alg == WPA_AUTH_ALG_FT) {
@@ -2616,6 +2764,16 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
 
        wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATED);
        if (os_memcmp(bssid, wpa_s->bssid, ETH_ALEN) != 0) {
+               if (os_reltime_initialized(&wpa_s->session_start)) {
+                       os_reltime_age(&wpa_s->session_start,
+                                      &wpa_s->session_length);
+                       wpa_s->session_start.sec = 0;
+                       wpa_s->session_start.usec = 0;
+                       wpas_notify_session_length(wpa_s);
+               } else {
+                       wpas_notify_auth_changed(wpa_s);
+                       os_get_reltime(&wpa_s->session_start);
+               }
                wpa_dbg(wpa_s, MSG_DEBUG, "Associated to a new BSS: BSSID="
                        MACSTR, MAC2STR(bssid));
                new_bss = 1;
@@ -2678,7 +2836,7 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
        if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) ||
            wpa_s->key_mgmt == WPA_KEY_MGMT_DPP ||
            wpa_s->key_mgmt == WPA_KEY_MGMT_OWE || ft_completed ||
-           already_authorized)
+           already_authorized || wpa_s->drv_authorized_port)
                eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
        /* 802.1X::portControl = Auto */
        eapol_sm_notify_portEnabled(wpa_s->eapol, TRUE);
@@ -2686,7 +2844,7 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
        if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
            wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE ||
            (wpa_s->current_ssid &&
-            wpa_s->current_ssid->mode == IEEE80211_MODE_IBSS)) {
+            wpa_s->current_ssid->mode == WPAS_MODE_IBSS)) {
                if (wpa_s->current_ssid &&
                    wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE &&
                    (wpa_s->drv_flags &
@@ -2706,8 +2864,17 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
        }
        wpa_supplicant_cancel_scan(wpa_s);
 
-       if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) &&
-           wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
+       if (ft_completed) {
+               /*
+                * FT protocol completed - make sure EAPOL state machine ends
+                * up in authenticated.
+                */
+               wpa_supplicant_cancel_auth_timeout(wpa_s);
+               wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
+               eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
+               eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
+       } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE_PSK) &&
+                  wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
                /*
                 * We are done; the driver will take care of RSN 4-way
                 * handshake.
@@ -2716,7 +2883,7 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
                wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
                eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
                eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
-       } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) &&
+       } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE_8021X) &&
                   wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {
                /*
                 * The driver will take care of RSN 4-way handshake, so we need
@@ -2724,15 +2891,6 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
                 * waiting for WPA supplicant.
                 */
                eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
-       } else if (ft_completed) {
-               /*
-                * FT protocol completed - make sure EAPOL state machine ends
-                * up in authenticated.
-                */
-               wpa_supplicant_cancel_auth_timeout(wpa_s);
-               wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
-               eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
-               eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
        }
 
        wpa_s->last_eapol_matches_bssid = 0;
@@ -2909,6 +3067,10 @@ static void wpa_supplicant_event_disassoc_finish(struct wpa_supplicant *wpa_s,
                if (wpas_p2p_4way_hs_failed(wpa_s) > 0)
                        return; /* P2P group removed */
                wpas_auth_failed(wpa_s, "WRONG_KEY");
+#ifdef CONFIG_DPP2
+               wpas_dpp_send_conn_status_result(wpa_s,
+                                                DPP_STATUS_AUTH_FAILURE);
+#endif /* CONFIG_DPP2 */
        }
        if (!wpa_s->disconnected &&
            (!wpa_s->auto_reconnect_disabled ||
@@ -2978,7 +3140,7 @@ static void wpa_supplicant_event_disassoc_finish(struct wpa_supplicant *wpa_s,
            !disallowed_ssid(wpa_s, fast_reconnect->ssid,
                             fast_reconnect->ssid_len) &&
            !wpas_temp_disabled(wpa_s, fast_reconnect_ssid) &&
-           !wpa_is_bss_tmp_disallowed(wpa_s, fast_reconnect->bssid)) {
+           !wpa_is_bss_tmp_disallowed(wpa_s, fast_reconnect)) {
 #ifndef CONFIG_NO_SCAN_PROCESSING
                wpa_dbg(wpa_s, MSG_DEBUG, "Try to reconnect to the same BSS");
                if (wpa_supplicant_connect(wpa_s, fast_reconnect,
@@ -3357,26 +3519,22 @@ static void ft_rx_action(struct wpa_supplicant *wpa_s, const u8 *data,
 static void wpa_supplicant_event_unprot_deauth(struct wpa_supplicant *wpa_s,
                                               struct unprot_deauth *e)
 {
-#ifdef CONFIG_IEEE80211W
        wpa_printf(MSG_DEBUG, "Unprotected Deauthentication frame "
                   "dropped: " MACSTR " -> " MACSTR
                   " (reason code %u)",
                   MAC2STR(e->sa), MAC2STR(e->da), e->reason_code);
        sme_event_unprot_disconnect(wpa_s, e->sa, e->da, e->reason_code);
-#endif /* CONFIG_IEEE80211W */
 }
 
 
 static void wpa_supplicant_event_unprot_disassoc(struct wpa_supplicant *wpa_s,
                                                 struct unprot_disassoc *e)
 {
-#ifdef CONFIG_IEEE80211W
        wpa_printf(MSG_DEBUG, "Unprotected Disassociation frame "
                   "dropped: " MACSTR " -> " MACSTR
                   " (reason code %u)",
                   MAC2STR(e->sa), MAC2STR(e->da), e->reason_code);
        sme_event_unprot_disconnect(wpa_s, e->sa, e->da, e->reason_code);
-#endif /* CONFIG_IEEE80211W */
 }
 
 
@@ -3443,8 +3601,9 @@ static void wpas_event_disassoc(struct wpa_supplicant *wpa_s,
                ie_len = info->ie_len;
                reason_code = info->reason_code;
                locally_generated = info->locally_generated;
-               wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u%s", reason_code,
-                       locally_generated ? " (locally generated)" : "");
+               wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u (%s)%s", reason_code,
+                       reason2str(reason_code),
+                       locally_generated ? " locally_generated=1" : "");
                if (addr)
                        wpa_dbg(wpa_s, MSG_DEBUG, " * address " MACSTR,
                                MAC2STR(addr));
@@ -3497,9 +3656,9 @@ static void wpas_event_deauth(struct wpa_supplicant *wpa_s,
                ie_len = info->ie_len;
                reason_code = info->reason_code;
                locally_generated = info->locally_generated;
-               wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u%s",
-                       reason_code,
-                       locally_generated ? " (locally generated)" : "");
+               wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u (%s)%s",
+                       reason_code, reason2str(reason_code),
+                       locally_generated ? " locally_generated=1" : "");
                if (addr) {
                        wpa_dbg(wpa_s, MSG_DEBUG, " * address " MACSTR,
                                MAC2STR(addr));
@@ -3551,8 +3710,8 @@ static const char * reg_type_str(enum reg_type type)
 }
 
 
-static void wpa_supplicant_update_channel_list(
-       struct wpa_supplicant *wpa_s, struct channel_list_changed *info)
+void wpa_supplicant_update_channel_list(struct wpa_supplicant *wpa_s,
+                                       struct channel_list_changed *info)
 {
        struct wpa_supplicant *ifs;
        u8 dfs_domain;
@@ -3566,10 +3725,13 @@ static void wpa_supplicant_update_channel_list(
        for (ifs = wpa_s; ifs->parent && ifs != ifs->parent; ifs = ifs->parent)
                ;
 
-       wpa_msg(ifs, MSG_INFO, WPA_EVENT_REGDOM_CHANGE "init=%s type=%s%s%s",
-               reg_init_str(info->initiator), reg_type_str(info->type),
-               info->alpha2[0] ? " alpha2=" : "",
-               info->alpha2[0] ? info->alpha2 : "");
+       if (info) {
+               wpa_msg(ifs, MSG_INFO,
+                       WPA_EVENT_REGDOM_CHANGE "init=%s type=%s%s%s",
+                       reg_init_str(info->initiator), reg_type_str(info->type),
+                       info->alpha2[0] ? " alpha2=" : "",
+                       info->alpha2[0] ? info->alpha2 : "");
+       }
 
        if (wpa_s->drv_priv == NULL)
                return; /* Ignore event during drv initialization */
@@ -3630,14 +3792,12 @@ static void wpas_event_rx_mgmt_action(struct wpa_supplicant *wpa_s,
        }
 #endif /* CONFIG_IEEE80211R */
 
-#ifdef CONFIG_IEEE80211W
 #ifdef CONFIG_SME
        if (category == WLAN_ACTION_SA_QUERY) {
                sme_sa_query_rx(wpa_s, mgmt->sa, payload, plen);
                return;
        }
 #endif /* CONFIG_SME */
-#endif /* CONFIG_IEEE80211W */
 
 #ifdef CONFIG_WNM
        if (mgmt->u.action.category == WLAN_ACTION_WNM) {
@@ -3778,6 +3938,7 @@ static void wpa_supplicant_event_port_authorized(struct wpa_supplicant *wpa_s)
                wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
                eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
                eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
+               wpa_s->drv_authorized_port = 1;
        }
 }
 
@@ -3808,7 +3969,7 @@ static void wpas_event_dfs_cac_started(struct wpa_supplicant *wpa_s,
                                       struct dfs_event *radar)
 {
 #if defined(NEED_AP_MLME) && defined(CONFIG_AP)
-       if (wpa_s->ap_iface) {
+       if (wpa_s->ap_iface || wpa_s->ifmsh) {
                wpas_ap_event_dfs_cac_started(wpa_s, radar);
        } else
 #endif /* NEED_AP_MLME && CONFIG_AP */
@@ -3829,7 +3990,7 @@ static void wpas_event_dfs_cac_finished(struct wpa_supplicant *wpa_s,
                                        struct dfs_event *radar)
 {
 #if defined(NEED_AP_MLME) && defined(CONFIG_AP)
-       if (wpa_s->ap_iface) {
+       if (wpa_s->ap_iface || wpa_s->ifmsh) {
                wpas_ap_event_dfs_cac_finished(wpa_s, radar);
        } else
 #endif /* NEED_AP_MLME && CONFIG_AP */
@@ -3845,7 +4006,7 @@ static void wpas_event_dfs_cac_aborted(struct wpa_supplicant *wpa_s,
                                       struct dfs_event *radar)
 {
 #if defined(NEED_AP_MLME) && defined(CONFIG_AP)
-       if (wpa_s->ap_iface) {
+       if (wpa_s->ap_iface || wpa_s->ifmsh) {
                wpas_ap_event_dfs_cac_aborted(wpa_s, radar);
        } else
 #endif /* NEED_AP_MLME && CONFIG_AP */
@@ -3902,9 +4063,18 @@ static void wpas_event_assoc_reject(struct wpa_supplicant *wpa_s,
                                    union wpa_event_data *data)
 {
        const u8 *bssid = data->assoc_reject.bssid;
+#ifdef CONFIG_MBO
+       struct wpa_bss *reject_bss;
+#endif /* CONFIG_MBO */
 
        if (!bssid || is_zero_ether_addr(bssid))
                bssid = wpa_s->pending_bssid;
+#ifdef CONFIG_MBO
+       if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
+               reject_bss = wpa_s->current_bss;
+       else
+               reject_bss = wpa_bss_get_bssid(wpa_s, bssid);
+#endif /* CONFIG_MBO */
 
        if (data->assoc_reject.bssid)
                wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_ASSOC_REJECT
@@ -3952,6 +4122,30 @@ static void wpas_event_assoc_reject(struct wpa_supplicant *wpa_s,
        }
 #endif /* CONFIG_OWE */
 
+#ifdef CONFIG_MBO
+       if (data->assoc_reject.status_code ==
+           WLAN_STATUS_DENIED_POOR_CHANNEL_CONDITIONS &&
+           reject_bss && data->assoc_reject.resp_ies) {
+               const u8 *rssi_rej;
+
+               rssi_rej = mbo_get_attr_from_ies(
+                       data->assoc_reject.resp_ies,
+                       data->assoc_reject.resp_ies_len,
+                       OCE_ATTR_ID_RSSI_BASED_ASSOC_REJECT);
+               if (rssi_rej && rssi_rej[1] == 2) {
+                       wpa_printf(MSG_DEBUG,
+                                  "OCE: RSSI-based association rejection from "
+                                  MACSTR " (Delta RSSI: %u, Retry Delay: %u)",
+                                  MAC2STR(reject_bss->bssid),
+                                  rssi_rej[2], rssi_rej[3]);
+                       wpa_bss_tmp_disallow(wpa_s,
+                                            reject_bss->bssid,
+                                            rssi_rej[3],
+                                            rssi_rej[2] + reject_bss->level);
+               }
+       }
+#endif /* CONFIG_MBO */
+
        if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) {
                sme_event_assoc_reject(wpa_s, data);
                return;
@@ -3969,12 +4163,24 @@ static void wpas_event_assoc_reject(struct wpa_supplicant *wpa_s,
        }
 #endif /* CONFIG_SAE */
 
+#ifdef CONFIG_DPP
+       if (wpa_s->current_ssid &&
+           wpa_s->current_ssid->key_mgmt == WPA_KEY_MGMT_DPP &&
+           !data->assoc_reject.timed_out) {
+               wpa_dbg(wpa_s, MSG_DEBUG, "DPP: Drop PMKSA cache entry");
+               wpa_sm_aborted_cached(wpa_s->wpa);
+               wpa_sm_pmksa_cache_flush(wpa_s->wpa, wpa_s->current_ssid);
+       }
+#endif /* CONFIG_DPP */
+
 #ifdef CONFIG_FILS
        /* Update ERP next sequence number */
-       if (wpa_s->auth_alg == WPA_AUTH_ALG_FILS)
+       if (wpa_s->auth_alg == WPA_AUTH_ALG_FILS) {
                eapol_sm_update_erp_next_seq_num(
                        wpa_s->eapol,
                        data->assoc_reject.fils_erp_next_seq_num);
+               fils_connection_failure(wpa_s);
+       }
 #endif /* CONFIG_FILS */
 
        wpas_connection_failed(wpa_s, bssid);
@@ -3987,6 +4193,9 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 {
        struct wpa_supplicant *wpa_s = ctx;
        int resched;
+#ifndef CONFIG_NO_STDOUT_DEBUG
+       int level = MSG_DEBUG;
+#endif /* CONFIG_NO_STDOUT_DEBUG */
 
        if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED &&
            event != EVENT_INTERFACE_ENABLED &&
@@ -4000,9 +4209,6 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
        }
 
 #ifndef CONFIG_NO_STDOUT_DEBUG
-{
-       int level = MSG_DEBUG;
-
        if (event == EVENT_RX_MGMT && data->rx_mgmt.frame_len >= 24) {
                const struct ieee80211_hdr *hdr;
                u16 fc;
@@ -4015,7 +4221,6 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 
        wpa_dbg(wpa_s, level, "Event %s (%d) received",
                event_to_string(event), event);
-}
 #endif /* CONFIG_NO_STDOUT_DEBUG */
 
        switch (event) {
@@ -4027,6 +4232,8 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                                   "FST: MB IEs updated from auth IE");
 #endif /* CONFIG_FST */
                sme_event_auth(wpa_s, data);
+               wpa_s->auth_status_code = data->auth.status_code;
+               wpas_notify_auth_status_code(wpa_s);
                break;
        case EVENT_ASSOC:
 #ifdef CONFIG_TESTING_OPTIONS
@@ -4042,6 +4249,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                }
 #endif /* CONFIG_TESTING_OPTIONS */
                wpa_supplicant_event_assoc(wpa_s, data);
+               wpa_s->assoc_status_code = WLAN_STATUS_SUCCESS;
                if (data &&
                    (data->assoc_info.authorized ||
                     (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) &&
@@ -4265,18 +4473,24 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                                       data->rx_from_unknown.wds);
                break;
 #endif /* CONFIG_AP */
+
+       case EVENT_CH_SWITCH_STARTED:
        case EVENT_CH_SWITCH:
                if (!data || !wpa_s->current_ssid)
                        break;
 
-               wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_CHANNEL_SWITCH
-                       "freq=%d ht_enabled=%d ch_offset=%d ch_width=%s cf1=%d cf2=%d",
+               wpa_msg(wpa_s, MSG_INFO,
+                       "%sfreq=%d ht_enabled=%d ch_offset=%d ch_width=%s cf1=%d cf2=%d",
+                       event == EVENT_CH_SWITCH ? WPA_EVENT_CHANNEL_SWITCH :
+                       WPA_EVENT_CHANNEL_SWITCH_STARTED,
                        data->ch_switch.freq,
                        data->ch_switch.ht_enabled,
                        data->ch_switch.ch_offset,
                        channel_width_to_string(data->ch_switch.ch_width),
                        data->ch_switch.cf1,
                        data->ch_switch.cf2);
+               if (event == EVENT_CH_SWITCH_STARTED)
+                       break;
 
                wpa_s->assoc_freq = data->ch_switch.freq;
                wpa_s->current_ssid->frequency = data->ch_switch.freq;
@@ -4284,6 +4498,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 #ifdef CONFIG_AP
                if (wpa_s->current_ssid->mode == WPAS_MODE_AP ||
                    wpa_s->current_ssid->mode == WPAS_MODE_P2P_GO ||
+                   wpa_s->current_ssid->mode == WPAS_MODE_MESH ||
                    wpa_s->current_ssid->mode ==
                    WPAS_MODE_P2P_GROUP_FORMATION) {
                        wpas_ap_ch_switch(wpa_s, data->ch_switch.freq,
@@ -4291,11 +4506,14 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                                          data->ch_switch.ch_offset,
                                          data->ch_switch.ch_width,
                                          data->ch_switch.cf1,
-                                         data->ch_switch.cf2);
+                                         data->ch_switch.cf2,
+                                         1);
                }
 #endif /* CONFIG_AP */
 
+               sme_event_ch_switch(wpa_s);
                wpas_p2p_update_channel_list(wpa_s, WPAS_P2P_CHANNEL_UPDATE_CS);
+               wnm_clear_coloc_intf_reporting(wpa_s);
                break;
 #ifdef CONFIG_AP
 #ifdef NEED_AP_MLME
@@ -4500,6 +4718,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                wpa_dbg(wpa_s, MSG_DEBUG, "Interface was enabled");
                if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
                        wpa_supplicant_update_mac_addr(wpa_s);
+                       wpa_supplicant_set_default_scan_ies(wpa_s);
                        if (wpa_s->p2p_mgmt) {
                                wpa_supplicant_set_state(wpa_s,
                                                         WPA_DISCONNECTED);
@@ -4662,7 +4881,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                break;
        case EVENT_WPS_BUTTON_PUSHED:
 #ifdef CONFIG_WPS
-               wpas_wps_start_pbc(wpa_s, NULL, 0);
+               wpas_wps_start_pbc(wpa_s, NULL, 0, 0);
 #endif /* CONFIG_WPS */
                break;
        case EVENT_AVOID_FREQUENCIES: