[PATCH] P2P: Do not use AP PSK 4-way offload for GO

Chung-Hsien Hsu chung-hsien.hsu at infineon.com
Fri Jun 12 04:57:44 PDT 2026


WPA_DRIVER_FLAGS2_4WAY_HANDSHAKE_AP_PSK describes support for
WPA-Personal 4-way handshake offload in AP mode. A P2P GO is started
through the AP/hostapd code path in wpa_supplicant, but using that
capability for P2P GO requires separate driver/firmware support.

The AP code currently uses this flag in two places: to pass a PSK/PMK
to the driver when setting the beacon and to skip starting the hostapd
WPA authenticator for a newly associated STA. On drivers that advertise
the AP capability but cannot use it for P2P GO, this can leave the P2P
client without a working 4-way handshake and break group formation.

Add an internal BSS configuration flag to disable AP PSK 4-way handshake
offload for P2P GO and P2P group formation. Keep the original driver
capability unchanged so normal AP mode continues to use the offload.

Signed-off-by: Chung-Hsien Hsu <chung-hsien.hsu at infineon.com>
Signed-off-by: Avishad Verma <avishad.verma at infineon.com>
---
 src/ap/ap_config.h  | 1 +
 src/ap/beacon.c     | 3 +--
 src/ap/hostapd.c    | 3 +--
 src/ap/hostapd.h    | 9 +++++++++
 wpa_supplicant/ap.c | 4 ++++
 5 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index 18a5c469b4fa..c4f8a50b530e 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -365,6 +365,7 @@ struct hostapd_bss_config {
 
 	int wpa; /* bitfield of WPA_PROTO_WPA, WPA_PROTO_RSN */
 	int extended_key_id;
+	bool disable_4way_handshake_ap_psk_offload;
 	int wpa_key_mgmt;
 	int rsn_override_key_mgmt;
 	int rsn_override_key_mgmt_2;
diff --git a/src/ap/beacon.c b/src/ap/beacon.c
index ca59c3dfd41f..7b5eae38b20c 100644
--- a/src/ap/beacon.c
+++ b/src/ap/beacon.c
@@ -2589,8 +2589,7 @@ int ieee802_11_build_ap_params(struct hostapd_data *hapd,
 
 	/* If key management offload is enabled, configure PSK to the driver. */
 	if (wpa_key_mgmt_wpa_psk_no_sae(hapd->conf->wpa_key_mgmt) &&
-	    (hapd->iface->drv_flags2 &
-	     WPA_DRIVER_FLAGS2_4WAY_HANDSHAKE_AP_PSK)) {
+	    hostapd_ap_psk_4way_offload(hapd)) {
 		if (hapd->conf->ssid.wpa_psk && hapd->conf->ssid.wpa_psk_set) {
 			os_memcpy(params->psk, hapd->conf->ssid.wpa_psk->psk,
 				  PMK_LEN);
diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index 122544b53951..ca97a81d067c 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -4230,8 +4230,7 @@ void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
 		    sta->auth_alg != WLAN_AUTH_FILS_PK &&
 		    !(sta->flags & (WLAN_STA_WPS | WLAN_STA_MAYBE_WPS)))
 			wpa_auth_sm_event(sta->wpa_sm, WPA_REAUTH);
-	} else if (!(hapd->iface->drv_flags2 &
-		     WPA_DRIVER_FLAGS2_4WAY_HANDSHAKE_AP_PSK)) {
+	} else if (!hostapd_ap_psk_4way_offload(hapd)) {
 		/* The 4-way handshake offloaded case will have this handled
 		 * based on the port authorized event. */
 		wpa_auth_sta_associated(hapd->wpa_auth, sta->wpa_sm);
diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
index 974964d341e9..c0e01e10d8f3 100644
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -862,6 +862,15 @@ void hostapd_event_sta_opmode_changed(struct hostapd_data *hapd, const u8 *addr,
 				      enum smps_mode smps_mode,
 				      enum chan_width chan_width, u8 rx_nss);
 
+static inline bool hostapd_ap_psk_4way_offload(struct hostapd_data *hapd)
+{
+	if (!(hapd->iface->drv_flags2 &
+	      WPA_DRIVER_FLAGS2_4WAY_HANDSHAKE_AP_PSK))
+		return false;
+
+	return !hapd->conf->disable_4way_handshake_ap_psk_offload;
+}
+
 int hostapd_change_config_freq(struct hostapd_data *hapd,
 			       struct hostapd_config *conf,
 			       struct hostapd_freq_params *params,
diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index d0a1a96fd5b4..de9f4212dc78 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -548,6 +548,10 @@ static int wpa_supplicant_conf_ap(struct wpa_supplicant *wpa_s,
 	bss->force_per_enrollee_psk = wpa_s->global->p2p_per_sta_psk;
 	bss->wpa_deny_ptk0_rekey = ssid->wpa_deny_ptk0_rekey;
 
+	if (ssid->mode == WPAS_MODE_P2P_GO ||
+	    ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION)
+		bss->disable_4way_handshake_ap_psk_offload = true;
+
 	if (ssid->p2p_group) {
 		os_memcpy(bss->ip_addr_go, wpa_s->p2pdev->conf->ip_addr_go, 4);
 		os_memcpy(bss->ip_addr_mask, wpa_s->p2pdev->conf->ip_addr_mask,
-- 
2.25.1




More information about the Hostap mailing list