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=202410 header.b=JRpDRHYs; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 0E2F15A004E for ; Tue, 15 Oct 2024 02:45:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202410; t=1728953102; bh=4io62x+zuGDCqvYlUgILSaa93CxxFLuhk15oCZLmNHg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JRpDRHYsjaQjll6XXiZxIuw95X4y3iBft6XUT9yxda/pF8vvLUaWO1/fEF4/Tcki2 BKYnyXOMYA6/PSfDnDiUkVRkxVxceTeMguFvQRAc+x8dZCufRIBlIMYggXgIaPq3UN 0b1FgC7s200FKKxbGhYQ9QKyiL25Bc3uy2U2qWTaOHoShXSX1d1x1hMplJ6l+i16mI dqDjs/lFdH9Gt9CQ0DBIMsIDa10STEMWs/kraEWRbehcOt2f2vS8d3Qde6QleLuIzC uOnHHjjvuV3JTWwApib8acWjFgfUuxR+9GmwfVl3LLtYn15t5RcbsW2SjepANphrQA sFY0iTRrbmSXQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4XSFk63GPLz4x8C; Tue, 15 Oct 2024 11:45:02 +1100 (AEDT) Date: Tue, 15 Oct 2024 11:01:59 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] tcp: Send "empty" handshake ACK before first data segment Message-ID: References: <20241014223820.912829-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rJa6ec68RDBilOri" Content-Disposition: inline In-Reply-To: <20241014223820.912829-1-sbrivio@redhat.com> Message-ID-Hash: 2I3CMHPHGKWJHAHCTTZ4C3B7NLFOKSSX X-Message-ID-Hash: 2I3CMHPHGKWJHAHCTTZ4C3B7NLFOKSSX 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 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: --rJa6ec68RDBilOri Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 15, 2024 at 12:38:20AM +0200, Stefano Brivio wrote: > Starting from commit 9178a9e3462d ("tcp: Always send an ACK segment > once the handshake is completed"), we always send an ACK segment, > without any payload, to complete the three-way handshake while > establishing a connection started from a socket. >=20 > We queue that segment after checking if we already have data to send > to the tap, which means that its sequence number is higher than any > segment with data we're sending in the same iteration, if any data is > available on the socket. >=20 > However, in tcp_defer_handler(), we first flush "flags" buffers, that > is, we send out segments without any data first, and then segments > with data, which means that our "empty" ACK is sent before the ACK > segment with data (if any), which has a lower sequence number. >=20 > This appears to be harmless as the guest or container will generally > reorder segments, but it looks rather weird and we can't exclude it's > actually causing problems. >=20 > Queue the empty ACK first, so that it gets a lower sequence number, > before checking for any data from the socket. >=20 > Reported-by: David Gibson > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > tcp.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) >=20 > diff --git a/tcp.c b/tcp.c > index 9617b7a..b2155ab 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -1957,11 +1957,12 @@ static void tcp_conn_from_sock_finish(const struc= t ctx *c, > return; > } > =20 > + tcp_send_flag(c, conn, ACK); > + > /* The client might have sent data already, which we didn't > * dequeue waiting for SYN,ACK from tap -- check now. > */ > tcp_data_from_sock(c, conn); > - tcp_send_flag(c, conn, ACK); > } > =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 --rJa6ec68RDBilOri Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmcNsOwACgkQzQJF27ox 2Gcbdg//cZKd9jfOzYm8DD15/Ir/hW0aTbROb5Gdkm+UrVUzo6Ajt2AciOwpVRD0 meV2fCu6pnLyh0sJ+p4V9F0EIDcmDMEgwrKI3eGZDRbY2WGGKOcW7VciRWzG/9gv x9qXGIct3RZrY1lddQ6xyYOOA9Bm3E+tJAiccfY3JnByt57DncX04OeAonzH0gK+ oZb6uSYjkcX9sijDkkli3E27gRgXJrQ2ay7OmiJawzkudBfTXvtMkbIDKZVW4aR3 BjRvdtgU61LrWvFZ0dsCYrjk7RAW63DplWQGK35mFRFt0LpwjYE03akT+5dPYpxJ 8mpVOdL1Hcay99SIDVAlGZFsjauGSz8v60MpQu7/fA3GRWfxVH6fZdtxh86BL294 1Zgx9SrOxH1N7JER7JsrdQnIdzDrxi+GkwhruOrCWDmVqYs1b6nFJ6DF4o3WDBRe zIY/NXr3XiweDhjivUTvv7f3pU21HRINqx6akPvIjfVJ+34gAdxxeH+MqdZnIQBE qK3VMG7ktuIoLNUS4fRnkEsNVhtgHVSAh07KOw5wb9gr860uTNJ7QIsLvvdEqPZq NGFmRH9NDYCI257hMjGUFOn4GpSSX7y2bGZtAcIc4ynIzEnrljXIWuzRxqLeaVK3 FWOyM8lBdlmA4066rySxOSpr3CG+VNUqWjF4xlWwRYodbkcqkWs= =br0p -----END PGP SIGNATURE----- --rJa6ec68RDBilOri--