2 * Copyright (c) 2007-2012 Nicira, Inc.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of version 2 of the GNU General Public
6 * License as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 #include <linux/netlink.h>
24 #ifndef HAVE_NLA_NUL_STRING
25 static inline int CHECK_NUL_STRING(struct nlattr *attr, int maxlen)
37 if (s[len - 1] != '\0')
43 static inline int CHECK_NUL_STRING(struct nlattr *attr, int maxlen)
47 #endif /* !HAVE_NLA_NUL_STRING */
49 static inline void skb_clear_rxhash(struct sk_buff *skb)
51 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
56 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
57 #define GENL_SOCK(net) (genl_sock)
60 #define GENL_SOCK(net) ((net)->genl_sock)
61 #define SET_NETNSOK .netnsok = true,
64 #ifdef HAVE_PARALLEL_OPS
65 #define SET_PARALLEL_OPS .parallel_ops = true,
67 #define SET_PARALLEL_OPS
71 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
72 #ifdef CONFIG_NETFILTER
73 static inline u32 skb_get_mark(struct sk_buff *skb)
78 static inline void skb_set_mark(struct sk_buff *skb, u32 mark)
82 #else /* CONFIG_NETFILTER */
83 static inline u32 skb_get_mark(struct sk_buff *skb)
88 static inline void skb_set_mark(struct sk_buff *skb, u32 mark)
92 #else /* before 2.6.20 */
93 static inline u32 skb_get_mark(struct sk_buff *skb)
98 static inline void skb_set_mark(struct sk_buff *skb, u32 mark)
102 #endif /* after 2.6.20 */
104 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
105 #define rt_dst(rt) (rt->dst)
107 #define rt_dst(rt) (rt->u.dst)
110 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
111 #define inet_sport(sk) (inet_sk(sk)->sport)
113 #define inet_sport(sk) (inet_sk(sk)->inet_sport)
116 #endif /* compat.h */