Эх сурвалжийг харах

ipv6: Pass proto to csum_ipv6_magic as __u8 instead of unsigned short

This patch updates csum_ipv6_magic so that it correctly recognizes that
protocol is a unsigned 8 bit value.

This will allow us to better understand what limitations may or may not be
present in how we handle the data.  For example there are a number of
places that call htonl on the protocol value.  This is likely not necessary
and can be replaced with a multiplication by ntohl(1) which will be
converted to a shift by the compiler.

Signed-off-by: Alexander Duyck <aduyck@mirantis.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Alexander Duyck 9 жил өмнө
parent
commit
1e94082963

+ 1 - 2
arch/alpha/include/asm/checksum.h

@@ -67,6 +67,5 @@ static inline __sum16 csum_fold(__wsum csum)
 #define _HAVE_ARCH_IPV6_CSUM
 #define _HAVE_ARCH_IPV6_CSUM
 extern __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 extern __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 			       const struct in6_addr *daddr,
 			       const struct in6_addr *daddr,
-			       __u32 len, unsigned short proto,
-			       __wsum sum);
+			       __u32 len, __u8 proto, __wsum sum);
 #endif
 #endif

+ 2 - 2
arch/arm/include/asm/checksum.h

@@ -144,8 +144,8 @@ __csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr, __
 		__be32 proto, __wsum sum);
 		__be32 proto, __wsum sum);
 
 
 static inline __sum16
 static inline __sum16
-csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr, __u32 len,
-		unsigned short proto, __wsum sum)
+csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
+		__u32 len, __u8 proto, __wsum sum)
 {
 {
 	return csum_fold(__csum_ipv6_magic(saddr, daddr, htonl(len),
 	return csum_fold(__csum_ipv6_magic(saddr, daddr, htonl(len),
 					   htonl(proto), sum));
 					   htonl(proto), sum));

+ 1 - 1
arch/frv/include/asm/checksum.h

@@ -135,7 +135,7 @@ extern __sum16 ip_compute_csum(const void *buff, int len);
 #define _HAVE_ARCH_IPV6_CSUM
 #define _HAVE_ARCH_IPV6_CSUM
 static inline __sum16
 static inline __sum16
 csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
 csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
-		__u32 len, unsigned short proto, __wsum sum)
+		__u32 len, __u8 proto, __wsum sum)
 {
 {
 	unsigned long tmp, tmp2;
 	unsigned long tmp, tmp2;
 
 

+ 2 - 2
arch/ia64/include/asm/checksum.h

@@ -69,7 +69,7 @@ static inline __sum16 csum_fold(__wsum csum)
 #define _HAVE_ARCH_IPV6_CSUM	1
 #define _HAVE_ARCH_IPV6_CSUM	1
 struct in6_addr;
 struct in6_addr;
 extern __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 extern __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
-	const struct in6_addr *daddr, __u32 len, unsigned short proto,
-	__wsum csum);
+			       const struct in6_addr *daddr,
+			       __u32 len, __u8 proto, __wsum csum);
 
 
 #endif /* _ASM_IA64_CHECKSUM_H */
 #endif /* _ASM_IA64_CHECKSUM_H */

+ 1 - 1
arch/m68k/include/asm/checksum.h

@@ -117,7 +117,7 @@ static inline __sum16 ip_compute_csum(const void *buff, int len)
 #define _HAVE_ARCH_IPV6_CSUM
 #define _HAVE_ARCH_IPV6_CSUM
 static __inline__ __sum16
 static __inline__ __sum16
 csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
 csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
-		__u32 len, unsigned short proto, __wsum sum)
+		__u32 len, __u8 proto, __wsum sum)
 {
 {
 	register unsigned long tmp;
 	register unsigned long tmp;
 	__asm__("addl %2@,%0\n\t"
 	__asm__("addl %2@,%0\n\t"

+ 1 - 1
arch/mips/include/asm/checksum.h

@@ -215,7 +215,7 @@ static inline __sum16 ip_compute_csum(const void *buff, int len)
 #define _HAVE_ARCH_IPV6_CSUM
 #define _HAVE_ARCH_IPV6_CSUM
 static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 					  const struct in6_addr *daddr,
 					  const struct in6_addr *daddr,
-					  __u32 len, unsigned short proto,
+					  __u32 len, __u8 proto,
 					  __wsum sum)
 					  __wsum sum)
 {
 {
 	__wsum tmp;
 	__wsum tmp;

+ 1 - 1
arch/parisc/include/asm/checksum.h

@@ -122,7 +122,7 @@ static inline __sum16 ip_compute_csum(const void *buf, int len)
 #define _HAVE_ARCH_IPV6_CSUM
 #define _HAVE_ARCH_IPV6_CSUM
 static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 					  const struct in6_addr *daddr,
 					  const struct in6_addr *daddr,
-					  __u32 len, unsigned short proto,
+					  __u32 len, __u8 proto,
 					  __wsum sum)
 					  __wsum sum)
 {
 {
 	__asm__ __volatile__ (
 	__asm__ __volatile__ (

+ 2 - 3
arch/score/include/asm/checksum.h

@@ -179,9 +179,8 @@ static inline unsigned short ip_compute_csum(const void *buff, int len)
 
 
 #define _HAVE_ARCH_IPV6_CSUM
 #define _HAVE_ARCH_IPV6_CSUM
 static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
-				const struct in6_addr *daddr,
-				__u32 len, unsigned short proto,
-				__wsum sum)
+				      const struct in6_addr *daddr,
+				      __u32 len, __u8 proto, __wsum sum)
 {
 {
 	__asm__ __volatile__(
 	__asm__ __volatile__(
 		".set\tvolatile\t\t\t# csum_ipv6_magic\n\t"
 		".set\tvolatile\t\t\t# csum_ipv6_magic\n\t"

+ 1 - 2
arch/sh/include/asm/checksum_32.h

@@ -159,8 +159,7 @@ static inline __sum16 ip_compute_csum(const void *buff, int len)
 #define _HAVE_ARCH_IPV6_CSUM
 #define _HAVE_ARCH_IPV6_CSUM
 static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 				      const struct in6_addr *daddr,
 				      const struct in6_addr *daddr,
-				      __u32 len, unsigned short proto,
-				      __wsum sum)
+				      __u32 len, __u8 proto, __wsum sum)
 {
 {
 	unsigned int __dummy;
 	unsigned int __dummy;
 	__asm__("clrt\n\t"
 	__asm__("clrt\n\t"

+ 1 - 2
arch/sparc/include/asm/checksum_32.h

@@ -199,8 +199,7 @@ static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
 
 
 static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 				      const struct in6_addr *daddr,
 				      const struct in6_addr *daddr,
-				      __u32 len, unsigned short proto,
-				      __wsum sum)
+				      __u32 len, __u8 proto, __wsum sum)
 {
 {
 	__asm__ __volatile__ (
 	__asm__ __volatile__ (
 		"addcc	%3, %4, %%g4\n\t"
 		"addcc	%3, %4, %%g4\n\t"

+ 1 - 2
arch/sparc/include/asm/checksum_64.h

@@ -125,8 +125,7 @@ static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
 
 
 static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 				      const struct in6_addr *daddr,
 				      const struct in6_addr *daddr,
-				      __u32 len, unsigned short proto,
-				      __wsum sum)
+				      __u32 len, __u8 proto, __wsum sum)
 {
 {
 	__asm__ __volatile__ (
 	__asm__ __volatile__ (
 "	addcc		%3, %4, %%g7\n"
 "	addcc		%3, %4, %%g7\n"

+ 1 - 2
arch/x86/include/asm/checksum_32.h

@@ -149,8 +149,7 @@ static inline __sum16 ip_compute_csum(const void *buff, int len)
 #define _HAVE_ARCH_IPV6_CSUM
 #define _HAVE_ARCH_IPV6_CSUM
 static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 				      const struct in6_addr *daddr,
 				      const struct in6_addr *daddr,
-				      __u32 len, unsigned short proto,
-				      __wsum sum)
+				      __u32 len, __u8 proto, __wsum sum)
 {
 {
 	asm("addl 0(%1), %0	;\n"
 	asm("addl 0(%1), %0	;\n"
 	    "adcl 4(%1), %0	;\n"
 	    "adcl 4(%1), %0	;\n"

+ 1 - 1
arch/x86/include/asm/checksum_64.h

@@ -177,7 +177,7 @@ struct in6_addr;
 #define _HAVE_ARCH_IPV6_CSUM 1
 #define _HAVE_ARCH_IPV6_CSUM 1
 extern __sum16
 extern __sum16
 csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
 csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
-		__u32 len, unsigned short proto, __wsum sum);
+		__u32 len, __u8 proto, __wsum sum);
 
 
 static inline unsigned add32_with_carry(unsigned a, unsigned b)
 static inline unsigned add32_with_carry(unsigned a, unsigned b)
 {
 {

+ 1 - 1
arch/x86/lib/csum-wrappers_64.c

@@ -135,7 +135,7 @@ EXPORT_SYMBOL(csum_partial_copy_nocheck);
 
 
 __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 			const struct in6_addr *daddr,
 			const struct in6_addr *daddr,
-			__u32 len, unsigned short proto, __wsum sum)
+			__u32 len, __u8 proto, __wsum sum)
 {
 {
 	__u64 rest, sum64;
 	__u64 rest, sum64;
 
 

+ 1 - 1
arch/x86/um/asm/checksum_32.h

@@ -13,7 +13,7 @@ static inline __sum16 ip_compute_csum(const void *buff, int len)
 #define _HAVE_ARCH_IPV6_CSUM
 #define _HAVE_ARCH_IPV6_CSUM
 static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 					  const struct in6_addr *daddr,
 					  const struct in6_addr *daddr,
-					  __u32 len, unsigned short proto,
+					  __u32 len, __u8 proto,
 					  __wsum sum)
 					  __wsum sum)
 {
 {
 	__asm__(
 	__asm__(

+ 1 - 1
arch/xtensa/include/asm/checksum.h

@@ -175,7 +175,7 @@ static __inline__ __sum16 ip_compute_csum(const void *buff, int len)
 #define _HAVE_ARCH_IPV6_CSUM
 #define _HAVE_ARCH_IPV6_CSUM
 static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 					  const struct in6_addr *daddr,
 					  const struct in6_addr *daddr,
-					  __u32 len, unsigned short proto,
+					  __u32 len, __u8 proto,
 					  __wsum sum)
 					  __wsum sum)
 {
 {
 	unsigned int __dummy;
 	unsigned int __dummy;

+ 1 - 2
include/net/ip6_checksum.h

@@ -37,8 +37,7 @@
 #ifndef _HAVE_ARCH_IPV6_CSUM
 #ifndef _HAVE_ARCH_IPV6_CSUM
 __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 			const struct in6_addr *daddr,
 			const struct in6_addr *daddr,
-			__u32 len, unsigned short proto,
-			__wsum csum);
+			__u32 len, __u8 proto, __wsum csum);
 #endif
 #endif
 
 
 static inline __wsum ip6_compute_pseudo(struct sk_buff *skb, int proto)
 static inline __wsum ip6_compute_pseudo(struct sk_buff *skb, int proto)

+ 1 - 2
net/ipv6/ip6_checksum.c

@@ -6,8 +6,7 @@
 #ifndef _HAVE_ARCH_IPV6_CSUM
 #ifndef _HAVE_ARCH_IPV6_CSUM
 __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
 			const struct in6_addr *daddr,
 			const struct in6_addr *daddr,
-			__u32 len, unsigned short proto,
-			__wsum csum)
+			__u32 len, __u8 proto, __wsum csum)
 {
 {
 
 
 	int carry;
 	int carry;