Skip to content

Improve stream reset handling#85

Open
boivie wants to merge 4 commits intowebrtc:mainfrom
boivie:feature-improve-stream-reset
Open

Improve stream reset handling#85
boivie wants to merge 4 commits intowebrtc:mainfrom
boivie:feature-improve-stream-reset

Conversation

@boivie
Copy link
Collaborator

@boivie boivie commented Jan 29, 2026

With commit 823705f, stream handling was extracted to its own module, similar to how to C++ module was initially written. With that, it was possible to backport the stream reset handling unit tests to this Rust implementation. With that, some additional validation was added that was missing in the Rust version.

The C++ version has had two recent improvements to become compliant with RFC6525, which was identified in https://issues.webrtc.org/issues/379844648. As this was a breaking change, this was rolled out into two parts in the C++ version: One part that relaxed sequence number handling for incoming requests, to support both the old implementation and the RFC compliant behavior. This was rolled out to Chrome 144. Now with Chrome 146 to be released next, the next part was submitted to the C++ version, to use the correct sequence number when sending out requests.

These two changes have now been backported to the Rust version.

Also, the code has been refactored, to make it easier to maintain.

Please try to enjoy each commit equally.

@boivie boivie force-pushed the feature-improve-stream-reset branch from 5c3ffda to b48ff88 Compare January 29, 2026 09:46
With stream_reset.rs extracted into its own module, it's easier to create 
unit tests that verify edge cases etc. The existing C++ unit tests from
stream_reset_handler_test.cc could now be migrated.

To make tests more readable, a fixture was created that could be re-used 
in similar modules. For now, keep them private until we add more test
coverage to the other modules.

Some test cases could not easily be converted 1:1 as the C++ implementation
works with the send queue as an interface (and mocks it), while the Rust 
implementation doesn't use mocks.
    
The current implementation of the Stream Reset Handler strictly validates
incoming Re-configuration Request Sequence Numbers. If a request is a
retransmission (same sequence number), it immediately returns the cached
response, which was how RFC6525 was interpreted.

However, per recent discussions (and there will be an errata to clarify
this), if a request was previously responded to with "In Progress"
(because the Sender's Last Assigned TSN hadn't been reached), the
receiver must re-evaluate the condition upon receiving a retransmission.
The current implementation creates a deadlock with peers that does this:
The peer retransmits the same sequence number, and dcSCTP keeps replying
"In Progress" from its cache without checking if the TSN condition is
now met.

This CL relaxes the validation logic. If a request is a retransmission
and the last result was "In Progress", the handler will now re-evaluate
the state (check the cumulative ack against the sender's last assigned
TSN). If the condition is met, it proceeds to reset the streams;
otherwise, it returns "In Progress" again.

This change maintains backward compatibility with older peers (like
current dcSCTP senders) that increment the sequence number when retrying
after an "In Progress" response.

This is a Rust backport of 
https://webrtc-review.googlesource.com/c/src/+/427361
Separate handling of (incoming, outgoing) requests, and responses.
@boivie boivie force-pushed the feature-improve-stream-reset branch 3 times, most recently from 7e06093 to d6176ef Compare January 29, 2026 10:12
RFC6525 requires that if a Re-configuration Request is responded to
with "In Progress", the sender should wait and then retransmit the same
request (with the same Request Sequence Number). Previously, dcSCTP
would treat an "In Progress" response as a trigger to retry with a new
sequence number (incremented). This behavior was initially kept for
compatibility while the receiver-side fix (to handle retransmissions
correctly) was being rolled out.

Now that receivers can correctly handle retransmissions of requests that
were previously "In Progress" (by re-evaluating the conditions), this CL
updates the sender to be compliant with the RFC.

When a Stream Reset Request receives an "In Progress" response:

1. The timer is restarted.
2. The request is re-sent with the same sequence number (instead of
    incrementing it).
3. The retransmission is NOT counted as an error (timeout). This is
    crucial because "In Progress" is a valid state, not a failure, and
    counting it as an error could lead to premature connection tear-down.

This completes the work to make Stream Reset fully compliant with
RFC6525 regarding "In Progress" handling.

This is a Rust backport of 
https://webrtc-review.googlesource.com/c/src/+/443941.
@boivie boivie force-pushed the feature-improve-stream-reset branch from d6176ef to 9d93b89 Compare January 29, 2026 10:14
@boivie boivie requested review from eshrubs and lndmrk January 29, 2026 10:18
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.

1 participant