]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
rtnetlink: Add rtnl_net_lock_killable().
authorKuniyuki Iwashima <kuniyu@amazon.com>
Sat, 4 Jan 2025 08:21:48 +0000 (17:21 +0900)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 7 Jan 2025 12:45:53 +0000 (13:45 +0100)
rtnl_lock_killable() is used only in register_netdev()
and will be converted to per-netns RTNL.

Let's unexport it and add the corresponding helper.

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
include/linux/rtnetlink.h
net/core/rtnetlink.c

index 3b9d132cbc9ef38007c48b01d0d9fc50c72cd254..4bc2ee0b10b053bf255c85bb0adc6f5a1502a040 100644 (file)
@@ -102,6 +102,7 @@ void __rtnl_net_unlock(struct net *net);
 void rtnl_net_lock(struct net *net);
 void rtnl_net_unlock(struct net *net);
 int rtnl_net_trylock(struct net *net);
+int rtnl_net_lock_killable(struct net *net);
 int rtnl_net_lock_cmp_fn(const struct lockdep_map *a, const struct lockdep_map *b);
 
 bool rtnl_net_is_locked(struct net *net);
@@ -138,6 +139,11 @@ static inline int rtnl_net_trylock(struct net *net)
        return rtnl_trylock();
 }
 
+static inline int rtnl_net_lock_killable(struct net *net)
+{
+       return rtnl_lock_killable();
+}
+
 static inline void ASSERT_RTNL_NET(struct net *net)
 {
        ASSERT_RTNL();
index 6b745096809dca0534d016c7644cd88a6807599a..1f4d4b5570ab896593a6b3216678b90c7b0696de 100644 (file)
@@ -84,7 +84,6 @@ int rtnl_lock_killable(void)
 {
        return mutex_lock_killable(&rtnl_mutex);
 }
-EXPORT_SYMBOL(rtnl_lock_killable);
 
 static struct sk_buff *defer_kfree_skb_list;
 void rtnl_kfree_skbs(struct sk_buff *head, struct sk_buff *tail)
@@ -221,6 +220,16 @@ int rtnl_net_trylock(struct net *net)
 }
 EXPORT_SYMBOL(rtnl_net_trylock);
 
+int rtnl_net_lock_killable(struct net *net)
+{
+       int ret = rtnl_lock_killable();
+
+       if (!ret)
+               __rtnl_net_lock(net);
+
+       return ret;
+}
+
 static int rtnl_net_cmp_locks(const struct net *net_a, const struct net *net_b)
 {
        if (net_eq(net_a, net_b))