* [PATCH v3] tcp: Limit fast retransmit to one per loss event
@ 2026-11-20 17:37 Anshu Kumari
2026-11-20 19:48 ` Jon Maloy
2026-11-20 20:18 ` Stefano Brivio
0 siblings, 2 replies; 5+ messages in thread
From: Anshu Kumari @ 2026-11-20 17:37 UTC (permalink / raw)
To: passt-dev, sbrivio, ada.urbaniec+bugzilla; +Cc: anskuma
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.
Link: https://bugs.passt.top/show_bug.cgi?id=224
Signed-off-by: Anshu Kumari <anskuma@redhat.com>
---
tcp.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tcp.c b/tcp.c
index 95f4f3e1..d3d65f76 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);
@@ -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->retries) {
+ conn->retries++;
+
flow_trace(conn,
"fast re-transmit, ACK: %u, previous sequence: %u",
ntohl(th->ack_seq), conn->seq_to_tap);
--
2.55.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] tcp: Limit fast retransmit to one per loss event
2026-11-20 17:37 [PATCH v3] tcp: Limit fast retransmit to one per loss event Anshu Kumari
@ 2026-11-20 19:48 ` Jon Maloy
2026-11-20 20:18 ` Stefano Brivio
1 sibling, 0 replies; 5+ messages in thread
From: Jon Maloy @ 2026-11-20 19:48 UTC (permalink / raw)
To: passt-dev
On 2026-11-20 12:37, 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.
>
> Link: https://bugs.passt.top/show_bug.cgi?id=224
> Signed-off-by: Anshu Kumari <anskuma@redhat.com>
> ---
> tcp.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/tcp.c b/tcp.c
> index 95f4f3e1..d3d65f76 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);
> @@ -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->retries) {
> + conn->retries++;
> +
> flow_trace(conn,
> "fast re-transmit, ACK: %u, previous sequence: %u",
> ntohl(th->ack_seq), conn->seq_to_tap);
This looks correct to me, and matches what Stefano suggested for v2.
Two minor things:
- Missing changelog for v3 below the '---' line.
- In the TAP_FIN_RCVD path, tcp_data_from_sock() is still called if
'retr' is set but we skip the retransmission because conn->retries
is non-zero. It's probably harmless (no rewind, so we just send
what the window allows), but it might be cleaner to fold the
!conn->retries check into 'retr' there, so that both uses agree.
It might also be worth mentioning in the commit message that, as we
now account a fast retransmit in conn->retries, the next RTO is
doubled (tcp_timer_ctl() uses it as backoff exponent), and the
retransmission counts towards TCP_MAX_RETRIES.
With or without those changes:
Reviewed-by: Jon Maloy <jmaloy@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] tcp: Limit fast retransmit to one per loss event
2026-11-20 17:37 [PATCH v3] tcp: Limit fast retransmit to one per loss event Anshu Kumari
2026-11-20 19:48 ` Jon Maloy
@ 2026-11-20 20:18 ` Stefano Brivio
[not found] ` <CAA7t2yTP5oGNbyv4B3jt36buwTo2+_61OQoSRkE5m97xxdckzQ@mail.gmail.com>
1 sibling, 1 reply; 5+ messages in thread
From: Stefano Brivio @ 2026-11-20 20:18 UTC (permalink / raw)
To: ada.urbaniec+bugzilla; +Cc: Anshu Kumari, passt-dev
On Fri, 20 Nov 2026 23:07:56 +0530
Anshu Kumari <anskuma@redhat.com> 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.
Ada, would you have a chance to try this patch out? Would you like to
be credited with a Reported-by: tag?
--
Stefano
^ permalink raw reply [flat|nested] 5+ messages in thread
* Fwd: [PATCH v3] tcp: Limit fast retransmit to one per loss event
[not found] ` <CAA7t2yTP5oGNbyv4B3jt36buwTo2+_61OQoSRkE5m97xxdckzQ@mail.gmail.com>
@ 2026-11-21 11:00 ` Ada Urbaniec
2026-11-23 0:27 ` Stefano Brivio
0 siblings, 1 reply; 5+ messages in thread
From: Ada Urbaniec @ 2026-11-21 11:00 UTC (permalink / raw)
To: Anshu Kumari, passt-dev
[-- Attachment #1: Type: text/plain, Size: 1918 bytes --]
Hi Stefano, Anshu,
Thanks! Yes, I would be happy to have a Reported-by tag. Happy to help!
I tested v3 as sent on my laptop, using source revision 6aa4f88 and Linux
7.0.0-43. I used an extended version of the reproducer I uploaded to bug
224 (attachment 73), with added periodic ACKs, delayed ACKs, zero-window
cases and retry timing measurements.
With both directions open, dropping the first data segment stops causing a
retransmission storm. If the segment remains missing, v3 retries after
about two seconds.
With a half-closed connection (the client sends FIN, then waits for the
response), v3 also stops the storm. Two cases still fail when the client
sends the same ACK every 10 ms:
* If the missing segment is never accepted, there is no further retry
during the four-second test.
* If the client starts accepting that segment after 100 ms, there is still
no retry, and the transfer does not complete within four seconds.
Without those repeated ACKs, the half-close recovery case completes after
about two seconds.
V3 stops the storm, but repeated ACKs can still prevent a half-closed
connection from retrying. The earlier patch with the timer fix does retry
under the same conditions.
On Fri, Nov 20, 2026 at 9:18 PM Stefano Brivio <sbrivio@redhat.com> wrote:
> On Fri, 20 Nov 2026 23:07:56 +0530
> Anshu Kumari <anskuma@redhat.com> 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.
>
> Ada, would you have a chance to try this patch out? Would you like to
> be credited with a Reported-by: tag?
>
> --
> Stefano
>
>
[-- Attachment #2: Type: text/html, Size: 2451 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] tcp: Limit fast retransmit to one per loss event
2026-11-21 11:00 ` Fwd: " Ada Urbaniec
@ 2026-11-23 0:27 ` Stefano Brivio
0 siblings, 0 replies; 5+ messages in thread
From: Stefano Brivio @ 2026-11-23 0:27 UTC (permalink / raw)
To: Ada Urbaniec; +Cc: Anshu Kumari, passt-dev, Jon Maloy
On Sat, 21 Nov 2026 12:00:38 +0100
Ada Urbaniec <ada.urbaniec@gmail.com> wrote:
> Hi Stefano, Anshu,
>
> Thanks! Yes, I would be happy to have a Reported-by tag. Happy to help!
>
> I tested v3 as sent on my laptop, using source revision 6aa4f88 and Linux
> 7.0.0-43. I used an extended version of the reproducer I uploaded to bug
> 224 (attachment 73), with added periodic ACKs, delayed ACKs, zero-window
> cases and retry timing measurements.
Thanks for testing. Would you have a chance to upload that extended
version to the ticket, so that we can try further changes against that?
> With both directions open, dropping the first data segment stops causing a
> retransmission storm. If the segment remains missing, v3 retries after
> about two seconds.
>
> With a half-closed connection (the client sends FIN, then waits for the
> response), v3 also stops the storm. Two cases still fail when the client
> sends the same ACK every 10 ms:
>
> * If the missing segment is never accepted, there is no further retry
> during the four-second test.
> * If the client starts accepting that segment after 100 ms, there is still
> no retry, and the transfer does not complete within four seconds.
Fixing things for proper compliance with RFC 5681 will need a more
involved rework, and this looks relatively minor (it should just take
longer), so we could probably ignore this for the moment. On the other
hand, I guess I know what's going on, and maybe we can quickly improve
this temporary fix without adding much complexity:
- in the TAP_FIN_RCVD path, as of v3, as noted by Jon at:
https://archives.passt.top/passt-dev/7875d8c3-7d95-4986-a2f5-2c4a8618f328@redhat.com/
we still call tcp_data_from_sock(), which actually comes with the
side effect of resetting timers (via conn_flag()) and unnecessarily
delay retransmissions. If we skip that on !retr, as suggested by
Jon, we should fix a part of this (maybe even all of it, I didn't
test)
- we now increase conn->retries so that it will start from 1 on a slow
retransmit (not preceded by a fast retransmit), affecting (I'm not
entirely sure) the timeout calculations in tcp_timer_ctl().
I don't see a simple way to avoid that side effect with the current
meaning of conn->retries. But if we *later* introduce one bit
indicating that we already started retransmitting, as Anshu's v2
does, then we should be able to account for this and avoid to
spuriously increase the timeout (conn->retries could start from 0,
and we would just skip fast retransmits if conn->retransmitting is
already set).
In any case, this needs a more complete implementation, as I pointed
out, so I wouldn't change this for the moment being.
> Without those repeated ACKs, the half-close recovery case completes after
> about two seconds.
>
> V3 stops the storm, but repeated ACKs can still prevent a half-closed
> connection from retrying. The earlier patch with the timer fix does retry
> under the same conditions.
The only issue I see with that patch is that it introduces further
complexity (including a new flag) that we might very likely want to
drop at a later point, because RFC 5681 dictates a more complicated
implementation compared to what we have now.
So I would really try to avoid that if we can fix the most annoying
part of the issue with 4-5 lines now (without a new connection flag).
--
Stefano
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-23 0:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20 17:37 [PATCH v3] tcp: Limit fast retransmit to one per loss event Anshu Kumari
2026-11-20 19:48 ` Jon Maloy
2026-11-20 20:18 ` Stefano Brivio
[not found] ` <CAA7t2yTP5oGNbyv4B3jt36buwTo2+_61OQoSRkE5m97xxdckzQ@mail.gmail.com>
2026-11-21 11:00 ` Fwd: " Ada Urbaniec
2026-11-23 0:27 ` Stefano Brivio
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).