public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: Anshu Kumari <anskuma@redhat.com>
Cc: ada.urbaniec+bugzilla@gmail.com, passt-dev@passt.top
Subject: Re: [PATCH v2] tcp: Limit fast retransmit to one per loss event
Date: Fri, 20 Nov 2026 10:07:12 +0100 (CET)	[thread overview]
Message-ID: <20261120100711.6df974db@elisabeth> (raw)
In-Reply-To: <20261120074304.1698961-1-anskuma@redhat.com>

On Fri, 20 Nov 2026 13:13:04 +0530
Anshu Kumari <anskuma@redhat.com> wrote:

> Every duplicate ACK unconditionally triggered a fast retransmit,
> even when the ACK sequence hadn't advanced.
> 
> Add a dup_acks counter (as a union with retries) to
> tcp_tap_conn and tcp_tap_transfer that gets incremented on the
> first fast retransmit and cleared when the ACK sequence
> advances.

I still can't understand this part.  Why do we need to do this in this
patch? That is, in detail:

> 
> This is a quick fix to stop the amplification storm. Full
> compliance with RFC 5681 Section 3.2 (three duplicate ACKs)
> is left to a later patch.
> 
> Link: https://bugs.passt.top/show_bug.cgi?id=224
> Signed-off-by: Anshu Kumari <anskuma@redhat.com>
> ---
> v2:
>   - added union for retries and dup_acks.
>   - removed retransmitting flag.
> ---
>  tcp.c      | 12 ++++++++----
>  tcp_conn.h | 16 ++++++++++++----
>  2 files changed, 20 insertions(+), 8 deletions(-)
> 
> diff --git a/tcp.c b/tcp.c
> index 95f4f3e1..d205cd41 100644
> --- a/tcp.c
> +++ b/tcp.c
> @@ -242,7 +242,7 @@
>   *     - consume buffer by difference between new ack_seq and @seq_ack_from_tap
>   *     - update @seq_ack_from_tap from ack_seq in header
>   *     - on two duplicated ACKs, reset @seq_to_tap to @seq_ack_from_tap, and
> - *       resend with steps listed above
> + *       resend with steps listed above, once per loss event
>   *
>   * - from tap/guest to socket:
>   *   - on packet from tap/guest:
> @@ -1263,7 +1263,7 @@ static void tcp_update_seqack_from_tap(const struct ctx *c,
>  		if (SEQ_LT(seq, conn->seq_to_tap))
>  			conn_flag(c, conn, ACK_FROM_TAP_DUE, now);
>  
> -		conn->retries = 0;
> +		conn->dup_acks = 0;

We're not actually counting them, so this isn't entirely true (and in
any case not needed in this patch).

>  		conn->seq_ack_from_tap = seq;
>  	}
>  }
> @@ -2082,7 +2082,9 @@ static int tcp_data_from_tap(const struct ctx *c, struct tcp_tap_conn *conn,
>  
>  	tcp_tap_window_update(c, conn, max_ack_seq_wnd, now);
>  
> -	if (retr) {
> +	if (retr && !conn->dup_acks) {

This isn't about the number of duplicate ACKs.  What I was suggesting
in my draft patch on https://bugs.passt.top/show_bug.cgi?id=224 is:

	if (retr && !conn->retries)

meaning: we have a request for fast retransmit, and we didn't
retransmit yet.

> +		conn->dup_acks++;

This isn't true either.  We can't count them yet, with this patch.  I
think this should be conn->retries++ (or conn->retries = 1).

> +
>  		flow_trace(conn,
>  			   "fast re-transmit, ACK: %u, previous sequence: %u",
>  			   conn->seq_ack_from_tap, conn->seq_to_tap);
> @@ -2443,7 +2445,9 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af,
>  			tcp_update_seqack_from_tap(c, conn, ntohl(th->ack_seq),
>  						   now);
>  
> -		if (retr) {
> +		if (retr && !conn->dup_acks) {

Same as above, I think this should be if (retr && !conn->retries).

> +			conn->dup_acks++;

Same as above, I think this should be conn->retries++.

> +
>  			flow_trace(conn,
>  				   "fast re-transmit, ACK: %u, previous sequence: %u",
>  				   ntohl(th->ack_seq), conn->seq_to_tap);
> diff --git a/tcp_conn.h b/tcp_conn.h
> index 3173ddb9..ba175a3e 100644
> --- a/tcp_conn.h
> +++ b/tcp_conn.h
> @@ -16,7 +16,8 @@
>  /**
>   * struct tcp_tap_conn - Descriptor for a TCP connection (not spliced)
>   * @f:			Generic flow information
> - * @retries:		Number of retries occurred due to timeouts
> + * @retries:		Number of retries due to timeouts
> + * @dup_acks:		Number of duplicate ACKs (union with @retries)

Not true, at the moment.  This is simply @retries with this patch.
This change is not needed.

>   * @ws_from_tap:	Window scaling factor advertised from tap/guest
>   * @ws_to_tap:		Window scaling factor advertised to tap/guest
>   * @tap_mss:		MSS advertised by tap/guest, rounded to 2 ^ TCP_MSS_BITS
> @@ -41,7 +42,10 @@ struct tcp_tap_conn {
>  	struct flow_common f;
>  
>  #define TCP_RETRIES_BITS		3
> -	unsigned int	retries		:TCP_RETRIES_BITS;
> +	union {
> +		unsigned int	retries		:TCP_RETRIES_BITS;
> +		unsigned int	dup_acks	:TCP_RETRIES_BITS;
> +	};

Same here, I don't think this part is needed at this stage.

>  #define TCP_MAX_RETRIES			MAX_FROM_BITS(TCP_RETRIES_BITS)
>  
>  #define TCP_WS_BITS			4	/* RFC 7323 */
> @@ -122,7 +126,8 @@ struct tcp_tap_conn {
>   * struct tcp_tap_transfer - Migrated TCP data, flow table part, network order
>   * @pif:		Interfaces for each side of the flow
>   * @side:		Addresses and ports for each side of the flow
> - * @retries:		Number of retries occurred due to timeouts
> + * @retries:		Number of retries due to timeouts
> + * @dup_acks:		Number of duplicate ACKs (union with @retries)

Same here (not needed).

>   * @ws_from_tap:	Window scaling factor advertised from tap/guest
>   * @ws_to_tap:		Window scaling factor advertised to tap/guest
>   * @events:		Connection events, implying connection states
> @@ -142,7 +147,10 @@ struct tcp_tap_transfer {
>  	uint8_t		pif[SIDES];
>  	struct flowside	side[SIDES];
>  
> -	uint8_t		retries;
> +	union {
> +		uint8_t		retries;
> +		uint8_t		dup_acks;
> +	};

And here (not needed).

>  	uint8_t		ws_from_tap;
>  	uint8_t		ws_to_tap;
>  	uint8_t		events;

-- 
Stefano


      reply	other threads:[~2026-11-20  9:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  7:43 Anshu Kumari
2026-11-20  9:07 ` Stefano Brivio [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=20261120100711.6df974db@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=ada.urbaniec+bugzilla@gmail.com \
    --cc=anskuma@redhat.com \
    --cc=passt-dev@passt.top \
    /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).