Re: [PATCH net-next v1] net: Use csum_replace_... and csum_sub() helpers instead of opencoding

From: Christophe Leroy
Date: Thu Feb 17 2022 - 13:12:09 EST




Le 17/02/2022 à 18:24, Jakub Kicinski a écrit :
> On Thu, 17 Feb 2022 16:43:55 +0100 Christophe Leroy wrote:
>> 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, fsum, tsum);
>
> Sparse says:
>
> net/netfilter/nft_payload.c:560:28: warning: incorrect type in argument 2 (different base types)
> net/netfilter/nft_payload.c:560:28: expected restricted __be32 [usertype] from
> net/netfilter/nft_payload.c:560:28: got restricted __wsum [usertype] fsum

Yes I saw it in patchwork, thanks.

Looks like csum_replace4() expects __be32 inputs, I'll look at it but
I'm not inclined at adding force cast, so will probably leave
nft_csum_replace() as is.

Thanks
Christophe