]> git.proxmox.com Git - mirror_ovs.git/blob - datapath/compat.h
compat: Detect and use nf_ipv6_ops->fragment.
[mirror_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 #include <net/netfilter/ipv6/nf_defrag_ipv6.h>
29
30 #ifdef HAVE_GENL_MULTICAST_GROUP_WITH_ID
31 #define GROUP_ID(grp) ((grp)->id)
32 #else
33 #define GROUP_ID(grp) 0
34 #endif
35
36 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
37 #define rt_dst(rt) (rt->dst)
38 #else
39 #define rt_dst(rt) (rt->u.dst)
40 #endif
41
42 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
43 #define inet_sport(sk) (inet_sk(sk)->sport)
44 #else
45 #define inet_sport(sk) (inet_sk(sk)->inet_sport)
46 #endif
47
48 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
49 static inline bool skb_encapsulation(struct sk_buff *skb)
50 {
51 return skb->encapsulation;
52 }
53 #else
54 #define skb_encapsulation(skb) false
55 #endif
56
57 #ifdef OVS_FRAGMENT_BACKPORT
58 #ifdef HAVE_NF_IPV6_OPS_FRAGMENT
59 static inline int __init ip6_output_init(void) { return 0; }
60 static inline void ip6_output_exit(void) { }
61 #else
62 int __init ip6_output_init(void);
63 void ip6_output_exit(void);
64 #endif
65
66 static inline int __init compat_init(void)
67 {
68 int err;
69
70 err = ipfrag_init();
71 if (err)
72 return err;
73
74 err = nf_ct_frag6_init();
75 if (err)
76 goto error_ipfrag_exit;
77
78 err = ip6_output_init();
79 if (err)
80 goto error_frag6_exit;
81
82 return 0;
83
84 error_frag6_exit:
85 nf_ct_frag6_cleanup();
86 error_ipfrag_exit:
87 rpl_ipfrag_fini();
88 return err;
89 }
90 static inline void compat_exit(void)
91 {
92 ip6_output_exit();
93 nf_ct_frag6_cleanup();
94 rpl_ipfrag_fini();
95 }
96 #else
97 static inline int __init compat_init(void) { return 0; }
98 static inline void compat_exit(void) { }
99 #endif
100
101 #endif /* compat.h */