[scripts] env: colorize git output
[openwrt.git] / target / linux / ar71xx / patches-3.3 / 902-unaligned_access_hacks.patch
1 --- a/arch/mips/include/asm/checksum.h
2 +++ b/arch/mips/include/asm/checksum.h
3 @@ -12,6 +12,7 @@
4 #define _ASM_CHECKSUM_H
5
6 #include <linux/in6.h>
7 +#include <linux/unaligned/packed_struct.h>
8
9 #include <asm/uaccess.h>
10
11 @@ -104,26 +105,30 @@ static inline __sum16 ip_fast_csum(const
12 const unsigned int *stop = word + ihl;
13 unsigned int csum;
14 int carry;
15 + unsigned int w;
16
17 - csum = word[0];
18 - csum += word[1];
19 - carry = (csum < word[1]);
20 + csum = __get_unaligned_cpu32(word++);
21 +
22 + w = __get_unaligned_cpu32(word++);
23 + csum += w;
24 + carry = (csum < w);
25 csum += carry;
26
27 - csum += word[2];
28 - carry = (csum < word[2]);
29 + w = __get_unaligned_cpu32(word++);
30 + csum += w;
31 + carry = (csum < w);
32 csum += carry;
33
34 - csum += word[3];
35 - carry = (csum < word[3]);
36 + w = __get_unaligned_cpu32(word++);
37 + csum += w;
38 + carry = (csum < w);
39 csum += carry;
40
41 - word += 4;
42 do {
43 - csum += *word;
44 - carry = (csum < *word);
45 + w = __get_unaligned_cpu32(word++);
46 + csum += w;
47 + carry = (csum < w);
48 csum += carry;
49 - word++;
50 } while (word != stop);
51
52 return csum_fold(csum);
53 --- a/include/linux/ip.h
54 +++ b/include/linux/ip.h
55 @@ -102,7 +102,7 @@ struct iphdr {
56 __be32 saddr;
57 __be32 daddr;
58 /*The options start here. */
59 -};
60 +} __packed;
61
62 #ifdef __KERNEL__
63 #include <linux/skbuff.h>
64 --- a/include/linux/ipv6.h
65 +++ b/include/linux/ipv6.h
66 @@ -126,7 +126,7 @@ struct ipv6hdr {
67
68 struct in6_addr saddr;
69 struct in6_addr daddr;
70 -};
71 +} __packed;
72
73 #ifdef __KERNEL__
74 /*
75 --- a/include/linux/tcp.h
76 +++ b/include/linux/tcp.h
77 @@ -54,7 +54,7 @@ struct tcphdr {
78 __be16 window;
79 __sum16 check;
80 __be16 urg_ptr;
81 -};
82 +} __packed;
83
84 /*
85 * The union cast uses a gcc extension to avoid aliasing problems
86 --- a/include/linux/udp.h
87 +++ b/include/linux/udp.h
88 @@ -24,7 +24,7 @@ struct udphdr {
89 __be16 dest;
90 __be16 len;
91 __sum16 check;
92 -};
93 +} __packed;
94
95 /* UDP socket options */
96 #define UDP_CORK 1 /* Never send partially complete segments */
97 --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
98 +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
99 @@ -14,6 +14,7 @@
100 #include <linux/skbuff.h>
101 #include <linux/icmp.h>
102 #include <linux/sysctl.h>
103 +#include <linux/unaligned/packed_struct.h>
104 #include <net/route.h>
105 #include <net/ip.h>
106
107 @@ -44,8 +45,8 @@ static bool ipv4_pkt_to_tuple(const stru
108 if (ap == NULL)
109 return false;
110
111 - tuple->src.u3.ip = ap[0];
112 - tuple->dst.u3.ip = ap[1];
113 + tuple->src.u3.ip = __get_unaligned_cpu32(ap++);
114 + tuple->dst.u3.ip = __get_unaligned_cpu32(ap);
115
116 return true;
117 }
This page took 0.04888 seconds and 5 git commands to generate.