net: introduce rcu_dereference_rtnl
authorEric Dumazet <eric.dumazet@gmail.com>
Wed, 8 Sep 2010 21:15:32 +0000 (14:15 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 8 Sep 2010 21:15:32 +0000 (14:15 -0700)
We use rcu_dereference_check(p, rcu_read_lock_held() ||
lockdep_rtnl_is_held()) several times in network stack.

More usages to come too, so its time to create a helper.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/rtnetlink.h

index 58d44491880fa79ec30d7c863f609547c4ed7439..263690d991a833ce6636c35eaf311efc830af896 100644 (file)
@@ -749,6 +749,17 @@ extern int rtnl_is_locked(void);
 extern int lockdep_rtnl_is_held(void);
 #endif /* #ifdef CONFIG_PROVE_LOCKING */
 
+/**
+ * rcu_dereference_rtnl - rcu_dereference with debug checking
+ * @p: The pointer to read, prior to dereferencing
+ *
+ * Do an rcu_dereference(p), but check caller either holds rcu_read_lock()
+ * or RTNL
+ */
+#define rcu_dereference_rtnl(p)                                        \
+       rcu_dereference_check(p, rcu_read_lock_held() ||        \
+                                lockdep_rtnl_is_held())
+
 extern void rtnetlink_init(void);
 extern void __rtnl_unlock(void);