Commit 464eb03c authored by Johannes Berg's avatar Johannes Berg Committed by David S. Miller

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: default avatarJohannes Berg <johannes.berg@intel.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 84c41dca
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/refcount.h> #include <linux/refcount.h>
#include <linux/cleanup.h>
#include <uapi/linux/rtnetlink.h> #include <uapi/linux/rtnetlink.h>
extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo); 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); ...@@ -46,6 +47,8 @@ extern int rtnl_is_locked(void);
extern int rtnl_lock_killable(void); extern int rtnl_lock_killable(void);
extern bool refcount_dec_and_rtnl_lock(refcount_t *r); extern bool refcount_dec_and_rtnl_lock(refcount_t *r);
DEFINE_LOCK_GUARD_0(rtnl, rtnl_lock(), rtnl_unlock())
extern wait_queue_head_t netdev_unregistering_wq; extern wait_queue_head_t netdev_unregistering_wq;
extern atomic_t dev_unreg_count; extern atomic_t dev_unreg_count;
extern struct rw_semaphore pernet_ops_rwsem; extern struct rw_semaphore pernet_ops_rwsem;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment