Skip to content

Commit 464eb03

Browse files
jmberg-inteldavem330
authored andcommitted
rtnetlink: add guard for RTNL
The new guard/scoped_gard can be useful for the RTNL as well, so add a guard definition for it. It gets used like { guard(rtnl)(); // RTNL held until end of block } or scoped_guard(rtnl) { // RTNL held in this block } as with any other guard/scoped_guard. Signed-off-by: Johannes Berg <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 84c41dc commit 464eb03

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

include/linux/rtnetlink.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/netdevice.h>
88
#include <linux/wait.h>
99
#include <linux/refcount.h>
10+
#include <linux/cleanup.h>
1011
#include <uapi/linux/rtnetlink.h>
1112

1213
extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo);
@@ -46,6 +47,8 @@ extern int rtnl_is_locked(void);
4647
extern int rtnl_lock_killable(void);
4748
extern bool refcount_dec_and_rtnl_lock(refcount_t *r);
4849

50+
DEFINE_LOCK_GUARD_0(rtnl, rtnl_lock(), rtnl_unlock())
51+
4952
extern wait_queue_head_t netdev_unregistering_wq;
5053
extern atomic_t dev_unreg_count;
5154
extern struct rw_semaphore pernet_ops_rwsem;

0 commit comments

Comments
 (0)