public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top, Jon Maloy <jmaloy@redhat.com>
Subject: Re: [PATCH] tcp: Send "empty" handshake ACK before first data segment
Date: Tue, 15 Oct 2024 11:01:59 +1100	[thread overview]
Message-ID: <Zw2w9xERyWMWZ3QO@zatzit.fritz.box> (raw)
In-Reply-To: <20241014223820.912829-1-sbrivio@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2077 bytes --]

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.
> 
> 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.
> 
> 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.
> 
> 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.
> 
> Queue the empty ACK first, so that it gets a lower sequence number,
> before checking for any data from the socket.
> 
> Reported-by: David Gibson <david@gibson.dropbear.id.au>
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  tcp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> 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 struct ctx *c,
>  		return;
>  	}
>  
> +	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);
>  }
>  
>  /**

-- 
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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2024-10-15  0:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-14 22:38 [PATCH] tcp: Send "empty" handshake ACK before first data segment Stefano Brivio
2024-10-15  0:01 ` David Gibson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zw2w9xERyWMWZ3QO@zatzit.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=jmaloy@redhat.com \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).