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=ilXdYjaO; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 2F33D5A061A for ; Thu, 21 May 2026 04:29:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1779330549; bh=oYHwFRIxb5//bpeGV6FAmzz0XYtctqNIxtDbfMoKH20=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ilXdYjaOBJeKyq5nktgmWpbAMoK/jfb/ygeR5O2HaaodYnzno4KF28xCVi3ToC/Xk rc4yY2p3f0JDDee76he8OccQn5JSbMb7m6cHQ9itcxVrMTrcES2Tq25/lpUjM/DoY+ o7UsJfNhz4rbRLqt7sdu97bG1UjJWO+oCWz5S0K/qSJJOy4tM6nnysZUWi0jh9NIoB cQE8IfbhANYVjb41k21risZ0BBnvmsGWqjXEGwRwuvIhLedFHXhj9vjzaKLPKeUB5E I5xP0YNljEbtmTHFkX6HF4rV8Qr1drVwcmZzPSy1B85nFml6Fascs4UufyUd434bwu DYMfpbbutHdiQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gLXR96Xkqz4wLV; Thu, 21 May 2026 12:29:09 +1000 (AEST) Date: Thu, 21 May 2026 12:11:49 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 6/6] tcp_splice: Simplify shutdown(2) handling Message-ID: References: <20260520130851.436931-1-david@gibson.dropbear.id.au> <20260520130851.436931-7-david@gibson.dropbear.id.au> <20260520223022.43916fc2@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="PmDjQjXsN6B3EWMw" Content-Disposition: inline In-Reply-To: <20260520223022.43916fc2@elisabeth> Message-ID-Hash: J2KGT332PYMN6DHW6YNLKKKYCDSROPIS X-Message-ID-Hash: J2KGT332PYMN6DHW6YNLKKKYCDSROPIS 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, Paul Holzinger 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: --PmDjQjXsN6B3EWMw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 20, 2026 at 10:30:23PM +0200, Stefano Brivio wrote: > On Wed, 20 May 2026 23:08:51 +1000 > David Gibson wrote: >=20 > > At the end of tcp_splice_forward(), we check for half-closed connections > > and propagate the FIN to the other side with a shutdown(2). Currently = we > > check for a half closed connection in either direction. That's unneces= sary > > here, because tcp_splice_forward() will already be called for each > > direction if there are any relevant events. >=20 > True, but do we have the guarantee that tcp_splice_forward() will also > be called once all relevant FIN_RCVD / FIN_SENT flags have been sent? Yes, because tcp_splice_forward() is (now) the only place that *sets* FIN_RCVD (or FIN_SENT). > The reason why we check both sides here is that we might have updated > flags for one side, and now we need to double check if it's time to > call shutdown() as a consequence. >=20 > Maybe we never have to, but I think it's not really obvious to prove. tcp_splice_forward() only touches FIN_RCVD(fromsidei). So, we only need to examine FIN_RCVD(fromsidei). If FIN_RCVD is set for the other side, it must be in another call to tcp_splice_forward() which will also examine that other flag and shutdown() as necessary. > > Signed-off-by: David Gibson > > --- > > tcp_splice.c | 22 ++++++++-------------- > > 1 file changed, 8 insertions(+), 14 deletions(-) > >=20 > > diff --git a/tcp_splice.c b/tcp_splice.c > > index b45f0060..e5018f2e 100644 > > --- a/tcp_splice.c > > +++ b/tcp_splice.c > > @@ -582,21 +582,15 @@ retry: > > break; > > } > > =20 > > - if (!conn->pending[fromsidei] && > > - conn->events & FIN_RCVD(fromsidei)) { > > - unsigned sidei; > > - > > - flow_foreach_sidei(sidei) { > > - if ((conn->events & FIN_RCVD(sidei)) && > > - !(conn->events & FIN_SENT(!sidei))) { > > - if (shutdown(conn->s[!sidei], SHUT_WR) < 0) { > > - flow_perror(conn, "shutdown() on %s", > > - pif_name(conn->f.pif[!sidei])); > > - return -1; > > - } > > - conn_event(conn, FIN_SENT(!sidei)); > > - } > > + if ((conn->events & FIN_RCVD(fromsidei)) && > > + !(conn->events & FIN_SENT(!fromsidei)) && > > + !conn->pending[fromsidei]) { > > + if (shutdown(conn->s[!fromsidei], SHUT_WR) < 0) { > > + flow_perror(conn, "shutdown() on %s", > > + pif_name(conn->f.pif[!fromsidei])); > > + return -1; > > } > > + conn_event(conn, FIN_SENT(!fromsidei)); > > } > > =20 > > return 0; >=20 > --=20 > Stefano >=20 --=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 --PmDjQjXsN6B3EWMw Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmoOaeUACgkQzQJF27ox 2GfbTRAAk2briIuBpubiOvoBVV9EiDmD2t0+zVwaakJeeZrMoS6DgwJbRBFyyZOa OKCklZAHcpnQnEcAE8kGAWCcEojDhBLS+ha7897Zn7df2ZIelenMaJLGYH9pCY7+ wh0yK1DdmhE3NORyCl/b5HJQOeHhhP4oP55A6P5WhhM5ZK2Lvp+agT0sgAV4vIhq /zKlJjp6d15fMpO4t3qXemYS00l52Dxk2a7uZ7ngjoh29ZLJrjAQFc7f3G590WbP EIv/lBSvj59BTh1eKKT4HIGgJiAdy/T9XX7lxNemPGP0KaTh594FYoZB43J3eEGQ YyYesYopGHAGdEwV7aVTmZWhQpREd9CX3jR8+yFgpO/fcs3CWgnF7Vff2KZ+5ymF 7ipSrRPzDk3qC9UWHMzvvBQLSKhmqs/j41XzMvfUQ/Utg2XTLDCpPNqmHKi6YhXS iknrWngikwLmlGn4JMEOgckqHU6bX3PSAtwF8UsNyIO2c850jsj4gs6SEJgwuPsV /MrbWGhZ8aqFstfdp6ZQCKaf3l6msH1jKOXfBX2pV2bDYgWgu7LEN76LF/mrsuQr OtPwEp9K6QdYwS5zDOJipEuRpRjEbBixj+ES+d0vzKdN8VyCnmXYM2z9FEpet8Om 1tM+HbbES8235KdKb1kB8MAIA/RJoWBvVld+o0a5jrqUV5qWnSc= =9AK+ -----END PGP SIGNATURE----- --PmDjQjXsN6B3EWMw--