datapath: supply a dummy err_handler of gre_cisco_protocol to prevent kernel crash
[cascardo/ovs.git] / datapath / linux / compat / include / net / gre.h
1 #ifndef __LINUX_GRE_WRAPPER_H
2 #define __LINUX_GRE_WRAPPER_H
3
4 #include <linux/skbuff.h>
5 #include <net/ip_tunnels.h>
6
7 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) || \
8    defined(HAVE_GRE_CISCO_REGISTER)
9 #include_next <net/gre.h>
10 #endif
11
12 #ifndef HAVE_GRE_CISCO_REGISTER
13
14 /* GRE demux not available, implement our own demux. */
15 #define MAX_GRE_PROTO_PRIORITY 255
16
17 struct gre_cisco_protocol {
18         int (*handler)(struct sk_buff *skb, const struct tnl_ptk_info *tpi);
19         int (*err_handler)(struct sk_buff *skb, u32 info,
20                            const struct tnl_ptk_info *tpi);
21         u8 priority;
22 };
23
24 #define gre_cisco_register rpl_gre_cisco_register
25 int gre_cisco_register(struct gre_cisco_protocol *proto);
26
27 #define gre_cisco_unregister rpl_gre_cisco_unregister
28 int gre_cisco_unregister(struct gre_cisco_protocol *proto);
29
30 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
31 struct gre_base_hdr {
32         __be16 flags;
33         __be16 protocol;
34 };
35 #define GRE_HEADER_SECTION 4
36
37 static inline __be16 gre_flags_to_tnl_flags(__be16 flags)
38 {
39         __be16 tflags = 0;
40
41         if (flags & GRE_CSUM)
42                 tflags |= TUNNEL_CSUM;
43         if (flags & GRE_ROUTING)
44                 tflags |= TUNNEL_ROUTING;
45         if (flags & GRE_KEY)
46                 tflags |= TUNNEL_KEY;
47         if (flags & GRE_SEQ)
48                 tflags |= TUNNEL_SEQ;
49         if (flags & GRE_STRICT)
50                 tflags |= TUNNEL_STRICT;
51         if (flags & GRE_REC)
52                 tflags |= TUNNEL_REC;
53         if (flags & GRE_VERSION)
54                 tflags |= TUNNEL_VERSION;
55
56         return tflags;
57 }
58
59 static inline __be16 tnl_flags_to_gre_flags(__be16 tflags)
60 {
61         __be16 flags = 0;
62
63         if (tflags & TUNNEL_CSUM)
64                 flags |= GRE_CSUM;
65         if (tflags & TUNNEL_ROUTING)
66                 flags |= GRE_ROUTING;
67         if (tflags & TUNNEL_KEY)
68                 flags |= GRE_KEY;
69         if (tflags & TUNNEL_SEQ)
70                 flags |= GRE_SEQ;
71         if (tflags & TUNNEL_STRICT)
72                 flags |= GRE_STRICT;
73         if (tflags & TUNNEL_REC)
74                 flags |= GRE_REC;
75         if (tflags & TUNNEL_VERSION)
76                 flags |= GRE_VERSION;
77
78         return flags;
79 }
80 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) */
81 #endif /* HAVE_GRE_CISCO_REGISTER */
82
83 #define gre_build_header rpl_gre_build_header
84 void gre_build_header(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
85                       int hdr_len);
86
87 #define gre_handle_offloads rpl_gre_handle_offloads
88 struct sk_buff *gre_handle_offloads(struct sk_buff *skb, bool gre_csum);
89
90 #define ip_gre_calc_hlen rpl_ip_gre_calc_hlen
91 static inline int ip_gre_calc_hlen(__be16 o_flags)
92 {
93         int addend = 4;
94
95         if (o_flags & TUNNEL_CSUM)
96                 addend += 4;
97         if (o_flags & TUNNEL_KEY)
98                 addend += 4;
99         if (o_flags & TUNNEL_SEQ)
100                 addend += 4;
101         return addend;
102 }
103
104 #endif