* [PATCH net-next v2] netfilter: nft_payload: Use csum_replace4() instead of opencoding
@ 2025-08-18 9:48 Christophe Leroy
2025-08-27 12:41 ` Simon Horman
0 siblings, 1 reply; 2+ messages in thread
From: Christophe Leroy @ 2025-08-18 9:48 UTC (permalink / raw)
To: Pablo Neira Ayuso, Jozsef Kadlecsik, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: Christophe Leroy, netfilter-devel, coreteam, netdev, linux-kernel
Open coded calculation can be avoided and replaced by the
equivalent csum_replace4() in nft_csum_replace().
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
v2: Add cast to __be32 to match csum_replace4() expected param types
---
net/netfilter/nft_payload.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c
index 7dfc5343dae4..059b28ffad0e 100644
--- a/net/netfilter/nft_payload.c
+++ b/net/netfilter/nft_payload.c
@@ -684,7 +684,7 @@ static const struct nft_expr_ops nft_payload_inner_ops = {
static inline void nft_csum_replace(__sum16 *sum, __wsum fsum, __wsum tsum)
{
- *sum = csum_fold(csum_add(csum_sub(~csum_unfold(*sum), fsum), tsum));
+ csum_replace4(sum, (__force __be32)fsum, (__force __be32)tsum);
if (*sum == 0)
*sum = CSUM_MANGLED_0;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next v2] netfilter: nft_payload: Use csum_replace4() instead of opencoding
2025-08-18 9:48 [PATCH net-next v2] netfilter: nft_payload: Use csum_replace4() instead of opencoding Christophe Leroy
@ 2025-08-27 12:41 ` Simon Horman
0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2025-08-27 12:41 UTC (permalink / raw)
To: Christophe Leroy
Cc: Pablo Neira Ayuso, Jozsef Kadlecsik, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, netfilter-devel,
coreteam, netdev, linux-kernel
On Mon, Aug 18, 2025 at 11:48:30AM +0200, Christophe Leroy wrote:
> Open coded calculation can be avoided and replaced by the
> equivalent csum_replace4() in nft_csum_replace().
>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-27 12:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-18 9:48 [PATCH net-next v2] netfilter: nft_payload: Use csum_replace4() instead of opencoding Christophe Leroy
2025-08-27 12:41 ` Simon Horman
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).