kernel: backport flow dissector batman-adv support
[openwrt/openwrt.git] / target / linux / generic / backport-4.14 / 272-batman-adv-Remove-kernel-fixed-width-types-in-packet.patch
1 From: Sven Eckelmann <sven.eckelmann@openmesh.com>
2 Date: Thu, 21 Dec 2017 10:17:40 +0100
3 Subject: [PATCH] batman-adv: Remove kernel fixed width types in packet.h
4
5 The uapi headers use the __u8/__u16/... version of the fixed width types
6 instead of u8/u16/... The use of the latter must be avoided before
7 packet.h is copied to include/uapi/linux/.
8
9 Signed-off-by: Sven Eckelmann <sven.eckelmann@openmesh.com>
10 Signed-off-by: David S. Miller <davem@davemloft.net>
11 ---
12
13 --- a/net/batman-adv/packet.h
14 +++ b/net/batman-adv/packet.h
15 @@ -22,7 +22,7 @@
16 #include <linux/if_ether.h>
17 #include <linux/types.h>
18
19 -#define batadv_tp_is_error(n) ((u8)(n) > 127 ? 1 : 0)
20 +#define batadv_tp_is_error(n) ((__u8)(n) > 127 ? 1 : 0)
21
22 /**
23 * enum batadv_packettype - types for batman-adv encapsulated packets
24 @@ -169,8 +169,8 @@ enum batadv_tvlv_type {
25 * transport the claim type and the group id
26 */
27 struct batadv_bla_claim_dst {
28 - u8 magic[3]; /* FF:43:05 */
29 - u8 type; /* bla_claimframe */
30 + __u8 magic[3]; /* FF:43:05 */
31 + __u8 type; /* bla_claimframe */
32 __be16 group; /* group id */
33 };
34
35 @@ -190,15 +190,15 @@ struct batadv_bla_claim_dst {
36 * @tvlv_len: length of tvlv data following the ogm header
37 */
38 struct batadv_ogm_packet {
39 - u8 packet_type;
40 - u8 version;
41 - u8 ttl;
42 - u8 flags;
43 + __u8 packet_type;
44 + __u8 version;
45 + __u8 ttl;
46 + __u8 flags;
47 __be32 seqno;
48 - u8 orig[ETH_ALEN];
49 - u8 prev_sender[ETH_ALEN];
50 - u8 reserved;
51 - u8 tq;
52 + __u8 orig[ETH_ALEN];
53 + __u8 prev_sender[ETH_ALEN];
54 + __u8 reserved;
55 + __u8 tq;
56 __be16 tvlv_len;
57 /* __packed is not needed as the struct size is divisible by 4,
58 * and the largest data type in this struct has a size of 4.
59 @@ -219,12 +219,12 @@ struct batadv_ogm_packet {
60 * @throughput: the currently flooded path throughput
61 */
62 struct batadv_ogm2_packet {
63 - u8 packet_type;
64 - u8 version;
65 - u8 ttl;
66 - u8 flags;
67 + __u8 packet_type;
68 + __u8 version;
69 + __u8 ttl;
70 + __u8 flags;
71 __be32 seqno;
72 - u8 orig[ETH_ALEN];
73 + __u8 orig[ETH_ALEN];
74 __be16 tvlv_len;
75 __be32 throughput;
76 /* __packed is not needed as the struct size is divisible by 4,
77 @@ -243,9 +243,9 @@ struct batadv_ogm2_packet {
78 * @elp_interval: currently used ELP sending interval in ms
79 */
80 struct batadv_elp_packet {
81 - u8 packet_type;
82 - u8 version;
83 - u8 orig[ETH_ALEN];
84 + __u8 packet_type;
85 + __u8 version;
86 + __u8 orig[ETH_ALEN];
87 __be32 seqno;
88 __be32 elp_interval;
89 };
90 @@ -268,14 +268,14 @@ struct batadv_elp_packet {
91 * members are padded the same way as they are in real packets.
92 */
93 struct batadv_icmp_header {
94 - u8 packet_type;
95 - u8 version;
96 - u8 ttl;
97 - u8 msg_type; /* see ICMP message types above */
98 - u8 dst[ETH_ALEN];
99 - u8 orig[ETH_ALEN];
100 - u8 uid;
101 - u8 align[3];
102 + __u8 packet_type;
103 + __u8 version;
104 + __u8 ttl;
105 + __u8 msg_type; /* see ICMP message types above */
106 + __u8 dst[ETH_ALEN];
107 + __u8 orig[ETH_ALEN];
108 + __u8 uid;
109 + __u8 align[3];
110 };
111
112 /**
113 @@ -291,14 +291,14 @@ struct batadv_icmp_header {
114 * @seqno: ICMP sequence number
115 */
116 struct batadv_icmp_packet {
117 - u8 packet_type;
118 - u8 version;
119 - u8 ttl;
120 - u8 msg_type; /* see ICMP message types above */
121 - u8 dst[ETH_ALEN];
122 - u8 orig[ETH_ALEN];
123 - u8 uid;
124 - u8 reserved;
125 + __u8 packet_type;
126 + __u8 version;
127 + __u8 ttl;
128 + __u8 msg_type; /* see ICMP message types above */
129 + __u8 dst[ETH_ALEN];
130 + __u8 orig[ETH_ALEN];
131 + __u8 uid;
132 + __u8 reserved;
133 __be16 seqno;
134 };
135
136 @@ -320,15 +320,15 @@ struct batadv_icmp_packet {
137 * store it using network order
138 */
139 struct batadv_icmp_tp_packet {
140 - u8 packet_type;
141 - u8 version;
142 - u8 ttl;
143 - u8 msg_type; /* see ICMP message types above */
144 - u8 dst[ETH_ALEN];
145 - u8 orig[ETH_ALEN];
146 - u8 uid;
147 - u8 subtype;
148 - u8 session[2];
149 + __u8 packet_type;
150 + __u8 version;
151 + __u8 ttl;
152 + __u8 msg_type; /* see ICMP message types above */
153 + __u8 dst[ETH_ALEN];
154 + __u8 orig[ETH_ALEN];
155 + __u8 uid;
156 + __u8 subtype;
157 + __u8 session[2];
158 __be32 seqno;
159 __be32 timestamp;
160 };
161 @@ -359,16 +359,16 @@ enum batadv_icmp_tp_subtype {
162 * @rr: route record array
163 */
164 struct batadv_icmp_packet_rr {
165 - u8 packet_type;
166 - u8 version;
167 - u8 ttl;
168 - u8 msg_type; /* see ICMP message types above */
169 - u8 dst[ETH_ALEN];
170 - u8 orig[ETH_ALEN];
171 - u8 uid;
172 - u8 rr_cur;
173 + __u8 packet_type;
174 + __u8 version;
175 + __u8 ttl;
176 + __u8 msg_type; /* see ICMP message types above */
177 + __u8 dst[ETH_ALEN];
178 + __u8 orig[ETH_ALEN];
179 + __u8 uid;
180 + __u8 rr_cur;
181 __be16 seqno;
182 - u8 rr[BATADV_RR_LEN][ETH_ALEN];
183 + __u8 rr[BATADV_RR_LEN][ETH_ALEN];
184 };
185
186 #define BATADV_ICMP_MAX_PACKET_SIZE sizeof(struct batadv_icmp_packet_rr)
187 @@ -394,11 +394,11 @@ struct batadv_icmp_packet_rr {
188 * @dest: originator destination of the unicast packet
189 */
190 struct batadv_unicast_packet {
191 - u8 packet_type;
192 - u8 version;
193 - u8 ttl;
194 - u8 ttvn; /* destination translation table version number */
195 - u8 dest[ETH_ALEN];
196 + __u8 packet_type;
197 + __u8 version;
198 + __u8 ttl;
199 + __u8 ttvn; /* destination translation table version number */
200 + __u8 dest[ETH_ALEN];
201 /* "4 bytes boundary + 2 bytes" long to make the payload after the
202 * following ethernet header again 4 bytes boundary aligned
203 */
204 @@ -413,9 +413,9 @@ struct batadv_unicast_packet {
205 */
206 struct batadv_unicast_4addr_packet {
207 struct batadv_unicast_packet u;
208 - u8 src[ETH_ALEN];
209 - u8 subtype;
210 - u8 reserved;
211 + __u8 src[ETH_ALEN];
212 + __u8 subtype;
213 + __u8 reserved;
214 /* "4 bytes boundary + 2 bytes" long to make the payload after the
215 * following ethernet header again 4 bytes boundary aligned
216 */
217 @@ -435,22 +435,22 @@ struct batadv_unicast_4addr_packet {
218 * @total_size: size of the merged packet
219 */
220 struct batadv_frag_packet {
221 - u8 packet_type;
222 - u8 version; /* batman version field */
223 - u8 ttl;
224 + __u8 packet_type;
225 + __u8 version; /* batman version field */
226 + __u8 ttl;
227 #if defined(__BIG_ENDIAN_BITFIELD)
228 - u8 no:4;
229 - u8 priority:3;
230 - u8 reserved:1;
231 + __u8 no:4;
232 + __u8 priority:3;
233 + __u8 reserved:1;
234 #elif defined(__LITTLE_ENDIAN_BITFIELD)
235 - u8 reserved:1;
236 - u8 priority:3;
237 - u8 no:4;
238 + __u8 reserved:1;
239 + __u8 priority:3;
240 + __u8 no:4;
241 #else
242 #error "unknown bitfield endianness"
243 #endif
244 - u8 dest[ETH_ALEN];
245 - u8 orig[ETH_ALEN];
246 + __u8 dest[ETH_ALEN];
247 + __u8 orig[ETH_ALEN];
248 __be16 seqno;
249 __be16 total_size;
250 };
251 @@ -465,12 +465,12 @@ struct batadv_frag_packet {
252 * @orig: originator of the broadcast packet
253 */
254 struct batadv_bcast_packet {
255 - u8 packet_type;
256 - u8 version; /* batman version field */
257 - u8 ttl;
258 - u8 reserved;
259 + __u8 packet_type;
260 + __u8 version; /* batman version field */
261 + __u8 ttl;
262 + __u8 reserved;
263 __be32 seqno;
264 - u8 orig[ETH_ALEN];
265 + __u8 orig[ETH_ALEN];
266 /* "4 bytes boundary + 2 bytes" long to make the payload after the
267 * following ethernet header again 4 bytes boundary aligned
268 */
269 @@ -494,19 +494,19 @@ struct batadv_bcast_packet {
270 * @coded_len: length of network coded part of the payload
271 */
272 struct batadv_coded_packet {
273 - u8 packet_type;
274 - u8 version; /* batman version field */
275 - u8 ttl;
276 - u8 first_ttvn;
277 - /* u8 first_dest[ETH_ALEN]; - saved in mac header destination */
278 - u8 first_source[ETH_ALEN];
279 - u8 first_orig_dest[ETH_ALEN];
280 + __u8 packet_type;
281 + __u8 version; /* batman version field */
282 + __u8 ttl;
283 + __u8 first_ttvn;
284 + /* __u8 first_dest[ETH_ALEN]; - saved in mac header destination */
285 + __u8 first_source[ETH_ALEN];
286 + __u8 first_orig_dest[ETH_ALEN];
287 __be32 first_crc;
288 - u8 second_ttl;
289 - u8 second_ttvn;
290 - u8 second_dest[ETH_ALEN];
291 - u8 second_source[ETH_ALEN];
292 - u8 second_orig_dest[ETH_ALEN];
293 + __u8 second_ttl;
294 + __u8 second_ttvn;
295 + __u8 second_dest[ETH_ALEN];
296 + __u8 second_source[ETH_ALEN];
297 + __u8 second_orig_dest[ETH_ALEN];
298 __be32 second_crc;
299 __be16 coded_len;
300 };
301 @@ -525,14 +525,14 @@ struct batadv_coded_packet {
302 * @align: 2 bytes to align the header to a 4 byte boundary
303 */
304 struct batadv_unicast_tvlv_packet {
305 - u8 packet_type;
306 - u8 version; /* batman version field */
307 - u8 ttl;
308 - u8 reserved;
309 - u8 dst[ETH_ALEN];
310 - u8 src[ETH_ALEN];
311 + __u8 packet_type;
312 + __u8 version; /* batman version field */
313 + __u8 ttl;
314 + __u8 reserved;
315 + __u8 dst[ETH_ALEN];
316 + __u8 src[ETH_ALEN];
317 __be16 tvlv_len;
318 - u16 align;
319 + __u16 align;
320 };
321
322 /**
323 @@ -542,8 +542,8 @@ struct batadv_unicast_tvlv_packet {
324 * @len: tvlv container length
325 */
326 struct batadv_tvlv_hdr {
327 - u8 type;
328 - u8 version;
329 + __u8 type;
330 + __u8 version;
331 __be16 len;
332 };
333
334 @@ -566,8 +566,8 @@ struct batadv_tvlv_gateway_data {
335 * one batadv_tvlv_tt_vlan_data object per announced vlan
336 */
337 struct batadv_tvlv_tt_data {
338 - u8 flags;
339 - u8 ttvn;
340 + __u8 flags;
341 + __u8 ttvn;
342 __be16 num_vlan;
343 };
344
345 @@ -581,7 +581,7 @@ struct batadv_tvlv_tt_data {
346 struct batadv_tvlv_tt_vlan_data {
347 __be32 crc;
348 __be16 vid;
349 - u16 reserved;
350 + __u16 reserved;
351 };
352
353 /**
354 @@ -593,9 +593,9 @@ struct batadv_tvlv_tt_vlan_data {
355 * @vid: VLAN identifier
356 */
357 struct batadv_tvlv_tt_change {
358 - u8 flags;
359 - u8 reserved[3];
360 - u8 addr[ETH_ALEN];
361 + __u8 flags;
362 + __u8 reserved[3];
363 + __u8 addr[ETH_ALEN];
364 __be16 vid;
365 };
366
367 @@ -605,7 +605,7 @@ struct batadv_tvlv_tt_change {
368 * @vid: VLAN identifier
369 */
370 struct batadv_tvlv_roam_adv {
371 - u8 client[ETH_ALEN];
372 + __u8 client[ETH_ALEN];
373 __be16 vid;
374 };
375
376 @@ -615,8 +615,8 @@ struct batadv_tvlv_roam_adv {
377 * @reserved: reserved field
378 */
379 struct batadv_tvlv_mcast_data {
380 - u8 flags;
381 - u8 reserved[3];
382 + __u8 flags;
383 + __u8 reserved[3];
384 };
385
386 #endif /* _NET_BATMAN_ADV_PACKET_H_ */