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

Fix stopped recv stream flow control underflow under reordering #1869

Merged
merged 4 commits into from
May 22, 2024

Conversation

Ralith
Copy link
Collaborator

@Ralith Ralith commented May 18, 2024

Fixes #1818 (probably). Second commit isn't necessary but feels a bit tidier.

If frames are received out of order (e.g. due to packet loss) on a
stopped stream, the local `end` might be less than the high water mark
`Recv::end`. The previous code would set `Assembler::bytes_read` to
that incorrect lower value, potentially after it had previously taken
a higher value.

If `MAX_STREAM_DATA` frames are then queued for that stream (e.g. due
to retransmits prompted by packet loss), we might attempt to transmit
a smaller flow control credit than we had previously. This would cause
an underflow in the subtraction used to judge whether an increase in
flow control credit is worth sending, and violates the spec besides.

Because additional data on a stopped stream isn't useful, there's no
benefit to updating stream-level flow control at all, so we might as
well remove that path entirely. Connection-level flow control is still
maintained at the StreamsState level based on change in the stream's
high-water mark or determination of the final offset.
We only queue MAX_STREAM_DATA when stream data is read by the
application, which never happens for stopped streams, but loss of
packets carrying previously sent MAX_STREAM_DATA frames could still
cause fresh ones to be queued unnecessarily. Filtering them out isn't
strictly necessary, but saves some space in the packet.
@Ralith Ralith force-pushed the fix-stream-credit-underflow branch from b20761c to 825d646 Compare May 19, 2024 00:59
@Ralith
Copy link
Collaborator Author

Ralith commented May 19, 2024

Added a narrow unit test that thoroughly exercises the broken case.

quinn-proto/src/connection/streams/recv.rs Outdated Show resolved Hide resolved
@Ralith Ralith force-pushed the fix-stream-credit-underflow branch from 0b9bed0 to 05423b3 Compare May 22, 2024 20:07
@Ralith Ralith merged commit 91dd240 into main May 22, 2024
8 checks passed
@Ralith Ralith deleted the fix-stream-credit-underflow branch May 22, 2024 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Underflow computing growth in stream data flow control credit
2 participants