mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-19 17:14:40 +08:00
c693cc4676
All callers of these primitives will * discard anything we might've copied in case of error * ignore the csum value in case of error * always pass 0xffffffff as the initial sum, so the resulting csum value (in case of success, that is) will never be 0. That suggest the following calling conventions: * don't pass err_ptr - just return 0 on error. * don't bother with zeroing destination, etc. in case of error * don't pass the initial sum - just use 0xffffffff. This commit does the minimal conversion in the instances of csum_and_copy_...(); the changes of actual asm code behind them are done later in the series. Note that this asm code is often shared with csum_partial_copy_nocheck(); the difference is that csum_partial_copy_nocheck() passes 0 for initial sum while csum_and_copy_..._user() pass 0xffffffff. Fortunately, we are free to pass 0xffffffff in all cases and subsequent patches will use that freedom without any special comments. A part that could be split off: parisc and uml/i386 claimed to have csum_and_copy_to_user() instances of their own, but those were identical to the generic one, so we simply drop them. Not sure if it's worth a separate commit... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
39 lines
804 B
C
39 lines
804 B
C
/*
|
|
* Licensed under the GPL
|
|
*/
|
|
|
|
#ifndef __UM_SYSDEP_CHECKSUM_H
|
|
#define __UM_SYSDEP_CHECKSUM_H
|
|
|
|
static inline __sum16 ip_compute_csum(const void *buff, int len)
|
|
{
|
|
return csum_fold (csum_partial(buff, len, 0));
|
|
}
|
|
|
|
#define _HAVE_ARCH_IPV6_CSUM
|
|
static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
|
|
const struct in6_addr *daddr,
|
|
__u32 len, __u8 proto,
|
|
__wsum sum)
|
|
{
|
|
__asm__(
|
|
"addl 0(%1), %0 ;\n"
|
|
"adcl 4(%1), %0 ;\n"
|
|
"adcl 8(%1), %0 ;\n"
|
|
"adcl 12(%1), %0 ;\n"
|
|
"adcl 0(%2), %0 ;\n"
|
|
"adcl 4(%2), %0 ;\n"
|
|
"adcl 8(%2), %0 ;\n"
|
|
"adcl 12(%2), %0 ;\n"
|
|
"adcl %3, %0 ;\n"
|
|
"adcl %4, %0 ;\n"
|
|
"adcl $0, %0 ;\n"
|
|
: "=&r" (sum)
|
|
: "r" (saddr), "r" (daddr),
|
|
"r"(htonl(len)), "r"(htonl(proto)), "0"(sum));
|
|
|
|
return csum_fold(sum);
|
|
}
|
|
|
|
#endif
|