1 /*
2 * Temporal C versions of the checksum functions until optimized assembler versions
3 * can go in.
4 */
5
6 #include <net/checksum.h>
7
8 /*
9 * Copy from userspace and compute checksum. If we catch an exception
10 * then zero the rest of the buffer.
11 */
csum_partial_copy_from_user(const char * src,char * dst,int len,unsigned int sum,int * err_ptr)12 unsigned int csum_partial_copy_from_user (const char *src, char *dst,
13 int len, unsigned int sum,
14 int *err_ptr)
15 {
16 int missing;
17
18 missing = copy_from_user(dst, src, len);
19 if (missing) {
20 memset(dst + len - missing, 0, missing);
21 *err_ptr = -EFAULT;
22 }
23
24 return csum_partial(dst, len, sum);
25 }
26
csum_partial_copy_nocheck(const char * src,char * dst,int len,unsigned int sum)27 unsigned int csum_partial_copy_nocheck(const char *src, char *dst, int len, unsigned int sum)
28 {
29 memcpy(dst,src,len);
30 return csum_partial(dst,len,sum);
31 }
32
33 /* Fallback for csum_and_copy_to_user is currently in include/net/checksum.h */
34