OpenWrt – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --- a/arch/mips/include/asm/checksum.h |
2 | +++ b/arch/mips/include/asm/checksum.h |
||
3 | @@ -134,26 +134,30 @@ static inline __sum16 ip_fast_csum(const |
||
4 | const unsigned int *stop = word + ihl; |
||
5 | unsigned int csum; |
||
6 | int carry; |
||
7 | + unsigned int w; |
||
8 | |||
9 | - csum = word[0]; |
||
10 | - csum += word[1]; |
||
11 | - carry = (csum < word[1]); |
||
12 | + csum = net_hdr_word(word++); |
||
13 | + |
||
14 | + w = net_hdr_word(word++); |
||
15 | + csum += w; |
||
16 | + carry = (csum < w); |
||
17 | csum += carry; |
||
18 | |||
19 | - csum += word[2]; |
||
20 | - carry = (csum < word[2]); |
||
21 | + w = net_hdr_word(word++); |
||
22 | + csum += w; |
||
23 | + carry = (csum < w); |
||
24 | csum += carry; |
||
25 | |||
26 | - csum += word[3]; |
||
27 | - carry = (csum < word[3]); |
||
28 | + w = net_hdr_word(word++); |
||
29 | + csum += w; |
||
30 | + carry = (csum < w); |
||
31 | csum += carry; |
||
32 | |||
33 | - word += 4; |
||
34 | do { |
||
35 | - csum += *word; |
||
36 | - carry = (csum < *word); |
||
37 | + w = net_hdr_word(word++); |
||
38 | + csum += w; |
||
39 | + carry = (csum < w); |
||
40 | csum += carry; |
||
41 | - word++; |
||
42 | } while (word != stop); |
||
43 | |||
44 | return csum_fold(csum); |
||
45 | @@ -214,73 +218,6 @@ static inline __sum16 ip_compute_csum(co |
||
46 | return csum_fold(csum_partial(buff, len, 0)); |
||
47 | } |
||
48 | |||
49 | -#define _HAVE_ARCH_IPV6_CSUM |
||
50 | -static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr, |
||
51 | - const struct in6_addr *daddr, |
||
52 | - __u32 len, __u8 proto, |
||
53 | - __wsum sum) |
||
54 | -{ |
||
55 | - __wsum tmp; |
||
56 | - |
||
57 | - __asm__( |
||
58 | - " .set push # csum_ipv6_magic\n" |
||
59 | - " .set noreorder \n" |
||
60 | - " .set noat \n" |
||
61 | - " addu %0, %5 # proto (long in network byte order)\n" |
||
62 | - " sltu $1, %0, %5 \n" |
||
63 | - " addu %0, $1 \n" |
||
64 | - |
||
65 | - " addu %0, %6 # csum\n" |
||
66 | - " sltu $1, %0, %6 \n" |
||
67 | - " lw %1, 0(%2) # four words source address\n" |
||
68 | - " addu %0, $1 \n" |
||
69 | - " addu %0, %1 \n" |
||
70 | - " sltu $1, %0, %1 \n" |
||
71 | - |
||
72 | - " lw %1, 4(%2) \n" |
||
73 | - " addu %0, $1 \n" |
||
74 | - " addu %0, %1 \n" |
||
75 | - " sltu $1, %0, %1 \n" |
||
76 | - |
||
77 | - " lw %1, 8(%2) \n" |
||
78 | - " addu %0, $1 \n" |
||
79 | - " addu %0, %1 \n" |
||
80 | - " sltu $1, %0, %1 \n" |
||
81 | - |
||
82 | - " lw %1, 12(%2) \n" |
||
83 | - " addu %0, $1 \n" |
||
84 | - " addu %0, %1 \n" |
||
85 | - " sltu $1, %0, %1 \n" |
||
86 | - |
||
87 | - " lw %1, 0(%3) \n" |
||
88 | - " addu %0, $1 \n" |
||
89 | - " addu %0, %1 \n" |
||
90 | - " sltu $1, %0, %1 \n" |
||
91 | - |
||
92 | - " lw %1, 4(%3) \n" |
||
93 | - " addu %0, $1 \n" |
||
94 | - " addu %0, %1 \n" |
||
95 | - " sltu $1, %0, %1 \n" |
||
96 | - |
||
97 | - " lw %1, 8(%3) \n" |
||
98 | - " addu %0, $1 \n" |
||
99 | - " addu %0, %1 \n" |
||
100 | - " sltu $1, %0, %1 \n" |
||
101 | - |
||
102 | - " lw %1, 12(%3) \n" |
||
103 | - " addu %0, $1 \n" |
||
104 | - " addu %0, %1 \n" |
||
105 | - " sltu $1, %0, %1 \n" |
||
106 | - |
||
107 | - " addu %0, $1 # Add final carry\n" |
||
108 | - " .set pop" |
||
109 | - : "=&r" (sum), "=&r" (tmp) |
||
110 | - : "r" (saddr), "r" (daddr), |
||
111 | - "0" (htonl(len)), "r" (htonl(proto)), "r" (sum)); |
||
112 | - |
||
113 | - return csum_fold(sum); |
||
114 | -} |
||
115 | - |
||
116 | #include <asm-generic/checksum.h> |
||
117 | #endif /* CONFIG_GENERIC_CSUM */ |
||
118 | |||
119 | --- a/include/uapi/linux/ip.h |
||
120 | +++ b/include/uapi/linux/ip.h |
||
121 | @@ -103,7 +103,7 @@ struct iphdr { |
||
122 | __be32 saddr; |
||
123 | __be32 daddr; |
||
124 | /*The options start here. */ |
||
125 | -}; |
||
126 | +} __attribute__((packed, aligned(2))); |
||
127 | |||
128 | |||
129 | struct ip_auth_hdr { |
||
130 | --- a/include/uapi/linux/ipv6.h |
||
131 | +++ b/include/uapi/linux/ipv6.h |
||
132 | @@ -104,7 +104,7 @@ struct ipv6_destopt_hao { |
||
133 | __u8 type; |
||
134 | __u8 length; |
||
135 | struct in6_addr addr; |
||
136 | -} __attribute__((packed)); |
||
137 | +} __attribute__((packed, aligned(2))); |
||
138 | |||
139 | /* |
||
140 | * IPv6 fixed header |
||
141 | @@ -131,7 +131,7 @@ struct ipv6hdr { |
||
142 | |||
143 | struct in6_addr saddr; |
||
144 | struct in6_addr daddr; |
||
145 | -}; |
||
146 | +} __attribute__((packed, aligned(2))); |
||
147 | |||
148 | |||
149 | /* index values for the variables in ipv6_devconf */ |
||
150 | --- a/include/uapi/linux/tcp.h |
||
151 | +++ b/include/uapi/linux/tcp.h |
||
152 | @@ -55,7 +55,7 @@ struct tcphdr { |
||
153 | __be16 window; |
||
154 | __sum16 check; |
||
155 | __be16 urg_ptr; |
||
156 | -}; |
||
157 | +} __attribute__((packed, aligned(2))); |
||
158 | |||
159 | /* |
||
160 | * The union cast uses a gcc extension to avoid aliasing problems |
||
161 | @@ -65,7 +65,7 @@ struct tcphdr { |
||
162 | union tcp_word_hdr { |
||
163 | struct tcphdr hdr; |
||
164 | __be32 words[5]; |
||
165 | -}; |
||
166 | +} __attribute__((packed, aligned(2))); |
||
167 | |||
168 | #define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3]) |
||
169 | |||
170 | --- a/include/uapi/linux/udp.h |
||
171 | +++ b/include/uapi/linux/udp.h |
||
172 | @@ -25,7 +25,7 @@ struct udphdr { |
||
173 | __be16 dest; |
||
174 | __be16 len; |
||
175 | __sum16 check; |
||
176 | -}; |
||
177 | +} __attribute__((packed, aligned(2))); |
||
178 | |||
179 | /* UDP socket options */ |
||
180 | #define UDP_CORK 1 /* Never send partially complete segments */ |
||
181 | --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c |
||
182 | +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c |
||
183 | @@ -48,8 +48,8 @@ static bool ipv4_pkt_to_tuple(const stru |
||
184 | if (ap == NULL) |
||
185 | return false; |
||
186 | |||
187 | - tuple->src.u3.ip = ap[0]; |
||
188 | - tuple->dst.u3.ip = ap[1]; |
||
189 | + tuple->src.u3.ip = net_hdr_word(ap++); |
||
190 | + tuple->dst.u3.ip = net_hdr_word(ap); |
||
191 | |||
192 | return true; |
||
193 | } |
||
194 | --- a/include/uapi/linux/icmp.h |
||
195 | +++ b/include/uapi/linux/icmp.h |
||
196 | @@ -82,7 +82,7 @@ struct icmphdr { |
||
197 | } frag; |
||
198 | __u8 reserved[4]; |
||
199 | } un; |
||
200 | -}; |
||
201 | +} __attribute__((packed, aligned(2))); |
||
202 | |||
203 | |||
204 | /* |
||
205 | --- a/include/uapi/linux/in6.h |
||
206 | +++ b/include/uapi/linux/in6.h |
||
207 | @@ -43,7 +43,7 @@ struct in6_addr { |
||
208 | #define s6_addr16 in6_u.u6_addr16 |
||
209 | #define s6_addr32 in6_u.u6_addr32 |
||
210 | #endif |
||
211 | -}; |
||
212 | +} __attribute__((packed, aligned(2))); |
||
213 | #endif /* __UAPI_DEF_IN6_ADDR */ |
||
214 | |||
215 | #if __UAPI_DEF_SOCKADDR_IN6 |
||
216 | --- a/net/ipv6/tcp_ipv6.c |
||
217 | +++ b/net/ipv6/tcp_ipv6.c |
||
218 | @@ -39,6 +39,7 @@ |
||
219 | #include <linux/ipsec.h> |
||
220 | #include <linux/times.h> |
||
221 | #include <linux/slab.h> |
||
222 | +#include <asm/unaligned.h> |
||
223 | #include <linux/uaccess.h> |
||
224 | #include <linux/ipv6.h> |
||
225 | #include <linux/icmpv6.h> |
||
226 | @@ -819,10 +820,10 @@ static void tcp_v6_send_response(const s |
||
227 | topt = (__be32 *)(t1 + 1); |
||
228 | |||
229 | if (tsecr) { |
||
230 | - *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | |
||
231 | - (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP); |
||
232 | - *topt++ = htonl(tsval); |
||
233 | - *topt++ = htonl(tsecr); |
||
234 | + put_unaligned_be32((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | |
||
235 | + (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP, topt++); |
||
236 | + put_unaligned_be32(tsval, topt++); |
||
237 | + put_unaligned_be32(tsecr, topt++); |
||
238 | } |
||
239 | |||
240 | #ifdef CONFIG_TCP_MD5SIG |
||
241 | --- a/include/linux/ipv6.h |
||
242 | +++ b/include/linux/ipv6.h |
||
243 | @@ -6,6 +6,7 @@ |
||
244 | |||
245 | #define ipv6_optlen(p) (((p)->hdrlen+1) << 3) |
||
246 | #define ipv6_authlen(p) (((p)->hdrlen+2) << 2) |
||
247 | + |
||
248 | /* |
||
249 | * This structure contains configuration options per IPv6 link. |
||
250 | */ |
||
251 | --- a/net/ipv6/datagram.c |
||
252 | +++ b/net/ipv6/datagram.c |
||
253 | @@ -486,7 +486,7 @@ int ipv6_recv_error(struct sock *sk, str |
||
254 | ipv6_iface_scope_id(&sin->sin6_addr, |
||
255 | IP6CB(skb)->iif); |
||
256 | } else { |
||
257 | - ipv6_addr_set_v4mapped(*(__be32 *)(nh + serr->addr_offset), |
||
258 | + ipv6_addr_set_v4mapped(net_hdr_word(nh + serr->addr_offset), |
||
259 | &sin->sin6_addr); |
||
260 | sin->sin6_scope_id = 0; |
||
261 | } |
||
262 | @@ -835,12 +835,12 @@ int ip6_datagram_send_ctl(struct net *ne |
||
263 | } |
||
264 | |||
265 | if (fl6->flowlabel&IPV6_FLOWINFO_MASK) { |
||
266 | - if ((fl6->flowlabel^*(__be32 *)CMSG_DATA(cmsg))&~IPV6_FLOWINFO_MASK) { |
||
267 | + if ((fl6->flowlabel^net_hdr_word(CMSG_DATA(cmsg)))&~IPV6_FLOWINFO_MASK) { |
||
268 | err = -EINVAL; |
||
269 | goto exit_f; |
||
270 | } |
||
271 | } |
||
272 | - fl6->flowlabel = IPV6_FLOWINFO_MASK & *(__be32 *)CMSG_DATA(cmsg); |
||
273 | + fl6->flowlabel = IPV6_FLOWINFO_MASK & net_hdr_word(CMSG_DATA(cmsg)); |
||
274 | break; |
||
275 | |||
276 | case IPV6_2292HOPOPTS: |
||
277 | --- a/net/ipv6/ip6_gre.c |
||
278 | +++ b/net/ipv6/ip6_gre.c |
||
279 | @@ -397,7 +397,7 @@ static void ip6gre_err(struct sk_buff *s |
||
280 | return; |
||
281 | ipv6h = (const struct ipv6hdr *)skb->data; |
||
282 | greh = (const struct gre_base_hdr *)(skb->data + offset); |
||
283 | - key = key_off ? *(__be32 *)(skb->data + key_off) : 0; |
||
284 | + key = key_off ? net_hdr_word((__be32 *)(skb->data + key_off)) : 0; |
||
285 | |||
286 | t = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr, |
||
287 | key, greh->protocol); |
||
288 | --- a/net/ipv6/exthdrs.c |
||
289 | +++ b/net/ipv6/exthdrs.c |
||
290 | @@ -733,7 +733,7 @@ static bool ipv6_hop_jumbo(struct sk_buf |
||
291 | goto drop; |
||
292 | } |
||
293 | |||
294 | - pkt_len = ntohl(*(__be32 *)(nh + optoff + 2)); |
||
295 | + pkt_len = ntohl(net_hdr_word(nh + optoff + 2)); |
||
296 | if (pkt_len <= IPV6_MAXPLEN) { |
||
297 | __IP6_INC_STATS(net, ipv6_skb_idev(skb), |
||
298 | IPSTATS_MIB_INHDRERRORS); |
||
299 | --- a/include/linux/types.h |
||
300 | +++ b/include/linux/types.h |
||
301 | @@ -229,5 +229,11 @@ struct callback_head { |
||
302 | typedef void (*rcu_callback_t)(struct rcu_head *head); |
||
303 | typedef void (*call_rcu_func_t)(struct rcu_head *head, rcu_callback_t func); |
||
304 | |||
305 | +struct net_hdr_word { |
||
306 | + u32 words[1]; |
||
307 | +} __attribute__((packed, aligned(2))); |
||
308 | + |
||
309 | +#define net_hdr_word(_p) (((struct net_hdr_word *) (_p))->words[0]) |
||
310 | + |
||
311 | #endif /* __ASSEMBLY__ */ |
||
312 | #endif /* _LINUX_TYPES_H */ |
||
313 | --- a/net/ipv4/af_inet.c |
||
314 | +++ b/net/ipv4/af_inet.c |
||
315 | @@ -1352,8 +1352,8 @@ struct sk_buff **inet_gro_receive(struct |
||
316 | if (unlikely(ip_fast_csum((u8 *)iph, 5))) |
||
317 | goto out_unlock; |
||
318 | |||
319 | - id = ntohl(*(__be32 *)&iph->id); |
||
320 | - flush = (u16)((ntohl(*(__be32 *)iph) ^ skb_gro_len(skb)) | (id & ~IP_DF)); |
||
321 | + id = ntohl(net_hdr_word(&iph->id)); |
||
322 | + flush = (u16)((ntohl(net_hdr_word(iph)) ^ skb_gro_len(skb)) | (id & ~IP_DF)); |
||
323 | id >>= 16; |
||
324 | |||
325 | for (p = *head; p; p = p->next) { |
||
326 | --- a/net/ipv4/route.c |
||
327 | +++ b/net/ipv4/route.c |
||
328 | @@ -465,7 +465,7 @@ static struct neighbour *ipv4_neigh_look |
||
329 | else if (skb) |
||
330 | pkey = &ip_hdr(skb)->daddr; |
||
331 | |||
332 | - n = __ipv4_neigh_lookup(dev, *(__force u32 *)pkey); |
||
333 | + n = __ipv4_neigh_lookup(dev, net_hdr_word(pkey)); |
||
334 | if (n) |
||
335 | return n; |
||
336 | return neigh_create(&arp_tbl, pkey, dev); |
||
337 | --- a/net/ipv4/tcp_output.c |
||
338 | +++ b/net/ipv4/tcp_output.c |
||
339 | @@ -454,48 +454,53 @@ static void tcp_options_write(__be32 *pt |
||
340 | u16 options = opts->options; /* mungable copy */ |
||
341 | |||
342 | if (unlikely(OPTION_MD5 & options)) { |
||
343 | - *ptr++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | |
||
344 | - (TCPOPT_MD5SIG << 8) | TCPOLEN_MD5SIG); |
||
345 | + net_hdr_word(ptr++) = |
||
346 | + htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | |
||
347 | + (TCPOPT_MD5SIG << 8) | TCPOLEN_MD5SIG); |
||
348 | /* overload cookie hash location */ |
||
349 | opts->hash_location = (__u8 *)ptr; |
||
350 | ptr += 4; |
||
351 | } |
||
352 | |||
353 | if (unlikely(opts->mss)) { |
||
354 | - *ptr++ = htonl((TCPOPT_MSS << 24) | |
||
355 | - (TCPOLEN_MSS << 16) | |
||
356 | - opts->mss); |
||
357 | + net_hdr_word(ptr++) = |
||
358 | + htonl((TCPOPT_MSS << 24) | (TCPOLEN_MSS << 16) | |
||
359 | + opts->mss); |
||
360 | } |
||
361 | |||
362 | if (likely(OPTION_TS & options)) { |
||
363 | if (unlikely(OPTION_SACK_ADVERTISE & options)) { |
||
364 | - *ptr++ = htonl((TCPOPT_SACK_PERM << 24) | |
||
365 | - (TCPOLEN_SACK_PERM << 16) | |
||
366 | - (TCPOPT_TIMESTAMP << 8) | |
||
367 | - TCPOLEN_TIMESTAMP); |
||
368 | + net_hdr_word(ptr++) = |
||
369 | + htonl((TCPOPT_SACK_PERM << 24) | |
||
370 | + (TCPOLEN_SACK_PERM << 16) | |
||
371 | + (TCPOPT_TIMESTAMP << 8) | |
||
372 | + TCPOLEN_TIMESTAMP); |
||
373 | options &= ~OPTION_SACK_ADVERTISE; |
||
374 | } else { |
||
375 | - *ptr++ = htonl((TCPOPT_NOP << 24) | |
||
376 | - (TCPOPT_NOP << 16) | |
||
377 | - (TCPOPT_TIMESTAMP << 8) | |
||
378 | - TCPOLEN_TIMESTAMP); |
||
379 | + net_hdr_word(ptr++) = |
||
380 | + htonl((TCPOPT_NOP << 24) | |
||
381 | + (TCPOPT_NOP << 16) | |
||
382 | + (TCPOPT_TIMESTAMP << 8) | |
||
383 | + TCPOLEN_TIMESTAMP); |
||
384 | } |
||
385 | - *ptr++ = htonl(opts->tsval); |
||
386 | - *ptr++ = htonl(opts->tsecr); |
||
387 | + net_hdr_word(ptr++) = htonl(opts->tsval); |
||
388 | + net_hdr_word(ptr++) = htonl(opts->tsecr); |
||
389 | } |
||
390 | |||
391 | if (unlikely(OPTION_SACK_ADVERTISE & options)) { |
||
392 | - *ptr++ = htonl((TCPOPT_NOP << 24) | |
||
393 | - (TCPOPT_NOP << 16) | |
||
394 | - (TCPOPT_SACK_PERM << 8) | |
||
395 | - TCPOLEN_SACK_PERM); |
||
396 | + net_hdr_word(ptr++) = |
||
397 | + htonl((TCPOPT_NOP << 24) | |
||
398 | + (TCPOPT_NOP << 16) | |
||
399 | + (TCPOPT_SACK_PERM << 8) | |
||
400 | + TCPOLEN_SACK_PERM); |
||
401 | } |
||
402 | |||
403 | if (unlikely(OPTION_WSCALE & options)) { |
||
404 | - *ptr++ = htonl((TCPOPT_NOP << 24) | |
||
405 | - (TCPOPT_WINDOW << 16) | |
||
406 | - (TCPOLEN_WINDOW << 8) | |
||
407 | - opts->ws); |
||
408 | + net_hdr_word(ptr++) = |
||
409 | + htonl((TCPOPT_NOP << 24) | |
||
410 | + (TCPOPT_WINDOW << 16) | |
||
411 | + (TCPOLEN_WINDOW << 8) | |
||
412 | + opts->ws); |
||
413 | } |
||
414 | |||
415 | if (unlikely(opts->num_sack_blocks)) { |
||
416 | @@ -503,16 +508,17 @@ static void tcp_options_write(__be32 *pt |
||
417 | tp->duplicate_sack : tp->selective_acks; |
||
418 | int this_sack; |
||
419 | |||
420 | - *ptr++ = htonl((TCPOPT_NOP << 24) | |
||
421 | - (TCPOPT_NOP << 16) | |
||
422 | - (TCPOPT_SACK << 8) | |
||
423 | - (TCPOLEN_SACK_BASE + (opts->num_sack_blocks * |
||
424 | + net_hdr_word(ptr++) = |
||
425 | + htonl((TCPOPT_NOP << 24) | |
||
426 | + (TCPOPT_NOP << 16) | |
||
427 | + (TCPOPT_SACK << 8) | |
||
428 | + (TCPOLEN_SACK_BASE + (opts->num_sack_blocks * |
||
429 | TCPOLEN_SACK_PERBLOCK))); |
||
430 | |||
431 | for (this_sack = 0; this_sack < opts->num_sack_blocks; |
||
432 | ++this_sack) { |
||
433 | - *ptr++ = htonl(sp[this_sack].start_seq); |
||
434 | - *ptr++ = htonl(sp[this_sack].end_seq); |
||
435 | + net_hdr_word(ptr++) = htonl(sp[this_sack].start_seq); |
||
436 | + net_hdr_word(ptr++) = htonl(sp[this_sack].end_seq); |
||
437 | } |
||
438 | |||
439 | tp->rx_opt.dsack = 0; |
||
440 | @@ -525,13 +531,14 @@ static void tcp_options_write(__be32 *pt |
||
441 | |||
442 | if (foc->exp) { |
||
443 | len = TCPOLEN_EXP_FASTOPEN_BASE + foc->len; |
||
444 | - *ptr = htonl((TCPOPT_EXP << 24) | (len << 16) | |
||
445 | + net_hdr_word(ptr) = |
||
446 | + htonl((TCPOPT_EXP << 24) | (len << 16) | |
||
447 | TCPOPT_FASTOPEN_MAGIC); |
||
448 | p += TCPOLEN_EXP_FASTOPEN_BASE; |
||
449 | } else { |
||
450 | len = TCPOLEN_FASTOPEN_BASE + foc->len; |
||
451 | - *p++ = TCPOPT_FASTOPEN; |
||
452 | - *p++ = len; |
||
453 | + net_hdr_word(p++) = TCPOPT_FASTOPEN; |
||
454 | + net_hdr_word(p++) = len; |
||
455 | } |
||
456 | |||
457 | memcpy(p, foc->val, foc->len); |
||
458 | --- a/net/ipv4/igmp.c |
||
459 | +++ b/net/ipv4/igmp.c |
||
460 | @@ -537,7 +537,7 @@ static struct sk_buff *add_grec(struct s |
||
461 | if (!skb) |
||
462 | return NULL; |
||
463 | psrc = skb_put(skb, sizeof(__be32)); |
||
464 | - *psrc = psf->sf_inaddr; |
||
465 | + net_hdr_word(psrc) = psf->sf_inaddr; |
||
466 | scount++; stotal++; |
||
467 | if ((type == IGMPV3_ALLOW_NEW_SOURCES || |
||
468 | type == IGMPV3_BLOCK_OLD_SOURCES) && psf->sf_crcount) { |
||
469 | --- a/include/uapi/linux/igmp.h |
||
470 | +++ b/include/uapi/linux/igmp.h |
||
471 | @@ -33,7 +33,7 @@ struct igmphdr { |
||
472 | __u8 code; /* For newer IGMP */ |
||
473 | __sum16 csum; |
||
474 | __be32 group; |
||
475 | -}; |
||
476 | +} __attribute__((packed, aligned(2))); |
||
477 | |||
478 | /* V3 group record types [grec_type] */ |
||
479 | #define IGMPV3_MODE_IS_INCLUDE 1 |
||
480 | @@ -49,7 +49,7 @@ struct igmpv3_grec { |
||
481 | __be16 grec_nsrcs; |
||
482 | __be32 grec_mca; |
||
483 | __be32 grec_src[0]; |
||
484 | -}; |
||
485 | +} __attribute__((packed, aligned(2))); |
||
486 | |||
487 | struct igmpv3_report { |
||
488 | __u8 type; |
||
489 | @@ -58,7 +58,7 @@ struct igmpv3_report { |
||
490 | __be16 resv2; |
||
491 | __be16 ngrec; |
||
492 | struct igmpv3_grec grec[0]; |
||
493 | -}; |
||
494 | +} __attribute__((packed, aligned(2))); |
||
495 | |||
496 | struct igmpv3_query { |
||
497 | __u8 type; |
||
498 | @@ -79,7 +79,7 @@ struct igmpv3_query { |
||
499 | __u8 qqic; |
||
500 | __be16 nsrcs; |
||
501 | __be32 srcs[0]; |
||
502 | -}; |
||
503 | +} __attribute__((packed, aligned(2))); |
||
504 | |||
505 | #define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* From RFC1112 */ |
||
506 | #define IGMP_HOST_MEMBERSHIP_REPORT 0x12 /* Ditto */ |
||
507 | --- a/net/core/flow_dissector.c |
||
508 | +++ b/net/core/flow_dissector.c |
||
509 | @@ -108,7 +108,7 @@ __be32 __skb_flow_get_ports(const struct |
||
510 | ports = __skb_header_pointer(skb, thoff + poff, |
||
511 | sizeof(_ports), data, hlen, &_ports); |
||
512 | if (ports) |
||
513 | - return *ports; |
||
514 | + return (__be32)net_hdr_word(ports); |
||
515 | } |
||
516 | |||
517 | return 0; |
||
518 | --- a/include/uapi/linux/icmpv6.h |
||
519 | +++ b/include/uapi/linux/icmpv6.h |
||
520 | @@ -77,7 +77,7 @@ struct icmp6hdr { |
||
521 | #define icmp6_addrconf_other icmp6_dataun.u_nd_ra.other |
||
522 | #define icmp6_rt_lifetime icmp6_dataun.u_nd_ra.rt_lifetime |
||
523 | #define icmp6_router_pref icmp6_dataun.u_nd_ra.router_pref |
||
524 | -}; |
||
525 | +} __attribute__((packed, aligned(2))); |
||
526 | |||
527 | |||
528 | #define ICMPV6_ROUTER_PREF_LOW 0x3 |
||
529 | --- a/include/net/ndisc.h |
||
530 | +++ b/include/net/ndisc.h |
||
531 | @@ -89,7 +89,7 @@ struct ra_msg { |
||
532 | struct icmp6hdr icmph; |
||
533 | __be32 reachable_time; |
||
534 | __be32 retrans_timer; |
||
535 | -}; |
||
536 | +} __attribute__((packed, aligned(2))); |
||
537 | |||
538 | struct rd_msg { |
||
539 | struct icmp6hdr icmph; |
||
540 | @@ -368,10 +368,10 @@ static inline u32 ndisc_hashfn(const voi |
||
541 | { |
||
542 | const u32 *p32 = pkey; |
||
543 | |||
544 | - return (((p32[0] ^ hash32_ptr(dev)) * hash_rnd[0]) + |
||
545 | - (p32[1] * hash_rnd[1]) + |
||
546 | - (p32[2] * hash_rnd[2]) + |
||
547 | - (p32[3] * hash_rnd[3])); |
||
548 | + return (((net_hdr_word(&p32[0]) ^ hash32_ptr(dev)) * hash_rnd[0]) + |
||
549 | + (net_hdr_word(&p32[1]) * hash_rnd[1]) + |
||
550 | + (net_hdr_word(&p32[2]) * hash_rnd[2]) + |
||
551 | + (net_hdr_word(&p32[3]) * hash_rnd[3])); |
||
552 | } |
||
553 | |||
554 | static inline struct neighbour *__ipv6_neigh_lookup_noref(struct net_device *dev, const void *pkey) |
||
555 | --- a/net/sched/cls_u32.c |
||
556 | +++ b/net/sched/cls_u32.c |
||
557 | @@ -165,7 +165,7 @@ next_knode: |
||
558 | data = skb_header_pointer(skb, toff, 4, &hdata); |
||
559 | if (!data) |
||
560 | goto out; |
||
561 | - if ((*data ^ key->val) & key->mask) { |
||
562 | + if ((net_hdr_word(data) ^ key->val) & key->mask) { |
||
563 | n = rcu_dereference_bh(n->next); |
||
564 | goto next_knode; |
||
565 | } |
||
566 | @@ -218,8 +218,8 @@ check_terminal: |
||
567 | &hdata); |
||
568 | if (!data) |
||
569 | goto out; |
||
570 | - sel = ht->divisor & u32_hash_fold(*data, &n->sel, |
||
571 | - n->fshift); |
||
572 | + sel = ht->divisor & u32_hash_fold(net_hdr_word(data), |
||
573 | + &n->sel, n->fshift); |
||
574 | } |
||
575 | if (!(n->sel.flags & (TC_U32_VAROFFSET | TC_U32_OFFSET | TC_U32_EAT))) |
||
576 | goto next_ht; |
||
577 | --- a/net/ipv6/ip6_offload.c |
||
578 | +++ b/net/ipv6/ip6_offload.c |
||
579 | @@ -221,7 +221,7 @@ static struct sk_buff **ipv6_gro_receive |
||
580 | continue; |
||
581 | |||
582 | iph2 = (struct ipv6hdr *)(p->data + off); |
||
583 | - first_word = *(__be32 *)iph ^ *(__be32 *)iph2; |
||
584 | + first_word = net_hdr_word(iph) ^ net_hdr_word(iph2); |
||
585 | |||
586 | /* All fields must match except length and Traffic Class. |
||
587 | * XXX skbs on the gro_list have all been parsed and pulled |
||
588 | --- a/include/net/addrconf.h |
||
589 | +++ b/include/net/addrconf.h |
||
590 | @@ -47,7 +47,7 @@ struct prefix_info { |
||
591 | __be32 reserved2; |
||
592 | |||
593 | struct in6_addr prefix; |
||
594 | -}; |
||
595 | +} __attribute__((packed, aligned(2))); |
||
596 | |||
597 | #include <linux/netdevice.h> |
||
598 | #include <net/if_inet6.h> |
||
599 | --- a/include/net/inet_ecn.h |
||
600 | +++ b/include/net/inet_ecn.h |
||
601 | @@ -125,9 +125,9 @@ static inline int IP6_ECN_set_ce(struct |
||
602 | if (INET_ECN_is_not_ect(ipv6_get_dsfield(iph))) |
||
603 | return 0; |
||
604 | |||
605 | - from = *(__be32 *)iph; |
||
606 | + from = net_hdr_word(iph); |
||
607 | to = from | htonl(INET_ECN_CE << 20); |
||
608 | - *(__be32 *)iph = to; |
||
609 | + net_hdr_word(iph) = to; |
||
610 | if (skb->ip_summed == CHECKSUM_COMPLETE) |
||
611 | skb->csum = csum_add(csum_sub(skb->csum, (__force __wsum)from), |
||
612 | (__force __wsum)to); |
||
613 | @@ -136,7 +136,7 @@ static inline int IP6_ECN_set_ce(struct |
||
614 | |||
615 | static inline void IP6_ECN_clear(struct ipv6hdr *iph) |
||
616 | { |
||
617 | - *(__be32*)iph &= ~htonl(INET_ECN_MASK << 20); |
||
618 | + net_hdr_word(iph) &= ~htonl(INET_ECN_MASK << 20); |
||
619 | } |
||
620 | |||
621 | static inline void ipv6_copy_dscp(unsigned int dscp, struct ipv6hdr *inner) |
||
622 | --- a/include/net/ipv6.h |
||
623 | +++ b/include/net/ipv6.h |
||
624 | @@ -108,7 +108,7 @@ struct frag_hdr { |
||
625 | __u8 reserved; |
||
626 | __be16 frag_off; |
||
627 | __be32 identification; |
||
628 | -}; |
||
629 | +} __attribute__((packed, aligned(2))); |
||
630 | |||
631 | #define IP6_MF 0x0001 |
||
632 | #define IP6_OFFSET 0xFFF8 |
||
633 | @@ -437,8 +437,8 @@ static inline void __ipv6_addr_set_half( |
||
634 | } |
||
635 | #endif |
||
636 | #endif |
||
637 | - addr[0] = wh; |
||
638 | - addr[1] = wl; |
||
639 | + net_hdr_word(&addr[0]) = wh; |
||
640 | + net_hdr_word(&addr[1]) = wl; |
||
641 | } |
||
642 | |||
643 | static inline void ipv6_addr_set(struct in6_addr *addr, |
||
644 | @@ -497,6 +497,8 @@ static inline bool ipv6_prefix_equal(con |
||
645 | const __be32 *a1 = addr1->s6_addr32; |
||
646 | const __be32 *a2 = addr2->s6_addr32; |
||
647 | unsigned int pdw, pbi; |
||
648 | + /* Used for last <32-bit fraction of prefix */ |
||
649 | + u32 pbia1, pbia2; |
||
650 | |||
651 | /* check complete u32 in prefix */ |
||
652 | pdw = prefixlen >> 5; |
||
653 | @@ -505,7 +507,9 @@ static inline bool ipv6_prefix_equal(con |
||
654 | |||
655 | /* check incomplete u32 in prefix */ |
||
656 | pbi = prefixlen & 0x1f; |
||
657 | - if (pbi && ((a1[pdw] ^ a2[pdw]) & htonl((0xffffffff) << (32 - pbi)))) |
||
658 | + pbia1 = net_hdr_word(&a1[pdw]); |
||
659 | + pbia2 = net_hdr_word(&a2[pdw]); |
||
660 | + if (pbi && ((pbia1 ^ pbia2) & htonl((0xffffffff) << (32 - pbi)))) |
||
661 | return false; |
||
662 | |||
663 | return true; |
||
664 | @@ -634,13 +638,13 @@ static inline void ipv6_addr_set_v4mappe |
||
665 | */ |
||
666 | static inline int __ipv6_addr_diff32(const void *token1, const void *token2, int addrlen) |
||
667 | { |
||
668 | - const __be32 *a1 = token1, *a2 = token2; |
||
669 | + const struct in6_addr *a1 = token1, *a2 = token2; |
||
670 | int i; |
||
671 | |||
672 | addrlen >>= 2; |
||
673 | |||
674 | for (i = 0; i < addrlen; i++) { |
||
675 | - __be32 xb = a1[i] ^ a2[i]; |
||
676 | + __be32 xb = a1->s6_addr32[i] ^ a2->s6_addr32[i]; |
||
677 | if (xb) |
||
678 | return i * 32 + 31 - __fls(ntohl(xb)); |
||
679 | } |
||
680 | @@ -809,17 +813,18 @@ static inline int ip6_default_np_autolab |
||
681 | static inline void ip6_flow_hdr(struct ipv6hdr *hdr, unsigned int tclass, |
||
682 | __be32 flowlabel) |
||
683 | { |
||
684 | - *(__be32 *)hdr = htonl(0x60000000 | (tclass << 20)) | flowlabel; |
||
685 | + net_hdr_word((__be32 *)hdr) = |
||
686 | + htonl(0x60000000 | (tclass << 20)) | flowlabel; |
||
687 | } |
||
688 | |||
689 | static inline __be32 ip6_flowinfo(const struct ipv6hdr *hdr) |
||
690 | { |
||
691 | - return *(__be32 *)hdr & IPV6_FLOWINFO_MASK; |
||
692 | + return net_hdr_word((__be32 *)hdr) & IPV6_FLOWINFO_MASK; |
||
693 | } |
||
694 | |||
695 | static inline __be32 ip6_flowlabel(const struct ipv6hdr *hdr) |
||
696 | { |
||
697 | - return *(__be32 *)hdr & IPV6_FLOWLABEL_MASK; |
||
698 | + return net_hdr_word((__be32 *)hdr) & IPV6_FLOWLABEL_MASK; |
||
699 | } |
||
700 | |||
701 | static inline u8 ip6_tclass(__be32 flowinfo) |
||
702 | --- a/include/net/secure_seq.h |
||
703 | +++ b/include/net/secure_seq.h |
||
704 | @@ -3,6 +3,7 @@ |
||
705 | #define _NET_SECURE_SEQ |
||
706 | |||
707 | #include <linux/types.h> |
||
708 | +#include <linux/in6.h> |
||
709 | |||
710 | u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport); |
||
711 | u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr, |
||
712 | --- a/include/uapi/linux/in.h |
||
713 | +++ b/include/uapi/linux/in.h |
||
714 | @@ -84,7 +84,7 @@ enum { |
||
715 | /* Internet address. */ |
||
716 | struct in_addr { |
||
717 | __be32 s_addr; |
||
718 | -}; |
||
719 | +} __attribute__((packed, aligned(2))); |
||
720 | #endif |
||
721 | |||
722 | #define IP_TOS 1 |
||
723 | --- a/net/ipv6/ip6_fib.c |
||
724 | +++ b/net/ipv6/ip6_fib.c |
||
725 | @@ -137,7 +137,7 @@ static __be32 addr_bit_set(const void *t |
||
726 | * See include/asm-generic/bitops/le.h. |
||
727 | */ |
||
728 | return (__force __be32)(1 << ((~fn_bit ^ BITOP_BE32_SWIZZLE) & 0x1f)) & |
||
729 | - addr[fn_bit >> 5]; |
||
730 | + net_hdr_word(&addr[fn_bit >> 5]); |
||
731 | } |
||
732 | |||
733 | static struct fib6_node *node_alloc(void) |
||
734 | --- a/net/netfilter/nf_conntrack_proto_tcp.c |
||
735 | +++ b/net/netfilter/nf_conntrack_proto_tcp.c |
||
736 | @@ -447,7 +447,7 @@ static void tcp_sack(const struct sk_buf |
||
737 | |||
738 | /* Fast path for timestamp-only option */ |
||
739 | if (length == TCPOLEN_TSTAMP_ALIGNED |
||
740 | - && *(__be32 *)ptr == htonl((TCPOPT_NOP << 24) |
||
741 | + && net_hdr_word(ptr) == htonl((TCPOPT_NOP << 24) |
||
742 | | (TCPOPT_NOP << 16) |
||
743 | | (TCPOPT_TIMESTAMP << 8) |
||
744 | | TCPOLEN_TIMESTAMP)) |
||
745 | --- a/net/xfrm/xfrm_input.c |
||
746 | +++ b/net/xfrm/xfrm_input.c |
||
747 | @@ -193,8 +193,8 @@ int xfrm_parse_spi(struct sk_buff *skb, |
||
748 | if (!pskb_may_pull(skb, hlen)) |
||
749 | return -EINVAL; |
||
750 | |||
751 | - *spi = *(__be32 *)(skb_transport_header(skb) + offset); |
||
752 | - *seq = *(__be32 *)(skb_transport_header(skb) + offset_seq); |
||
753 | + *spi = net_hdr_word(skb_transport_header(skb) + offset); |
||
754 | + *seq = net_hdr_word(skb_transport_header(skb) + offset_seq); |
||
755 | return 0; |
||
756 | } |
||
757 | EXPORT_SYMBOL(xfrm_parse_spi); |
||
758 | --- a/net/ipv4/tcp_input.c |
||
759 | +++ b/net/ipv4/tcp_input.c |
||
760 | @@ -3858,14 +3858,16 @@ static bool tcp_parse_aligned_timestamp( |
||
761 | { |
||
762 | const __be32 *ptr = (const __be32 *)(th + 1); |
||
763 | |||
764 | - if (*ptr == htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
||
765 | - | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) { |
||
766 | + if (net_hdr_word(ptr) == |
||
767 | + htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | |
||
768 | + (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) { |
||
769 | tp->rx_opt.saw_tstamp = 1; |
||
770 | ++ptr; |
||
771 | - tp->rx_opt.rcv_tsval = ntohl(*ptr); |
||
772 | + tp->rx_opt.rcv_tsval = get_unaligned_be32(ptr); |
||
773 | ++ptr; |
||
774 | - if (*ptr) |
||
775 | - tp->rx_opt.rcv_tsecr = ntohl(*ptr) - tp->tsoffset; |
||
776 | + if (net_hdr_word(ptr)) |
||
777 | + tp->rx_opt.rcv_tsecr = get_unaligned_be32(ptr) - |
||
778 | + tp->tsoffset; |
||
779 | else |
||
780 | tp->rx_opt.rcv_tsecr = 0; |
||
781 | return true; |
||
782 | --- a/include/uapi/linux/if_pppox.h |
||
783 | +++ b/include/uapi/linux/if_pppox.h |
||
784 | @@ -51,6 +51,7 @@ struct pppoe_addr { |
||
785 | */ |
||
786 | struct pptp_addr { |
||
787 | __u16 call_id; |
||
788 | + __u16 pad; |
||
789 | struct in_addr sin_addr; |
||
790 | }; |
||
791 | |||
792 | --- a/net/ipv6/netfilter/nf_log_ipv6.c |
||
793 | +++ b/net/ipv6/netfilter/nf_log_ipv6.c |
||
794 | @@ -66,9 +66,9 @@ static void dump_ipv6_packet(struct nf_l |
||
795 | /* Max length: 44 "LEN=65535 TC=255 HOPLIMIT=255 FLOWLBL=FFFFF " */ |
||
796 | nf_log_buf_add(m, "LEN=%zu TC=%u HOPLIMIT=%u FLOWLBL=%u ", |
||
797 | ntohs(ih->payload_len) + sizeof(struct ipv6hdr), |
||
798 | - (ntohl(*(__be32 *)ih) & 0x0ff00000) >> 20, |
||
799 | + (ntohl(net_hdr_word(ih)) & 0x0ff00000) >> 20, |
||
800 | ih->hop_limit, |
||
801 | - (ntohl(*(__be32 *)ih) & 0x000fffff)); |
||
802 | + (ntohl(net_hdr_word(ih)) & 0x000fffff)); |
||
803 | |||
804 | fragment = 0; |
||
805 | ptr = ip6hoff + sizeof(struct ipv6hdr); |
||
806 | --- a/include/net/neighbour.h |
||
807 | +++ b/include/net/neighbour.h |
||
808 | @@ -265,8 +265,10 @@ static inline bool neigh_key_eq128(const |
||
809 | const u32 *n32 = (const u32 *)n->primary_key; |
||
810 | const u32 *p32 = pkey; |
||
811 | |||
812 | - return ((n32[0] ^ p32[0]) | (n32[1] ^ p32[1]) | |
||
813 | - (n32[2] ^ p32[2]) | (n32[3] ^ p32[3])) == 0; |
||
814 | + return ((n32[0] ^ net_hdr_word(&p32[0])) | |
||
815 | + (n32[1] ^ net_hdr_word(&p32[1])) | |
||
816 | + (n32[2] ^ net_hdr_word(&p32[2])) | |
||
817 | + (n32[3] ^ net_hdr_word(&p32[3]))) == 0; |
||
818 | } |
||
819 | |||
820 | static inline struct neighbour *___neigh_lookup_noref( |
||
821 | --- a/include/uapi/linux/netfilter_arp/arp_tables.h |
||
822 | +++ b/include/uapi/linux/netfilter_arp/arp_tables.h |
||
823 | @@ -70,7 +70,7 @@ struct arpt_arp { |
||
824 | __u8 flags; |
||
825 | /* Inverse flags */ |
||
826 | __u16 invflags; |
||
827 | -}; |
||
828 | +} __attribute__((aligned(4))); |
||
829 | |||
830 | /* Values for "flag" field in struct arpt_ip (general arp structure). |
||
831 | * No flags defined yet. |
||
832 | --- a/net/core/utils.c |
||
833 | +++ b/net/core/utils.c |
||
834 | @@ -424,8 +424,14 @@ void inet_proto_csum_replace16(__sum16 * |
||
835 | bool pseudohdr) |
||
836 | { |
||
837 | __be32 diff[] = { |
||
838 | - ~from[0], ~from[1], ~from[2], ~from[3], |
||
839 | - to[0], to[1], to[2], to[3], |
||
840 | + ~net_hdr_word(&from[0]), |
||
841 | + ~net_hdr_word(&from[1]), |
||
842 | + ~net_hdr_word(&from[2]), |
||
843 | + ~net_hdr_word(&from[3]), |
||
844 | + net_hdr_word(&to[0]), |
||
845 | + net_hdr_word(&to[1]), |
||
846 | + net_hdr_word(&to[2]), |
||
847 | + net_hdr_word(&to[3]), |
||
848 | }; |
||
849 | if (skb->ip_summed != CHECKSUM_PARTIAL) { |
||
850 | *sum = csum_fold(csum_partial(diff, sizeof(diff), |
||
851 | --- a/drivers/net/vxlan.c |
||
852 | +++ b/drivers/net/vxlan.c |
||
853 | @@ -1857,15 +1857,15 @@ static int vxlan_build_skb(struct sk_buf |
||
854 | return err; |
||
855 | |||
856 | vxh = __skb_push(skb, sizeof(*vxh)); |
||
857 | - vxh->vx_flags = VXLAN_HF_VNI; |
||
858 | - vxh->vx_vni = vxlan_vni_field(vni); |
||
859 | + net_hdr_word(&vxh->vx_flags) = VXLAN_HF_VNI; |
||
860 | + net_hdr_word(&vxh->vx_vni) = vxlan_vni_field(vni); |
||
861 | |||
862 | if (type & SKB_GSO_TUNNEL_REMCSUM) { |
||
863 | unsigned int start; |
||
864 | |||
865 | start = skb_checksum_start_offset(skb) - sizeof(struct vxlanhdr); |
||
866 | - vxh->vx_vni |= vxlan_compute_rco(start, skb->csum_offset); |
||
867 | - vxh->vx_flags |= VXLAN_HF_RCO; |
||
868 | + net_hdr_word(&vxh->vx_vni) |= vxlan_compute_rco(start, skb->csum_offset); |
||
869 | + net_hdr_word(&vxh->vx_flags) |= VXLAN_HF_RCO; |
||
870 | |||
871 | if (!skb_is_gso(skb)) { |
||
872 | skb->ip_summed = CHECKSUM_NONE; |
||
873 | --- a/include/linux/etherdevice.h |
||
874 | +++ b/include/linux/etherdevice.h |
||
875 | @@ -480,7 +480,7 @@ static inline bool is_etherdev_addr(cons |
||
876 | * @b: Pointer to Ethernet header |
||
877 | * |
||
878 | * Compare two Ethernet headers, returns 0 if equal. |
||
879 | - * This assumes that the network header (i.e., IP header) is 4-byte |
||
880 | + * This assumes that the network header (i.e., IP header) is 2-byte |
||
881 | * aligned OR the platform can handle unaligned access. This is the |
||
882 | * case for all packets coming into netif_receive_skb or similar |
||
883 | * entry points. |
||
884 | @@ -503,11 +503,12 @@ static inline unsigned long compare_ethe |
||
885 | fold |= *(unsigned long *)(a + 6) ^ *(unsigned long *)(b + 6); |
||
886 | return fold; |
||
887 | #else |
||
888 | - u32 *a32 = (u32 *)((u8 *)a + 2); |
||
889 | - u32 *b32 = (u32 *)((u8 *)b + 2); |
||
890 | + const u16 *a16 = a; |
||
891 | + const u16 *b16 = b; |
||
892 | |||
893 | - return (*(u16 *)a ^ *(u16 *)b) | (a32[0] ^ b32[0]) | |
||
894 | - (a32[1] ^ b32[1]) | (a32[2] ^ b32[2]); |
||
895 | + return (a16[0] ^ b16[0]) | (a16[1] ^ b16[1]) | (a16[2] ^ b16[2]) | |
||
896 | + (a16[3] ^ b16[3]) | (a16[4] ^ b16[4]) | (a16[5] ^ b16[5]) | |
||
897 | + (a16[6] ^ b16[6]); |
||
898 | #endif |
||
899 | } |
||
900 | |||
901 | --- a/net/ipv4/tcp_offload.c |
||
902 | +++ b/net/ipv4/tcp_offload.c |
||
903 | @@ -226,7 +226,7 @@ struct sk_buff **tcp_gro_receive(struct |
||
904 | |||
905 | th2 = tcp_hdr(p); |
||
906 | |||
907 | - if (*(u32 *)&th->source ^ *(u32 *)&th2->source) { |
||
908 | + if (net_hdr_word(&th->source) ^ net_hdr_word(&th2->source)) { |
||
909 | NAPI_GRO_CB(p)->same_flow = 0; |
||
910 | continue; |
||
911 | } |
||
912 | @@ -244,8 +244,8 @@ found: |
||
913 | ~(TCP_FLAG_CWR | TCP_FLAG_FIN | TCP_FLAG_PSH)); |
||
914 | flush |= (__force int)(th->ack_seq ^ th2->ack_seq); |
||
915 | for (i = sizeof(*th); i < thlen; i += 4) |
||
916 | - flush |= *(u32 *)((u8 *)th + i) ^ |
||
917 | - *(u32 *)((u8 *)th2 + i); |
||
918 | + flush |= net_hdr_word((u8 *)th + i) ^ |
||
919 | + net_hdr_word((u8 *)th2 + i); |
||
920 | |||
921 | /* When we receive our second frame we can made a decision on if we |
||
922 | * continue this flow as an atomic flow with a fixed ID or if we use |
||
923 | --- a/net/ipv6/netfilter/ip6table_mangle.c |
||
924 | +++ b/net/ipv6/netfilter/ip6table_mangle.c |
||
925 | @@ -50,7 +50,7 @@ ip6t_mangle_out(struct sk_buff *skb, con |
||
926 | hop_limit = ipv6_hdr(skb)->hop_limit; |
||
927 | |||
928 | /* flowlabel and prio (includes version, which shouldn't change either */ |
||
929 | - flowlabel = *((u_int32_t *)ipv6_hdr(skb)); |
||
930 | + flowlabel = net_hdr_word(ipv6_hdr(skb)); |
||
931 | |||
932 | ret = ip6t_do_table(skb, state, state->net->ipv6.ip6table_mangle); |
||
933 | |||
934 | @@ -59,7 +59,7 @@ ip6t_mangle_out(struct sk_buff *skb, con |
||
935 | !ipv6_addr_equal(&ipv6_hdr(skb)->daddr, &daddr) || |
||
936 | skb->mark != mark || |
||
937 | ipv6_hdr(skb)->hop_limit != hop_limit || |
||
938 | - flowlabel != *((u_int32_t *)ipv6_hdr(skb)))) { |
||
939 | + flowlabel != net_hdr_word(ipv6_hdr(skb)))) { |
||
940 | err = ip6_route_me_harder(state->net, skb); |
||
941 | if (err < 0) |
||
942 | ret = NF_DROP_ERR(err); |