Revert "Revert "[wpa_supplicant] cumilative patch from commit 3a..."
Revert submission 28102966-revert-26533062-Supplicant_merge_June24-CUATTSRBBR
Reason for revert: Fixed the regression issue (ag/28389573)
Reverted changes: /q/submissionid:28102966-revert-26533062-Supplicant_merge_June24-CUATTSRBBR
Bug: 329004037
Test: Turn ON/OFF SoftAp multiple times
Change-Id: Ibfff2a847be5678f1a6d77e28506a05936812a91
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index d4401ff..a851024 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -1,6 +1,6 @@
/*
* WPA Supplicant
- * Copyright (c) 2003-2022, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2003-2024, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
@@ -65,6 +65,7 @@
#include "wpas_kay.h"
#include "mesh.h"
#include "dpp_supplicant.h"
+#include "nan_usd.h"
#ifdef CONFIG_MESH
#include "ap/ap_config.h"
#include "ap/hostapd.h"
@@ -584,7 +585,9 @@
wpa_tdls_deinit(wpa_s->wpa);
#endif /* CONFIG_TDLS */
+#ifndef CONFIG_NO_WMM_AC
wmm_ac_clear_saved_tspecs(wpa_s);
+#endif /* CONFIG_NO_WMM_AC */
pmksa_candidate_free(wpa_s->wpa);
ptksa_cache_deinit(wpa_s->ptksa);
wpa_s->ptksa = NULL;
@@ -701,7 +704,9 @@
wpa_s->vendor_elem[i] = NULL;
}
+#ifndef CONFIG_NO_WMM_AC
wmm_ac_notify_disassoc(wpa_s);
+#endif /* CONFIG_NO_WMM_AC */
wpa_s->sched_scan_plans_num = 0;
os_free(wpa_s->sched_scan_plans);
@@ -717,7 +722,9 @@
wpabuf_free(wpa_s->lci);
wpa_s->lci = NULL;
+#ifndef CONFIG_NO_RRM
wpas_clear_beacon_rep_data(wpa_s);
+#endif /* CONFIG_NO_RRM */
#ifdef CONFIG_PMKSA_CACHE_EXTERNAL
#ifdef CONFIG_MESH
@@ -746,11 +753,17 @@
wpa_s->dpp = NULL;
#endif /* CONFIG_DPP */
+#ifdef CONFIG_NAN_USD
+ wpas_nan_usd_deinit(wpa_s);
+#endif /* CONFIG_NAN_USD */
+
#ifdef CONFIG_PASN
wpas_pasn_auth_stop(wpa_s);
#endif /* CONFIG_PASN */
+#ifndef CONFIG_NO_ROBUST_AV
wpas_scs_deinit(wpa_s);
wpas_dscp_deinit(wpa_s);
+#endif /* CONFIG_NO_ROBUST_AV */
#ifdef CONFIG_OWE
os_free(wpa_s->owe_trans_scan_freq);
@@ -1068,8 +1081,10 @@
if (state == WPA_DISCONNECTED || state == WPA_INACTIVE)
wpa_supplicant_start_autoscan(wpa_s);
+#ifndef CONFIG_NO_WMM_AC
if (old_state >= WPA_ASSOCIATED && wpa_s->wpa_state < WPA_ASSOCIATED)
wmm_ac_notify_disassoc(wpa_s);
+#endif /* CONFIG_NO_WMM_AC */
if (wpa_s->wpa_state != old_state) {
wpas_notify_state_changed(wpa_s, wpa_s->wpa_state, old_state);
@@ -2009,7 +2024,7 @@
(wpa_s->connection_ht || wpa_s->connection_vht ||
wpa_s->connection_he || wpa_s->connection_eht);
if (!wmm && bss)
- wmm = wpa_bss_get_vendor_ie(bss, WMM_IE_VENDOR_TYPE);
+ wmm = !!wpa_bss_get_vendor_ie(bss, WMM_IE_VENDOR_TYPE);
wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_WMM_ENABLED, wmm);
if (!skip_default_rsne) {
@@ -2111,7 +2126,9 @@
static void wpas_ext_capab_byte(struct wpa_supplicant *wpa_s, u8 *pos, int idx,
struct wpa_bss *bss)
{
+#ifndef CONFIG_NO_ROBUST_AV
bool scs = true, mscs = true;
+#endif /* CONFIG_NO_ROBUST_AV */
*pos = 0x00;
@@ -2127,7 +2144,9 @@
case 2: /* Bits 16-23 */
#ifdef CONFIG_WNM
*pos |= 0x02; /* Bit 17 - WNM-Sleep Mode */
- if (!wpa_s->disable_mbo_oce && !wpa_s->conf->disable_btm)
+ if ((wpas_driver_bss_selection(wpa_s) ||
+ !wpa_s->disable_mbo_oce) &&
+ !wpa_s->conf->disable_btm)
*pos |= 0x08; /* Bit 19 - BSS Transition */
#endif /* CONFIG_WNM */
break;
@@ -2156,6 +2175,7 @@
#endif /* CONFIG_MBO */
break;
case 6: /* Bits 48-55 */
+#ifndef CONFIG_NO_ROBUST_AV
#ifdef CONFIG_TESTING_OPTIONS
if (wpa_s->disable_scs_support)
scs = false;
@@ -2169,6 +2189,7 @@
}
if (scs)
*pos |= 0x40; /* Bit 54 - SCS */
+#endif /* CONFIG_NO_ROBUST_AV */
break;
case 7: /* Bits 56-63 */
break;
@@ -2185,6 +2206,7 @@
#endif /* CONFIG_FILS */
break;
case 10: /* Bits 80-87 */
+#ifndef CONFIG_NO_ROBUST_AV
#ifdef CONFIG_TESTING_OPTIONS
if (wpa_s->disable_mscs_support)
mscs = false;
@@ -2198,6 +2220,7 @@
}
if (mscs)
*pos |= 0x20; /* Bit 85 - Mirrored SCS */
+#endif /* CONFIG_NO_ROBUST_AV */
break;
}
}
@@ -2315,8 +2338,7 @@
if (style == WPAS_MAC_ADDR_STYLE_DEDICATED_PER_ESS) {
/* Pregenerated addresses do not expire but their value
* might have changed, so let's check that. */
- if (os_memcmp(wpa_s->own_addr, ssid->mac_value,
- ETH_ALEN) == 0)
+ if (ether_addr_equal(wpa_s->own_addr, ssid->mac_value))
return 0;
} else if ((wpa_s->last_mac_addr_change.sec != 0 ||
wpa_s->last_mac_addr_change.usec != 0) &&
@@ -2495,7 +2517,12 @@
wpa_s->eapol_failed = 0;
wpa_s->multi_ap_ie = 0;
+#ifndef CONFIG_NO_WMM_AC
wmm_ac_clear_saved_tspecs(wpa_s);
+#endif /* CONFIG_NO_WMM_AC */
+#ifdef CONFIG_WNM
+ wpa_s->wnm_mode = 0;
+#endif /* CONFIG_WNM */
wpa_s->reassoc_same_bss = 0;
wpa_s->reassoc_same_ess = 0;
#ifdef CONFIG_TESTING_OPTIONS
@@ -2506,7 +2533,9 @@
wpa_dbg(wpa_s, MSG_DEBUG, "Re-association to the same ESS");
wpa_s->reassoc_same_ess = 1;
if (wpa_s->current_bss && wpa_s->current_bss == bss) {
+#ifndef CONFIG_NO_WMM_AC
wmm_ac_save_tspecs(wpa_s);
+#endif /* CONFIG_NO_WMM_AC */
wpa_s->reassoc_same_bss = 1;
} else if (wpa_s->current_bss && wpa_s->current_bss != bss) {
os_get_reltime(&wpa_s->roam_start);
@@ -3074,7 +3103,7 @@
struct hostapd_hw_modes *mode = NULL;
int i, obss_scan = 1;
u8 channel;
- bool is_6ghz;
+ bool is_6ghz, is_24ghz;
freq->freq = ssid->frequency;
@@ -3103,6 +3132,9 @@
if (!mode)
return;
+ is_24ghz = hw_mode == HOSTAPD_MODE_IEEE80211G ||
+ hw_mode == HOSTAPD_MODE_IEEE80211B;
+
is_6ghz = is_6ghz_freq(freq->freq);
freq->ht_enabled = 0;
@@ -3114,7 +3146,7 @@
freq->ht_enabled = ibss_mesh_can_use_ht(wpa_s, ssid, mode);
if (freq->ht_enabled)
freq->vht_enabled = ibss_mesh_can_use_vht(wpa_s, ssid, mode);
- if (freq->vht_enabled || is_6ghz)
+ if (freq->vht_enabled || (freq->ht_enabled && is_24ghz) || is_6ghz)
freq->he_enabled = ibss_mesh_can_use_he(wpa_s, ssid, mode,
ieee80211_mode);
freq->channel = channel;
@@ -3256,8 +3288,10 @@
size_t wfa_ie_len, buf_len;
os_memset(wfa_capa, 0, sizeof(wfa_capa));
+#ifndef CONFIG_NO_ROBUST_AV
if (wpa_s->enable_dscp_policy_capa)
wfa_capa[0] |= WFA_CAPA_QM_DSCP_POLICY;
+#endif /* CONFIG_NO_ROBUST_AV */
if (wpa_is_non_eht_scs_traffic_desc_supported(bss))
wfa_capa[0] |= WFA_CAPA_QM_NON_EHT_SCS_TRAFFIC_DESC;
@@ -3521,12 +3555,14 @@
os_memset(wpa_s->p2p_ip_addr_info, 0, sizeof(wpa_s->p2p_ip_addr_info));
#endif /* CONFIG_P2P */
+#ifndef CONFIG_NO_RRM
if (bss) {
wpa_ie_len += wpas_supp_op_class_ie(wpa_s, ssid, bss,
wpa_ie + wpa_ie_len,
max_wpa_ie_len -
wpa_ie_len);
}
+#endif /* CONFIG_NO_RRM */
/*
* Workaround: Add Extended Capabilities element only if the AP
@@ -3753,6 +3789,7 @@
wpa_ie_len += wpa_s->rsnxe_len;
}
+#ifndef CONFIG_NO_ROBUST_AV
#ifdef CONFIG_TESTING_OPTIONS
if (wpa_s->disable_mscs_support)
goto mscs_end;
@@ -3787,6 +3824,7 @@
wpabuf_free(mscs_ie);
}
mscs_end:
+#endif /* CONFIG_NO_ROBUST_AV */
wpa_ie_len = wpas_populate_wfa_capa(wpa_s, bss, wpa_ie, wpa_ie_len,
max_wpa_ie_len);
@@ -4071,7 +4109,9 @@
wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
wpa_sm_set_assoc_rsnxe(wpa_s->wpa, NULL, 0);
wpa_s->rsnxe_len = 0;
+#ifndef CONFIG_NO_ROBUST_AV
wpa_s->mscs_setup_done = false;
+#endif /* CONFIG_NO_ROBUST_AV */
wpa_ie = wpas_populate_assoc_ies(wpa_s, bss, ssid, ¶ms, NULL);
if (!wpa_ie) {
@@ -4466,7 +4506,8 @@
* can stop right here; the association will not
* succeed.
*/
- wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
+ wpas_connection_failed(wpa_s, wpa_s->pending_bssid,
+ NULL);
wpa_s->assoc_status_code = WLAN_STATUS_UNSPECIFIED_FAILURE;
wpas_notify_assoc_status_code(wpa_s, wpa_s->pending_bssid, 0, NULL, 0);
wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
@@ -4562,8 +4603,10 @@
if (old_ssid != wpa_s->current_ssid)
wpas_notify_network_changed(wpa_s);
+#ifndef CONFIG_NO_ROBUST_AV
wpas_scs_deinit(wpa_s);
wpas_dscp_deinit(wpa_s);
+#endif /* CONFIG_NO_ROBUST_AV */
eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL);
}
@@ -5343,14 +5386,14 @@
os_memcmp(ssid, entry->ssid, ssid_len) == 0)) ||
wired) &&
(!entry->bssid_set ||
- os_memcmp(bssid, entry->bssid, ETH_ALEN) == 0))
+ ether_addr_equal(bssid, entry->bssid)))
return entry;
#ifdef CONFIG_WPS
if (!wpas_network_disabled(wpa_s, entry) &&
(entry->key_mgmt & WPA_KEY_MGMT_WPS) &&
(entry->ssid == NULL || entry->ssid_len == 0) &&
(!entry->bssid_set ||
- os_memcmp(bssid, entry->bssid, ETH_ALEN) == 0))
+ ether_addr_equal(bssid, entry->bssid)))
return entry;
#endif /* CONFIG_WPS */
@@ -5360,13 +5403,13 @@
owe_trans_ssid_match(wpa_s, bssid, entry->ssid,
entry->ssid_len)) &&
(!entry->bssid_set ||
- os_memcmp(bssid, entry->bssid, ETH_ALEN) == 0))
+ ether_addr_equal(bssid, entry->bssid)))
return entry;
#endif /* CONFIG_OWE */
if (!wpas_network_disabled(wpa_s, entry) && entry->bssid_set &&
entry->ssid_len == 0 &&
- os_memcmp(bssid, entry->bssid, ETH_ALEN) == 0)
+ ether_addr_equal(bssid, entry->bssid))
return entry;
entry = entry->next;
@@ -5494,7 +5537,7 @@
#ifdef CONFIG_AP
!wpa_s->ap_iface &&
#endif /* CONFIG_AP */
- os_memcmp(src_addr, connected_addr, ETH_ALEN) != 0)) {
+ !ether_addr_equal(src_addr, connected_addr))) {
/*
* There is possible race condition between receiving the
* association event and the EAPOL frame since they are coming
@@ -5524,7 +5567,7 @@
}
wpa_s->last_eapol_matches_bssid =
- os_memcmp(src_addr, connected_addr, ETH_ALEN) == 0;
+ ether_addr_equal(src_addr, connected_addr);
#ifdef CONFIG_AP
if (wpa_s->ap_iface) {
@@ -5681,7 +5724,7 @@
fst_update_mac_addr(wpa_s->fst, wpa_s->own_addr);
#endif /* CONFIG_FST */
- if (os_memcmp(prev_mac_addr, wpa_s->own_addr, ETH_ALEN) != 0)
+ if (!ether_addr_equal(prev_mac_addr, wpa_s->own_addr))
wpas_notify_mac_address_changed(wpa_s);
return 0;
@@ -5698,7 +5741,7 @@
return;
eth = (const struct l2_ethhdr *) buf;
- if (os_memcmp(eth->h_dest, wpa_s->own_addr, ETH_ALEN) != 0 &&
+ if (!ether_addr_equal(eth->h_dest, wpa_s->own_addr) &&
!(eth->h_dest[0] & 0x01)) {
wpa_dbg(wpa_s, MSG_DEBUG, "RX EAPOL from " MACSTR " to " MACSTR
" (bridge - not for this interface - ignore)",
@@ -5873,8 +5916,11 @@
dl_list_init(&wpa_s->fils_hlp_req);
#ifdef CONFIG_TESTING_OPTIONS
dl_list_init(&wpa_s->drv_signal_override);
+ wpa_s->test_assoc_comeback_type = -1;
#endif /* CONFIG_TESTING_OPTIONS */
+#ifndef CONFIG_NO_ROBUST_AV
dl_list_init(&wpa_s->active_scs_ids);
+#endif /* CONFIG_NO_ROBUST_AV */
wpa_s->ml_probe_mld_id = -1;
return wpa_s;
@@ -6387,7 +6433,7 @@
{
struct wpa_supplicant *wpa_s = ctx;
- if (os_memcmp(wpa_s->bssid, da, ETH_ALEN) != 0) {
+ if (!ether_addr_equal(wpa_s->bssid, da)) {
wpa_printf(MSG_INFO, "FST:%s:bssid=" MACSTR " != da=" MACSTR,
__func__, MAC2STR(wpa_s->bssid), MAC2STR(da));
return -1;
@@ -6403,7 +6449,7 @@
{
struct wpa_supplicant *wpa_s = ctx;
- WPA_ASSERT(os_memcmp(wpa_s->bssid, addr, ETH_ALEN) == 0);
+ WPA_ASSERT(ether_addr_equal(wpa_s->bssid, addr));
return wpa_s->received_mb_ies;
}
@@ -6414,7 +6460,7 @@
struct wpa_supplicant *wpa_s = ctx;
struct mb_ies_info info;
- WPA_ASSERT(os_memcmp(wpa_s->bssid, addr, ETH_ALEN) == 0);
+ WPA_ASSERT(ether_addr_equal(wpa_s->bssid, addr));
if (!mb_ies_info_by_ies(&info, buf, size)) {
wpabuf_free(wpa_s->received_mb_ies);
@@ -7203,6 +7249,9 @@
return -1;
}
+ wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_FT_PREPEND_PMKID,
+ wpa_s->conf->ft_prepend_pmkid);
+
wpa_s->hw.modes = wpa_drv_get_hw_feature_data(wpa_s,
&wpa_s->hw.num_modes,
&wpa_s->hw.flags,
@@ -7251,7 +7300,9 @@
wpa_s->extended_capa_len = capa.extended_capa_len;
wpa_s->num_multichan_concurrent =
capa.num_multichan_concurrent;
+#ifndef CONFIG_NO_WMM_AC
wpa_s->wmm_ac_supported = capa.wmm_ac_supported;
+#endif /* CONFIG_NO_WMM_AC */
wpa_s->max_num_akms = capa.max_num_akms;
if (capa.mac_addr_rand_scan_supported)
@@ -7339,6 +7390,11 @@
return -1;
#endif /* CONFIG_DPP */
+#ifdef CONFIG_NAN_USD
+ if (wpas_nan_usd_init(wpa_s) < 0)
+ return -1;
+#endif /* CONFIG_NAN_USD */
+
if (wpa_supplicant_init_eapol(wpa_s) < 0)
return -1;
wpa_sm_set_eapol(wpa_s->wpa, wpa_s->eapol);
@@ -7408,7 +7464,9 @@
if (wpas_init_ext_pw(wpa_s) < 0)
return -1;
+#ifndef CONFIG_NO_RRM
wpas_rrm_reset(wpa_s);
+#endif /* CONFIG_NO_RRM */
wpas_sched_scan_plans_set(wpa_s, wpa_s->conf->sched_scan_plans);
@@ -8173,6 +8231,10 @@
if (wpa_s->conf->changed_parameters & CFG_CHANGED_DISABLE_BTM)
wpa_supplicant_set_default_scan_ies(wpa_s);
+ if (wpa_s->conf->changed_parameters & CFG_CHANGED_FT_PREPEND_PMKID)
+ wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_FT_PREPEND_PMKID,
+ wpa_s->conf->ft_prepend_pmkid);
+
#ifdef CONFIG_BGSCAN
/*
* We default to global bgscan parameters only when per-network bgscan
@@ -8241,7 +8303,8 @@
}
-void wpas_connection_failed(struct wpa_supplicant *wpa_s, const u8 *bssid)
+void wpas_connection_failed(struct wpa_supplicant *wpa_s, const u8 *bssid,
+ const u8 **link_bssids)
{
int timeout;
int count;
@@ -8276,6 +8339,12 @@
return;
}
+ /* Also mark links as failed */
+ while (link_bssids && *link_bssids) {
+ wpa_bssid_ignore_add(wpa_s, *link_bssids);
+ link_bssids++;
+ }
+
/*
* Add the failed BSSID into the ignore list and speed up next scan
* attempt if there could be other APs that could accept association.
@@ -8692,9 +8761,16 @@
int pmf_in_use(struct wpa_supplicant *wpa_s, const u8 *addr)
{
if (wpa_s->current_ssid == NULL ||
- wpa_s->wpa_state < WPA_4WAY_HANDSHAKE ||
- os_memcmp(addr, wpa_s->bssid, ETH_ALEN) != 0)
+ wpa_s->wpa_state < WPA_4WAY_HANDSHAKE)
return 0;
+ if (wpa_s->valid_links) {
+ if (!ether_addr_equal(addr, wpa_s->ap_mld_addr) &&
+ !wpas_ap_link_address(wpa_s, addr))
+ return 0;
+ } else {
+ if (!ether_addr_equal(addr, wpa_s->bssid))
+ return 0;
+ }
return wpa_sm_pmf_enabled(wpa_s->wpa);
}
@@ -8819,8 +8895,8 @@
return 0;
for (i = 0; i < wpa_s->disallow_aps_bssid_count; i++) {
- if (os_memcmp(wpa_s->disallow_aps_bssid + i * ETH_ALEN,
- bssid, ETH_ALEN) == 0)
+ if (ether_addr_equal(wpa_s->disallow_aps_bssid + i * ETH_ALEN,
+ bssid))
return 1;
}
@@ -9130,7 +9206,7 @@
dl_list_for_each(bss, &wpa_s->bss_tmp_disallowed,
struct wpa_bss_tmp_disallowed, list) {
- if (os_memcmp(bssid, bss->bssid, ETH_ALEN) == 0)
+ if (ether_addr_equal(bssid, bss->bssid))
return bss;
}
@@ -9213,7 +9289,7 @@
dl_list_for_each_safe(tmp, prev, &wpa_s->bss_tmp_disallowed,
struct wpa_bss_tmp_disallowed, list) {
- if (os_memcmp(bss->bssid, tmp->bssid, ETH_ALEN) == 0) {
+ if (ether_addr_equal(bss->bssid, tmp->bssid)) {
disallowed = tmp;
break;
}
@@ -9311,8 +9387,7 @@
dl_list_for_each(dso, &wpa_s->drv_signal_override,
struct driver_signal_override, list) {
- if (os_memcmp(wpa_s->bssid, dso->bssid,
- ETH_ALEN) != 0)
+ if (!ether_addr_equal(wpa_s->bssid, dso->bssid))
continue;
wpa_printf(MSG_DEBUG,
"Override driver signal_poll information: current_signal: %d->%d avg_signal: %d->%d avg_beacon_signal: %d->%d current_noise: %d->%d",
@@ -9357,7 +9432,7 @@
dl_list_for_each(dso, &wpa_s->drv_signal_override,
struct driver_signal_override, list) {
- if (os_memcmp(res->bssid, dso->bssid, ETH_ALEN) != 0)
+ if (!ether_addr_equal(res->bssid, dso->bssid))
continue;
wpa_printf(MSG_DEBUG,
"Override driver scan signal level %d->%d for "
@@ -9379,7 +9454,7 @@
}
-static bool wpas_ap_link_address(struct wpa_supplicant *wpa_s, const u8 *addr)
+bool wpas_ap_link_address(struct wpa_supplicant *wpa_s, const u8 *addr)
{
int i;
@@ -9390,7 +9465,7 @@
if (!(wpa_s->valid_links & BIT(i)))
continue;
- if (os_memcmp(wpa_s->links[i].bssid, addr, ETH_ALEN) == 0)
+ if (ether_addr_equal(wpa_s->links[i].bssid, addr))
return true;
}