From: Jon Maloy <jmaloy@redhat.com>
To: Anshu Kumari <anskuma@redhat.com>,
passt-dev@passt.top, sbrivio@redhat.com,
ada.urbaniec+bugzilla@gmail.com
Cc: Ada Urbaniec <ada.urbaniec@gmail.com>
Subject: Re: [PATCH v4] tcp: Limit fast retransmit to one per loss event
Date: Fri, 27 Nov 2026 16:07:25 -0500 [thread overview]
Message-ID: <6a6f9609-1fa7-4c51-971b-04133373d1c7@redhat.com> (raw)
In-Reply-To: <20261127175848.664310-1-anskuma@redhat.com>
On 2026-11-27 12:58, Anshu Kumari wrote:
> Every duplicate ACK unconditionally triggered a fast retransmit,
> even when the ACK sequence hadn't advanced.
>
> Guard fast retransmit on !conn->retries, and increment retries
> after the first retransmit. 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.
>
> As a fast retransmit is now accounted in conn->retries, the next
> retransmission timeout is doubled (tcp_timer_ctl() uses conn->retries
> as backoff exponent).
>
> Link: https://bugs.passt.top/show_bug.cgi?id=224
> Reported-by: Ada Urbaniec <ada.urbaniec@gmail.com>
> Signed-off-by: Anshu Kumari <anskuma@redhat.com>
> ---
> v4:
> - Move !conn->retries into the retr check in TAP_FIN_RCVD
> - Add previous ACK/window snapshots in TAP_FIN_RCVD
> - includes Reported-by
>
> ---
> tcp.c | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/tcp.c b/tcp.c
> index 95f4f3e1..f327e62e 100644
> --- a/tcp.c
> +++ b/tcp.c
> @@ -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->retries) {
> + conn->retries++;
> +
> flow_trace(conn,
> "fast re-transmit, ACK: %u, previous sequence: %u",
> conn->seq_ack_from_tap, conn->seq_to_tap);
> @@ -2417,6 +2419,8 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af,
>
> /* Established connections not accepting data from tap */
> if (conn->events & TAP_FIN_RCVD) {
> + uint32_t prev_ack = conn->seq_ack_from_tap;
> + uint16_t prev_wnd = conn->wnd_from_tap;
> bool fin_only, retr;
> size_t dlen;
>
> @@ -2432,7 +2436,7 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af,
> fin_only = (conn->events & TAP_FIN_SENT) &&
> conn->seq_to_tap == conn->seq_ack_from_tap + 1;
>
> - retr = th->ack && !th->fin && !fin_only &&
> + retr = th->ack && !th->fin && !fin_only && !conn->retries &&
> ntohl(th->ack_seq) == conn->seq_ack_from_tap &&
> ntohs(th->window) == conn->wnd_from_tap;
>
> @@ -2444,6 +2448,8 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af,
> now);
>
> if (retr) {
> + conn->retries++;
> +
> flow_trace(conn,
> "fast re-transmit, ACK: %u, previous sequence: %u",
> ntohl(th->ack_seq), conn->seq_to_tap);
> @@ -2452,8 +2458,10 @@ int tcp_tap_handler(const struct ctx *c, uint8_t pif, sa_family_t af,
> return -1;
> }
>
> - if (tcp_tap_window_update(c, conn, ntohs(th->window), now) ||
> - retr)
> + if (tcp_tap_window_update(c, conn, ntohs(th->window), now) &&
> + (retr ||
> + prev_ack != conn->seq_ack_from_tap ||
> + prev_wnd != conn->wnd_from_tap))
> tcp_data_from_sock(c, conn, now);
This looks correct to me: tcp_tap_window_update() updates wnd_from_tap
before the comparison, and seq_ack_from_tap was already updated above.
But the reason for this change isn't obvious from the code, nor from
the commit message. It fixes the half-close case Ada reported,
because tcp_data_from_sock() re-arms the retransmission timer via
conn_flag(), so periodic duplicate ACKs would delay retransmissions
indefinitely. I suggest you add a short comment about this here, a well
as paragraph about it in commit message.
With the comment and commit message updated:
Reviewed-by: Jon Maloy <jmaloy@redhat.com>
prev parent reply other threads:[~2026-11-27 21:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 17:58 Anshu Kumari
2026-11-27 21:07 ` Jon Maloy [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=6a6f9609-1fa7-4c51-971b-04133373d1c7@redhat.com \
--to=jmaloy@redhat.com \
--cc=ada.urbaniec+bugzilla@gmail.com \
--cc=ada.urbaniec@gmail.com \
--cc=anskuma@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).