ipv6: Pass proto to csum_ipv6_magic as __u8 instead of unsigned short
authorAlexander Duyck <aduyck@mirantis.com>
Fri, 11 Mar 2016 22:05:41 +0000 (14:05 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 14 Mar 2016 03:55:13 +0000 (23:55 -0400)
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>
18 files changed:
arch/alpha/include/asm/checksum.h
arch/arm/include/asm/checksum.h
arch/frv/include/asm/checksum.h
arch/ia64/include/asm/checksum.h
arch/m68k/include/asm/checksum.h
arch/mips/include/asm/checksum.h
arch/parisc/include/asm/checksum.h
arch/score/include/asm/checksum.h
arch/sh/include/asm/checksum_32.h
arch/sparc/include/asm/checksum_32.h
arch/sparc/include/asm/checksum_64.h
arch/x86/include/asm/checksum_32.h
arch/x86/include/asm/checksum_64.h
arch/x86/lib/csum-wrappers_64.c
arch/x86/um/asm/checksum_32.h
arch/xtensa/include/asm/checksum.h
include/net/ip6_checksum.h
net/ipv6/ip6_checksum.c

index cba34b1c738ccb59fc77ac9a995efd3cc65b2663..f2bbdd2ace511464bd9c6ca0a671a0aedca6bc5c 100644 (file)
@@ -67,6 +67,5 @@ static inline __sum16 csum_fold(__wsum csum)
 #define _HAVE_ARCH_IPV6_CSUM
 extern __sum16 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);
 #endif
index 42d020b7dfbaca99e930aa7600a564702512c113..524692f4acabf48906a9a2a4de9a053dba707068 100644 (file)
@@ -144,8 +144,8 @@ __csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr, __
                __be32 proto, __wsum sum);
 
 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),
                                           htonl(proto), sum));
index cd59cd4fd2d95565682ae4db70e0583e28767fb6..b77388c5901d6f2cf1fc740e091c4ce92b57f171 100644 (file)
@@ -135,7 +135,7 @@ extern __sum16 ip_compute_csum(const void *buff, int len);
 #define _HAVE_ARCH_IPV6_CSUM
 static inline __sum16
 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;
 
index ac9c687e8384cb9b0dbcf225c6b71442276a9049..7accf54162b2d978c4e78410f0435678a44c4ee6 100644 (file)
@@ -69,7 +69,7 @@ static inline __sum16 csum_fold(__wsum csum)
 #define _HAVE_ARCH_IPV6_CSUM   1
 struct in6_addr;
 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 */
index 2f88d867c711207cde22101226b11c3ff68802db..75e91f03b17825290bb5b76b07b501da86232d5c 100644 (file)
@@ -117,7 +117,7 @@ static inline __sum16 ip_compute_csum(const void *buff, int len)
 #define _HAVE_ARCH_IPV6_CSUM
 static __inline__ __sum16
 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;
        __asm__("addl %2@,%0\n\t"
index c635541d40b8786de63eb42bf6dd796c3edbd91c..bce1ce53149a89a574c27fb53adb9de0dcc24389 100644 (file)
@@ -215,7 +215,7 @@ static inline __sum16 ip_compute_csum(const void *buff, int len)
 #define _HAVE_ARCH_IPV6_CSUM
 static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
                                          const struct in6_addr *daddr,
-                                         __u32 len, unsigned short proto,
+                                         __u32 len, __u8 proto,
                                          __wsum sum)
 {
        __wsum tmp;
index 9815ab1fc8aad92a49547d296b4da9dafb964f20..60c2c42619c986f98250c3b8a55c6e9ce97d331e 100644 (file)
@@ -122,7 +122,7 @@ static inline __sum16 ip_compute_csum(const void *buf, int len)
 #define _HAVE_ARCH_IPV6_CSUM
 static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
                                          const struct in6_addr *daddr,
-                                         __u32 len, unsigned short proto,
+                                         __u32 len, __u8 proto,
                                          __wsum sum)
 {
        __asm__ __volatile__ (
index a375bc2700be8739d636586ebd9b43b515c73165..539d9fd45d211969a3fb5cd4ca697ae033722f10 100644 (file)
@@ -179,9 +179,8 @@ static inline unsigned short ip_compute_csum(const void *buff, int len)
 
 #define _HAVE_ARCH_IPV6_CSUM
 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__(
                ".set\tvolatile\t\t\t# csum_ipv6_magic\n\t"
index fd730f140c06e8b0e7be0d950034f65187b46443..9c84386d35cba988f95bc6d2c80b558cbc99ad9a 100644 (file)
@@ -159,8 +159,7 @@ static inline __sum16 ip_compute_csum(const void *buff, int len)
 #define _HAVE_ARCH_IPV6_CSUM
 static inline __sum16 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 int __dummy;
        __asm__("clrt\n\t"
index 86ae655a3c0fcb7ec36cc39ae8c18295ac8b41c0..eff748c871ec372009111d9fbf2f20701ce1e04f 100644 (file)
@@ -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,
                                      const struct in6_addr *daddr,
-                                     __u32 len, unsigned short proto,
-                                     __wsum sum)
+                                     __u32 len, __u8 proto, __wsum sum)
 {
        __asm__ __volatile__ (
                "addcc  %3, %4, %%g4\n\t"
index ef0c6f48189ac5fc3990fe21d751f228ff9e67fa..0395d75322e9640cda2a2de4d77fe8c980b6ca7a 100644 (file)
@@ -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,
                                      const struct in6_addr *daddr,
-                                     __u32 len, unsigned short proto,
-                                     __wsum sum)
+                                     __u32 len, __u8 proto, __wsum sum)
 {
        __asm__ __volatile__ (
 "      addcc           %3, %4, %%g7\n"
index 6f380605403d14799c340a4d32983877623a13ce..532f85e6651f4e86060fd35add94431d78c20df3 100644 (file)
@@ -149,8 +149,7 @@ static inline __sum16 ip_compute_csum(const void *buff, int len)
 #define _HAVE_ARCH_IPV6_CSUM
 static inline __sum16 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)
 {
        asm("addl 0(%1), %0     ;\n"
            "adcl 4(%1), %0     ;\n"
index 97b98e2039bcb66db099b45790e267588f176779..c020ee75dce7757efae7232a3e2a0815619a42fc 100644 (file)
@@ -177,7 +177,7 @@ struct in6_addr;
 #define _HAVE_ARCH_IPV6_CSUM 1
 extern __sum16
 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)
 {
index 1318f75d56e4f072885276a18ca00363f074fcd4..28a6654f0d08e34bb11d81747305fa8fbe67f4fe 100644 (file)
@@ -135,7 +135,7 @@ EXPORT_SYMBOL(csum_partial_copy_nocheck);
 
 __sum16 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)
 {
        __u64 rest, sum64;
 
index ab77b6f9a4bf3eef1abc883820067a50cb68ccd2..83a75f8a12330237a73b20a9d5c96c9a77d4b450 100644 (file)
@@ -13,7 +13,7 @@ static inline __sum16 ip_compute_csum(const void *buff, int len)
 #define _HAVE_ARCH_IPV6_CSUM
 static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
                                          const struct in6_addr *daddr,
-                                         __u32 len, unsigned short proto,
+                                         __u32 len, __u8 proto,
                                          __wsum sum)
 {
        __asm__(
index 62254e6688f5773d91438e48b6a08928ac966f23..ec35074fcb03ac1064af1e6c8f5112ae03187194 100644 (file)
@@ -175,7 +175,7 @@ static __inline__ __sum16 ip_compute_csum(const void *buff, int len)
 #define _HAVE_ARCH_IPV6_CSUM
 static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
                                          const struct in6_addr *daddr,
-                                         __u32 len, unsigned short proto,
+                                         __u32 len, __u8 proto,
                                          __wsum sum)
 {
        unsigned int __dummy;
index 1a49b73f7f6e372381f9d1f3b7cffdc5649794c6..cca840584c888589cb1f632fee8a967b2ce7d8a1 100644 (file)
@@ -37,8 +37,7 @@
 #ifndef _HAVE_ARCH_IPV6_CSUM
 __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
                        const struct in6_addr *daddr,
-                       __u32 len, unsigned short proto,
-                       __wsum csum);
+                       __u32 len, __u8 proto, __wsum csum);
 #endif
 
 static inline __wsum ip6_compute_pseudo(struct sk_buff *skb, int proto)
index 8f920580976facf5ef6371333e1ca288b0cf2b41..b2025bf3da4af20a19b61de59808d3ca91eead51 100644 (file)
@@ -6,8 +6,7 @@
 #ifndef _HAVE_ARCH_IPV6_CSUM
 __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
                        const struct in6_addr *daddr,
-                       __u32 len, unsigned short proto,
-                       __wsum csum)
+                       __u32 len, __u8 proto, __wsum csum)
 {
 
        int carry;