1 --- a/arch/mips/include/asm/checksum.h
2 +++ b/arch/mips/include/asm/checksum.h
4 #define _ASM_CHECKSUM_H
7 +#include <linux/unaligned/packed_struct.h>
9 #include <asm/uaccess.h>
11 @@ -104,26 +105,30 @@ static inline __sum16 ip_fast_csum(const
12 const unsigned int *stop = word + ihl;
19 - carry = (csum < word[1]);
20 + csum = __get_unaligned_cpu32(word++);
22 + w = __get_unaligned_cpu32(word++);
28 - carry = (csum < word[2]);
29 + w = __get_unaligned_cpu32(word++);
35 - carry = (csum < word[3]);
36 + w = __get_unaligned_cpu32(word++);
44 - carry = (csum < *word);
45 + w = __get_unaligned_cpu32(word++);
50 } while (word != stop);
52 return csum_fold(csum);
53 --- a/include/uapi/linux/ip.h
54 +++ b/include/uapi/linux/ip.h
55 @@ -102,7 +102,7 @@ struct iphdr {
58 /*The options start here. */
60 +} __packed __attribute__((aligned(2)));
64 --- a/include/uapi/linux/ipv6.h
65 +++ b/include/uapi/linux/ipv6.h
66 @@ -123,7 +123,7 @@ struct ipv6hdr {
68 struct in6_addr saddr;
69 struct in6_addr daddr;
71 +} __packed __attribute__((aligned(2)));
74 /* index values for the variables in ipv6_devconf */
75 --- a/include/uapi/linux/tcp.h
76 +++ b/include/uapi/linux/tcp.h
77 @@ -54,7 +54,7 @@ struct tcphdr {
82 +} __packed __attribute__((aligned(2)));
85 * The union cast uses a gcc extension to avoid aliasing problems
86 @@ -64,7 +64,7 @@ struct tcphdr {
91 +} __packed __attribute__((aligned(2)));
93 #define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3])
95 --- a/include/uapi/linux/udp.h
96 +++ b/include/uapi/linux/udp.h
97 @@ -24,7 +24,7 @@ struct udphdr {
102 +} __packed __attribute__((aligned(2)));
104 /* UDP socket options */
105 #define UDP_CORK 1 /* Never send partially complete segments */
106 --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
107 +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
109 #include <linux/skbuff.h>
110 #include <linux/icmp.h>
111 #include <linux/sysctl.h>
112 +#include <linux/unaligned/packed_struct.h>
113 #include <net/route.h>
116 @@ -39,8 +40,8 @@ static bool ipv4_pkt_to_tuple(const stru
120 - tuple->src.u3.ip = ap[0];
121 - tuple->dst.u3.ip = ap[1];
122 + tuple->src.u3.ip = __get_unaligned_cpu32(ap++);
123 + tuple->dst.u3.ip = __get_unaligned_cpu32(ap);
127 --- a/include/uapi/linux/icmp.h
128 +++ b/include/uapi/linux/icmp.h
129 @@ -80,7 +80,7 @@ struct icmphdr {
134 +} __packed __attribute__((aligned(2)));
138 --- a/net/ipv4/tcp_input.c
139 +++ b/net/ipv4/tcp_input.c
140 @@ -3842,13 +3842,14 @@ static bool tcp_parse_aligned_timestamp(
142 const __be32 *ptr = (const __be32 *)(th + 1);
144 - if (*ptr == htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16)
145 - | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) {
146 + if (__get_unaligned_cpu32(ptr) ==
147 + htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
148 + (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) {
149 tp->rx_opt.saw_tstamp = 1;
151 - tp->rx_opt.rcv_tsval = ntohl(*ptr);
152 + tp->rx_opt.rcv_tsval = get_unaligned_be32(ptr);
154 - tp->rx_opt.rcv_tsecr = ntohl(*ptr);
155 + tp->rx_opt.rcv_tsecr = get_unaligned_be32(ptr);