diff options
author | Puranjay Mohan <puranjay@kernel.org> | 2024-10-26 14:53:36 +0200 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2024-10-30 15:29:59 +0100 |
commit | db71aae70e3e646d8ba4cb50e4bd4c281a91c804 (patch) | |
tree | d4e420584ef738a26224803b3c1d726af5f12e25 /lib | |
parent | selftests/bpf: remove xdp_synproxy IP_DF check (diff) | |
download | linux-db71aae70e3e646d8ba4cb50e4bd4c281a91c804.tar.xz linux-db71aae70e3e646d8ba4cb50e4bd4c281a91c804.zip |
net: checksum: Move from32to16() to generic header
from32to16() is used by lib/checksum.c and also by
arch/parisc/lib/checksum.c. The next patch will use it in the
bpf_csum_diff helper.
Move from32to16() to the include/net/checksum.h as csum_from32to16() and
remove other implementations.
Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20241026125339.26459-2-puranjay@kernel.org
Diffstat (limited to 'lib')
-rw-r--r-- | lib/checksum.c | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/lib/checksum.c b/lib/checksum.c index 6860d6b05a17..025ba546e1ec 100644 --- a/lib/checksum.c +++ b/lib/checksum.c @@ -34,15 +34,6 @@ #include <asm/byteorder.h> #ifndef do_csum -static inline unsigned short from32to16(unsigned int x) -{ - /* add up 16-bit and 16-bit for 16+c bit */ - x = (x & 0xffff) + (x >> 16); - /* add up carry.. */ - x = (x & 0xffff) + (x >> 16); - return x; -} - static unsigned int do_csum(const unsigned char *buff, int len) { int odd; @@ -90,7 +81,7 @@ static unsigned int do_csum(const unsigned char *buff, int len) #else result += (*buff << 8); #endif - result = from32to16(result); + result = csum_from32to16(result); if (odd) result = ((result >> 8) & 0xff) | ((result & 0xff) << 8); out: |