checksum.c 940 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * This program is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU General Public License
  4. * as published by the Free Software Foundation; either version
  5. * 2 of the License, or (at your option) any later version.
  6. */
  7. #include <linux/module.h>
  8. #include <net/checksum.h>
  9. #include <asm/byteorder.h>
  10. /*
  11. * copy from fs while checksumming, otherwise like csum_partial
  12. */
  13. __wsum
  14. csum_partial_copy_from_user(const void __user *src, void *dst, int len,
  15. __wsum sum, int *csum_err)
  16. {
  17. int missing;
  18. missing = __copy_from_user(dst, src, len);
  19. if (missing) {
  20. memset(dst + len - missing, 0, missing);
  21. *csum_err = -EFAULT;
  22. } else
  23. *csum_err = 0;
  24. return csum_partial(dst, len, sum);
  25. }
  26. EXPORT_SYMBOL(csum_partial_copy_from_user);
  27. /* These are from csum_64plus.S */
  28. EXPORT_SYMBOL(csum_partial);
  29. EXPORT_SYMBOL(csum_partial_copy);
  30. EXPORT_SYMBOL(ip_compute_csum);
  31. EXPORT_SYMBOL(ip_fast_csum);