Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1151.
Cause
In
tcpoutput,usableis au32int:When more is in flight than the window allows (
sent > snd.wnd), the subtraction wraps to about 4G, so theif(usable < ssize)clamp never applies. The sender then sends a full segment every time it gets the chance.It takes very little to get there. Scaled windows are rounded to their granularity (8 bytes at scale 3, Linux's included), so the peer's right edge can draw back by a few bytes between ACKs. The sender is then a few bytes over its window, and from that moment it runs away.
What the traces showed
Pi 4, devssl over loopback, using diagnostic kernels with timestamped
netloglines:SENDER SAW SHRINK by 2, thenOVERRUN by 16346 ... usable -2, continuing toOVERRUN by 392258: the sender kept sending full segments ever further past the window.qlen 524280,rcv.wnd 0), sotcptrimdropped them.Fix
Clamp at zero:
if(usable > sent) usable -= sent; else usable = 0;. The sender now waits for the window, as it should.Measured
Pi 4,
crypto_benchover loopback, three 2 s runs per record size. Each block was a fresh tryboot. All kernels include #1150's loopback queue.Scope
This isn't specific to loopback or devssl. It affects any native-kernel TCP connection whose receiver falls behind its sender and fills its window: a slow consumer, a Pi serving a fast client, or a Linux peer whose scaled window rounds down. It doesn't affect the hosted emulator, which uses the host's TCP.
Tests
tests/host/kernelpins_test.shpins the clamp: everyusable -= sentintcpoutputmust be guarded. I checked that it fails on master'stcp.c.Not in this PR, possible follow-ups: