[PATCH 2/3] P2P: add/remove dedicated P2P Device when p2p_disabled is toggled

Benjamin Berg benjamin at sipsolutions.net
Wed Oct 15 08:44:00 PDT 2025


From: Benjamin Berg <benjamin.berg at intel.com>

Having a dedicated P2P Device interface can interfere with the operation
of other interface types (in particular NAN). As such, it is useful to
be able to toggle at runtime whether the dedicated P2P Device interface
exists.

Add the logic to add or remove the dependent dedicated P2P Device
interface when the p2p_disabled option is toggled on its parent
interface.

Signed-off-by: Benjamin Berg <benjamin.berg at intel.com>
Reviewed-by: Ilan Peer <ilan.peer at intel.com>
Reviewed-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
 wpa_supplicant/config.c         |  2 +-
 wpa_supplicant/config.h         |  1 +
 wpa_supplicant/wpa_supplicant.c | 43 +++++++++++++++++++++++++++++++++
 3 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index 4aa54c24f1..91077b45d9 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -5664,7 +5664,7 @@ static const struct global_parse_data global_fields[] = {
 	{ INT(p2p_go_vht), 0 },
 	{ INT(p2p_go_he), 0 },
 	{ INT(p2p_go_edmg), 0 },
-	{ INT(p2p_disabled), 0 },
+	{ INT(p2p_disabled), CFG_CHANGED_P2P_DISABLED },
 	{ INT_RANGE(p2p_go_ctwindow, 0, 127), 0 },
 	{ INT(p2p_no_group_iface), 0 },
 	{ INT_RANGE(p2p_ignore_shared_freq, 0, 1), 0 },
diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
index 3feef1fcb2..845264f413 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -481,6 +481,7 @@ struct wpa_dev_ik {
 #define CFG_CHANGED_DISABLE_BTM BIT(19)
 #define CFG_CHANGED_BGSCAN BIT(20)
 #define CFG_CHANGED_FT_PREPEND_PMKID BIT(21)
+#define CFG_CHANGED_P2P_DISABLED BIT(22)
 
 /**
  * struct wpa_config - wpa_supplicant configuration data
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index c9257bc853..ed36b52fcd 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -8773,6 +8773,49 @@ void wpa_supplicant_update_config(struct wpa_supplicant *wpa_s)
 		wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_FT_PREPEND_PMKID,
 				 wpa_s->conf->ft_prepend_pmkid);
 
+#ifdef CONFIG_P2P
+	if (wpa_s->conf->changed_parameters & CFG_CHANGED_P2P_DISABLED) {
+		if (wpa_s->conf->p2p_disabled) {
+			if (!(wpa_s->drv_flags &
+			      WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE) ||
+			    wpa_s->p2p_mgmt) {
+				wpa_printf(MSG_INFO,
+					   "P2P: Disable only implemented on parent interface");
+			} else {
+				if (wpa_s->global->p2p_init_wpa_s &&
+				    wpa_s->global->p2p &&
+				    wpa_s->global->p2p_init_wpa_s->parent == wpa_s) {
+					wpa_supplicant_remove_iface(
+						wpa_s->global,
+						wpa_s->global->p2p_init_wpa_s,
+						0);
+				} else {
+					wpa_printf(MSG_INFO,
+						   "P2P: Not global P2P owner");
+				}
+			}
+		} else {
+			if (!(wpa_s->drv_flags &
+			      WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE) ||
+			    wpa_s->p2p_mgmt) {
+				wpa_printf(MSG_INFO,
+					   "P2P: Enabling only implemented on parent interface");
+			} else if (!wpa_s->global->p2p &&
+				   !wpa_s->global->p2p_disabled) {
+				if (wpas_p2p_add_p2pdev_interface(
+					wpa_s,
+					wpa_s->global->params.conf_p2p_dev) < 0) {
+					wpa_printf(MSG_INFO,
+						  "P2P: Failed to enable P2P Device interface");
+				}
+			} else {
+				wpa_printf(MSG_INFO,
+					   "P2P: Not enabling, global P2P configured or globally disabled");
+			}
+		}
+	}
+#endif
+
 #ifdef CONFIG_BGSCAN
 	/*
 	 * We default to global bgscan parameters only when per-network bgscan
-- 
2.51.0




More information about the Hostap mailing list