summaryrefslogtreecommitdiff
path: root/include/net/netdev_lock.h
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2025-03-24 15:45:30 -0700
committerJakub Kicinski <kuba@kernel.org>2025-03-25 10:06:44 -0700
commit4b702f8b72c7b05daa1b763fdc0840aa78178c3a (patch)
tree51dec262188c65f5bcd29af24fbeb30f41a5b15d /include/net/netdev_lock.h
parente2f81e8f4d0c3109e1a18620c931fe16bfb235ef (diff)
net: explain "protection types" for the instance lock
Try to define some terminology for which fields are protected by which lock and how. Some fields are protected by both rtnl_lock and instance lock which is hard to talk about without having a "key phrase" to refer to a particular protection scheme. "ops protected" fields are defined later in the series, one by one. Add ASSERT_RTNL() to netdev_ops_assert_locked() for drivers not other instance protection of ops. Hopefully it's not too confusion that netdev_lock_ops() does not match the lock which netdev_ops_assert_locked() will assert, exactly. The noun "ops" is in a different place in the name, so I think it's acceptable... Acked-by: Stanislav Fomichev <sdf@fomichev.me> Link: https://patch.msgid.link/20250324224537.248800-5-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/net/netdev_lock.h')
-rw-r--r--include/net/netdev_lock.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/net/netdev_lock.h b/include/net/netdev_lock.h
index 689ffdfae50d..efd302375ef2 100644
--- a/include/net/netdev_lock.h
+++ b/include/net/netdev_lock.h
@@ -5,6 +5,7 @@
#include <linux/lockdep.h>
#include <linux/netdevice.h>
+#include <linux/rtnetlink.h>
static inline bool netdev_trylock(struct net_device *dev)
{
@@ -51,6 +52,8 @@ static inline void netdev_ops_assert_locked(const struct net_device *dev)
{
if (netdev_need_ops_lock(dev))
lockdep_assert_held(&dev->lock);
+ else
+ ASSERT_RTNL();
}
static inline int netdev_lock_cmp_fn(const struct lockdep_map *a,