1 #ifndef __RTNETLINK_WRAPPER_H
2 #define __RTNETLINK_WRAPPER_H 1
4 #include_next <linux/rtnetlink.h>
6 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
8 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
9 static inline void rtnl_notify(struct sk_buff *skb, u32 pid, u32 group,
10 struct nlmsghdr *nlh, gfp_t flags)
12 BUG_ON(nlh != NULL); /* not implemented */
14 /* errors reported via destination sk->sk_err */
15 nlmsg_multicast(rtnl, skb, 0, group, flags);
19 static inline void rtnl_set_sk_err(u32 group, int error)
21 netlink_set_err(rtnl, 0, group, error);
25 /* No 'net' parameter in these versions. */
26 #define rtnl_notify(skb, net, pid, group, nlh, flags) \
27 ((void) rtnl_notify(skb, pid, group, nlh, flags))
28 #define rtnl_set_sk_err(net, group, error) \
29 (rtnl_set_sk_err(group, error))
30 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
31 /* Make the return type effectively 'void' to match Linux 2.6.30+. */
32 #define rtnl_notify(skb, net, pid, group, nlh, flags) \
33 ((void) rtnl_notify(skb, net, pid, group, nlh, flags))
36 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
37 static inline int rtnl_is_locked(void)
39 if (unlikely(rtnl_trylock())) {
49 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)
50 #ifdef CONFIG_PROVE_LOCKING
51 static inline int lockdep_rtnl_is_held(void)
58 #ifndef rcu_dereference_rtnl
60 * rcu_dereference_rtnl - rcu_dereference with debug checking
61 * @p: The pointer to read, prior to dereferencing
63 * Do an rcu_dereference(p), but check caller either holds rcu_read_lock()
64 * or RTNL. Note : Please prefer rtnl_dereference() or rcu_dereference()
66 #define rcu_dereference_rtnl(p) \
67 rcu_dereference_check(p, rcu_read_lock_held() || \
68 lockdep_rtnl_is_held())
71 #ifndef rtnl_dereference
73 * rtnl_dereference - fetch RCU pointer when updates are prevented by RTNL
74 * @p: The pointer to read, prior to dereferencing
76 * Return the value of the specified RCU-protected pointer, but omit
77 * both the smp_read_barrier_depends() and the ACCESS_ONCE(), because
80 #define rtnl_dereference(p) \
81 rcu_dereference_protected(p, lockdep_rtnl_is_held())
84 #endif /* linux/rtnetlink.h wrapper */