Repository navigation
Keep segments within the MSS announced by the peer - #107
Open
FrenchToblerone54 wants to merge 1 commit into
Open
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
tcp-peer-mss
branch
from
October 17, 2026 09:38
9ce748d to
76418eb
Compare
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).TCP_MIN_MSS), so a peer cannot force a few bytes per packet. RFC 9293 section 3.7.1 only fixes the default of 536 for a SYN without the option, it sets no floor for an announced value.Test
segments_stay_within_the_peers_mssinsrc/stream/tcp.rscovers an announced MSS of 600 (segments of 600), of 100 (segments of 100) and of 40 (segments of 88). It fails without the change (left: 1460, right: 600) and passes with it.cargo testandcargo clippy --all-targetsare clean.