Skip to content

Commit 1e94082

Browse files
Alexander Duyckdavem330
authored andcommitted
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>
1 parent 01cfbad commit 1e94082

18 files changed

Lines changed: 21 additions & 29 deletions

File tree

arch/alpha/include/asm/checksum.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,5 @@ static inline __sum16 csum_fold(__wsum csum)
6767
#define _HAVE_ARCH_IPV6_CSUM
6868
extern __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
6969
const struct in6_addr *daddr,
70-
__u32 len, unsigned short proto,
71-
__wsum sum);
70+
__u32 len, __u8 proto, __wsum sum);
7271
#endif

arch/arm/include/asm/checksum.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ __csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr, __
144144
__be32 proto, __wsum sum);
145145

146146
static inline __sum16
147-
csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr, __u32 len,
148-
unsigned short proto, __wsum sum)
147+
csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
148+
__u32 len, __u8 proto, __wsum sum)
149149
{
150150
return csum_fold(__csum_ipv6_magic(saddr, daddr, htonl(len),
151151
htonl(proto), sum));

arch/frv/include/asm/checksum.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ extern __sum16 ip_compute_csum(const void *buff, int len);
135135
#define _HAVE_ARCH_IPV6_CSUM
136136
static inline __sum16
137137
csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
138-
__u32 len, unsigned short proto, __wsum sum)
138+
__u32 len, __u8 proto, __wsum sum)
139139
{
140140
unsigned long tmp, tmp2;
141141

arch/ia64/include/asm/checksum.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static inline __sum16 csum_fold(__wsum csum)
6969
#define _HAVE_ARCH_IPV6_CSUM 1
7070
struct in6_addr;
7171
extern __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
72-
const struct in6_addr *daddr, __u32 len, unsigned short proto,
73-
__wsum csum);
72+
const struct in6_addr *daddr,
73+
__u32 len, __u8 proto, __wsum csum);
7474

7575
#endif /* _ASM_IA64_CHECKSUM_H */

arch/m68k/include/asm/checksum.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static inline __sum16 ip_compute_csum(const void *buff, int len)
117117
#define _HAVE_ARCH_IPV6_CSUM
118118
static __inline__ __sum16
119119
csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
120-
__u32 len, unsigned short proto, __wsum sum)
120+
__u32 len, __u8 proto, __wsum sum)
121121
{
122122
register unsigned long tmp;
123123
__asm__("addl %2@,%0\n\t"

arch/mips/include/asm/checksum.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static inline __sum16 ip_compute_csum(const void *buff, int len)
215215
#define _HAVE_ARCH_IPV6_CSUM
216216
static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
217217
const struct in6_addr *daddr,
218-
__u32 len, unsigned short proto,
218+
__u32 len, __u8 proto,
219219
__wsum sum)
220220
{
221221
__wsum tmp;

arch/parisc/include/asm/checksum.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static inline __sum16 ip_compute_csum(const void *buf, int len)
122122
#define _HAVE_ARCH_IPV6_CSUM
123123
static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
124124
const struct in6_addr *daddr,
125-
__u32 len, unsigned short proto,
125+
__u32 len, __u8 proto,
126126
__wsum sum)
127127
{
128128
__asm__ __volatile__ (

arch/score/include/asm/checksum.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,8 @@ static inline unsigned short ip_compute_csum(const void *buff, int len)
179179

180180
#define _HAVE_ARCH_IPV6_CSUM
181181
static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
182-
const struct in6_addr *daddr,
183-
__u32 len, unsigned short proto,
184-
__wsum sum)
182+
const struct in6_addr *daddr,
183+
__u32 len, __u8 proto, __wsum sum)
185184
{
186185
__asm__ __volatile__(
187186
".set\tvolatile\t\t\t# csum_ipv6_magic\n\t"

arch/sh/include/asm/checksum_32.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ static inline __sum16 ip_compute_csum(const void *buff, int len)
159159
#define _HAVE_ARCH_IPV6_CSUM
160160
static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
161161
const struct in6_addr *daddr,
162-
__u32 len, unsigned short proto,
163-
__wsum sum)
162+
__u32 len, __u8 proto, __wsum sum)
164163
{
165164
unsigned int __dummy;
166165
__asm__("clrt\n\t"

arch/sparc/include/asm/checksum_32.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
199199

200200
static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
201201
const struct in6_addr *daddr,
202-
__u32 len, unsigned short proto,
203-
__wsum sum)
202+
__u32 len, __u8 proto, __wsum sum)
204203
{
205204
__asm__ __volatile__ (
206205
"addcc %3, %4, %%g4\n\t"

0 commit comments

Comments
 (0)