cumilative patch from commit 795075444

Bug: 341971059
Bug: 387693074
Test: Connect to open, WPA2, WPA3 and OWE
Test: Establish P2P connection
Test: Basic SoftAp tests
Test: Ran above tests on Pixel6
Test: Regression test (b/387705228)

BYPASS_INCLUSIVE_LANGUAGE_REASON=Merged from open source

795075444 EAP-TEAP: Add a compatibility mode for FreeRADIUS
50af5c1c9 EAP-TEAP: Fix S-IMCK derivation based on RFC 7170bis
9e04dac3c WNM: A more explicit check for a connection
b9e798339 MBO: Get rid of the is_first flag in neighbor report array
1f4a2e825 WNM: Use standard BSS selection and enable abridged bit handling
f3a8e4284 WNM: Fix pre-scan rejection heuristic for BTM handling
42fe546e0 tests: get_bss_transition_status() driver op
53f9d6f69 WNM: Move driver MBO transition rejection into wnm_is_bss_excluded()
977edbdd9 EAP-TEAP: Remove deprecated PAC support
2d74d34d3 Clear the pending EAPOL RX on disconnection
84c904093 WPS: Fix a race condition on WPS_CANCEL handling
1888b7efd Use BSS-specific ACL configuration when setting up driver-based ACL
ce7b3c2ca MBSSID: Allow BSS Index and maximum number of BSSs to be configured
2fe7a2b80 Do not add extra IEs to scan request if they do not fit driver limit
66442d1bc nl80211: Fetch maximum length of extra IE(s) for Probe Request frames
df0b6fa90 Introduce DUMP_BEACON command
7b529aad9 EAP-TEAP: Don't complain about missing PAC when teap_provisioning=0
edd85280f Check last scan SSIDs before triggering new scan for hidden network
470e32c20 Update link to prplMesh repository
9d80d5d71 Handle CONFIG_NO_WPA for wpa_sm_has_ptk_installed()
3fa38e55c mka: Accept MKPDU sent to any multicast address
ee9cd7d74 OWE: Fix SSID comparison in transition mode case
093a01422 OWE: Accept only BSS entries with an actual SSID for ROAM command
38ccd0677 nl80211: Use wpa_msg() to report netlink errors
614d42a50 nl80211: Make drv pointer available to send_and_recv()
13a4d7b09 hostapd: Respect obss_interval on 40 MHz intolerant disconnect
f8b898244 P2P2: Use global interface for USD
75b25ffbe nl80211: Allow PASN Authentication frames on P2P device interface
abedecd14 P2P2: Fix frequency selection for auto GO join
546812862 P2P2: Make sure password is set when using non opportunistic methods
af7d1a012 P2P2: Report R2 information in P2P-DEVICE-FOUND event
53d15ddc5 NAN: Remove excessive debug print about the next timer
0c496d3c5 wpa_cli: Support NAN USD commands
06c5265f7 NAN: Fix A3 for unicast P2P2 USD
50c563785 NAN: Fix A3 for multicast P2P2 USD
c330b5820 Send CTRL-EVENT-SIGNAL-CHANGE message to control interfaces only
d17a85ea1 hostapd: hostapd_cleanup_iface_partial: Fix hw_features use after free
089e360cc Android: Wrap a P2P-specific chunk in CONFIG_P2P
44a0560f1 EAPOL: Fix PMK setting for driver-based FT-SHA384
d8772c195 DPP: Handle EVENT_TX_WAIT_EXPIRE path for push button
6b5e7c003 P2P2: Remove redundant enable_pairing_verification flag
a931a4782 Fix using invalid memory during driver deinit
f55b9c405 Update STA authorized flag for AP SME in driver cases for open network
65338c581 Fix CONFIG_NO_STDOUT_DEBUG=y build
fbc67eae4 Fix sae_pk_gen compilation
430bc89b9 Include base64 for hostapd CONFIG_SAE_PK builds
c9a3b3e75 ext_password_file: Do not use wpa_config_get_line()
0d3db4fe5 Fix nan_usd linker error
550513ee5 Comment out WPA related code additions with CONFIG_NO_WPA
631fbbcfc Use consistent ifdef CONFIG_NO_WPA blocks
6857b0c41 Add empty inline functions for CONFIG_NO_WPA
24df236ca Fix CONFIG_NO_WPA compile/link errors related to RSNXE
1f88e0463 Include HMAC-SHA384/512 KDF for SAE if SHA384/512 is included
4e8686cd1 hlr_auc_gw: Add TERMINATE command
b39a9cae8 AP MLD: Do not try to set hapd->mld multiple times
baeedceb0 hostapd: Fix wrong puncturing bitmap in Bandwidth Indication subelement
5a0572a49 hostapd: Move punct_bitmap into hostapd_freq_params
982c634ac hostapd: Fix length of Bandwidth Indication subelement
290a793b0 Avoid EAPOL trigger in reassoc path for AP with 4-way handshake offload
782b0c2ba AP MLD: Fix a crash in hostapd_driver_init()
4f05eead3 BSS: MLD: Parse all TBTT entries after an invalid link
26273daef BSS: MLD: Limit TBTT parsing to correct length
8e490da87 P2P: Consult driver capabilities before setting HE bit in GO's conf
ca0bb5cc9 mesh: Use the correct 6 GHz operating class 137 for 320 MHz bandwidth
01677c47f AP: Support disconnect with MLD
45f626113 P2P: Check P2P 6 GHz capability to start P2P GO
3e5d2dbea Add QCA vendor attributes to configure antenna selection
7c52ff140 P2P2: Allow P2P2 client to connect to GO with preconfigured credentials
305cd9049 P2P2: Handle join case without pending GO interface address
2552de375 EHT: Fix HE center frequency for EHT 320 MHz with puncturing
888c5b212 nl80211: Update channels unavailability for 320 MHz
338e79b6f AP MLD: Fix radar event processing
711e837fd EHT: Update legacy bandwidth when puncturing is set in 320 MHz
4bcf145ca EHT: Update legacy bandwidth for 320 MHz in Wide Bandwidth subelement
e3fe940ac nl80211: Use nl80211_bss_msg() helper wherever BSS is accessible
00c2c20d7 hostapd: Maintain single wpa_driver_nl80211_data (drv) object across interfaces
54eeaa075 Add a vendor attribute to disable DFS owner capability
7ff2ee8cd Remove empty line between vendor attribute documentation and definition
e833c5af3 Add new QCA vendor attributes for TWT session updatability
3f046c7ce QCA vendor attribute to configure operating type for monitor mode
c0e8b16a3 AP MLD: Fix max number of simultaneous links in MLE during CAC
acc35945a AP: Fix dangling pointer access during 6 GHz NO_IR channel list update
525f7d94c Force a global operating class to be used with Wi-Fi Agile Multiband
63d77c899 SAE: Reject association for no PMKID match only for PMKSA caching
04f4caad5 DPP: Deinit Configurator process if Config Requst is not received
93f623f74 AP MLD: Fix crash during config reload from non-ML to ML
5e6119234 AP: Handle (Re)Association Response frame if rsn_override_omit_rsnxe is set
9ec982cb4 AP MLD: Show maximum number of simultaneous links info for non-AP MLDs
4cbbcd3b6 AP MLD: Show AP MLD Type Indication in STATUS command
4c3b32932 AP MLD: Show puncture bitmap in STATUS command
64ac39354 P2P: Avoid infinite loop with radio_remove_works(p2p-listen)
ae5ef60ed AP MLD: Remove common elements from per STA profile
7855b6d60 AP MLD: Send EML capabilities of an ML station to the driver
e0aac2cd3 AP MLD: Add NULL check for mld pointer during MLD link removal
a158fecc9 AP MLD: Remove unnecessary wpa_group get and put for ML cases
6637b44a9 AP MLD: Remove unnecessary outer for loop in authorizing ML STA
475f50d71 P2P2: Allow op class and channel override for Invitation Response
ebffcffd7 P2P2: Set P2P mode (R1 vs. R2) in the driver
61a36a226 P2P2: P2P connection compatibility mode with RSN overriding
007d3f01b RSNO: Allow RSN overriding to be enabled for a specific network
89455cc07 Add new QCA vendor attributes for TWT setup parameters
b74e8c1b1 Add new QCA vendor TWT capability values
374b73d4d Add a new QCA vendor attribute for TWT session suspendability
25d29d65a P2P: Clear wpa_s->p2p2 for NFC cases
59c608bd8 wlantest: Use AP's RSNXOE for capabilities when RSNO is used
0c147e622 NAN USD: Do not start pause state for P2P2 on Subscribe message RX
cd8b3ad8d NAN USD: Use different group address for P2P2
0806c21db P2P2: Allow PASN-PTK to be fetched for testing purposes
bd010a7ec P2P2: Allow P2P-PMK to be extracted for testing purposes
4ebca723f P2P2: Allow device address change when reinvoking a persistent group
df37010ad P2P2: Command to remove all P2P2 identity keys
7f6fbba23 P2P2: Store device identity key in wpa_supplicant configuration
1525e84d4 Helper functions for fetching PMK and PMKID
d0e2570a7 P2P2: Store WPA3 connection credentials in the configuration
95c195014 P2P2: Fix memory leak in awork deinit case for PASN authentication
29912be14 hostapd: Pass link ID for non-link agnostic Action frames
65d865e62 AP: Avoid double free of key data buffer if AES unwrap fails
422c5dc91 AP: NULL pointer check for bssid in hostapd_mgmt_tx_cb()
37061ef86 nl80211: NULL pointer check for msg in i802_flush()
9fdbc5901 dbus: NAN USD: Actually use freq_list parameter in NANPublish
5920e2b97 Automatic generation of supported WFA generational capabilities on STA
d4cd22ac9 Convert wpa_s->hw_capab into a bitmap and add HE and EHT
8f5ae8801 Wi-Fi Generational Capabilities Indication transmission on STA
c97b35bd9 Wi-Fi Generational Capabilities Indication reception on AP
a0ba416e7 Definitions for Wi-Fi Alliance generational capabilities indication
74792088b AP: Update the list of Action frame categories that are not robust
e9fc4eec3 nl80211: Register to receive Vendor Specific Protected action frames
2c46ebfd2 Control interface command to generate new random MAC address
eea566cfa NAN: Do not expire USD services based on last TX/RX message
77ac40275 NAN: Wait on the channel with publisher is in pauseState
3d6360fb5 NAN: Limit pauseState to be within service lifetime
2817554a3 NAN: Print a debug entry on TX wait time expiration
296141fe9 NAN: Make DE aware of maximum driver supported listen time
b752dfc1d NAN: Do not unpause publisher on fixed Follow-up message timeout
4ea2c336d P2P2: Add wpa_supplicant configuration parameters for P2P2
5f507ffcc dbus: Increment introspection buffer size
e9daa3fca P2P2: Enable TWT and Channel Usage support by default
b62bef8c2 Channel Usage, peer-to-peer TWT and TWT requester support
41d09f844 P2P2: Configuration of channel switch request for testing purposes
c2f90ef35 Avoid undefined behavior in RSNXE capability bit checker
c009ac474 P2P2: Validate DIRA and configure PMK
417c67468 P2P2: Add device identity block to wpa_supplicant configuration
72e154dbd P2P2: Update P2P Device Address when changing netdev address
a9c33fa0d P2P: Print dst/src/bssid in Action frame TX debug message
ea4e0116d SAE: Do not allow password identifier to be used without H2E
afd120d03 SAE: Send Commit message with unknown-password-id from Nothing state
90a3b4a91 SAE: Do not use the wpa_passphrase if SAE password identifier was used
d3b5887f3 Add new QCA vendor attributes for TWT statistics
6742284dc Add new QCA vendor TWT status values
999ef0499 Reserve QCA vendor sub command id 255
75e767666 Add QCA vendor interface for additional TWT Setup command types
9ff75554a dbus: Notify P2P2 bootstrapping request and completed events
319c4b4e9 P2P2: Configure PMK/PMKID to the driver on the GO
f35c8a9ff P2P2: Enable PASN on a P2P GO
ae36944a9 Control interface command to flush NAN publish and subscribe sessions
e5c8774e4 P2P2: Fix pairing verification without encrypted elements
103314d55 P2P2: Determine PASN KEK derivation based on peer capabilities
be8f31acb PASN: Mark PMK and PMKID const in functions adding PMKSA entries
e5edc8a6f P2P2: Remember password from connect command to starting after scan
a01652bd5 P2P2: Start client for join without WPS
bfd799126 P2P2: Support for GO to allow a client to join the group
a2f634be8 P2P2: Provisioning step on GO when a client joins
ba5bf4a34 P2P2: Fix a typo in function documentation
564c969a5 P2P2: Fix peer entry generation based on USD
07ee3e8b0 Remove STA entries if association is not completed in 60 seconds
28ebad01e SAE: More robust password identifier checks for AP mode
8a3351055 SAE: Reject unexpected password identifier in commit message parser
18e8a525b SAE: Avoid duplicated debug entries for IEs in SAE commit messages
161327f91 hostapd: Fix clearing up settings for color switch
914f3fe8d P2P2: Do not add WPS IE to join-a-group scan
b41138a13 P2P2: Use PASN for joining a group
ebdc3b53b P2P2: Allow group to be added for P2P2 as autonomous GO
d91466a4f P2P2: Add PMKSA entry on successful group formation
b80b37910 P2P2: Fix to check if sae_password is present
96e48a05a P2P2: Invitation using pairing verification
4efc0bd02 P2P2: Do not override peer_addr from BSSID in pairing verification
eed859cdf P2P2: Indicate P2P2 group in GO parameters
050618c88 P2P2: Set up PMKSA for pairing verification
29ad7ffe7 P2P2: Export p2p_build_inviation_req()
e6a96dbce P2P2: Do not add WSC IE for P2P2 Invitation Request
ff02a87c1 P2P2: Fetch PMK and PMKID for invitation using pairing verification
431053e39 P2P2: Stop invitation process before sending out Invitation Request
71b443a98 P2P2: Indication on whether P2P2 is used with P2P_INVITE
7ba52f6a4 P2P2: Parameter setting for testing purpose
9d0aad0fa P2P2: Enable GCMP-256 as a pairwise cipher
c55d1f9e8 P2P2: Clone P2P2 and bootstrapping state to group interfaces
cf30af7c2 P2P2: Start P2P Client appropriately for P2P2 group
339f39e10 P2P2: Add P2P2 IE for groups using P2P2
fa4b6e37b P2P2: Start GO with suitable parameters for P2P2
240e1297d P2P2: Indicate SAE password and PMK from pairing with GO negotiation
6efcc17cb P2P: Clear GO negotiation results from stack after use
84a4e0004 P2P2: Select PMKSA based on P2P Device Address and PMKID match
048c30cb4 P2P2: Function callbacks for PASN
394beb560 P2P2: Add a SAE password in PASN Encrypted Data element
626a73a6a P2P2: Parse and store peer's SAE password
3207ad1ca P2P2: Parser function for PASN Encrypted Data element and DevIK
b787d1621 FILS: Verify RSNXE when processing (Re)Association Response frame
d1337b159 RSNO: Omit RSNXE in (Re)Association Response frame like in Beacon frame
a041777ff FT: Omit RSNXE from Reassociation Response frame only with FT protocol
ae6d2a5c0 AP: Use helper functions in ap_sta_disconnect()
dc9616f58 AP: Clean up MLD changes that modified skipping DMG deauthentication
6aef223ce Avoid memcmp() with NULL pointer even if for zero length
5b4c8bdd2 wpa_supplicant: 320 MHz bandwidth support for mesh
5834062c2 AP MLD: Allow link ID to be specified for Action frame TX operations
bfc89d757 nl80211: Handle radar event properly during MLO
2657e97c5 nl80211: Send link ID when starting CAC for radar detection
00daadff9 hostapd: Fix clearing old BSS during config reload
8035c11df Remove unused arguments in ieee802_11_parse_link_assoc_req()
b83859c78 scan: Pass correct link ID in all cases
9bc75ef93 Add a QCA vendor event to indicate status of the idle shutdown
a9e562b29 Update documentation of the QCA vendor ACS channel list attributes
23e8a42ca wlantest: Fix BIP replay protection check
ea2ff4b3f FT: Do not omit RSNXE from FT initial mobility domain association
ec198cfae SAE: Allow network profile sae_pwe to be configured
2e061a909 P2P2: PASN Authentication frame TX status handling
c449b2e09 P2P2: Initiate PASN on bootstrapping completion
e147d24a0 P2P2: Add support for GO Negotiation wrapped in PASN auth frame
9304e899f PASN: Store PASN authentication frames 1 and 2
8cef9b1b1 PASN: Extend maximum buffer length in 3rd auth frame
e15242565 PASN: Routines for generating and processing encrypted data
0ff802a51 P2P2: Set DevIK expiration time to 24 hours
5fb90cf3f SAE: Use sae_pwe in network profile for STA mode
f46eb8d3f SAE: Extend Basic MLE Recognition to external auth case
4d6ad78d0 Extend EAPOL frames processing workaround for reassociation to same AP
e09358447 STA: Update driver roaming policy on connection completion
8a257f9a5 Add QCA vendor command to fetch offload scan data from firmware
7cd1f3c0a Add TEST_RSNXE_DATA for RSNXE testing of AP functionality
bb1316baa Allow forced enabling of EAPOL-Key msg 2/4 key info bits for testing
236d25e75 QCA vendor interface to exclude 6 GHz non-PSC channels as primary channel in ACS
eb529b0b5 Add QCA vendor status for TWT termination due to multiple MLO links activated
9e22afa48 Fix STA's SSID protection capability when AP SME is offloaded to driver
85cd98976 dbus: Methods for NAN USD
dcf58aec8 dbus: Signals for NAN USD
d2408e303 dbus: Dict helpers for fetching integers of any type
fd1a149d9 NAN: Fix UpdatePublish offload to driver
b3bd49f3c NAN: Handle A3 copying internally to simplify control interface
fbbc9cb9e NAN: Update A3 for USD to use NAN Network ID or NAN Cluster ID in A3
e0496580a hostapd: Add drv_send_action variant for forcing A3
83f9dcbb3 NAN: Process received NAN SDFs with NAN Network ID in A3 on AP
ccba6921d SAE: Recognize Basic MLE in Authentication frames even without H2E
c97168f58 FT: Discard EAPOL-Start frames when FT was used for association
f54359915 nl80211: Remove nl_msg free on send failure for NAN USD commands
61960e6c6 P2P2: Add alternative PASN RX handler
7d13410a8 SAE: Mark the groups argument to sae_derive_pt() const
9edd8b441 nl80211: Fix conditional checks of nlmsg attributes for NAN publish

Change-Id: If300ab0f4e93d221e7e576a08e11825cb0fd0bf9
Signed-off-by: Sunil Ravi <sunilravi@google.com>
diff --git a/hostapd/main.c b/hostapd/main.c
index 50b9f04..5769fa0 100644
--- a/hostapd/main.c
+++ b/hostapd/main.c
@@ -162,6 +162,7 @@
 	struct wpa_driver_capa capa;
 #ifdef CONFIG_IEEE80211BE
 	struct hostapd_data *h_hapd = NULL;
+	void *shared_hapd = NULL;
 #endif /* CONFIG_IEEE80211BE */
 
 	if (hapd->driver == NULL || hapd->driver->hapd_init == NULL) {
@@ -170,8 +171,11 @@
 	}
 
 #ifdef CONFIG_IEEE80211BE
-	if (conf->mld_ap)
+	if (conf->mld_ap) {
+		if (!hapd->mld)
+			hostapd_bss_setup_multi_link(hapd, iface->interfaces);
 		h_hapd = hostapd_mld_get_first_bss(hapd);
+	}
 
 	if (h_hapd) {
 		hapd->drv_priv = h_hapd->drv_priv;
@@ -255,6 +259,42 @@
 
 	params.own_addr = hapd->own_addr;
 
+#ifdef CONFIG_IEEE80211BE
+	if (hapd->driver->can_share_drv &&
+	    hapd->driver->can_share_drv(hapd, &params, &shared_hapd)) {
+		char force_ifname[IFNAMSIZ];
+		const u8 *addr = params.bssid;
+		u8 if_addr[ETH_ALEN];
+
+		if (!shared_hapd) {
+			wpa_printf(MSG_ERROR, "Failed to get the shared drv");
+			os_free(params.bridge);
+			return -1;
+		}
+
+		/* Share an already initialized driver interface instance
+		 * using an AP mode BSS in it instead of adding a new driver
+		 * interface instance for the same driver. */
+		if (hostapd_if_add(shared_hapd, WPA_IF_AP_BSS,
+				   params.ifname, addr, hapd,
+				   &hapd->drv_priv, force_ifname, if_addr,
+				   params.num_bridge && params.bridge[0] ?
+				   params.bridge[0] : NULL,
+				   0)) {
+			wpa_printf(MSG_ERROR, "Failed to add BSS (BSSID="
+				   MACSTR ")", MAC2STR(hapd->own_addr));
+			os_free(params.bridge);
+			return -1;
+		}
+		os_free(params.bridge);
+
+		hapd->interface_added = 1;
+		os_memcpy(params.own_addr, addr ? addr : if_addr, ETH_ALEN);
+
+		goto pre_setup_mld;
+	}
+#endif /* CONFIG_IEEE80211BE */
+
 	hapd->drv_priv = hapd->driver->hapd_init(hapd, &params);
 	os_free(params.bridge);
 	if (hapd->drv_priv == NULL) {
@@ -265,6 +305,7 @@
 	}
 
 #ifdef CONFIG_IEEE80211BE
+pre_setup_mld:
 	/*
 	 * This is the first interface added to the AP MLD, so have the
 	 * interface hardware address be the MLD address, while the link address