[PATCH 2/5] wpa_supplicant: Stop NAN when interface is removed or disabled

Andrei Otcheretianski andrei.otcheretianski at intel.com
Tue May 12 23:59:03 PDT 2026


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

- Stop and de-initialize NAN functionality when the associated
  interface is removed or disabled.
- Add a control interface notification indicating that NAN
  functionality has stopped.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 src/common/wpa_ctrl.h           | 1 +
 wpa_supplicant/nan_supplicant.c | 1 +
 wpa_supplicant/notify.c         | 7 +++++++
 wpa_supplicant/notify.h         | 1 +
 wpa_supplicant/wpa_supplicant.c | 9 +++++++++
 5 files changed, 19 insertions(+)

diff --git a/src/common/wpa_ctrl.h b/src/common/wpa_ctrl.h
index 1472553d9c..90597aa7aa 100644
--- a/src/common/wpa_ctrl.h
+++ b/src/common/wpa_ctrl.h
@@ -270,6 +270,7 @@ extern "C" {
  * parameters: map_id=<map_id> freq=<freq>
  */
 #define NAN_CHAN_EVACUATION "NAN-CHAN-EVACUATION "
+#define NAN_STOPPED "NAN-STOPPED "
 
 /* MESH events */
 #define MESH_GROUP_STARTED "MESH-GROUP-STARTED "
diff --git a/wpa_supplicant/nan_supplicant.c b/wpa_supplicant/nan_supplicant.c
index 9ffd0ff946..bc9baa4b7f 100644
--- a/wpa_supplicant/nan_supplicant.c
+++ b/wpa_supplicant/nan_supplicant.c
@@ -195,6 +195,7 @@ static void wpas_nan_stop_cb(void *ctx)
 
 	wpa_drv_nan_stop(wpa_s);
 	nan_de_set_cluster_id(wpa_s->nan_de, NULL);
+	wpas_notify_nan_stopped(wpa_s);
 }
 
 
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index 171508d12f..b816b71597 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -1531,6 +1531,13 @@ void wpas_notify_nan_chan_evacuation(struct wpa_supplicant *wpa_s,
 		       map_id, freq);
 }
 
+
+void wpas_notify_nan_stopped(struct wpa_supplicant *wpa_s)
+{
+	wpa_msg_global(wpa_s, MSG_INFO, NAN_STOPPED "ifname=%s",
+		       wpa_s->ifname);
+}
+
 #endif /* CONFIG_NAN || CONFIG_NAN_USD */
 
 
diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
index f8ce563cd7..fafa7d80e4 100644
--- a/wpa_supplicant/notify.h
+++ b/wpa_supplicant/notify.h
@@ -259,5 +259,6 @@ void wpas_notify_nan_pairing_status(struct wpa_supplicant *wpa_s,
 				    u16 status, const u8 *nd_pmk);
 void wpas_notify_nan_chan_evacuation(struct wpa_supplicant *wpa_s,
 				     u8 map_id, int freq);
+void wpas_notify_nan_stopped(struct wpa_supplicant *wpa_s);
 
 #endif /* NOTIFY_H */
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 5414eab0fb..3c50ba368a 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -1167,6 +1167,15 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
 	if (state == WPA_INTERFACE_DISABLED) {
 		/* Assure normal scan when interface is restored */
 		wpa_s->normal_scans = 0;
+
+		/*
+		 * A NAN management interface is not expected to be disabled. If
+		 * it disabled, it means that NAN functionality is no longer
+		 * possible so deinit (which would also stop any ongoing NAN
+		 * operations)
+		 */
+		if (wpa_s->nan_mgmt)
+			wpas_nan_deinit(wpa_s);
 	}
 
 	if (state == WPA_COMPLETED) {
-- 
2.53.0




More information about the Hostap mailing list