Repository navigation
feat(transport): close connection after N consecutive PTOs - #3662
Conversation
There was a problem hiding this comment.
Clean, well-motivated feature with good prior-art backing. The implementation is minimal and correctly mirrors the IdleTimeout path (direct transition to State::Closed, no CONNECTION_CLOSE sent into the black hole). The new pto_count() accessor cleanly delegates to the existing PtoState without duplicating state.
Two points worth discussing:
-
Handshake-phase PTOs: the check currently fires regardless of connection state. Initial/Handshake-space PTOs also increment
PtoState::count, so a lossy handshake (large server certificate, middlebox interference during handshake) could triggerTooManyPtosbefore the connection is established. The motivating scenario is post-handshake; gating onself.state.connected()would scope the feature to match. -
max_pto(Some(0)): sincePtoState::newstartscountat 1, a zero threshold would close the connection on the very first PTO, which is likely never desirable. A guard (debug assert orNonZeroUsize) would prevent accidental misconfiguration.
The test is solid — it verifies both the error variant and the "earlier than idle timeout" invariant. A follow-up test showing that an intermediate ACK resets the counter would further strengthen confidence in the consecutive-only semantics.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3662 +/- ##
==========================================
+ Coverage 95.19% 96.80% +1.60%
==========================================
Files 111 120 +9
Lines 38145 40882 +2737
Branches 38145 40882 +2737
==========================================
+ Hits 36314 39575 +3261
- Misses 1142 1280 +138
+ Partials 689 27 -662
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
What if there is just a temporary drop in connectivity? Killing connections because the link went down for 10s seems harsh? |
There was a problem hiding this comment.
Pull request overview
This PR introduces an opt-in transport safeguard to proactively close QUIC connections that appear to be on a black-holed path by limiting the number of consecutive, unacknowledged PTO firings, surfacing a distinct close reason to the application.
Changes:
- Add
ConnectionParameters::max_pto(Some(count))to configure a maximum number of consecutive PTOs without acknowledgements. - Close the connection locally with a new
Error::TooManyPtosonce the threshold is reached. - Add coverage to validate that
max_ptocloses earlier than the idle timeout in a black-hole scenario.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
neqo-transport/src/recovery/mod.rs |
Exposes consecutive PTO count from loss recovery state. |
neqo-transport/src/lib.rs |
Adds Error::TooManyPtos and validates its error-code mapping in unit tests. |
neqo-transport/src/connection/tests/idle.rs |
Adds a black-hole regression test ensuring close happens before idle timeout and reports TooManyPtos. |
neqo-transport/src/connection/params.rs |
Adds max_pto connection parameter with builder/getter and documentation. |
neqo-transport/src/connection/mod.rs |
Enforces max_pto during timer processing by closing after too many consecutive PTOs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merging this PR will regress 1 benchmark
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Memory | simulated/10-streams/each-1048576-bytes |
11.4 MB | 12.4 MB | -7.86% |
| ⚡ | Simulation | simulated/10-streams/each-1048576-bytes |
246.9 ms | 231 ms | +6.85% |
| ⚡ | Simulation | coalesce_acked_from_zero 1 ranges |
1.4 µs | 1.4 µs | +4.2% |
| ⚡ | Simulation | coalesce_acked_from_zero 3 ranges |
1.9 µs | 1.8 µs | +3.24% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing mxinden-bot:max-pto-declare-broken-connection (3d5d279) with main (9ec0cc6)
We would kill the connection and establish a new one. I would argue after a 10s connectivity loss, the <1s connection re-establishment time (potentially using 0-RTT) is negligible in terms of user experience. |
|
I'm all for automatically/transparently retrying sooner, but an earlier comments talks about "surface an actionable error page sooner", which is not that. |
@larseggert I am not sure I am following. Can you rephrase the above? In the facebook incident case, requests were sent on a dead connection, but only failed after 30s, i.e. the connection idle timeout. The faster we kill the dead connection, the faster Firefox learns that the request fails, the faster Firefox can show a network error page, e.g. with a hint to disable ones anti virus. |
|
From the first comment, it sounded like what this does is show an error page sooner, which I think is of questionable benefit. Your later comment then says this would let us retry sooner, which is obviously vastly better. I was reacting on the discrepancy. |
|
I'm supportive of this feature, though I think that we should move closer to the Chrome approach, where we enable the fast PTO as well. The fast PTO isn't quite a a TLP, but it does accelerate loss detection far more than a PTO. 7 PTOs with a PTO speedup brings the times down even further. Note that we should ensure that this feature is not engaged until we have an RTT estimate. I need to check how you implemented this, but the super-long RTT cases will fail to connect if we let this act without a solid estimate. |
|
FWIW, we have been doing fast PTO for the DoH connections in Gecko for a while now, and I don't think we're seeing issues. Am OK with doing it for all. |
|
14e8d80 to
4f4602a
Compare
Add `ConnectionParameters::max_pto`, closing the connection with a distinct `Error::TooManyPtos` once N consecutive PTOs fire without acknowledgement, i.e. the path has black-holed. A safeguard for a broken path that gives up sooner than, and with a more actionable reason than, the idle timeout. Disabled by default (`None`). Only engaged once connected, so a black-holed handshake is left to happy eyeballs; this also guarantees an RTT estimate underpins the PTO backoff. `max_pto` takes a `NonZeroUsize` so a zero threshold is unrepresentable, and `TooManyPtos` reuses the NO_VIABLE_PATH (0x10) transport error code. Prior art for giving up on a path before the idle timeout: - mvfst maxNumPTOs=7: https://github.com/facebook/mvfst/blob/main/quic/QuicConstants.h - QUICHE default 5-RTO blackhole detection (-> QUIC_TOO_MANY_RTOS): https://github.com/google/quiche/blob/main/quiche/quic/core/quic_sent_packet_manager.cc - msquic DisconnectTimeoutMs=16s: https://github.com/microsoft/msquic/blob/main/docs/Settings.md
4f4602a to
3d5d279
Compare
|
Thank you for the input. I would like to move forward here, i.e. merge independent of Fast PTO. In my eyes this PR is an improvement in itself, only getting better with Fast PTO. The latter I would like to further discuss in #1236 (comment). @martinthomson @larseggert any objections? |
Benchmark resultsNo significant performance differences relative to 9ec0cc6. All resultsstreams/walltime/1-streams/each-1000-bytes: Change within noise threshold. time: [549.39 µs 551.44 µs 553.80 µs]
thrpt: [1.7221 MiB/s 1.7294 MiB/s 1.7359 MiB/s]
change:
time: [+0.3652% +0.9652% +1.5887] (p = 0.00 < 0.05)
thrpt: [-1.5639% -0.9559% -0.3639]
Change within noise threshold.
Found 13 outliers among 100 measurements (13.00%)
1 (1.00%) high mild
12 (12.00%) high severestreams/walltime/1000-streams/each-1-bytes: Change within noise threshold. time: [11.130 ms 11.146 ms 11.161 ms]
thrpt: [87.497 KiB/s 87.618 KiB/s 87.738 KiB/s]
change:
time: [+0.9674% +1.1806% +1.3926] (p = 0.00 < 0.05)
thrpt: [-1.3735% -1.1668% -0.9582]
Change within noise threshold.streams/walltime/1000-streams/each-1000-bytes: Change within noise threshold. time: [31.634 ms 31.677 ms 31.720 ms]
thrpt: [30.065 MiB/s 30.106 MiB/s 30.147 MiB/s]
change:
time: [-1.7182% -1.5359% -1.3536] (p = 0.00 < 0.05)
thrpt: [+1.3721% +1.5598% +1.7483]
Change within noise threshold.streams-flow-controlled/walltime/1-streams/each-4194304-bytes: Change within noise threshold. time: [26.631 ms 26.679 ms 26.728 ms]
thrpt: [149.65 MiB/s 149.93 MiB/s 150.20 MiB/s]
change:
time: [-1.7823% -1.5486% -1.3112] (p = 0.00 < 0.05)
thrpt: [+1.3286% +1.5729% +1.8147]
Change within noise threshold.streams-flow-controlled/walltime/10-streams/each-1048576-bytes: Change within noise threshold. time: [69.996 ms 70.422 ms 70.857 ms]
thrpt: [141.13 MiB/s 142.00 MiB/s 142.86 MiB/s]
change:
time: [-3.4546% -2.5792% -1.7094] (p = 0.00 < 0.05)
thrpt: [+1.7391% +2.6475% +3.5783]
Change within noise threshold.transfer/walltime/pacing-false/varying-seeds: No change in performance detected. time: [18.433 ms 18.448 ms 18.462 ms]
thrpt: [216.66 MiB/s 216.83 MiB/s 217.00 MiB/s]
change:
time: [-0.1213% -0.0297% +0.0638] (p = 0.54 > 0.05)
thrpt: [-0.0637% +0.0297% +0.1214]
No change in performance detected.transfer/walltime/pacing-true/varying-seeds: Change within noise threshold. time: [18.785 ms 18.797 ms 18.809 ms]
thrpt: [212.67 MiB/s 212.80 MiB/s 212.94 MiB/s]
change:
time: [+1.4291% +1.5154% +1.6036] (p = 0.00 < 0.05)
thrpt: [-1.5783% -1.4928% -1.4089]
Change within noise threshold.transfer/walltime/pacing-false/same-seed: Change within noise threshold. time: [18.444 ms 18.455 ms 18.466 ms]
thrpt: [216.62 MiB/s 216.74 MiB/s 216.87 MiB/s]
change:
time: [+0.2122% +0.2986% +0.3819] (p = 0.00 < 0.05)
thrpt: [-0.3805% -0.2977% -0.2118]
Change within noise threshold.transfer/walltime/pacing-true/same-seed: Change within noise threshold. time: [18.869 ms 18.880 ms 18.892 ms]
thrpt: [211.73 MiB/s 211.86 MiB/s 211.99 MiB/s]
change:
time: [+0.1136% +0.1939% +0.2744] (p = 0.00 < 0.05)
thrpt: [-0.2737% -0.1936% -0.1134]
Change within noise threshold.
Found 5 outliers among 100 measurements (5.00%)
3 (3.00%) low mild
2 (2.00%) high mildDownload data for |
Failed Interop TestsQUIC Interop Runner, client vs. server, differences relative to
All resultsSucceeded Interop TestsQUIC Interop Runner, client vs. server neqo-pr as client
neqo-pr as server
Unsupported Interop TestsQUIC Interop Runner, client vs. server neqo-pr as client
neqo-pr as server
|
Client/server transfer resultsPerformance differences relative to 9ec0cc6. Transfer of 33554432 bytes over loopback, min. 100 runs. All unit-less numbers are in milliseconds.
Table above only shows statistically significant changes. See all results below. All resultsTransfer of 33554432 bytes over loopback, min. 100 runs. All unit-less numbers are in milliseconds.
Download data for |
|
Merging here. Discussed with Martin at IETF. Off by default anyways. Happy to follow-up on any additional review comments after merge. |
…Os (mozilla#3662) Add `ConnectionParameters::max_pto`, closing the connection with a distinct `Error::TooManyPtos` once N consecutive PTOs fire without acknowledgement, i.e. the path has black-holed. A safeguard for a broken path that gives up sooner than, and with a more actionable reason than, the idle timeout. Disabled by default (`None`). Only engaged once connected, so a black-holed handshake is left to happy eyeballs; this also guarantees an RTT estimate underpins the PTO backoff. `max_pto` takes a `NonZeroUsize` so a zero threshold is unrepresentable, and `TooManyPtos` reuses the NO_VIABLE_PATH (0x10) transport error code. Prior art for giving up on a path before the idle timeout: - mvfst maxNumPTOs=7: https://github.com/facebook/mvfst/blob/main/quic/QuicConstants.h - QUICHE default 5-RTO blackhole detection (-> QUIC_TOO_MANY_RTOS): https://github.com/google/quiche/blob/main/quiche/quic/core/quic_sent_packet_manager.cc - msquic DisconnectTimeoutMs=16s: https://github.com/microsoft/msquic/blob/main/docs/Settings.md
Set the `ConnectionParameters` default for `max_pto` to 7, turning on the black-hole detector added in mozilla#3662 (mozilla#3662) for all consumers instead of leaving it opt-in. A connection that sees 7 consecutive unacknowledged PTOs is almost certainly black-holed. Closing it then (`Error::TooManyPtos`, sent on the wire as `NO_VIABLE_PATH`) lets the application recover on a fresh path or another protocol rather than hanging until the idle timeout. At a 20ms RTT the 7th PTO fires around 2.5 to 5.7s, well inside the 30s idle timeout. I plan to enable this in Firefox soon, so it is worth running neqo's own unit tests with the detector on by default already.
Set the `ConnectionParameters` default for `max_pto` to 7, turning on the black-hole detector added in mozilla#3662 (mozilla#3662) for all consumers instead of leaving it opt-in. A connection that sees 7 consecutive unacknowledged PTOs is almost certainly black-holed. Closing it then (`Error::TooManyPtos`, sent on the wire as `NO_VIABLE_PATH`) lets the application recover on a fresh path or another protocol rather than hanging until the idle timeout. At a 20ms RTT the 7th PTO fires around 2.5 to 5.7s, well inside the 30s idle timeout. I plan to enable this in Firefox soon, so it is worth running neqo's own unit tests with the detector on by default already.
Set the `ConnectionParameters` default for `max_pto` to 7, turning on the black-hole detector added in mozilla#3662 (mozilla#3662) by default instead of leaving it opt-in. A connection that sees 7 consecutive unacknowledged PTOs is almost certainly black-holed. Closing it then (`Error::TooManyPtos`, sent on the wire as `NO_VIABLE_PATH`) lets the application recover on a fresh path or another protocol rather than hanging until the idle timeout. At a 20ms RTT the 7th PTO fires around 2.5 to 5.7s, well inside the 30s idle timeout. Firefox is the only consumer today and I plan to enable this on its side soon, so it is worth running neqo's own unit tests with the detector on by default already.
Set the `ConnectionParameters` default for `max_pto` to 7, turning on the black-hole detector added in mozilla#3662 (mozilla#3662) by default instead of leaving it opt-in. A connection that sees 7 consecutive unacknowledged PTOs is almost certainly black-holed. Closing it then (`Error::TooManyPtos`, sent on the wire as `NO_VIABLE_PATH`) lets the application recover on a fresh path or another protocol rather than hanging until the idle timeout. At a 20ms RTT the 7th PTO fires around 2.5 to 5.7s, well inside the 30s idle timeout. Firefox is the only consumer today and I plan to enable this on its side soon, so it is worth running neqo's own unit tests with the detector on by default already. `fetch_noresponse_will_idletimeout` asserts an idle-timeout close that the new default now preempts, so it opts out with `max_pto(None)` to keep exercising that path.
Set the `ConnectionParameters` default for `max_pto` to 7, turning on the black-hole detector added in mozilla#3662 (mozilla#3662) by default instead of leaving it opt-in. A connection that sees 7 consecutive unacknowledged PTOs is almost certainly black-holed. Closing it then (`Error::TooManyPtos`, sent on the wire as `NO_VIABLE_PATH`) lets the application recover on a fresh path or another protocol rather than hanging until the idle timeout. At a 20ms RTT the 7th PTO fires around 2.5 to 5.7s, well inside the 30s idle timeout. Firefox is the only consumer today and I plan to enable this on its side soon, so it is worth running neqo's own unit tests with the detector on by default already. Replace `fetch_noresponse_will_idletimeout`, whose silent-server scenario now black-holes, with `fetch_noresponse_healthy_path_stays_open`: the server keeps acknowledging the client's keepalives but never answers the request, so the path stays healthy and the connection must remain open. This checks max_pto does not fire while packets are still getting through.
Set the `ConnectionParameters` default for `max_pto` to 7, turning on the black-hole detector added in mozilla#3662 (mozilla#3662) by default instead of leaving it opt-in. A connection that sees 7 consecutive unacknowledged PTOs is almost certainly black-holed. Closing it then (`Error::TooManyPtos`, sent on the wire as `NO_VIABLE_PATH`) lets the application recover on a fresh path or another protocol rather than hanging until the idle timeout. At a 20ms RTT the 7th PTO fires around 2.5 to 5.7s, well inside the 30s idle timeout. Firefox is the only consumer today and I plan to enable this on its side soon, so it is worth running neqo's own unit tests with the detector on by default already. Replace `fetch_noresponse_will_idletimeout`, whose silent-server scenario now black-holes, with `fetch_noresponse_healthy_path_stays_open`: the server keeps acknowledging the client's keepalives but never answers the request, so the path stays healthy and the connection must remain open. This checks max_pto does not fire while packets are still getting through.
Set the `ConnectionParameters` default for `max_pto` to 7, turning on the black-hole detector added in mozilla#3662 (mozilla#3662) by default instead of leaving it opt-in. A connection that sees 7 consecutive unacknowledged PTOs is almost certainly black-holed. Closing it then (`Error::TooManyPtos`, sent on the wire as `NO_VIABLE_PATH`) lets the application recover on a fresh path or another protocol rather than hanging until the idle timeout. At a 20ms RTT the 7th PTO fires around 2.5 to 5.7s, well inside the 30s idle timeout. Firefox is the only consumer today and I plan to enable this on its side soon, so it is worth running neqo's own unit tests with the detector on by default already. Replace `fetch_noresponse_will_idletimeout`, whose silent-server scenario now black-holes, with `fetch_noresponse_healthy_path_stays_open`: the server keeps acknowledging the client's keepalives but never answers the request, so the path stays healthy and the connection must remain open. This checks max_pto does not fire while packets are still getting through.
Set the `ConnectionParameters` default for `max_pto` to 7, turning on the black-hole detector added in mozilla#3662 (mozilla#3662) by default instead of leaving it opt-in. A connection that sees 7 consecutive unacknowledged PTOs is almost certainly black-holed. Closing it then (`Error::TooManyPtos`, sent on the wire as `NO_VIABLE_PATH`) lets the application recover on a fresh path or another protocol rather than hanging until the idle timeout. At a 20ms RTT the 7th PTO fires around 2.5 to 5.7s, well inside the 30s idle timeout. Firefox is the only consumer today and I plan to enable this on its side soon, so it is worth running neqo's own unit tests with the detector on by default already. Replace `fetch_noresponse_will_idletimeout`, whose silent-server scenario now black-holes, with `fetch_noresponse_healthy_path_stays_open`: the server keeps acknowledging the client's keepalives but never answers the request, so the path stays healthy and the connection must remain open. This checks max_pto does not fire while packets are still getting through.
* Add some more tests for the HTTP/3 integration * Reliable reset handling for HTTP/3 This follow-up to the RESET_STREAM_AT PR (mozilla#3754) makes changes to the event handling in the HTTP/3 stack to make reliable delivery work better. This is entirely unnecessary, but I think that the change is worthwhile doing on balance. I wanted to improve test coverage and found that the HTTP/3 event handling wasn't quite able to handle reliable resets properly. Making it proper took very little extra work (for the LLM), so I think this is worth it. The fixes here aren't likely to make a material difference in the real world -- HTTP/3 requests that receive any type of reset probably need to be dropped anyway -- but it makes our code more robust and better tested. * Confirm that we got a reset * usize conversions (mozilla#3812) * Start to move to a checked usize conversion * Audit u64 to usize conversions These turn out to be pretty reasonable to fix while I'm half paying attention. * Format better, because vscode * Cleanup * Deal with LLM feedback * Don't overconstrain type bounds * More LLM feedback * Correct a comment --------- Co-authored-by: Lars Eggert <lars@eggert.org> * chore: prepare v0.30.1 (mozilla#3818) * build(deps): bump CodSpeedHQ/action from 4.18.2 to 4.18.5 (mozilla#3822) Bumps [CodSpeedHQ/action](https://github.com/codspeedhq/action) from 4.18.2 to 4.18.5. - [Release notes](https://github.com/codspeedhq/action/releases) - [Changelog](https://github.com/CodSpeedHQ/action/blob/main/CHANGELOG.md) - [Commits](CodSpeedHQ/action@4e96933...f99becd) --- updated-dependencies: - dependency-name: CodSpeedHQ/action dependency-version: 4.18.5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump vmactions/netbsd-vm (mozilla#3821) Bumps the vm-actions group with 1 update in the /.github/actions/check-vm directory: [vmactions/netbsd-vm](https://github.com/vmactions/netbsd-vm). Updates `vmactions/netbsd-vm` from 1.4.1 to 1.4.2 - [Release notes](https://github.com/vmactions/netbsd-vm/releases) - [Commits](vmactions/netbsd-vm@1d97677...0c26a4c) --- updated-dependencies: - dependency-name: vmactions/netbsd-vm dependency-version: 1.4.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: vm-actions ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump reactivecircus/android-emulator-runner (mozilla#3824) Bumps [reactivecircus/android-emulator-runner](https://github.com/reactivecircus/android-emulator-runner) from 2.37.0 to 2.38.0. - [Release notes](https://github.com/reactivecircus/android-emulator-runner/releases) - [Changelog](https://github.com/ReactiveCircus/android-emulator-runner/blob/main/CHANGELOG.md) - [Commits](ReactiveCircus/android-emulator-runner@e89f39f...a421e43) --- updated-dependencies: - dependency-name: reactivecircus/android-emulator-runner dependency-version: 2.38.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump actions/setup-java in /.github/actions/check-android (mozilla#3825) Bumps [actions/setup-java](https://github.com/actions/setup-java) from 5.4.0 to 5.5.0. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](actions/setup-java@1bcf9fb...0f481fc) --- updated-dependencies: - dependency-name: actions/setup-java dependency-version: 5.5.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump github/codeql-action/upload-sarif (mozilla#3823) Bumps [github/codeql-action/upload-sarif](https://github.com/github/codeql-action) from 4.36.3 to 4.37.0. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@54f647b...99df26d) --- updated-dependencies: - dependency-name: github/codeql-action/upload-sarif dependency-version: 4.37.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat(transport): optionally close a connection after N consecutive PTOs (mozilla#3662) Add `ConnectionParameters::max_pto`, closing the connection with a distinct `Error::TooManyPtos` once N consecutive PTOs fire without acknowledgement, i.e. the path has black-holed. A safeguard for a broken path that gives up sooner than, and with a more actionable reason than, the idle timeout. Disabled by default (`None`). Only engaged once connected, so a black-holed handshake is left to happy eyeballs; this also guarantees an RTT estimate underpins the PTO backoff. `max_pto` takes a `NonZeroUsize` so a zero threshold is unrepresentable, and `TooManyPtos` reuses the NO_VIABLE_PATH (0x10) transport error code. Prior art for giving up on a path before the idle timeout: - mvfst maxNumPTOs=7: https://github.com/facebook/mvfst/blob/main/quic/QuicConstants.h - QUICHE default 5-RTO blackhole detection (-> QUIC_TOO_MANY_RTOS): https://github.com/google/quiche/blob/main/quiche/quic/core/quic_sent_packet_manager.cc - msquic DisconnectTimeoutMs=16s: https://github.com/microsoft/msquic/blob/main/docs/Settings.md * Make @omansfeld code owner for neqo-transport (mozilla#3826) * Make @omansfeld code owner for neqo-transport Signed-off-by: Lars Eggert <lars@eggert.org> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Lars Eggert <lars@eggert.org> * Update .github/CODEOWNERS Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: Lars Eggert <lars@eggert.org> --------- Signed-off-by: Lars Eggert <lars@eggert.org> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Remove stream error mapping on the recv path * Add tests for some fairly gnarly corner cases * fix comment [ci skip] Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: Martin Thomson <mt@lowentropy.net> * Fix clippy mess * Take a comment suggestion Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: Martin Thomson <mt@lowentropy.net> * A version of the suggestion Signed-off-by: Martin Thomson <mt@lowentropy.net> --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Lars Eggert <lars@eggert.org> Signed-off-by: Martin Thomson <mt@lowentropy.net> Co-authored-by: Lars Eggert <lars@eggert.org> Co-authored-by: Max Inden <mail@max-inden.de> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
User-visible changes since v0.30.1: - Update nss-rs to 0.14.4, now requiring NSS >= 3.126: mozilla#3874 - WebTransport getStats() support: mozilla#3835 - Reliable reset handling for HTTP/3: mozilla#3777 - Optionally close a connection after N consecutive PTOs: mozilla#3662 - Reject 0-RTT downgrade of h3 datagram and WebTransport settings: mozilla#3852 - Reject connection-specific header fields in HTTP/3 messages: mozilla#3806 - Reject qpack dynamic reference at or above required insert count: mozilla#3807 - Discard server Initial packets that carry a token: mozilla#3814
User-visible changes since v0.30.1: - Update nss-rs to 0.14.4, now requiring NSS >= 3.126: mozilla#3874 - WebTransport getStats() support: mozilla#3835 - Reliable reset handling for HTTP/3: mozilla#3777 - Optionally close a connection after N consecutive PTOs: mozilla#3662 - Reject 0-RTT downgrade of h3 datagram and WebTransport settings: mozilla#3852 - Reject connection-specific header fields in HTTP/3 messages: mozilla#3806 - Reject qpack dynamic reference at or above required insert count: mozilla#3807 - Discard server Initial packets that carry a token: mozilla#3814
Set the `ConnectionParameters` default for `max_pto` to 7, turning on the black-hole detector added in mozilla#3662 (mozilla#3662) by default instead of leaving it opt-in. A connection that sees 7 consecutive unacknowledged PTOs is almost certainly black-holed. Closing it then (`Error::TooManyPtos`, sent on the wire as `NO_VIABLE_PATH`) lets the application recover on a fresh path or another protocol rather than hanging until the idle timeout. At a 20ms RTT the 7th PTO fires around 2.5 to 5.7s, well inside the 30s idle timeout. Firefox is the only consumer today and I plan to enable this on its side soon, so it is worth running neqo's own unit tests with the detector on by default already. Replace `fetch_noresponse_will_idletimeout`, whose silent-server scenario now black-holes, with `fetch_noresponse_healthy_path_stays_open`: the server keeps acknowledging the client's keepalives but never answers the request, so the path stays healthy and the connection must remain open. This checks max_pto does not fire while packets are still getting through.
Summary
Adds an opt-in
ConnectionParameters::max_pto(Some(count)). When set, the connection is closed locally with a new, distinct reasonError::TooManyPtosoncecountconsecutive PTOs have fired without any acknowledgement, i.e. the path has black-holed.This is a safeguard for when the path breaks: if packets stop getting through entirely, the connection is closed promptly and with a reason the application can act on, instead of waiting out
max_idle_timeoutand reporting a generic timeout.Motivation: the
facebook-not-loadingincidentRecent incident (the same one behind #3573): with SCONE padding enabled, a client completed the QUIC handshake to Facebook, exchanged some application data, and then an on-path antivirus middlebox (BitDefender) silently dropped the altered post-handshake server frames. From neqo's point of view: the client had requests outstanding, its packets stopped being acked, and nothing came back.
Per RFC 9002 §6.2.1 the PTO backs off without bound, and per RFC 9000 §10.1 the idle timeout is the designated backstop (and is held
>= 3*PTOprecisely so probes can be lost before it fires). The consequence for this incident: the only thing that ends a post-handshake black hole today is the idle timeout, 30 s, and HTTP/3 has no HTTP/2 fallback after the handshake. The user sees a spinner, and a reload just pins a fresh request onto the same dead connection for another 30 s.The sooner the connection is declared broken, the better on two fronts. First, fewer requests are sent into the abyss: the application stops piling new streams onto a dead connection. Second, Firefox can surface an actionable error page sooner, for example one suggesting the user disable their antivirus, instead of leaving them on a spinner for 30 s per attempt.
Worked example
With exponential backoff (
pto_period = base_PTO * 2^count, defaultfast_ptofactor = 1), the n-th consecutive PTO fires atbase_PTO * (2^n - 1), somax_pto = 7fires at127 * base_PTO.Facebook's edge is close; take RTT ~= 50 ms, so
base_PTO = smoothed_rtt + 4*rttvar + max_ack_delay ~= 50 + ~25 + 25 = ~100 ms.max_pto = 7:127 * 100 ms~= 12.7 sHow it scales (the virtue of a count over a fixed timer: it tracks RTT, so it fails fast on a quick path and waits longer on a genuinely slow one):
Beyond "earlier", the close carries a distinct reason (
TooManyPtos, notIdleTimeout), so the application can tell a black hole apart from an ordinary idle close and react (error page, disable HTTP/3 for the origin and retry over HTTP/2, ...). That consumption is out of scope here; this PR only produces the earlier, distinct signal.Prior art (this is not novel)
Closing or abandoning a path before the idle timeout, driven by unacked probes, is what the other major stacks already do, including the server in this incident:
maxNumPTOs = 7tears the connection down, with a degrading/blackhole ladder at 4/6: https://github.com/facebook/mvfst/blob/main/quic/QuicConstants.hQUIC_TOO_MANY_RTOS, on for clients: https://github.com/google/quiche/blob/main/quiche/quic/core/quic_sent_packet_manager.ccDisconnectTimeoutMs = 16s(RTT-independent, so it does not track the path the way a PTO count does): https://github.com/microsoft/msquic/blob/main/docs/Settings.md7is chosen to match mvfst'smaxNumPTOsand QUICHE's effective 2+5 cumulative RTO delays. We might want to be more aggressive, i.e. choose a value like5.