]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
netfilter: nft_payload: Use csum_replace4() instead of opencoding
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Mon, 18 Aug 2025 09:48:30 +0000 (11:48 +0200)
committerFlorian Westphal <fw@strlen.de>
Tue, 2 Sep 2025 13:28:17 +0000 (15:28 +0200)
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>
Signed-off-by: Florian Westphal <fw@strlen.de>
net/netfilter/nft_payload.c

index 7dfc5343dae46f3d117092667272175de9346819..059b28ffad0eb1248501f92243e81e2f2fd9a4f5 100644 (file)
@@ -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;
 }