]> git.proxmox.com Git - ovs.git/blob - datapath/linux/compat/include/net/gre.h
compat: Clean up gre_calc_hlen
[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/version.h>
5 #include <linux/skbuff.h>
6 #include <net/ip_tunnels.h>
7
8 #ifdef USE_UPSTREAM_TUNNEL
9 #include_next <net/gre.h>
10
11 static inline int rpl_ipgre_init(void)
12 {
13 return 0;
14 }
15 static inline void rpl_ipgre_fini(void)
16 {}
17
18 static inline int rpl_ip6gre_init(void)
19 {
20 return 0;
21 }
22
23 static inline void rpl_ip6gre_fini(void)
24 {}
25
26 static inline int rpl_ip6_tunnel_init(void)
27 {
28 return 0;
29 }
30
31 static inline void rpl_ip6_tunnel_cleanup(void)
32 {
33 }
34
35 static inline int rpl_gre_init(void)
36 {
37 return 0;
38 }
39
40 static inline void rpl_gre_exit(void)
41 {
42 }
43
44 #define gre_fb_xmit dev_queue_xmit
45
46 #ifdef CONFIG_INET
47 #ifndef HAVE_NAME_ASSIGN_TYPE
48 static inline struct net_device *rpl_gretap_fb_dev_create(
49 struct net *net, const char *name, u8 name_assign_type) {
50 return gretap_fb_dev_create(net, name);
51 }
52 #define gretap_fb_dev_create rpl_gretap_fb_dev_create
53 #endif
54 #endif
55
56 #else
57 #include_next <net/gre.h>
58
59 #ifndef HAVE_GRE_CALC_HLEN
60 static inline int gre_calc_hlen(__be16 o_flags)
61 {
62 int addend = 4;
63
64 if (o_flags & TUNNEL_CSUM)
65 addend += 4;
66 if (o_flags & TUNNEL_KEY)
67 addend += 4;
68 if (o_flags & TUNNEL_SEQ)
69 addend += 4;
70 return addend;
71 }
72
73 #define ip_gre_calc_hlen gre_calc_hlen
74 #else
75 #ifdef HAVE_IP_GRE_CALC_HLEN
76 #define gre_calc_hlen ip_gre_calc_hlen
77 #endif
78 #endif
79
80 #define tnl_flags_to_gre_flags rpl_tnl_flags_to_gre_flags
81 static inline __be16 rpl_tnl_flags_to_gre_flags(__be16 tflags)
82 {
83 __be16 flags = 0;
84
85 if (tflags & TUNNEL_CSUM)
86 flags |= GRE_CSUM;
87 if (tflags & TUNNEL_ROUTING)
88 flags |= GRE_ROUTING;
89 if (tflags & TUNNEL_KEY)
90 flags |= GRE_KEY;
91 if (tflags & TUNNEL_SEQ)
92 flags |= GRE_SEQ;
93 if (tflags & TUNNEL_STRICT)
94 flags |= GRE_STRICT;
95 if (tflags & TUNNEL_REC)
96 flags |= GRE_REC;
97 if (tflags & TUNNEL_VERSION)
98 flags |= GRE_VERSION;
99
100 return flags;
101 }
102
103 #define gre_flags_to_tnl_flags rpl_gre_flags_to_tnl_flags
104 static inline __be16 rpl_gre_flags_to_tnl_flags(__be16 flags)
105 {
106 __be16 tflags = 0;
107
108 if (flags & GRE_CSUM)
109 tflags |= TUNNEL_CSUM;
110 if (flags & GRE_ROUTING)
111 tflags |= TUNNEL_ROUTING;
112 if (flags & GRE_KEY)
113 tflags |= TUNNEL_KEY;
114 if (flags & GRE_SEQ)
115 tflags |= TUNNEL_SEQ;
116 if (flags & GRE_STRICT)
117 tflags |= TUNNEL_STRICT;
118 if (flags & GRE_REC)
119 tflags |= TUNNEL_REC;
120 if (flags & GRE_VERSION)
121 tflags |= TUNNEL_VERSION;
122
123 return tflags;
124 }
125 #define gre_tnl_flags_to_gre_flags rpl_gre_tnl_flags_to_gre_flags
126 static inline __be16 rpl_gre_tnl_flags_to_gre_flags(__be16 tflags)
127 {
128 __be16 flags = 0;
129
130 if (tflags & TUNNEL_CSUM)
131 flags |= GRE_CSUM;
132 if (tflags & TUNNEL_ROUTING)
133 flags |= GRE_ROUTING;
134 if (tflags & TUNNEL_KEY)
135 flags |= GRE_KEY;
136 if (tflags & TUNNEL_SEQ)
137 flags |= GRE_SEQ;
138 if (tflags & TUNNEL_STRICT)
139 flags |= GRE_STRICT;
140 if (tflags & TUNNEL_REC)
141 flags |= GRE_REC;
142 if (tflags & TUNNEL_VERSION)
143 flags |= GRE_VERSION;
144
145 return flags;
146 }
147
148 #define gre_build_header rpl_gre_build_header
149 void rpl_gre_build_header(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
150 int hdr_len);
151
152 int rpl_ipgre_init(void);
153 void rpl_ipgre_fini(void);
154 int rpl_ip6gre_init(void);
155 void rpl_ip6gre_fini(void);
156 int rpl_ip6_tunnel_init(void);
157 void rpl_ip6_tunnel_cleanup(void);
158 int rpl_gre_init(void);
159 void rpl_gre_exit(void);
160
161 #define gretap_fb_dev_create rpl_gretap_fb_dev_create
162 struct net_device *rpl_gretap_fb_dev_create(struct net *net, const char *name,
163 u8 name_assign_type);
164
165 #define gre_parse_header rpl_gre_parse_header
166 int rpl_gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
167 bool *csum_err, __be16 proto, int nhs);
168
169 #define gre_fb_xmit rpl_gre_fb_xmit
170 netdev_tx_t rpl_gre_fb_xmit(struct sk_buff *skb);
171
172 #define gre_add_protocol rpl_gre_add_protocol
173 int rpl_gre_add_protocol(const struct gre_protocol *proto, u8 version);
174 #define gre_del_protocol rpl_gre_del_protocol
175 int rpl_gre_del_protocol(const struct gre_protocol *proto, u8 version);
176 #endif /* USE_UPSTREAM_TUNNEL */
177
178 #define ipgre_init rpl_ipgre_init
179 #define ipgre_fini rpl_ipgre_fini
180 #define ip6gre_init rpl_ip6gre_init
181 #define ip6gre_fini rpl_ip6gre_fini
182 #define ip6_tunnel_init rpl_ip6_tunnel_init
183 #define ip6_tunnel_cleanup rpl_ip6_tunnel_cleanup
184 #define gre_init rpl_gre_init
185 #define gre_exit rpl_gre_exit
186
187 #define gre_fill_metadata_dst ovs_gre_fill_metadata_dst
188 int ovs_gre_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb);
189
190
191 #endif