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=202502 header.b=aLJleIUy; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 471305A0271 for ; Thu, 20 Mar 2025 02:50:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202502; t=1742435409; bh=lTzyPMNSnnf80y2XvalDUj/Iw5rqAAoLDAie28zL37Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aLJleIUyJ/KEPzh16OSubCEAk0wBxOe0Cqd5YOig072CpNu3g11gsuFWPKqmZMp7L nQxoifbIy2EznBdyq3nHHxwsk7xyyksVbMFM30Ytfr9zDwqscxai+B/s2lGLPysVIc 4cx3yq9xexrTX9KsamECDiro2k1WGNCgtktr4p8llGyb2IzJgamCFNGpg1pynWbYGM lctfna7FmiOWM/64IcncDiudYGejGxpKaR3HFOq0Roan2EmOo05bt+V4HtaxDsTKJc GoydMFEPKoR1pj8a5Bh1ZCwV5gYbYI8pXhEXOwE83LToLHgjjf86lahnfSXciDaICK 6VdQTnqh3gz4w== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4ZJ7nF5sDNz4x3p; Thu, 20 Mar 2025 12:50:09 +1100 (AEDT) Date: Thu, 20 Mar 2025 11:33:51 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] tcp: Flush socket before checking for more data in active close state Message-ID: References: <20250319190519.3184123-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="v75ECjI+4DeBZGM/" Content-Disposition: inline In-Reply-To: <20250319190519.3184123-1-sbrivio@redhat.com> Message-ID-Hash: MDXDSHIWQEK3IIMD3VMEZT74EY47XLLT X-Message-ID-Hash: MDXDSHIWQEK3IIMD3VMEZT74EY47XLLT 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, Marek =?iso-8859-1?Q?Marczykowski-G=F3recki?= 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: --v75ECjI+4DeBZGM/ Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Mar 19, 2025 at 08:05:19PM +0100, Stefano Brivio wrote: > Otherwise, if all the pending data is acknowledged: >=20 > - tcp_update_seqack_from_tap() updates the current tap-side ACK > sequence (conn->seq_ack_from_tap) >=20 > - next, we compare the sequence we sent (conn->seq_to_tap) to the > ACK sequence (conn->seq_ack_from_tap) in tcp_data_from_sock() to > understand if there's more data we can send. >=20 > If they match, we conclude that we haven't sent any of that data, > and keep re-sending it. >=20 > We need, instead, to flush the socket (drop acknowledged data) before > calling tcp_update_seqack_from_tap(), so that once we update > conn->seq_ack_from_tap, we can be sure that all data until there is > gone from the socket. IIUC, this is, roughly speaking, a manifestation of the difference between "seq ack from tap" and "seq ack to sock". We don't track the latter, because it's kind of implied by the former. However, with the incorrect ordering here the brief window in which they're not the same is biting us. > Link: https://bugs.passt.top/show_bug.cgi?id=3D114 > Reported-by: Marek Marczykowski-G=F3recki > Fixes: 30f1e082c3c0 ("tcp: Keep updating window and checking for socket d= ata after FIN from guest") > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > tcp.c | 1 + > 1 file changed, 1 insertion(+) >=20 > diff --git a/tcp.c b/tcp.c > index 68af43d..fa1d885 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -2049,6 +2049,7 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pi= f, sa_family_t af, > =20 > /* Established connections not accepting data from tap */ > 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(conn, ntohs(th->window)); > tcp_data_from_sock(c, conn); --=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 --v75ECjI+4DeBZGM/ Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmfbYm4ACgkQzQJF27ox 2GcaXQ//ZbI/x9w7Ev6kXRO4MIRg5dRjmV02J3jbwx0QXZEk+nWHloxDJEkSvkMS M+x2vO+kSvm1baxz6BggSCUJYcvh2mB7YSTEJcQX0x0dqFhSjWZahy0Fgo7sCWWK GGYWJjPxO3uukUWFwmCfBewmGjsI5oMLWFOKu2TbZEE7MlppV61czfCtYsiFXLwW XgIJ/hhgsFW+AUocaA17pEqZimVz61g6VZBwUAws1vVok9wYs9uLz6PyX/Dvaf+p RbBl6fa4VBpKMfetmlGI6untztOCW7boSSbGR1PBFGR6izhn26OhyfWaDkLSybVB CIYGDOU5IR+KqJFeaaXFt67Az7ujIZrm21iS9NZbjwUXgLJN91ZX4PSbwpeHtnVa uHOb1UXCu960Xq6KIWPb2b60vajuxCwNkHVCkKLVSbhQke6NGNtS40zoAeQxD/RQ szqMw/XeE1/MRxjDxSt0+KPDfsaqOVIqaCOM37edQXVhBeI0cIlUN9HqPOQ5oUK4 mOpiQAgs5B19c5MPnNPaUAfbneDN7FvFllhfu8ex9W5UDI8ALR23ReBxDbXGSKWz i4xqNWHvZwziud5nyvApOD9UN9NUyth1avY8q9PXc+i+kqT0/2WnX0jl9qddko+N KbiC+WgPUmLPXhdEWCDwbRNKZaD/HhHRo1mOsP81N0r4TbTp7as= =gPRB -----END PGP SIGNATURE----- --v75ECjI+4DeBZGM/--