[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c182ba60-81fc-4776-b3bb-6997e87f7749@engleder-embedded.com>
Date: Tue, 24 Jun 2025 22:53:41 +0200
From: Gerhard Engleder <gerhard@...leder-embedded.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: netdev@...r.kernel.org, edumazet@...gle.com, pabeni@...hat.com,
andrew+netdev@...n.ch, horms@...nel.org, o.rempel@...gutronix.de,
davem@...emloft.net
Subject: Re: [PATCH net] net: selftests: fix TCP packet checksum
On 24.06.25 20:32, Jakub Kicinski wrote:
> The length in the pseudo header should be the length of the L3 payload
> AKA the L4 header+payload. The selftest code builds the packet from
> the lower layers up, so all the headers are pushed already when it
> constructs L4. We need to subtract the lower layer headers from skb->len.
>
> Fixes: 3e1e58d64c3d ("net: add generic selftest support")
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> ---
> CC: o.rempel@...gutronix.de
> CC: gerhard@...leder-embedded.com
>
> I changed the math from the pointers to the offsets (which is what
> udp4_hwcsum() does). Oleksij, would you be willing to retest and send
> your Reported-and-tested-by: tag?
> ---
> net/core/selftests.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/net/core/selftests.c b/net/core/selftests.c
> index 35f807ea9952..406faf8e5f3f 100644
> --- a/net/core/selftests.c
> +++ b/net/core/selftests.c
> @@ -160,8 +160,9 @@ static struct sk_buff *net_test_get_skb(struct net_device *ndev,
> skb->csum = 0;
> skb->ip_summed = CHECKSUM_PARTIAL;
> if (attr->tcp) {
> - thdr->check = ~tcp_v4_check(skb->len, ihdr->saddr,
> - ihdr->daddr, 0);
> + int l4len = skb->len - skb_transport_offset(skb);
> +
> + thdr->check = ~tcp_v4_check(l4len, ihdr->saddr, ihdr->daddr, 0);
> skb->csum_start = skb_transport_header(skb) - skb->head;
> skb->csum_offset = offsetof(struct tcphdr, check);
> } else {
Reviewed-by: Gerhard Engleder <gerhard@...leder-embedded.com>
And also tested with my selftest patches for tsnep, which did not made
it into mainline. So I'm not sure if a Tested-by is allowed.
(Tested-by: Gerhard Engleder <gerhard@...leder-embedded.com>)
gerhard
Powered by blists - more mailing lists