Skip to content

Commit 7bd72a4

Browse files
q2venPaolo Abeni
authored andcommitted
rtnetlink: Add rtnl_net_lock_killable().
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 <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 2f4f889 commit 7bd72a4

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

include/linux/rtnetlink.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ void __rtnl_net_unlock(struct net *net);
102102
void rtnl_net_lock(struct net *net);
103103
void rtnl_net_unlock(struct net *net);
104104
int rtnl_net_trylock(struct net *net);
105+
int rtnl_net_lock_killable(struct net *net);
105106
int rtnl_net_lock_cmp_fn(const struct lockdep_map *a, const struct lockdep_map *b);
106107

107108
bool rtnl_net_is_locked(struct net *net);
@@ -138,6 +139,11 @@ static inline int rtnl_net_trylock(struct net *net)
138139
return rtnl_trylock();
139140
}
140141

142+
static inline int rtnl_net_lock_killable(struct net *net)
143+
{
144+
return rtnl_lock_killable();
145+
}
146+
141147
static inline void ASSERT_RTNL_NET(struct net *net)
142148
{
143149
ASSERT_RTNL();

net/core/rtnetlink.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ int rtnl_lock_killable(void)
8484
{
8585
return mutex_lock_killable(&rtnl_mutex);
8686
}
87-
EXPORT_SYMBOL(rtnl_lock_killable);
8887

8988
static struct sk_buff *defer_kfree_skb_list;
9089
void rtnl_kfree_skbs(struct sk_buff *head, struct sk_buff *tail)
@@ -221,6 +220,16 @@ int rtnl_net_trylock(struct net *net)
221220
}
222221
EXPORT_SYMBOL(rtnl_net_trylock);
223222

223+
int rtnl_net_lock_killable(struct net *net)
224+
{
225+
int ret = rtnl_lock_killable();
226+
227+
if (!ret)
228+
__rtnl_net_lock(net);
229+
230+
return ret;
231+
}
232+
224233
static int rtnl_net_cmp_locks(const struct net *net_a, const struct net *net_b)
225234
{
226235
if (net_eq(net_a, net_b))

0 commit comments

Comments
 (0)