[PATCH 3/5] P2P2: Reuse an existing P2P GO interface

Andrei Otcheretianski andrei.otcheretianski at intel.com
Thu Oct 23 03:45:32 PDT 2025


From: Ilan Peer <ilan.peer at intel.com>

When calling 'p2p_connect' with 'p2p2', 'join' and 'auth' the
intention is to allow a peer device connection to an existing
running P2P GO.

Modify the exiting implementation to do so instead of trying
to create an new interface etc.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 wpa_supplicant/p2p_supplicant.c | 36 ++++++++++++++++++++++++---------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 26f3513e13..9488e6bb40 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -7078,21 +7078,25 @@ int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
 			if (!wpa_s->p2p2)
 				return ret;
 
-			wpa_s->create_p2p_iface = wpas_p2p_create_iface(wpa_s);
-			if (wpa_s->create_p2p_iface) {
-				if_addr = wpa_s->pending_interface_addr;
-			} else {
-				if (wpa_s->p2p_mgmt)
-					if_addr = wpa_s->parent->own_addr;
-				else
-					if_addr = wpa_s->own_addr;
-				os_memset(wpa_s->go_dev_addr, 0, ETH_ALEN);
+			/* When P2P connect request is configured with 'p2p2'
+			 * 'join' and 'auth', the local device is expected to
+			 * allow a peer device to join an exiting group. Thus,
+			 * having 'persistent_id' set is not allowed.
+			 */
+			if (ssid) {
+				wpa_printf(MSG_DEBUG,
+					   "P2P: No persistent group SSID provided for P2P2 join");
+				return -1;
 			}
 
+			/* Iterate over existing interface and try to find an
+			 * interface that is already hosting a P2P GO
+			 */
 			dl_list_for_each(ifs, &wpa_s->radio->ifaces,
 					 struct wpa_supplicant, radio_list) {
 				if (!ifs->current_ssid ||
-				    ifs->current_ssid->mode != WPAS_MODE_P2P_GO)
+				    ifs->current_ssid->mode != WPAS_MODE_P2P_GO ||
+				    ifs->wpa_state != WPA_COMPLETED)
 					continue;
 
 				ssid = ifs->current_ssid;
@@ -7106,6 +7110,18 @@ int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
 				force_freq = ifs->ap_iface->freq;
 				break;
 			}
+
+			if (ssid) {
+				wpa_printf(MSG_DEBUG,
+					   "P2P: Reusing existing GO interface=%s",
+					   ifs->ifname);
+				if_addr = ifs->own_addr;
+			} else {
+				wpa_printf(MSG_DEBUG,
+					   "P2P: No existing GO interface found for P2P2 join");
+				return -1;
+			}
+
 			p2p_set_go_role(wpa_s->global->p2p, true);
 			return wpas_p2p_auth_go_neg(wpa_s, peer_addr,
 						    wps_method, 15, if_addr,
-- 
2.49.0




More information about the Hostap mailing list