aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorAnshu Kumari <anskuma@redhat.com>2026-11-30 12:14:14 +0530
committerStefano Brivio <sbrivio@redhat.com>2026-11-30 22:20:29 +0100
commit2ac075a62864822f109b766fd474eeb9274d7431 (patch)
tree785b828fb271218156e0ec5a8913db8f39be24c9
parentbb42edcc223ad40ee642004f83d2a62ebb47ae0b (diff)
downloadpasst-2ac075a62864822f109b766fd474eeb9274d7431.tar
passt-2ac075a62864822f109b766fd474eeb9274d7431.tar.gz
passt-2ac075a62864822f109b766fd474eeb9274d7431.tar.bz2
passt-2ac075a62864822f109b766fd474eeb9274d7431.tar.lz
passt-2ac075a62864822f109b766fd474eeb9274d7431.tar.xz
passt-2ac075a62864822f109b766fd474eeb9274d7431.tar.zst
passt-2ac075a62864822f109b766fd474eeb9274d7431.zip
tcp: Limit fast retransmit to one per loss event
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). In TAP_FIN_RECVD path, tcp_tap_window_update() returns true for any non-zero window because of which tcp_data_from_sock() gets called for every ACKs(even for unchanged duplicate ACK). If the send window is full calling tcp_data_from_sock() re-armed the retransmission timer via conn_flag(),so periodic duplicate ACKs could delay retransmission indefinitely and prevent a half-closed connection from recovering. Therefore, only call tcp_data_from_sock() when the ACK or window actually changed. 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> Reviewed-by: Jon Maloy <jmaloy@redhat.com> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--tcp.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/tcp.c b/tcp.c
index 409f4ce..07a5e9c 100644
--- a/tcp.c
+++ b/tcp.c
@@ -2091,7 +2091,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);
@@ -2427,6 +2429,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;
@@ -2442,7 +2446,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;
@@ -2454,6 +2458,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);
@@ -2462,8 +2468,11 @@ 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)
+ /* An unchanged ACK and window must not restart the timer. */
+ 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);
if (conn->seq_ack_from_tap == conn->seq_to_tap) {