compat: Backport IPv4 reassembly.
[cascardo/ovs.git] / datapath / compat.h
1 /*
2  * Copyright (c) 2007-2015 Nicira, Inc.
3  *
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.
7  *
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.
12  *
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
16  * 02110-1301, USA
17  */
18
19 #ifndef COMPAT_H
20 #define COMPAT_H 1
21
22 #include <linux/in.h>
23 #include <linux/in_route.h>
24 #include <linux/netlink.h>
25 #include <net/ip.h>
26 #include <net/route.h>
27 #include <net/xfrm.h>
28
29 #ifdef HAVE_GENL_MULTICAST_GROUP_WITH_ID
30 #define GROUP_ID(grp)   ((grp)->id)
31 #else
32 #define GROUP_ID(grp)   0
33 #endif
34
35 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
36 #define rt_dst(rt) (rt->dst)
37 #else
38 #define rt_dst(rt) (rt->u.dst)
39 #endif
40
41 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
42 #define inet_sport(sk)  (inet_sk(sk)->sport)
43 #else
44 #define inet_sport(sk)  (inet_sk(sk)->inet_sport)
45 #endif
46
47 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
48 static inline bool skb_encapsulation(struct sk_buff *skb)
49 {
50         return skb->encapsulation;
51 }
52 #else
53 #define skb_encapsulation(skb) false
54 #endif
55
56 #ifdef OVS_FRAGMENT_BACKPORT
57 static inline int __init compat_init(void)
58 {
59         return ipfrag_init();
60 }
61 static inline void compat_exit(void)
62 {
63         rpl_ipfrag_fini();
64 }
65 #else
66 static inline int __init compat_init(void) { return 0; }
67 static inline void compat_exit(void) { }
68 #endif
69
70 #endif /* compat.h */