Repository navigation
Keep segments within the MSS announced by the peer - #103
Closed
FrenchToblerone54 wants to merge 1 commit into
Closed
FrenchToblerone54 wants to merge 1 commit into
FrenchToblerone54 wants to merge 1 commit into
Conversation
Segments were cut to the stack's MTU alone, so a peer on a smaller link received segments larger than the MSS it had announced in its SYN. Read the option from the SYN and bound the payload by it (RFC 9293 3.7.1), counting the TCP options of the segment against it. An announced value below 536 is read as 536.
FrenchToblerone54
force-pushed
the
fix-peer-mss
branch
from
October 17, 2026 08:54
32c9008 to
9ce748d
Compare
Author
|
Reopened as #107 with a cleaned-up commit. |
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.
Problem
Outgoing segments are cut to the stack's MTU and the peer's window only. The MSS option in the peer's SYN is ignored, so a peer behind a smaller link gets segments larger than it said it can take, which can be dropped or fragmented on the way (RFC 9293 section 3.7.1 says a sender must not send a segment larger than the MSS the peer announced).
Reproduce
Open a connection with a SYN carrying
MaximumSegmentSize(600)and write 1460 bytes. The stack sends 1460 bytes in one segment. The new test does this.Fix
Tcbkeepspeer_mss, unbounded by default so connections without the option behave as before.calculate_payload_max_lenbounds the payload by the MSS minus the TCP options of the segment (the MSS counts options but not the 20-byte base header).Test
segments_stay_within_the_peers_mssinsrc/stream/tcp.rscovers an announced MSS of 600 (segments of 600) and of 100 (segments of 536). It fails without the change (left: 1460, right: 600) and passes with it.cargo testandcargo clippy --all-targetsare clean.