Skip to content

net/tcp/tcp_send: Remove work_available check when updating retransmit timer - #19589

Open
zhekunren wants to merge 1 commit into
apache:masterfrom
zhekunren:fix/tcp-retransmit-timer-remove-work-available
Open

net/tcp/tcp_send: Remove work_available check when updating retransmit timer#19589
zhekunren wants to merge 1 commit into
apache:masterfrom
zhekunren:fix/tcp-retransmit-timer-remove-work-available

Conversation

@zhekunren

Copy link
Copy Markdown

Problem

The original condition work_available(&conn->work) && tx_unacked != 0
prevented tcp_update_retrantimer from being called when the work queue
was still busy, leaving conn->timer stale or zero. This caused the RTT
estimation to compute a false RTT (m = rto - 0 = rto), creating a
positive feedback loop that inflated the RTO to extreme values (e.g.,
232 half-seconds = ~116 seconds).

Detailed Scenario

  1. First send: work_available is true, the condition passes,
    conn->timer is set to conn->rto, and the work queue is scheduled.
  2. Second send (work still running): work_available is false, the
    condition fails, tcp_update_retrantimer is not executed, and
    conn->timer keeps its previous value.
  3. Third send (work just fired but still unavailable): work_available
    is still false, the timer is not reset; if the timer expires in the
    meantime, conn->timer is decremented to 0.
  4. ACK arrives: conn->timer is 0, so the RTT estimation computes
    m = rto - 0 = rto, producing a bogus measurement.

Fix

Remove the work_available check so that tcp_update_retrantimer is
always called when there is unacknowledged data. The decision to re-queue
the work is handled internally by tcp_update_timer. This ensures:

  • When the ACK arrives, timer is always a freshly set value.
  • m = rto - timer truthfully reflects the actual RTT.
  • The bogus measurement caused by timer = 0 is avoided.

@zhekunren
zhekunren force-pushed the fix/tcp-retransmit-timer-remove-work-available branch from 2606ae9 to c127429 Compare July 31, 2026 09:31
@masc2008

Copy link
Copy Markdown
Contributor

smart fix : )

@jerpelea jerpelea left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename the commit tile to
net/tcp/tcp_send: Remove work_available check when updating retransmit timer

@jerpelea jerpelea changed the title tcp_send: Remove work_available check when updating retransmit timer net/tcp/tcp_send: Remove work_available check when updating retransmit timer Jul 31, 2026
@github-actions github-actions Bot added Area: Networking Effects networking subsystem Size: XS The size of the change in this PR is very small labels Jul 31, 2026
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

hifive1-revb

@zhekunren
zhekunren requested a review from jerpelea August 3, 2026 02:16
…t timer

The condition work_available(&conn->work) && tx_unacked != 0
prevented tcp_update_retrantimer from being called when the work
queue was still busy, leaving conn->timer stale or zero on
subsequent sends. This caused the RTT estimation to compute a
false RTT (m = rto - 0 = rto), creating a positive feedback loop
that inflated the RTO to extreme values (e.g., 232 half-seconds
= ~116 seconds).

Fix: remove the work_available check so that tcp_update_retrantimer
is always called when there is unacknowledged data. The decision to
re-queue the work is handled internally by tcp_update_timer.

Signed-off-by: zhekunren <zhekunren@qq.com>
@zhekunren
zhekunren force-pushed the fix/tcp-retransmit-timer-remove-work-available branch from c127429 to c3267f8 Compare August 3, 2026 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Networking Effects networking subsystem Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants