diff options
author | Kuniyuki Iwashima <kuniyu@amazon.com> | 2024-10-21 11:32:36 -0700 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2024-10-29 11:54:57 +0100 |
commit | d1c81818aa227b37d65b40f9883109c5256b9bfb (patch) | |
tree | bddaf06e3b31d5ef3e6147037816559696547fa4 /net/core/rtnetlink.c | |
parent | c350c4761e7f4767dea59aef036ce13276466fd0 (diff) |
rtnetlink: Define rtnl_net_trylock().
We will need the per-netns version of rtnl_trylock().
rtnl_net_trylock() calls __rtnl_net_lock() only when rtnl_trylock()
successfully holds RTNL.
When RTNL is removed, we will use mutex_trylock() for per-netns RTNL.
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net/core/rtnetlink.c')
-rw-r--r-- | net/core/rtnetlink.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 194a81e5f608..dda8230fdfd4 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -210,6 +210,17 @@ void rtnl_net_unlock(struct net *net) } EXPORT_SYMBOL(rtnl_net_unlock); +int rtnl_net_trylock(struct net *net) +{ + int ret = rtnl_trylock(); + + if (ret) + __rtnl_net_lock(net); + + return ret; +} +EXPORT_SYMBOL(rtnl_net_trylock); + static int rtnl_net_cmp_locks(const struct net *net_a, const struct net *net_b) { if (net_eq(net_a, net_b)) |