d03be756428edd5ad6977929e88d558c3f979b9c
[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
17 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
18 static inline int rpl_iptunnel_xmit(struct sock *sk, struct rtable *rt,
19                                     struct sk_buff *skb, __be32 src,
20                                     __be32 dst, __u8 proto, __u8 tos,
21                                     __u8 ttl, __be16 df, bool xnet)
22 {
23 #ifdef HAVE_IPTUNNEL_XMIT_NET
24         return iptunnel_xmit(NULL, rt, skb, src, dst, proto, tos, ttl, df);
25 #else
26         return iptunnel_xmit(rt, skb, src, dst, proto, tos, ttl, df, xnet);
27 #endif
28 }
29 #define iptunnel_xmit rpl_iptunnel_xmit
30 #endif
31
32 #else
33
34 #include <linux/if_tunnel.h>
35 #include <linux/netdevice.h>
36 #include <linux/skbuff.h>
37 #include <linux/types.h>
38 #include <net/dsfield.h>
39 #include <net/flow.h>
40 #include <net/inet_ecn.h>
41 #include <net/ip.h>
42 #include <net/rtnetlink.h>
43
44 #define TUNNEL_CSUM     __cpu_to_be16(0x01)
45 #define TUNNEL_ROUTING  __cpu_to_be16(0x02)
46 #define TUNNEL_KEY      __cpu_to_be16(0x04)
47 #define TUNNEL_SEQ      __cpu_to_be16(0x08)
48 #define TUNNEL_STRICT   __cpu_to_be16(0x10)
49 #define TUNNEL_REC      __cpu_to_be16(0x20)
50 #define TUNNEL_VERSION  __cpu_to_be16(0x40)
51 #define TUNNEL_NO_KEY   __cpu_to_be16(0x80)
52 #define TUNNEL_DONT_FRAGMENT    __cpu_to_be16(0x0100)
53
54 struct tnl_ptk_info {
55         __be16 flags;
56         __be16 proto;
57         __be32 key;
58         __be32 seq;
59 };
60
61 #define PACKET_RCVD     0
62 #define PACKET_REJECT   1
63
64 int iptunnel_xmit(struct sock *sk, struct rtable *rt,
65                   struct sk_buff *skb,
66                   __be32 src, __be32 dst, __u8 proto,
67                   __u8 tos, __u8 ttl, __be16 df, bool xnet);
68
69 int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto);
70
71 #endif
72
73 /* Not yet upstream */
74 #define TUNNEL_OAM      __cpu_to_be16(0x0200)
75 #define TUNNEL_CRIT_OPT __cpu_to_be16(0x0400)
76 #define TUNNEL_OPTIONS_PRESENT  __cpu_to_be16(0x0800)
77
78 #endif /* __NET_IP_TUNNELS_H */