summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2026-05-21 17:40:38 +0000
committerJakub Kicinski <kuba@kernel.org>2026-05-22 17:32:56 -0700
commitb8de39a06535bfccf9f693e42dc8cfbee35d07be (patch)
tree786c2d9e9f331ee9db097e53c89919b008275520
parent24822968aa928ab087fc612ec1c6d2751ec91a4a (diff)
rtnetlink: do not use RTNL in rtnl_af_register() and rtnl_af_unregister()
rtnl_af_lookup() does not rely on RTNL anymoe, remove the stale ASSERT_RTNL(). Add a private spinlock (rtnl_af_ops_lock) to protect rtnl_af_ops list instead of using RTNL. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260521174038.204481-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--net/core/rtnetlink.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 3d40ebe035b3..5e461c752df1 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -750,13 +750,12 @@ static size_t rtnl_link_get_size(const struct net_device *dev)
}
static LIST_HEAD(rtnl_af_ops);
+static DEFINE_SPINLOCK(rtnl_af_ops_lock);
static struct rtnl_af_ops *rtnl_af_lookup(const int family, int *srcu_index)
{
struct rtnl_af_ops *ops;
- ASSERT_RTNL();
-
rcu_read_lock();
list_for_each_entry_rcu(ops, &rtnl_af_ops, list) {
@@ -791,9 +790,9 @@ int rtnl_af_register(struct rtnl_af_ops *ops)
if (err)
return err;
- rtnl_lock();
+ spin_lock(&rtnl_af_ops_lock);
list_add_tail_rcu(&ops->list, &rtnl_af_ops);
- rtnl_unlock();
+ spin_unlock(&rtnl_af_ops_lock);
return 0;
}
@@ -805,9 +804,9 @@ EXPORT_SYMBOL_GPL(rtnl_af_register);
*/
void rtnl_af_unregister(struct rtnl_af_ops *ops)
{
- rtnl_lock();
+ spin_lock(&rtnl_af_ops_lock);
list_del_rcu(&ops->list);
- rtnl_unlock();
+ spin_unlock(&rtnl_af_ops_lock);
synchronize_rcu();
synchronize_srcu(&ops->srcu);