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=hd7lW7Wx; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id BA7C85A027B 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=JCKO0yUqzG70qA6t2GbdY8lPmDZpfas4yLwCwOsud7M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hd7lW7Wxj7W4TyP2KQUhfjoGjRaQt1E9XNYY4gidNeGR1/AlVNDn9R8AZxPUPuOpn 3fk+RRrrFdGSsgg1btoEiDK+lOhGu1C2buYuAV8/ohtKGp6Y1nAZ7BATbB7wClihqe 36NKBUU6WY2WvMWAhx+31TjhLGj2E5JarebCUhucMZJmO/T7sl8XpUFDHSMHUM4Pzu T/LMmaSb5rRFCbWIms97vp0Qw7n5AnZuENF3Xr+Z3GPS41W5UNLi3xKVtGEMywNLp/ vpAxsSDzGP0+vbCWXhQDsypfjgssBhzzOB9IFRfaoEsnqkeiui2xnqKlaae397CHJ7 Lcmu6wp2MSpnQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4c4yH53TF7z4x5M; Mon, 18 Aug 2025 13:04:17 +1000 (AEST) Date: Mon, 18 Aug 2025 12:56:09 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 5/6] tcp: Don't try to transmit right after the peer shrank the window to zero Message-ID: References: <20250815161042.3606244-1-sbrivio@redhat.com> <20250815161042.3606244-6-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="S+mi2A/o4H+lz334" Content-Disposition: inline In-Reply-To: <20250815161042.3606244-6-sbrivio@redhat.com> Message-ID-Hash: 5OXNTIK6OSBBNR2F45DOVPDR7MVJBEU6 X-Message-ID-Hash: 5OXNTIK6OSBBNR2F45DOVPDR7MVJBEU6 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: --S+mi2A/o4H+lz334 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 15, 2025 at 06:10:41PM +0200, Stefano Brivio wrote: > If the peer shrinks the window to zero, we'll skip storing the new > window, as a convenient way to cause window probes (which exceed any > zero-sized window, strictly speaking) if we don't get window updates > in a while. Strictly speaking, not storing the new zero window feels slightly wrong to me - I wonder if it would be more correct to store the zero window, but still send window probes as a special case. > As we do so, though, we need to ensure we don't try to queue more data > from the socket right after we process this window update, as the > entire point of a zero-window advertisement is to keep us from sending > more data. >=20 > Signed-off-by: Stefano Brivio For the meantime, though, I'm reasonably confident that this is still an improvement, so, Reviewed-by: David Gibson > --- > tcp.c | 16 +++++++++------- > 1 file changed, 9 insertions(+), 7 deletions(-) >=20 > diff --git a/tcp.c b/tcp.c > index aed25a9..624e7f4 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -1260,8 +1260,10 @@ static void tcp_get_tap_ws(struct tcp_tap_conn *co= nn, > * @c: Execution context > * @conn: Connection pointer > * @wnd: Window value, host order, unscaled > + * > + * Return: false on zero window (not stored to wnd_from_tap), true other= wise > */ > -static void tcp_tap_window_update(const struct ctx *c, > +static bool tcp_tap_window_update(const struct ctx *c, > struct tcp_tap_conn *conn, unsigned wnd) > { > wnd =3D MIN(MAX_WINDOW, wnd << conn->ws_from_tap); > @@ -1274,13 +1276,14 @@ static void tcp_tap_window_update(const struct ct= x *c, > */ > if (!wnd && SEQ_LT(conn->seq_ack_from_tap, conn->seq_to_tap)) { > tcp_rewind_seq(c, conn); > - return; > + return false; > } > =20 > conn->wnd_from_tap =3D MIN(wnd >> conn->ws_from_tap, USHRT_MAX); > =20 > /* FIXME: reflect the tap-side receiver's window back to the sock-side > * sender by adjusting SO_RCVBUF? */ > + return true; > } > =20 > /** > @@ -2066,9 +2069,8 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pi= f, sa_family_t af, > if (!th->ack) > goto reset; > =20 > - tcp_tap_window_update(c, conn, ntohs(th->window)); > - > - tcp_data_from_sock(c, conn); > + if (tcp_tap_window_update(c, conn, ntohs(th->window))) > + tcp_data_from_sock(c, conn); > =20 > if (p->count - idx =3D=3D 1) > return 1; > @@ -2078,8 +2080,8 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pi= f, sa_family_t af, > if (conn->events & TAP_FIN_RCVD) { > tcp_sock_consume(conn, ntohl(th->ack_seq)); > tcp_update_seqack_from_tap(c, conn, ntohl(th->ack_seq)); > - tcp_tap_window_update(c, conn, ntohs(th->window)); > - tcp_data_from_sock(c, conn); > + if (tcp_tap_window_update(c, conn, ntohs(th->window))) > + tcp_data_from_sock(c, conn); > =20 > if (conn->seq_ack_from_tap =3D=3D conn->seq_to_tap) { > if (th->ack && conn->events & TAP_FIN_SENT) --=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 --S+mi2A/o4H+lz334 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmiilkgACgkQzQJF27ox 2GeXyQ/8D0dlUZcOZpZn/m6eECiIQ4vKNL584LXc2UulMhs4/RhYZJhOa4b3lR2I F2hmA8VqYc0ff2pbspn19TfS5A/4+YrmRRtr8aUx3R0o9Jn/kT5iIb8cclIL/ylI bwE8HvHXm656hpw4Am7UA0gGGV8GLfNFOJXhyrS20oEn3fsRHAtqosv9Fa7jKp/r 6BHCLCj4khG5N7XwG53tBF5T7+ctTHk7IRULX5soV+sMtmqlDEouNCA53GyZnmjy bQeQ5MuTF6pv0QtPYfhLlh6Pv7KG2HCXU5U26vFTh7rDj3OQog2Enf3zaG2vx+MK 5vOCU2Ybxjn0oPPu6Ap4iAyz/YFldlg5bEMimvdoz65DJXdQf7GIYy54swFzlDps fAezcwxuwBk+wXN4031xYZeOcLZcNFYyYyp6kb26IL9dHhR5QL2rbuS8jLfY03zx uYKHBic7HBov/A2rCgdl8RrnDOufR3EK8QS/OYi4LpNb/rYhxiTnxCKbBRWZAqAr l/oDyAf4znqeR+z4oOGqFqyiSY8+qsHJBaveKJDBkRNoZihfQBiNyLpYxtET/EH4 LZIwqGW/gHvP4MvMwS+h3/qkgrYvFU+ZcT37fs5eqSf5DnKH87UXHbvIy/eKMAFc EbXoCliQoUtAjz6U4Z4NGreUDo0ZgvyH6kXFMQRdHutn6uvGXRA= =KwwA -----END PGP SIGNATURE----- --S+mi2A/o4H+lz334--