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;
11 - carry = (csum < word[1]);
12 + csum = net_hdr_word(word++);
14 + w = net_hdr_word(word++);
20 - carry = (csum < word[2]);
21 + w = net_hdr_word(word++);
27 - carry = (csum < word[3]);
28 + w = net_hdr_word(word++);
36 - carry = (csum < *word);
37 + w = net_hdr_word(word++);
42 } while (word != stop);
44 return csum_fold(csum);
45 @@ -222,69 +226,4 @@ static inline __sum16 ip_compute_csum(co
46 return csum_fold(csum_partial(buff, len, 0));
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, unsigned short proto,
56 - " .set push # csum_ipv6_magic\n"
57 - " .set noreorder \n"
59 - " addu %0, %5 # proto (long in network byte order)\n"
60 - " sltu $1, %0, %5 \n"
63 - " addu %0, %6 # csum\n"
64 - " sltu $1, %0, %6 \n"
65 - " lw %1, 0(%2) # four words source address\n"
68 - " sltu $1, %0, %1 \n"
73 - " sltu $1, %0, %1 \n"
78 - " sltu $1, %0, %1 \n"
83 - " sltu $1, %0, %1 \n"
88 - " sltu $1, %0, %1 \n"
93 - " sltu $1, %0, %1 \n"
98 - " sltu $1, %0, %1 \n"
100 - " lw %1, 12(%3) \n"
103 - " sltu $1, %0, %1 \n"
105 - " addu %0, $1 # Add final carry\n"
107 - : "=r" (sum), "=r" (proto)
108 - : "r" (saddr), "r" (daddr),
109 - "0" (htonl(len)), "1" (htonl(proto)), "r" (sum));
111 - return csum_fold(sum);
114 #endif /* _ASM_CHECKSUM_H */
115 --- a/include/uapi/linux/ip.h
116 +++ b/include/uapi/linux/ip.h
117 @@ -102,7 +102,7 @@ struct iphdr {
120 /*The options start here. */
122 +} __attribute__((packed, aligned(2)));
126 --- a/include/uapi/linux/ipv6.h
127 +++ b/include/uapi/linux/ipv6.h
128 @@ -125,7 +125,7 @@ struct ipv6hdr {
130 struct in6_addr saddr;
131 struct in6_addr daddr;
133 +} __attribute__((packed, aligned(2)));
136 /* index values for the variables in ipv6_devconf */
137 --- a/include/uapi/linux/tcp.h
138 +++ b/include/uapi/linux/tcp.h
139 @@ -54,7 +54,7 @@ struct tcphdr {
144 +} __attribute__((packed, aligned(2)));
147 * The union cast uses a gcc extension to avoid aliasing problems
148 @@ -64,7 +64,7 @@ struct tcphdr {
153 +} __attribute__((packed, aligned(2)));
155 #define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3])
157 --- a/include/uapi/linux/udp.h
158 +++ b/include/uapi/linux/udp.h
159 @@ -24,7 +24,7 @@ struct udphdr {
164 +} __attribute__((packed, aligned(2)));
166 /* UDP socket options */
167 #define UDP_CORK 1 /* Never send partially complete segments */
168 --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
169 +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
170 @@ -41,8 +41,8 @@ static bool ipv4_pkt_to_tuple(const stru
174 - tuple->src.u3.ip = ap[0];
175 - tuple->dst.u3.ip = ap[1];
176 + tuple->src.u3.ip = net_hdr_word(ap++);
177 + tuple->dst.u3.ip = net_hdr_word(ap);
181 --- a/include/uapi/linux/icmp.h
182 +++ b/include/uapi/linux/icmp.h
183 @@ -80,7 +80,7 @@ struct icmphdr {
188 +} __attribute__((packed, aligned(2)));
192 --- a/include/uapi/linux/in6.h
193 +++ b/include/uapi/linux/in6.h
194 @@ -42,7 +42,7 @@ struct in6_addr {
195 #define s6_addr16 in6_u.u6_addr16
196 #define s6_addr32 in6_u.u6_addr32
199 +} __attribute__((packed, aligned(2)));
200 #endif /* __UAPI_DEF_IN6_ADDR */
202 #if __UAPI_DEF_SOCKADDR_IN6
203 --- a/net/ipv6/tcp_ipv6.c
204 +++ b/net/ipv6/tcp_ipv6.c
206 #include <linux/ipsec.h>
207 #include <linux/times.h>
208 #include <linux/slab.h>
209 +#include <asm/unaligned.h>
210 #include <linux/uaccess.h>
211 #include <linux/ipv6.h>
212 #include <linux/icmpv6.h>
213 @@ -844,10 +845,10 @@ static void tcp_v6_send_response(struct
214 topt = (__be32 *)(t1 + 1);
217 - *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
218 - (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP);
219 - *topt++ = htonl(tsval);
220 - *topt++ = htonl(tsecr);
221 + put_unaligned_be32((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
222 + (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP, topt++);
223 + put_unaligned_be32(tsval, topt++);
224 + put_unaligned_be32(tsecr, topt++);
227 #ifdef CONFIG_TCP_MD5SIG
228 --- a/include/linux/ipv6.h
229 +++ b/include/linux/ipv6.h
232 #define ipv6_optlen(p) (((p)->hdrlen+1) << 3)
233 #define ipv6_authlen(p) (((p)->hdrlen+2) << 2)
236 * This structure contains configuration options per IPv6 link.
238 --- a/net/ipv6/datagram.c
239 +++ b/net/ipv6/datagram.c
240 @@ -390,7 +390,7 @@ int ipv6_recv_error(struct sock *sk, str
241 ipv6_iface_scope_id(&sin->sin6_addr,
244 - ipv6_addr_set_v4mapped(*(__be32 *)(nh + serr->addr_offset),
245 + ipv6_addr_set_v4mapped(net_hdr_word(nh + serr->addr_offset),
247 sin->sin6_scope_id = 0;
249 @@ -724,12 +724,12 @@ int ip6_datagram_send_ctl(struct net *ne
252 if (fl6->flowlabel&IPV6_FLOWINFO_MASK) {
253 - if ((fl6->flowlabel^*(__be32 *)CMSG_DATA(cmsg))&~IPV6_FLOWINFO_MASK) {
254 + if ((fl6->flowlabel^net_hdr_word(CMSG_DATA(cmsg)))&~IPV6_FLOWINFO_MASK) {
259 - fl6->flowlabel = IPV6_FLOWINFO_MASK & *(__be32 *)CMSG_DATA(cmsg);
260 + fl6->flowlabel = IPV6_FLOWINFO_MASK & net_hdr_word(CMSG_DATA(cmsg));
263 case IPV6_2292HOPOPTS:
264 --- a/net/ipv6/ip6_gre.c
265 +++ b/net/ipv6/ip6_gre.c
266 @@ -482,11 +482,11 @@ static int ip6gre_rcv(struct sk_buff *sk
270 - key = *(__be32 *)(h + offset);
271 + key = net_hdr_word(h + offset);
275 - seqno = ntohl(*(__be32 *)(h + offset));
276 + seqno = ntohl(net_hdr_word(h + offset));
280 @@ -751,7 +751,7 @@ static netdev_tx_t ip6gre_xmit2(struct s
282 if (tunnel->parms.o_flags&GRE_SEQ) {
284 - *ptr = htonl(tunnel->o_seqno);
285 + net_hdr_word(ptr) = htonl(tunnel->o_seqno);
288 if (tunnel->parms.o_flags&GRE_KEY) {
289 @@ -847,7 +847,7 @@ static inline int ip6gre_xmit_ipv6(struc
291 dsfield = ipv6_get_dsfield(ipv6h);
292 if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
293 - fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_TCLASS_MASK);
294 + fl6.flowlabel |= net_hdr_word(ipv6h) & IPV6_TCLASS_MASK;
295 if (t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL)
296 fl6.flowlabel |= ip6_flowlabel(ipv6h);
297 if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
298 --- a/net/ipv6/ip6_tunnel.c
299 +++ b/net/ipv6/ip6_tunnel.c
300 @@ -1301,7 +1301,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, str
302 dsfield = ipv6_get_dsfield(ipv6h);
303 if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
304 - fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_TCLASS_MASK);
305 + fl6.flowlabel |= net_hdr_word(ipv6h) & IPV6_TCLASS_MASK;
306 if (t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL)
307 fl6.flowlabel |= ip6_flowlabel(ipv6h);
308 if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
309 --- a/net/ipv6/exthdrs.c
310 +++ b/net/ipv6/exthdrs.c
311 @@ -573,7 +573,7 @@ static bool ipv6_hop_jumbo(struct sk_buf
315 - pkt_len = ntohl(*(__be32 *)(nh + optoff + 2));
316 + pkt_len = ntohl(net_hdr_word(nh + optoff + 2));
317 if (pkt_len <= IPV6_MAXPLEN) {
318 IP6_INC_STATS_BH(net, ipv6_skb_idev(skb),
319 IPSTATS_MIB_INHDRERRORS);
320 --- a/include/linux/types.h
321 +++ b/include/linux/types.h
322 @@ -213,5 +213,11 @@ struct callback_head {
324 #define rcu_head callback_head
326 +struct net_hdr_word {
328 +} __attribute__((packed, aligned(2)));
330 +#define net_hdr_word(_p) (((struct net_hdr_word *) (_p))->words[0])
332 #endif /* __ASSEMBLY__ */
333 #endif /* _LINUX_TYPES_H */
334 --- a/net/ipv4/af_inet.c
335 +++ b/net/ipv4/af_inet.c
336 @@ -1329,8 +1329,8 @@ static struct sk_buff **inet_gro_receive
337 if (unlikely(ip_fast_csum((u8 *)iph, 5)))
340 - id = ntohl(*(__be32 *)&iph->id);
341 - flush = (u16)((ntohl(*(__be32 *)iph) ^ skb_gro_len(skb)) | (id & ~IP_DF));
342 + id = ntohl(net_hdr_word(&iph->id));
343 + flush = (u16)((ntohl(net_hdr_word(iph)) ^ skb_gro_len(skb)) | (id & ~IP_DF));
346 for (p = *head; p; p = p->next) {
347 --- a/net/ipv4/route.c
348 +++ b/net/ipv4/route.c
349 @@ -454,7 +454,7 @@ static struct neighbour *ipv4_neigh_look
351 pkey = &ip_hdr(skb)->daddr;
353 - n = __ipv4_neigh_lookup(dev, *(__force u32 *)pkey);
354 + n = __ipv4_neigh_lookup(dev, net_hdr_word(pkey));
357 return neigh_create(&arp_tbl, pkey, dev);
358 --- a/net/ipv4/tcp_output.c
359 +++ b/net/ipv4/tcp_output.c
360 @@ -446,48 +446,53 @@ static void tcp_options_write(__be32 *pt
361 u16 options = opts->options; /* mungable copy */
363 if (unlikely(OPTION_MD5 & options)) {
364 - *ptr++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
365 - (TCPOPT_MD5SIG << 8) | TCPOLEN_MD5SIG);
366 + net_hdr_word(ptr++) =
367 + htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
368 + (TCPOPT_MD5SIG << 8) | TCPOLEN_MD5SIG);
369 /* overload cookie hash location */
370 opts->hash_location = (__u8 *)ptr;
374 if (unlikely(opts->mss)) {
375 - *ptr++ = htonl((TCPOPT_MSS << 24) |
376 - (TCPOLEN_MSS << 16) |
378 + net_hdr_word(ptr++) =
379 + htonl((TCPOPT_MSS << 24) | (TCPOLEN_MSS << 16) |
383 if (likely(OPTION_TS & options)) {
384 if (unlikely(OPTION_SACK_ADVERTISE & options)) {
385 - *ptr++ = htonl((TCPOPT_SACK_PERM << 24) |
386 - (TCPOLEN_SACK_PERM << 16) |
387 - (TCPOPT_TIMESTAMP << 8) |
388 - TCPOLEN_TIMESTAMP);
389 + net_hdr_word(ptr++) =
390 + htonl((TCPOPT_SACK_PERM << 24) |
391 + (TCPOLEN_SACK_PERM << 16) |
392 + (TCPOPT_TIMESTAMP << 8) |
393 + TCPOLEN_TIMESTAMP);
394 options &= ~OPTION_SACK_ADVERTISE;
396 - *ptr++ = htonl((TCPOPT_NOP << 24) |
397 - (TCPOPT_NOP << 16) |
398 - (TCPOPT_TIMESTAMP << 8) |
399 - TCPOLEN_TIMESTAMP);
400 + net_hdr_word(ptr++) =
401 + htonl((TCPOPT_NOP << 24) |
402 + (TCPOPT_NOP << 16) |
403 + (TCPOPT_TIMESTAMP << 8) |
404 + TCPOLEN_TIMESTAMP);
406 - *ptr++ = htonl(opts->tsval);
407 - *ptr++ = htonl(opts->tsecr);
408 + net_hdr_word(ptr++) = htonl(opts->tsval);
409 + net_hdr_word(ptr++) = htonl(opts->tsecr);
412 if (unlikely(OPTION_SACK_ADVERTISE & options)) {
413 - *ptr++ = htonl((TCPOPT_NOP << 24) |
414 - (TCPOPT_NOP << 16) |
415 - (TCPOPT_SACK_PERM << 8) |
416 - TCPOLEN_SACK_PERM);
417 + net_hdr_word(ptr++) =
418 + htonl((TCPOPT_NOP << 24) |
419 + (TCPOPT_NOP << 16) |
420 + (TCPOPT_SACK_PERM << 8) |
421 + TCPOLEN_SACK_PERM);
424 if (unlikely(OPTION_WSCALE & options)) {
425 - *ptr++ = htonl((TCPOPT_NOP << 24) |
426 - (TCPOPT_WINDOW << 16) |
427 - (TCPOLEN_WINDOW << 8) |
429 + net_hdr_word(ptr++) =
430 + htonl((TCPOPT_NOP << 24) |
431 + (TCPOPT_WINDOW << 16) |
432 + (TCPOLEN_WINDOW << 8) |
436 if (unlikely(opts->num_sack_blocks)) {
437 @@ -495,16 +500,17 @@ static void tcp_options_write(__be32 *pt
438 tp->duplicate_sack : tp->selective_acks;
441 - *ptr++ = htonl((TCPOPT_NOP << 24) |
442 - (TCPOPT_NOP << 16) |
443 - (TCPOPT_SACK << 8) |
444 - (TCPOLEN_SACK_BASE + (opts->num_sack_blocks *
445 + net_hdr_word(ptr++) =
446 + htonl((TCPOPT_NOP << 24) |
447 + (TCPOPT_NOP << 16) |
448 + (TCPOPT_SACK << 8) |
449 + (TCPOLEN_SACK_BASE + (opts->num_sack_blocks *
450 TCPOLEN_SACK_PERBLOCK)));
452 for (this_sack = 0; this_sack < opts->num_sack_blocks;
454 - *ptr++ = htonl(sp[this_sack].start_seq);
455 - *ptr++ = htonl(sp[this_sack].end_seq);
456 + net_hdr_word(ptr++) = htonl(sp[this_sack].start_seq);
457 + net_hdr_word(ptr++) = htonl(sp[this_sack].end_seq);
460 tp->rx_opt.dsack = 0;
461 @@ -513,9 +519,10 @@ static void tcp_options_write(__be32 *pt
462 if (unlikely(OPTION_FAST_OPEN_COOKIE & options)) {
463 struct tcp_fastopen_cookie *foc = opts->fastopen_cookie;
465 - *ptr++ = htonl((TCPOPT_EXP << 24) |
466 - ((TCPOLEN_EXP_FASTOPEN_BASE + foc->len) << 16) |
467 - TCPOPT_FASTOPEN_MAGIC);
468 + net_hdr_word(ptr++) =
469 + htonl((TCPOPT_EXP << 24) |
470 + ((TCPOLEN_EXP_FASTOPEN_BASE + foc->len) << 16) |
471 + TCPOPT_FASTOPEN_MAGIC);
473 memcpy(ptr, foc->val, foc->len);
474 if ((foc->len & 3) == 2) {
475 --- a/net/ipv4/igmp.c
476 +++ b/net/ipv4/igmp.c
477 @@ -495,7 +495,7 @@ static struct sk_buff *add_grec(struct s
480 psrc = (__be32 *)skb_put(skb, sizeof(__be32));
481 - *psrc = psf->sf_inaddr;
482 + net_hdr_word(psrc) = psf->sf_inaddr;
484 if ((type == IGMPV3_ALLOW_NEW_SOURCES ||
485 type == IGMPV3_BLOCK_OLD_SOURCES) && psf->sf_crcount) {
486 --- a/include/uapi/linux/igmp.h
487 +++ b/include/uapi/linux/igmp.h
488 @@ -32,7 +32,7 @@ struct igmphdr {
489 __u8 code; /* For newer IGMP */
493 +} __attribute__((packed, aligned(2)));
495 /* V3 group record types [grec_type] */
496 #define IGMPV3_MODE_IS_INCLUDE 1
497 @@ -48,7 +48,7 @@ struct igmpv3_grec {
502 +} __attribute__((packed, aligned(2)));
504 struct igmpv3_report {
506 @@ -57,7 +57,7 @@ struct igmpv3_report {
509 struct igmpv3_grec grec[0];
511 +} __attribute__((packed, aligned(2)));
513 struct igmpv3_query {
515 @@ -78,7 +78,7 @@ struct igmpv3_query {
520 +} __attribute__((packed, aligned(2)));
522 #define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* From RFC1112 */
523 #define IGMP_HOST_MEMBERSHIP_REPORT 0x12 /* Ditto */
524 --- a/net/core/flow_dissector.c
525 +++ b/net/core/flow_dissector.c
526 @@ -53,7 +53,7 @@ __be32 __skb_flow_get_ports(const struct
527 ports = __skb_header_pointer(skb, thoff + poff,
528 sizeof(_ports), data, hlen, &_ports);
531 + return (__be32)net_hdr_word(ports);
535 --- a/include/uapi/linux/icmpv6.h
536 +++ b/include/uapi/linux/icmpv6.h
537 @@ -76,7 +76,7 @@ struct icmp6hdr {
538 #define icmp6_addrconf_other icmp6_dataun.u_nd_ra.other
539 #define icmp6_rt_lifetime icmp6_dataun.u_nd_ra.rt_lifetime
540 #define icmp6_router_pref icmp6_dataun.u_nd_ra.router_pref
542 +} __attribute__((packed, aligned(2)));
545 #define ICMPV6_ROUTER_PREF_LOW 0x3
546 --- a/include/net/ndisc.h
547 +++ b/include/net/ndisc.h
548 @@ -76,7 +76,7 @@ struct ra_msg {
549 struct icmp6hdr icmph;
550 __be32 reachable_time;
551 __be32 retrans_timer;
553 +} __attribute__((packed, aligned(2)));
556 struct icmp6hdr icmph;
557 @@ -148,10 +148,10 @@ static inline u32 ndisc_hashfn(const voi
559 const u32 *p32 = pkey;
561 - return (((p32[0] ^ hash32_ptr(dev)) * hash_rnd[0]) +
562 - (p32[1] * hash_rnd[1]) +
563 - (p32[2] * hash_rnd[2]) +
564 - (p32[3] * hash_rnd[3]));
565 + return (((net_hdr_word(&p32[0]) ^ hash32_ptr(dev)) * hash_rnd[0]) +
566 + (net_hdr_word(&p32[1]) * hash_rnd[1]) +
567 + (net_hdr_word(&p32[2]) * hash_rnd[2]) +
568 + (net_hdr_word(&p32[3]) * hash_rnd[3]));
571 static inline struct neighbour *__ipv6_neigh_lookup_noref(struct net_device *dev, const void *pkey)
572 @@ -168,8 +168,10 @@ static inline struct neighbour *__ipv6_n
573 n = rcu_dereference_bh(n->next)) {
574 u32 *n32 = (u32 *) n->primary_key;
576 - ((n32[0] ^ p32[0]) | (n32[1] ^ p32[1]) |
577 - (n32[2] ^ p32[2]) | (n32[3] ^ p32[3])) == 0)
578 + ((n32[0] ^ net_hdr_word(&p32[0])) |
579 + (n32[1] ^ net_hdr_word(&p32[1])) |
580 + (n32[2] ^ net_hdr_word(&p32[2])) |
581 + (n32[3] ^ net_hdr_word(&p32[3]))) == 0)
585 --- a/net/sched/cls_u32.c
586 +++ b/net/sched/cls_u32.c
587 @@ -151,7 +151,7 @@ next_knode:
588 data = skb_header_pointer(skb, toff, 4, &hdata);
591 - if ((*data ^ key->val) & key->mask) {
592 + if ((net_hdr_word(data) ^ key->val) & key->mask) {
593 n = rcu_dereference_bh(n->next);
596 @@ -204,8 +204,8 @@ check_terminal:
600 - sel = ht->divisor & u32_hash_fold(*data, &n->sel,
602 + sel = ht->divisor & u32_hash_fold(net_hdr_word(data),
603 + &n->sel, n->fshift);
605 if (!(n->sel.flags & (TC_U32_VAROFFSET | TC_U32_OFFSET | TC_U32_EAT)))
607 --- a/net/ipv6/ip6_offload.c
608 +++ b/net/ipv6/ip6_offload.c
609 @@ -224,7 +224,7 @@ static struct sk_buff **ipv6_gro_receive
612 iph2 = (struct ipv6hdr *)(p->data + off);
613 - first_word = *(__be32 *)iph ^ *(__be32 *)iph2;
614 + first_word = net_hdr_word(iph) ^ net_hdr_word(iph2);
616 /* All fields must match except length and Traffic Class.
617 * XXX skbs on the gro_list have all been parsed and pulled
618 --- a/include/net/addrconf.h
619 +++ b/include/net/addrconf.h
620 @@ -45,7 +45,7 @@ struct prefix_info {
623 struct in6_addr prefix;
625 +} __attribute__((packed, aligned(2)));
628 #include <linux/netdevice.h>
629 --- a/include/net/inet_ecn.h
630 +++ b/include/net/inet_ecn.h
631 @@ -124,9 +124,9 @@ static inline int IP6_ECN_set_ce(struct
632 if (INET_ECN_is_not_ect(ipv6_get_dsfield(iph)))
635 - from = *(__be32 *)iph;
636 + from = net_hdr_word(iph);
637 to = from | htonl(INET_ECN_CE << 20);
638 - *(__be32 *)iph = to;
639 + net_hdr_word(iph) = to;
640 if (skb->ip_summed == CHECKSUM_COMPLETE)
641 skb->csum = csum_add(csum_sub(skb->csum, from), to);
643 @@ -134,7 +134,7 @@ static inline int IP6_ECN_set_ce(struct
645 static inline void IP6_ECN_clear(struct ipv6hdr *iph)
647 - *(__be32*)iph &= ~htonl(INET_ECN_MASK << 20);
648 + net_hdr_word(iph) &= ~htonl(INET_ECN_MASK << 20);
651 static inline void ipv6_copy_dscp(unsigned int dscp, struct ipv6hdr *inner)
652 --- a/include/net/ipv6.h
653 +++ b/include/net/ipv6.h
654 @@ -109,7 +109,7 @@ struct frag_hdr {
657 __be32 identification;
659 +} __attribute__((packed, aligned(2)));
661 #define IP6_MF 0x0001
662 #define IP6_OFFSET 0xFFF8
663 @@ -417,8 +417,8 @@ static inline void __ipv6_addr_set_half(
669 + net_hdr_word(&addr[0]) = wh;
670 + net_hdr_word(&addr[1]) = wl;
673 static inline void ipv6_addr_set(struct in6_addr *addr,
674 @@ -477,6 +477,8 @@ static inline bool ipv6_prefix_equal(con
675 const __be32 *a1 = addr1->s6_addr32;
676 const __be32 *a2 = addr2->s6_addr32;
677 unsigned int pdw, pbi;
678 + /* Used for last <32-bit fraction of prefix */
681 /* check complete u32 in prefix */
682 pdw = prefixlen >> 5;
683 @@ -485,7 +487,9 @@ static inline bool ipv6_prefix_equal(con
685 /* check incomplete u32 in prefix */
686 pbi = prefixlen & 0x1f;
687 - if (pbi && ((a1[pdw] ^ a2[pdw]) & htonl((0xffffffff) << (32 - pbi))))
688 + pbia1 = net_hdr_word(&a1[pdw]);
689 + pbia2 = net_hdr_word(&a2[pdw]);
690 + if (pbi && ((pbia1 ^ pbia2) & htonl((0xffffffff) << (32 - pbi))))
694 @@ -629,13 +633,13 @@ static inline void ipv6_addr_set_v4mappe
696 static inline int __ipv6_addr_diff32(const void *token1, const void *token2, int addrlen)
698 - const __be32 *a1 = token1, *a2 = token2;
699 + const struct in6_addr *a1 = token1, *a2 = token2;
704 for (i = 0; i < addrlen; i++) {
705 - __be32 xb = a1[i] ^ a2[i];
706 + __be32 xb = a1->s6_addr32[i] ^ a2->s6_addr32[i];
708 return i * 32 + 31 - __fls(ntohl(xb));
710 @@ -759,17 +763,18 @@ static inline __be32 ip6_make_flowlabel(
711 static inline void ip6_flow_hdr(struct ipv6hdr *hdr, unsigned int tclass,
714 - *(__be32 *)hdr = htonl(0x60000000 | (tclass << 20)) | flowlabel;
715 + net_hdr_word((__be32 *)hdr) =
716 + htonl(0x60000000 | (tclass << 20)) | flowlabel;
719 static inline __be32 ip6_flowinfo(const struct ipv6hdr *hdr)
721 - return *(__be32 *)hdr & IPV6_FLOWINFO_MASK;
722 + return net_hdr_word((__be32 *)hdr) & IPV6_FLOWINFO_MASK;
725 static inline __be32 ip6_flowlabel(const struct ipv6hdr *hdr)
727 - return *(__be32 *)hdr & IPV6_FLOWLABEL_MASK;
728 + return net_hdr_word((__be32 *)hdr) & IPV6_FLOWLABEL_MASK;
731 static inline u8 ip6_tclass(__be32 flowinfo)
732 --- a/include/net/secure_seq.h
733 +++ b/include/net/secure_seq.h
735 #define _NET_SECURE_SEQ
737 #include <linux/types.h>
738 +#include <linux/in6.h>
740 u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
741 u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
742 --- a/include/uapi/linux/in.h
743 +++ b/include/uapi/linux/in.h
744 @@ -78,7 +78,7 @@ enum {
745 /* Internet address. */
749 +} __attribute__((packed, aligned(2)));
753 --- a/net/core/secure_seq.c
754 +++ b/net/core/secure_seq.c
755 @@ -46,11 +46,12 @@ __u32 secure_tcpv6_sequence_number(const
756 u32 secret[MD5_MESSAGE_BYTES / 4];
757 u32 hash[MD5_DIGEST_WORDS];
759 + const struct in6_addr *daddr6 = (struct in6_addr *) daddr;
762 memcpy(hash, saddr, 16);
763 for (i = 0; i < 4; i++)
764 - secret[i] = net_secret[i] + (__force u32)daddr[i];
765 + secret[i] = net_secret[i] + (__force u32)daddr6->s6_addr32[i];
766 secret[4] = net_secret[4] +
767 (((__force u16)sport << 16) + (__force u16)dport);
768 for (i = 5; i < MD5_MESSAGE_BYTES / 4; i++)
769 @@ -68,11 +69,12 @@ u32 secure_ipv6_port_ephemeral(const __b
770 u32 secret[MD5_MESSAGE_BYTES / 4];
771 u32 hash[MD5_DIGEST_WORDS];
773 + const struct in6_addr *daddr6 = (struct in6_addr *) daddr;
776 memcpy(hash, saddr, 16);
777 for (i = 0; i < 4; i++)
778 - secret[i] = net_secret[i] + (__force u32) daddr[i];
779 + secret[i] = net_secret[i] + (__force u32) daddr6->s6_addr32[i];
780 secret[4] = net_secret[4] + (__force u32)dport;
781 for (i = 5; i < MD5_MESSAGE_BYTES / 4; i++)
782 secret[i] = net_secret[i];
783 @@ -150,11 +152,12 @@ u64 secure_dccpv6_sequence_number(__be32
784 u32 hash[MD5_DIGEST_WORDS];
787 + const struct in6_addr *daddr6 = (struct in6_addr *) daddr;
790 memcpy(hash, saddr, 16);
791 for (i = 0; i < 4; i++)
792 - secret[i] = net_secret[i] + daddr[i];
793 + secret[i] = net_secret[i] + daddr6->s6_addr32[i];
794 secret[4] = net_secret[4] +
795 (((__force u16)sport << 16) + (__force u16)dport);
796 for (i = 5; i < MD5_MESSAGE_BYTES / 4; i++)
797 --- a/net/ipv6/ip6_fib.c
798 +++ b/net/ipv6/ip6_fib.c
799 @@ -137,7 +137,7 @@ static __be32 addr_bit_set(const void *t
800 * See include/asm-generic/bitops/le.h.
802 return (__force __be32)(1 << ((~fn_bit ^ BITOP_BE32_SWIZZLE) & 0x1f)) &
804 + net_hdr_word(&addr[fn_bit >> 5]);
807 static struct fib6_node *node_alloc(void)
808 --- a/net/netfilter/nf_conntrack_proto_tcp.c
809 +++ b/net/netfilter/nf_conntrack_proto_tcp.c
810 @@ -456,7 +456,7 @@ static void tcp_sack(const struct sk_buf
812 /* Fast path for timestamp-only option */
813 if (length == TCPOLEN_TSTAMP_ALIGNED
814 - && *(__be32 *)ptr == htonl((TCPOPT_NOP << 24)
815 + && net_hdr_word(ptr) == htonl((TCPOPT_NOP << 24)
817 | (TCPOPT_TIMESTAMP << 8)
818 | TCPOLEN_TIMESTAMP))
819 --- a/net/xfrm/xfrm_input.c
820 +++ b/net/xfrm/xfrm_input.c
821 @@ -154,8 +154,8 @@ int xfrm_parse_spi(struct sk_buff *skb,
822 if (!pskb_may_pull(skb, hlen))
825 - *spi = *(__be32 *)(skb_transport_header(skb) + offset);
826 - *seq = *(__be32 *)(skb_transport_header(skb) + offset_seq);
827 + *spi = net_hdr_word(skb_transport_header(skb) + offset);
828 + *seq = net_hdr_word(skb_transport_header(skb) + offset_seq);
832 --- a/net/ipv4/tcp_input.c
833 +++ b/net/ipv4/tcp_input.c
834 @@ -3682,14 +3682,16 @@ static bool tcp_parse_aligned_timestamp(
836 const __be32 *ptr = (const __be32 *)(th + 1);
838 - if (*ptr == htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16)
839 - | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) {
840 + if (net_hdr_word(ptr) ==
841 + htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
842 + (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) {
843 tp->rx_opt.saw_tstamp = 1;
845 - tp->rx_opt.rcv_tsval = ntohl(*ptr);
846 + tp->rx_opt.rcv_tsval = get_unaligned_be32(ptr);
849 - tp->rx_opt.rcv_tsecr = ntohl(*ptr) - tp->tsoffset;
850 + if (net_hdr_word(ptr))
851 + tp->rx_opt.rcv_tsecr = get_unaligned_be32(ptr) -
854 tp->rx_opt.rcv_tsecr = 0;
856 --- a/include/uapi/linux/if_pppox.h
857 +++ b/include/uapi/linux/if_pppox.h
858 @@ -47,6 +47,7 @@ struct pppoe_addr {
863 struct in_addr sin_addr;
866 --- a/net/ipv6/netfilter/nf_log_ipv6.c
867 +++ b/net/ipv6/netfilter/nf_log_ipv6.c
868 @@ -63,9 +63,9 @@ static void dump_ipv6_packet(struct nf_l
869 /* Max length: 44 "LEN=65535 TC=255 HOPLIMIT=255 FLOWLBL=FFFFF " */
870 nf_log_buf_add(m, "LEN=%Zu TC=%u HOPLIMIT=%u FLOWLBL=%u ",
871 ntohs(ih->payload_len) + sizeof(struct ipv6hdr),
872 - (ntohl(*(__be32 *)ih) & 0x0ff00000) >> 20,
873 + (ntohl(net_hdr_word(ih)) & 0x0ff00000) >> 20,
875 - (ntohl(*(__be32 *)ih) & 0x000fffff));
876 + (ntohl(net_hdr_word(ih)) & 0x000fffff));
879 ptr = ip6hoff + sizeof(struct ipv6hdr);