Skip to content

Conversation

@matheus23
Copy link
Member

This adds a previously failing test case that best illustrates the problem.

Here's a picture anyways:
image

When the server receives a MAX_PATH_ID frame and agrees to increase it, it'll increase it after sending a MAX_PATH_ID frame itself.
Now, from the server's perspective the maximum path ID might be set to 14 (a value I saw in practice).
Then it starts issuing NEW_CONNECTION_ID frames with path IDs up to what it thinks is the max path id.
However, these two datagrams might get reordered. This is what we synthetically make happen in the test issue_max_path_id_reordered.
Then, the client will receive newer NEW_CONNECTION_ID frames while it still thinks the max path ID might be something like 12 and promptly close the connection with a protocol violation.

The fix I propose is to be more lenient when reading incoming packets. The NEW_CONNECTION_ID frame we got IMO is fine because we've already sent out a MAX_PATH_ID frame with 14. The fact that the other side hasn't sent us a MAX_PATH_ID frame is kind of secondary.
The other possible fix would be to delay the remote using any higher path IDs until it made sure the MAX_PATH_ID frame was acknowledged. I think this adds unnecessary delays.

The specification doesn't really seem to agree with me on this.
Section 4 says:

Receipt of multipath-specific frames that use a path ID that is
greater than the announced Maximum Paths value in the MAX_PATH_ID
frame or in the initial_max_path_id transport parameter, if no
MAX_PATH_ID frame was received yet, MUST be treated as a connection
error of type PROTOCOL_VIOLATION.

I interpret the MAX_PATH_ID frames as the ones that are received, due to it referring to having received them or not in the next sentence.
This means the situation from the picture above would be the connection's flow according to the specification. (But I think that's a specification bug.)

@matheus23 matheus23 self-assigned this Nov 26, 2025
@n0bot n0bot bot added this to iroh Nov 26, 2025
@github-project-automation github-project-automation bot moved this to 🏗 In progress in iroh Nov 26, 2025
Copy link
Collaborator

@flub flub left a comment

Choose a reason for hiding this comment

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

Nice, but please update the description because as discussed this is not being more lenient. This is rather the correct interpretation of the spec.

@matheus23 matheus23 changed the title fix: Be more lenient when accepting frames with path_ids bigger than Connection::max_path_id fix: Accept or reject incoming frames based on self.local_max_path_id instead of Connection::max_path_id Nov 27, 2025
@matheus23
Copy link
Member Author

I'm just going to merge the two commits separately, if that's fine by you. The description isn't included in that case.

@matheus23 matheus23 merged commit 5bd31b7 into protocol-simplification Nov 27, 2025
2 of 13 checks passed
@matheus23 matheus23 deleted the matheus23/fix-max-path-id branch November 27, 2025 10:01
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in iroh Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants