]> git.proxmox.com Git - mirror_ovs.git/blob - datapath/linux/compat/include/linux/rtnetlink.h
datapath: Rename linux-2.6 and compat-2.6 directories.
[mirror_ovs.git] / datapath / linux / compat / include / linux / rtnetlink.h
1 #ifndef __RTNETLINK_WRAPPER_H
2 #define __RTNETLINK_WRAPPER_H 1
3
4 #include_next <linux/rtnetlink.h>
5
6 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
7
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)
11 {
12 BUG_ON(nlh != NULL); /* not implemented */
13 if (group) {
14 /* errors reported via destination sk->sk_err */
15 nlmsg_multicast(rtnl, skb, 0, group, flags);
16 }
17 }
18
19 static inline void rtnl_set_sk_err(u32 group, int error)
20 {
21 netlink_set_err(rtnl, 0, group, error);
22 }
23 #endif
24
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))
34 #endif
35
36 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
37 static inline int rtnl_is_locked(void)
38 {
39 if (unlikely(rtnl_trylock())) {
40 rtnl_unlock();
41 return 0;
42 }
43
44 return 1;
45 }
46
47 #endif
48
49 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)
50 #ifdef CONFIG_PROVE_LOCKING
51 static inline int lockdep_rtnl_is_held(void)
52 {
53 return 1;
54 }
55 #endif
56 #endif
57
58 #ifndef rcu_dereference_rtnl
59 /**
60 * rcu_dereference_rtnl - rcu_dereference with debug checking
61 * @p: The pointer to read, prior to dereferencing
62 *
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()
65 */
66 #define rcu_dereference_rtnl(p) \
67 rcu_dereference_check(p, rcu_read_lock_held() || \
68 lockdep_rtnl_is_held())
69 #endif
70
71 #ifndef rtnl_dereference
72 /**
73 * rtnl_dereference - fetch RCU pointer when updates are prevented by RTNL
74 * @p: The pointer to read, prior to dereferencing
75 *
76 * Return the value of the specified RCU-protected pointer, but omit
77 * both the smp_read_barrier_depends() and the ACCESS_ONCE(), because
78 * caller holds RTNL.
79 */
80 #define rtnl_dereference(p) \
81 rcu_dereference_protected(p, lockdep_rtnl_is_held())
82 #endif
83
84 #endif /* linux/rtnetlink.h wrapper */