On Mon, Jan 13, 2025 at 07:51:08PM -0800, Jakub Kicinski wrote:
Add helpers for accessing netdevs under netdev_lock().
There's some careful handling needed to find the device and lock it
safely, without it getting unregistered, and without taking rtnl_lock
(the latter being the whole point of the new locking, after all).
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
net/core/dev.h | 16 +++++++
net/core/dev.c | 110 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 126 insertions(+)
[...]
quoted hunk ↗ jump to hunk
diff --git a/net/core/dev.c b/net/core/dev.c
index fda4e1039bf0..5c1e71afbe1c 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -783,6 +783,49 @@ struct napi_struct *netdev_napi_by_id(struct net *net, unsigned int napi_id)
return napi;
}
[...]
+
+struct net_device *
+netdev_xa_find_lock(struct net *net, struct net_device *dev,
+ unsigned long *index)
Minor nit, the other added helper functions have docs, but (unless I
missed it somewhere) this one doesn't. Maybe worthwhile to add
docs if sending a v2, but probably not worth a re-roll just for
this.