public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Laurent Vivier <lvivier@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH] tcp: Encode checksum computation flags in a single parameter
Date: Wed, 25 Mar 2026 10:56:40 +1100	[thread overview]
Message-ID: <acMkuLNnrSq0tA8r@zatzit> (raw)
In-Reply-To: <20260324110123.1748798-1-lvivier@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1903 bytes --]

On Tue, Mar 24, 2026 at 12:01:23PM +0100, Laurent Vivier wrote:
> tcp_fill_headers() takes a pointer to a previously computed IPv4 header
> checksum to avoid recalculating it when the payload length doesn't
> change, and a separate bool to skip TCP checksum computation.
> 
> Replace both parameters with a single uint32_t csum_flags that encodes:
> - IP4_CSUM (bit 31): compute IPv4 header checksum from scratch
> - TCP_CSUM (bit 30): compute TCP checksum
> - IP4_CMASK (low 16 bits): cached IPv4 header checksum value
> 
> When IP4_CSUM is not set, the cached checksum is extracted from the low
> 16 bits.  This is cleaner than the pointer-based approach, and also
> avoids a potential dangling pointer issue: a subsequent patch makes
> tcp_fill_headers() access ip4h via with_header(), which scopes it to a
> temporary variable, so a pointer to ip4h->check would become invalid
> after the with_header() block.
> 
> Suggested-by: David Gibson <david@gibson.dropbear.id.au>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>

When I suggested this, I'd missed the fact that @ip4_check and
@no_tcp_csum were talking about different checksums, oops.
Nonetheless you've made it work :).

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

[snip]
>  	if (ip4h)
> -		*check = &ip4h->check;
> +		*csum_flags = (*csum_flags & TCP_CSUM) | ip4h->check;

Now that I've realised my mistake, I'm pretty neutral on whether we
include the TCP checksum control in this parameter.  I still think
avoiding the pointer is a significant win - not referencing one
packet's buffer when we're working on another means less non-obvious
constraints in how we organise those buffers.

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2026-03-24 23:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-24 11:01 Laurent Vivier
2026-03-24 23:56 ` David Gibson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=acMkuLNnrSq0tA8r@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=lvivier@redhat.com \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

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 IMAP folder(s).