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=202508 header.b=LY0fsPWo; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 9AC785A027A for ; Mon, 18 Aug 2025 05:04:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202508; t=1755486257; bh=sLJv0QdHyAQ/VIUpx70+5YOaFEmp5AUbgGPzxKFZgxU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LY0fsPWoF6kkOWbOnjlAMD26cLmtV8AVlgwZfkstueD4oLXUxroHZO9Yn49OeRtGQ IPsWsqv0ipdeLY5nwF+I4c+H6IvaTVnXKQdYB3+gsd6TIdV6hNmGuW6hZA733PgZb0 lJGWeAWzwJXqXuIHucMQUbH9UoTh96UbnrocadxXGfWFAYvStQ0ROlT0aDU0W7kKlA 00ihmrD3OyvDlhI1qL/qG9Vn8hzMPz9TlZtQXATkiG79asbhdzZ/KLNnp2rJrwIxO6 sJp3xY7iHWLfl9iCK+Vq/6hpQtCTqlJVXdP3CmkvooJtPMOQJ1p0XEdO2drPUZtTAa p3L1Z10PxIy8A== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4c4yH52tXjz4wyh; Mon, 18 Aug 2025 13:04:17 +1000 (AEST) Date: Mon, 18 Aug 2025 12:46:47 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 2/6] tcp: Factor sequence rewind for retransmissions into a new function Message-ID: References: <20250815161042.3606244-1-sbrivio@redhat.com> <20250815161042.3606244-3-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="OP4WYIRzFLQsI6Ps" Content-Disposition: inline In-Reply-To: <20250815161042.3606244-3-sbrivio@redhat.com> Message-ID-Hash: QAW7WIOOKGMZOPZLXMN4G5D5XFT2GPXP X-Message-ID-Hash: QAW7WIOOKGMZOPZLXMN4G5D5XFT2GPXP 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, Jon Maloy , 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: --OP4WYIRzFLQsI6Ps Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 15, 2025 at 06:10:38PM +0200, Stefano Brivio wrote: > ...as I'm going to need a third occurrence of this in the next change. >=20 > This introduces a small functional change in tcp_data_from_tap(): the > sequence was previously rewound to the highest ACK number we found in > the current packet batch, and not to the current value of > seq_ack_from_tap. >=20 > The two might differ in case tcp_sock_consume() failed, because in > that case we're ignoring that ACK altogether. But if we're ignoring > it, it looks more correct to me to start retransmitting from an > earlier sequence anyway. >=20 > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > tcp.c | 47 ++++++++++++++++++++++++++++++++--------------- > 1 file changed, 32 insertions(+), 15 deletions(-) >=20 > diff --git a/tcp.c b/tcp.c > index 7c1f237..1402ca2 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -1097,6 +1097,26 @@ static void tcp_update_seqack_from_tap(const struc= t ctx *c, > } > } > =20 > +/** > + * tcp_rewind_seq() - Rewind sequence to tap and socket offset to curren= t ACK > + * @c: Execution context > + * @conn: Connection pointer > + * > + * Return: 0 on success, -1 on failure, with connection reset > + */ > +static int tcp_rewind_seq(const struct ctx *c, struct tcp_tap_conn *conn) > +{ > + conn->seq_to_tap =3D conn->seq_ack_from_tap; > + conn->events &=3D ~TAP_FIN_SENT; > + > + if (tcp_set_peek_offset(conn, 0)) { > + tcp_rst(c, conn); > + return -1; > + } > + > + return 0; > +} > + > /** > * tcp_prepare_flags() - Prepare header for flags-only segment (no paylo= ad) > * @c: Execution context > @@ -1757,13 +1777,11 @@ static int tcp_data_from_tap(const struct ctx *c,= struct tcp_tap_conn *conn, > if (retr) { > flow_trace(conn, > "fast re-transmit, ACK: %u, previous sequence: %u", > - max_ack_seq, conn->seq_to_tap); > - conn->seq_to_tap =3D max_ack_seq; > - conn->events &=3D ~TAP_FIN_SENT; > - if (tcp_set_peek_offset(conn, 0)) { > - tcp_rst(c, conn); > + conn->seq_ack_from_tap, conn->seq_to_tap); > + > + if (tcp_rewind_seq(c, conn)) > return -1; > - } > + > tcp_data_from_sock(c, conn); > } > =20 > @@ -2285,17 +2303,16 @@ void tcp_timer_handler(const struct ctx *c, union= epoll_ref ref) > tcp_rst(c, conn); > } else { > flow_dbg(conn, "ACK timeout, retry"); > - conn->retrans++; > - conn->seq_to_tap =3D conn->seq_ack_from_tap; > - conn->events &=3D ~TAP_FIN_SENT; > + > if (!conn->wnd_from_tap) > conn->wnd_from_tap =3D 1; /* Zero-window probe */ > - if (tcp_set_peek_offset(conn, 0)) { > - tcp_rst(c, conn); > - } else { > - tcp_data_from_sock(c, conn); > - tcp_timer_ctl(c, conn); > - } > + > + conn->retrans++; > + if (tcp_rewind_seq(c, conn)) > + return; > + > + tcp_data_from_sock(c, conn); > + tcp_timer_ctl(c, conn); > } > } else { > struct itimerspec new =3D { { 0 }, { ACT_TIMEOUT, 0 } }; --=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 --OP4WYIRzFLQsI6Ps Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmiilBYACgkQzQJF27ox 2GdC1w/7B8qZqSsIFJP4MQIc9xYSI7aQyF6AqkzRrd5tEHIPmv558d/KiDwhR+M9 cBrrZjwogfdfm5EVNvrFSvLQHV8B9aVNcc9iSV8UAWndoc47RIUSGTccQrFT5uk9 jtix7H+1oCrwl75ukgLb8a+bpkItQtAVdSEmvOVE/gW/v4biy9U6tpoNNfwabdl9 VaSxLl0oki5Qs6YF2XdC2xzKMCtQOWNu9LnRFtL3rTQ16mrkRh1qaQ14tpUcm86w HllgpK3g2D91rk0SmbK5cnDLlVtvGZUJjfDjNB4rEy4V6qsvGzgvnVOE9A2lOw04 AxX/IzxklmQgrzHzme5ffaLsdXvytmgwsZE0MSUmw0EGyAQMsXa1D6hqiCtXjSyh sFhedb6NT/u6PJpaKVJYfBs66usiXHueVstOY+s6J7BWVkfNsA0j88c8L9vVU9Uv 8eu71S3Q+FYZx/jhdkDsCpa7E5qfkxxFpMDAyyXVRm3CfZ4o4BoEGqQOKZb2ADEt JtjTBg2fdjv0Y/ksh2wWojHakeleRntWw/o3GzIxUXOh6L3hcG6TF47ZYTaATy+5 4zKUmkoGflp4GCp7aTYhaeuRrc3ibXiicJ64YecdctXKjsd/PeJzRjO/OUdNBnCo VFxuyIaWI+BjrzK3xJmHTsW8Ve/xsq/WhEUGirqY/aDk0QmSeas= =evTP -----END PGP SIGNATURE----- --OP4WYIRzFLQsI6Ps--