Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCP exponential backoff fix #1020

Closed
wants to merge 1 commit into from

Conversation

tomDev5
Copy link
Contributor

@tomDev5 tomDev5 commented Dec 23, 2024

Currently, after a TCP retransmit, the socket timer was set to idle, which means that no actions except for keep-alive are required.
This is incorrect in the case where another TCP retransmission will be required.
This PR adds a test and fixes the problem.

And just to make sure I didn't miss anything - what if set_for_retransmit sets a timeout larger than the keep alive?
I assume that's OK because the socket won't close with unacknowledged data?

Copy link

codecov bot commented Dec 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.83%. Comparing base (2ecd77f) to head (4917477).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1020      +/-   ##
==========================================
+ Coverage   80.81%   80.83%   +0.02%     
==========================================
  Files          81       81              
  Lines       28385    28415      +30     
==========================================
+ Hits        22939    22969      +30     
  Misses       5446     5446              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tomDev5 tomDev5 force-pushed the tcp-exponential-backoff-bug branch from 2640d18 to a94f1eb Compare December 23, 2024 10:21
@tomDev5 tomDev5 force-pushed the tcp-exponential-backoff-bug branch from a94f1eb to a92ec0a Compare December 23, 2024 15:41
@tomDev5 tomDev5 force-pushed the tcp-exponential-backoff-bug branch from a92ec0a to 4917477 Compare December 23, 2024 15:42
@Dirbaio Dirbaio added this pull request to the merge queue Dec 27, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Dec 27, 2024
self.timer.set_for_idle(cx.now(), self.keep_alive);
// Set next time of retransmission. `set_for_retransmit` will exponentially increase it.
self.timer
.set_for_retransmit(cx.now(), self.rtte.retransmission_timeout());
Copy link
Member

@Dirbaio Dirbaio Dec 27, 2024

Choose a reason for hiding this comment

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

i'm not sure if restarting the retransmit timer here is 100% correct, because it's not yet guaranteed we're going to send a packet. Actually transmitting is done further below, which might fail because there's not enough buffers in the device for example.

i've opened #1023 which does this a slightly different way: it still does set_for_idle here so we only restart the retransmit timer if we did actually send a retransmission packet (because it's done after sending), and keeps the delay variable outside the timer (in the RTTE struct) so it doesn't get cleared.

i've included your test from this PR in it.

@tomDev5 tomDev5 deleted the tcp-exponential-backoff-bug branch December 27, 2024 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants