datapath: Don't read net namespace on kernels that don't use them.
[sliver-openvswitch.git] / datapath / linux-2.6 / compat-2.6 / 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);            /* not implemented */
13         if (group) {
14                 /* errors reported via destination sk->sk_err */
15                 nlmsg_multicast(rtnl, skb, 0, group);
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 #endif /* linux/rtnetlink.h wrapper */