* [PATCH net-next v2] net: core: Use csum_replace_by_diff() and csum_sub() instead of opencoding
@ 2022-02-18 8:03 Christophe Leroy
2022-02-21 12:00 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Christophe Leroy @ 2022-02-18 8:03 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski; +Cc: Christophe Leroy, linux-kernel, netdev
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(-)
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)));
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next v2] net: core: Use csum_replace_by_diff() and csum_sub() instead of opencoding
2022-02-18 8:03 [PATCH net-next v2] net: core: Use csum_replace_by_diff() and csum_sub() instead of opencoding Christophe Leroy
@ 2022-02-21 12:00 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-02-21 12:00 UTC (permalink / raw)
To: Christophe Leroy; +Cc: davem, kuba, linux-kernel, netdev
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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-02-21 12:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-18 8:03 [PATCH net-next v2] net: core: Use csum_replace_by_diff() and csum_sub() instead of opencoding Christophe Leroy
2022-02-21 12:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).