4fc4fb4af1cbb5388a7e3034add41f8c1f0e2693
[cascardo/ovs.git] / datapath / linux / compat / include / net / ip_tunnels.h
1 #ifndef __NET_IP_TUNNELS_WRAPPER_H
2 #define __NET_IP_TUNNELS_WRAPPER_H 1
3
4 #include <linux/version.h>
5 #if defined(HAVE_GRE_HANDLE_OFFLOADS) && \
6      LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) && \
7      defined(HAVE_VXLAN_XMIT_SKB)
8 /* RHEL6 and RHEL7 both has backported tunnel API but RHEL6 has
9  * older version, so avoid using RHEL6 backports.
10  */
11 #define USE_KERNEL_TUNNEL_API
12 #endif
13
14 #ifdef USE_KERNEL_TUNNEL_API
15 #include_next <net/ip_tunnels.h>
16 static inline int rpl_iptunnel_xmit(struct rtable *rt,
17                                     struct sk_buff *skb, __be32 src,
18                                     __be32 dst, __u8 proto, __u8 tos,
19                                     __u8 ttl, __be16 df, bool xnet)
20 {
21 #ifdef HAVE_IPTUNNEL_XMIT_NET
22         return iptunnel_xmit(NULL, rt, skb, src, dst, proto, tos, ttl, df);
23 #else
24         return iptunnel_xmit(rt, skb, src, dst, proto, tos, ttl, df, xnet);
25 #endif
26 }
27 #define iptunnel_xmit rpl_iptunnel_xmit
28
29 #else
30
31 #include <linux/if_tunnel.h>
32 #include <linux/netdevice.h>
33 #include <linux/skbuff.h>
34 #include <linux/types.h>
35 #include <net/dsfield.h>
36 #include <net/flow.h>
37 #include <net/inet_ecn.h>
38 #include <net/ip.h>
39 #include <net/rtnetlink.h>
40
41 #define TUNNEL_CSUM     __cpu_to_be16(0x01)
42 #define TUNNEL_ROUTING  __cpu_to_be16(0x02)
43 #define TUNNEL_KEY      __cpu_to_be16(0x04)
44 #define TUNNEL_SEQ      __cpu_to_be16(0x08)
45 #define TUNNEL_STRICT   __cpu_to_be16(0x10)
46 #define TUNNEL_REC      __cpu_to_be16(0x20)
47 #define TUNNEL_VERSION  __cpu_to_be16(0x40)
48 #define TUNNEL_NO_KEY   __cpu_to_be16(0x80)
49 #define TUNNEL_DONT_FRAGMENT    __cpu_to_be16(0x0100)
50
51 struct tnl_ptk_info {
52         __be16 flags;
53         __be16 proto;
54         __be32 key;
55         __be32 seq;
56 };
57
58 #define PACKET_RCVD     0
59 #define PACKET_REJECT   1
60
61 int iptunnel_xmit(struct rtable *rt,
62                   struct sk_buff *skb,
63                   __be32 src, __be32 dst, __u8 proto,
64                   __u8 tos, __u8 ttl, __be16 df, bool xnet);
65
66 int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto);
67
68 #endif
69 #endif /* __NET_IP_TUNNELS_H */