diff mbox series

[RFC,02/13] wifi: mac80211: Fix debugfs handling for virtual monitor

Message ID 20250127162625.20747-3-Alexander@wetzel-home.de
State New
Headers show
Series Convert mac80211 to TXQs only | expand

Commit Message

Alexander Wetzel Jan. 27, 2025, 4:26 p.m. UTC
Create debugfs entry for the virtual monitor interface when it's
created and delete them again when it's deleted again.
Instead of creating them on deletion, when calling
drv_remove_interface().

This fixes debugfs name collisions when deleting and re-creating a
monitor interface with the same name.

Signed-off-by: Alexander Wetzel <Alexander@wetzel-home.de>
---
A user can still create collisions in the debugfs when using names like
e.g. phy0-monitor for another monitor interface. And then trigger the
creation of the virtual monitor interface... But I guess that's ok and
not worth the hassle to fix it.
---
 net/mac80211/iface.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index b0c02942dac3..1a2b682c452c 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1162,6 +1162,7 @@  int ieee80211_add_virtual_monitor(struct ieee80211_local *local)
 		}
 	}
 
+	ieee80211_debugfs_recreate_netdev(sdata, false);
 	set_bit(SDATA_STATE_RUNNING, &sdata->state);
 
 	ret = ieee80211_check_queues(sdata, NL80211_IFTYPE_MONITOR);
@@ -1212,6 +1213,7 @@  void ieee80211_del_virtual_monitor(struct ieee80211_local *local)
 		return;
 	}
 
+	clear_bit(SDATA_STATE_RUNNING, &sdata->state);
 	RCU_INIT_POINTER(local->monitor_sdata, NULL);
 	mutex_unlock(&local->iflist_mtx);
 
@@ -1222,6 +1224,7 @@  void ieee80211_del_virtual_monitor(struct ieee80211_local *local)
 	if (ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF))
 		drv_remove_interface(local, sdata);
 
+	ieee80211_debugfs_remove_netdev(sdata);
 	kfree(sdata);
 }