diff mbox series

[net-next,v2] net: core: Use csum_replace_by_diff() and csum_sub() instead of opencoding

Message ID 491e9d549dd6b5d1b50e4540536f4fa4ce4e968f.1645171288.git.christophe.leroy@csgroup.eu (mailing list archive)
State Accepted
Commit 0f6938eb2ecc572896ef9ad11238eb2846dcaad3
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v2] net: core: Use csum_replace_by_diff() and csum_sub() instead of opencoding | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2 this patch: 2
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Christophe Leroy Feb. 18, 2022, 8:03 a.m. UTC
Open coded calculation can be avoided and replaced by the
equivalent csum_replace_by_diff() and csum_sub().

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
v2: Dropped the change in nft_csum_replace() as it would
require nasty casts.
---
 net/core/utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Feb. 21, 2022, noon UTC | #1
Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Fri, 18 Feb 2022 09:03:48 +0100 you wrote:
> Open coded calculation can be avoided and replaced by the
> equivalent csum_replace_by_diff() and csum_sub().
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
> v2: Dropped the change in nft_csum_replace() as it would
> require nasty casts.
> 
> [...]

Here is the summary with links:
  - [net-next,v2] net: core: Use csum_replace_by_diff() and csum_sub() instead of opencoding
    https://git.kernel.org/netdev/net-next/c/0f6938eb2ecc

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/core/utils.c b/net/core/utils.c
index 1f31a39236d5..938495bc1d34 100644
--- a/net/core/utils.c
+++ b/net/core/utils.c
@@ -476,9 +476,9 @@  void inet_proto_csum_replace_by_diff(__sum16 *sum, struct sk_buff *skb,
 				     __wsum diff, bool pseudohdr)
 {
 	if (skb->ip_summed != CHECKSUM_PARTIAL) {
-		*sum = csum_fold(csum_add(diff, ~csum_unfold(*sum)));
+		csum_replace_by_diff(sum, diff);
 		if (skb->ip_summed == CHECKSUM_COMPLETE && pseudohdr)
-			skb->csum = ~csum_add(diff, ~skb->csum);
+			skb->csum = ~csum_sub(diff, skb->csum);
 	} else if (pseudohdr) {
 		*sum = ~csum_fold(csum_add(diff, csum_unfold(*sum)));
 	}