From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202602 header.b=SC9+xqnA; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 64F105A0269 for ; Wed, 25 Mar 2026 00:56:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1774396606; bh=/e4AOaoOpRL0WOqTsOF8q1iLV/16/gL2ziBjEYpRqNA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SC9+xqnAb2MAraLFiek1gtc+6eHkp+N934LuJQjmhVNL6U2opoRzzXgxw3wM9ImJy YpBIB7qXJYWW2veBpuc13DDf5JAwMJEGRJShY+qZc1BcfqMbNyiGsZxLaA+clQxtJv 7QC+UgSeywpOnWR/TJ+gjGk1Lk4rq7fQZbghoxI1agYsx40p867tSm6+QB73askoPK ynpl96TqvWjZj/vbbbsQS8QZzDajIfihnuBhkxaugfhNOt/mMx7g9jma+c4b3ijZKV 30Tf0p9zWbzpAssszM9kczy8cya6SWbTSr1KLo38Vm4aIq2M5c8pRTLd1sR3jlbPeL CFl2mMZo9qQNw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4fgRlf2LRrz4wHj; Wed, 25 Mar 2026 10:56:46 +1100 (AEDT) Date: Wed, 25 Mar 2026 10:56:40 +1100 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH] tcp: Encode checksum computation flags in a single parameter Message-ID: References: <20260324110123.1748798-1-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="pxtV7gW45+xDDzvf" Content-Disposition: inline In-Reply-To: <20260324110123.1748798-1-lvivier@redhat.com> Message-ID-Hash: PI72GBQ6PTJ7QT6GRQWUWVMISYAXO7XU X-Message-ID-Hash: PI72GBQ6PTJ7QT6GRQWUWVMISYAXO7XU X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --pxtV7gW45+xDDzvf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > 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 >=20 > 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. >=20 > Suggested-by: David Gibson > Signed-off-by: Laurent Vivier 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 [snip] > if (ip4h) > - *check =3D &ip4h->check; > + *csum_flags =3D (*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. --=20 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 --pxtV7gW45+xDDzvf Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmnDJLcACgkQzQJF27ox 2Gc2Yw/+Jwnlo1kHLM57J69eSin4aseH6bRBRN/baEVQkVSKlVkEgNONMrjqBy/t 9+KJ42ejqrAKfilMDJ378nvXkklIUEBJBenYsXXlo6MohUq+5/QadKDvZHImOUwc 0DL1bi77uttQv5hCFu0u2ySP50fS0/bm+ELA1BA/g7i0Ee5/4+vW4vc+s0Slw4/A gDIm4NWlZ6YuA+hTttPi7XEjQxTGgo2X5pV50fCp50kRcuKOWuN8t56EtQlhd1Uy 4LT+zEn2g1LUta6SNq16vki2dI5X9XeFRIQADkz43bVs9z62Uq8eRG/72zcp3+mB ohY9995UsgMlu1Kr6PUsr0xm8qViDlN88Du0iHf3xbJejzWJbL+lyX7EAd0PVKO8 fYjE5nYcl/aCFzQwnAJHM+7OrcA6f+OWLa2eBHJvE0Jc7MX75VpGfqW1YigY3wGh ctzKaNK0lWGlvKwH86D6njmmLJVln7r9eBm7BNZhjh89TCZIopFhxybDZSC2swU0 WVxssif4GWcL2ylyGJNMpAHW+FvnbogLy0d7YVgXLPQyaYyB1SLRFpnVBp3qE09t pDKMVM78m7S6nN21blIEpNpdC+BbnP9WsAA6hwyrxygzM6Z5t/wfGj/hnIirRmhm a6ObqStmHgrpEqy4QPEnBNhyVzD0xKHBkHCO6JNgDb+HODYzm1E= =iwNw -----END PGP SIGNATURE----- --pxtV7gW45+xDDzvf--