[PATCH 4/5] nl80211: Handle removal of a NAN management interface

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


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

While a netdev interface removal is handled by the
nl80211 driver, removal of a NAN Device interface is not.

To handle NAN Device interface removal, register for
receiving nl80211 configuration events, and when a
NAN device interface is removed, propagate this event
to the wpa_supplicant, so it could properly cleanup
its state.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 src/drivers/driver_nl80211.c       | 10 ++++++++++
 src/drivers/driver_nl80211_event.c | 26 ++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index ea89bcd8cc..2c2ea72abc 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -2199,6 +2199,16 @@ static int wpa_driver_nl80211_init_nl_global(struct nl80211_global *global)
 	nl_cb_set(global->nl_cb, NL_CB_VALID, NL_CB_CUSTOM,
 		  process_global_event, global);
 
+	ret = nl_get_multicast_id(global, "nl80211", "config");
+	if (ret >= 0)
+		ret = nl_socket_add_membership(global->nl_event, ret);
+	if (ret < 0) {
+		wpa_printf(MSG_ERROR, "nl80211: Could not add multicast "
+			   "membership for config events: %d (%s)",
+			   ret, nl_geterror(ret));
+		goto err;
+	}
+
 	ret = nl_get_multicast_id(global, "nl80211", "scan");
 	if (ret >= 0)
 		ret = nl_socket_add_membership(global->nl_event, ret);
diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c
index a281f59536..87f90aa6ce 100644
--- a/src/drivers/driver_nl80211_event.c
+++ b/src/drivers/driver_nl80211_event.c
@@ -4406,6 +4406,28 @@ nl80211_nan_channel_evacuate_event(struct wpa_driver_nl80211_data *drv,
 	wpa_supplicant_event(drv->ctx, EVENT_NAN_CHAN_EVACUATION, &data);
 }
 
+
+static void
+nl80211_nan_del_interface_event(struct i802_bss *bss, struct nlattr **tb)
+{
+	union wpa_event_data event;
+
+	os_memset(&event, 0, sizeof(event));
+
+	wpa_printf(MSG_DEBUG, "nl80211: NAN interface removed event for %s",
+		   bss->ifname);
+
+	os_strlcpy(event.interface_status.ifname, bss->ifname,
+		   sizeof(event.interface_status.ifname));
+
+	event.interface_status.ievent = EVENT_INTERFACE_REMOVED;
+
+	bss->drv->nan_started = false;
+
+	wpa_supplicant_event(bss->ctx, EVENT_INTERFACE_STATUS, &event);
+}
+
+
 #endif /* CONFIG_NAN */
 
 
@@ -4786,6 +4808,10 @@ static void do_process_drv_event(struct i802_bss *bss, int cmd,
 	case NL80211_CMD_NAN_CHANNEL_EVAC:
 		nl80211_nan_channel_evacuate_event(drv, tb);
 		break;
+	case NL80211_CMD_DEL_INTERFACE:
+		if (drv->nlmode == NL80211_IFTYPE_NAN)
+			nl80211_nan_del_interface_event(bss, tb);
+		break;
 #endif /* CONFIG_NAN */
 	case NL80211_CMD_INCUMBENT_SIGNAL_DETECT:
 		nl80211_incumbt_sig_intf_event(bss, tb);
-- 
2.53.0




More information about the Hostap mailing list