net: fold __skb_checksum() into skb_checksum()
authorEric Biggers <ebiggers@google.com>
Mon, 19 May 2025 17:50:08 +0000 (10:50 -0700)
committerJakub Kicinski <kuba@kernel.org>
Wed, 21 May 2025 22:40:16 +0000 (15:40 -0700)
Now that the only remaining caller of __skb_checksum() is
skb_checksum(), fold __skb_checksum() into skb_checksum().  This makes
struct skb_checksum_ops unnecessary, so remove that too and simply do
the "regular" net checksum.  It also makes the wrapper functions
csum_partial_ext() and csum_block_add_ext() unnecessary, so remove those
too and just use the underlying functions.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Link: https://patch.msgid.link/20250519175012.36581-7-ebiggers@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/skbuff.h
include/net/checksum.h
net/core/skbuff.c

index 7ccc6356acacaec1beb2c9295a02dd6a98ea431f..018c072305133c9f3055860dc71243ccaef3b45e 100644 (file)
@@ -4192,15 +4192,6 @@ static inline int memcpy_to_msg(struct msghdr *msg, void *data, int len)
        return copy_to_iter(data, len, &msg->msg_iter) == len ? 0 : -EFAULT;
 }
 
-struct skb_checksum_ops {
-       __wsum (*update)(const void *mem, int len, __wsum wsum);
-       __wsum (*combine)(__wsum csum, __wsum csum2, int offset, int len);
-};
-
-extern const struct skb_checksum_ops *crc32c_csum_stub __read_mostly;
-
-__wsum __skb_checksum(const struct sk_buff *skb, int offset, int len,
-                     __wsum csum, const struct skb_checksum_ops *ops);
 __wsum skb_checksum(const struct sk_buff *skb, int offset, int len,
                    __wsum csum);
 u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc);
index 243f972267b8d19bfb5f76f12411a1327505fdaf..e57986b173f8eb95878b059ea92b99e9f6425243 100644 (file)
@@ -98,12 +98,6 @@ csum_block_add(__wsum csum, __wsum csum2, int offset)
        return csum_add(csum, csum_shift(csum2, offset));
 }
 
-static __always_inline __wsum
-csum_block_add_ext(__wsum csum, __wsum csum2, int offset, int len)
-{
-       return csum_block_add(csum, csum2, offset);
-}
-
 static __always_inline __wsum
 csum_block_sub(__wsum csum, __wsum csum2, int offset)
 {
@@ -115,12 +109,6 @@ static __always_inline __wsum csum_unfold(__sum16 n)
        return (__force __wsum)n;
 }
 
-static __always_inline
-__wsum csum_partial_ext(const void *buff, int len, __wsum sum)
-{
-       return csum_partial(buff, len, sum);
-}
-
 #define CSUM_MANGLED_0 ((__force __sum16)0xffff)
 
 static __always_inline void csum_replace_by_diff(__sum16 *sum, __wsum diff)
index 94b977db47f9dae0d2ed72933a29ea73488ae1fa..85fc82f72d26883307a975a90336a0474debaf8e 100644 (file)
@@ -3445,8 +3445,7 @@ fault:
 EXPORT_SYMBOL(skb_store_bits);
 
 /* Checksum skb data. */
-__wsum __skb_checksum(const struct sk_buff *skb, int offset, int len,
-                     __wsum csum, const struct skb_checksum_ops *ops)
+__wsum skb_checksum(const struct sk_buff *skb, int offset, int len, __wsum csum)
 {
        int start = skb_headlen(skb);
        int i, copy = start - offset;
@@ -3457,8 +3456,7 @@ __wsum __skb_checksum(const struct sk_buff *skb, int offset, int len,
        if (copy > 0) {
                if (copy > len)
                        copy = len;
-               csum = INDIRECT_CALL_1(ops->update, csum_partial_ext,
-                                      skb->data + offset, copy, csum);
+               csum = csum_partial(skb->data + offset, copy, csum);
                if ((len -= copy) == 0)
                        return csum;
                offset += copy;
@@ -3488,13 +3486,9 @@ __wsum __skb_checksum(const struct sk_buff *skb, int offset, int len,
                                              skb_frag_off(frag) + offset - start,
                                              copy, p, p_off, p_len, copied) {
                                vaddr = kmap_atomic(p);
-                               csum2 = INDIRECT_CALL_1(ops->update,
-                                                       csum_partial_ext,
-                                                       vaddr + p_off, p_len, 0);
+                               csum2 = csum_partial(vaddr + p_off, p_len, 0);
                                kunmap_atomic(vaddr);
-                               csum = INDIRECT_CALL_1(ops->combine,
-                                                      csum_block_add_ext, csum,
-                                                      csum2, pos, p_len);
+                               csum = csum_block_add(csum, csum2, pos);
                                pos += p_len;
                        }
 
@@ -3515,10 +3509,9 @@ __wsum __skb_checksum(const struct sk_buff *skb, int offset, int len,
                        __wsum csum2;
                        if (copy > len)
                                copy = len;
-                       csum2 = __skb_checksum(frag_iter, offset - start,
-                                              copy, 0, ops);
-                       csum = INDIRECT_CALL_1(ops->combine, csum_block_add_ext,
-                                              csum, csum2, pos, copy);
+                       csum2 = skb_checksum(frag_iter, offset - start, copy,
+                                            0);
+                       csum = csum_block_add(csum, csum2, pos);
                        if ((len -= copy) == 0)
                                return csum;
                        offset += copy;
@@ -3530,18 +3523,6 @@ __wsum __skb_checksum(const struct sk_buff *skb, int offset, int len,
 
        return csum;
 }
-EXPORT_SYMBOL(__skb_checksum);
-
-__wsum skb_checksum(const struct sk_buff *skb, int offset,
-                   int len, __wsum csum)
-{
-       const struct skb_checksum_ops ops = {
-               .update  = csum_partial_ext,
-               .combine = csum_block_add_ext,
-       };
-
-       return __skb_checksum(skb, offset, len, csum, &ops);
-}
 EXPORT_SYMBOL(skb_checksum);
 
 /* Both of above in one bottle. */
@@ -3765,32 +3746,6 @@ __sum16 __skb_checksum_complete(struct sk_buff *skb)
 }
 EXPORT_SYMBOL(__skb_checksum_complete);
 
-static __wsum warn_crc32c_csum_update(const void *buff, int len, __wsum sum)
-{
-       net_warn_ratelimited(
-               "%s: attempt to compute crc32c without libcrc32c.ko\n",
-               __func__);
-       return 0;
-}
-
-static __wsum warn_crc32c_csum_combine(__wsum csum, __wsum csum2,
-                                      int offset, int len)
-{
-       net_warn_ratelimited(
-               "%s: attempt to compute crc32c without libcrc32c.ko\n",
-               __func__);
-       return 0;
-}
-
-static const struct skb_checksum_ops default_crc32c_ops = {
-       .update  = warn_crc32c_csum_update,
-       .combine = warn_crc32c_csum_combine,
-};
-
-const struct skb_checksum_ops *crc32c_csum_stub __read_mostly =
-       &default_crc32c_ops;
-EXPORT_SYMBOL(crc32c_csum_stub);
-
  /**
  *     skb_zerocopy_headlen - Calculate headroom needed for skb_zerocopy()
  *     @from: source buffer