diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-04-20 22:06:52 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-04-20 22:06:52 -0400 |
commit | 0eae88f31ca2b88911ce843452054139e028771f (patch) | |
tree | 90f50197d8e1e50e3621e9c525bd4ca2634fe368 /net/ipv6 | |
parent | cb903bf4ee2d6e53210e2174d363e10698112042 (diff) |
net: Fix various endianness glitches
Sparse can help us find endianness bugs, but we need to make some
cleanups to be able to more easily spot real bugs.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/addrconf.c | 3 | ||||
-rw-r--r-- | net/ipv6/ip6_fib.c | 3 | ||||
-rw-r--r-- | net/ipv6/tcp_ipv6.c | 4 | ||||
-rw-r--r-- | net/ipv6/udp.c | 4 |
4 files changed, 8 insertions, 6 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 7cba8845242f..34d2d649e396 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -588,7 +588,8 @@ static u32 ipv6_addr_hash(const struct in6_addr *addr) | |||
588 | * We perform the hash function over the last 64 bits of the address | 588 | * We perform the hash function over the last 64 bits of the address |
589 | * This will include the IEEE address token on links that support it. | 589 | * This will include the IEEE address token on links that support it. |
590 | */ | 590 | */ |
591 | return jhash_2words(addr->s6_addr32[2], addr->s6_addr32[3], 0) | 591 | return jhash_2words((__force u32)addr->s6_addr32[2], |
592 | (__force u32)addr->s6_addr32[3], 0) | ||
592 | & (IN6_ADDR_HSIZE - 1); | 593 | & (IN6_ADDR_HSIZE - 1); |
593 | } | 594 | } |
594 | 595 | ||
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index dc6e0b8f260d..92a122b7795d 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c | |||
@@ -144,7 +144,8 @@ static __inline__ __be32 addr_bit_set(void *token, int fn_bit) | |||
144 | * htonl(1 << ((~fn_bit)&0x1F)) | 144 | * htonl(1 << ((~fn_bit)&0x1F)) |
145 | * See include/asm-generic/bitops/le.h. | 145 | * See include/asm-generic/bitops/le.h. |
146 | */ | 146 | */ |
147 | return (1 << ((~fn_bit ^ BITOP_BE32_SWIZZLE) & 0x1f)) & addr[fn_bit >> 5]; | 147 | return (__force __be32)(1 << ((~fn_bit ^ BITOP_BE32_SWIZZLE) & 0x1f)) & |
148 | addr[fn_bit >> 5]; | ||
148 | } | 149 | } |
149 | 150 | ||
150 | static __inline__ struct fib6_node * node_alloc(void) | 151 | static __inline__ struct fib6_node * node_alloc(void) |
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index bd5ef7b6e48e..a92b4a5cd8bf 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -1234,12 +1234,12 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb) | |||
1234 | goto drop_and_free; | 1234 | goto drop_and_free; |
1235 | 1235 | ||
1236 | /* Secret recipe starts with IP addresses */ | 1236 | /* Secret recipe starts with IP addresses */ |
1237 | d = &ipv6_hdr(skb)->daddr.s6_addr32[0]; | 1237 | d = (__force u32 *)&ipv6_hdr(skb)->daddr.s6_addr32[0]; |
1238 | *mess++ ^= *d++; | 1238 | *mess++ ^= *d++; |
1239 | *mess++ ^= *d++; | 1239 | *mess++ ^= *d++; |
1240 | *mess++ ^= *d++; | 1240 | *mess++ ^= *d++; |
1241 | *mess++ ^= *d++; | 1241 | *mess++ ^= *d++; |
1242 | d = &ipv6_hdr(skb)->saddr.s6_addr32[0]; | 1242 | d = (__force u32 *)&ipv6_hdr(skb)->saddr.s6_addr32[0]; |
1243 | *mess++ ^= *d++; | 1243 | *mess++ ^= *d++; |
1244 | *mess++ ^= *d++; | 1244 | *mess++ ^= *d++; |
1245 | *mess++ ^= *d++; | 1245 | *mess++ ^= *d++; |
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 90824852f598..92bf9033e245 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -91,9 +91,9 @@ static unsigned int udp6_portaddr_hash(struct net *net, | |||
91 | if (ipv6_addr_any(addr6)) | 91 | if (ipv6_addr_any(addr6)) |
92 | hash = jhash_1word(0, mix); | 92 | hash = jhash_1word(0, mix); |
93 | else if (ipv6_addr_v4mapped(addr6)) | 93 | else if (ipv6_addr_v4mapped(addr6)) |
94 | hash = jhash_1word(addr6->s6_addr32[3], mix); | 94 | hash = jhash_1word((__force u32)addr6->s6_addr32[3], mix); |
95 | else | 95 | else |
96 | hash = jhash2(addr6->s6_addr32, 4, mix); | 96 | hash = jhash2((__force u32 *)addr6->s6_addr32, 4, mix); |
97 | 97 | ||
98 | return hash ^ port; | 98 | return hash ^ port; |
99 | } | 99 | } |