Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix preserves lower-limit behavior and includes regression coverage, with no unresolved findings.
No open issues 🎉
What changed in this PR
Prevents high download rate limits from enlarging HTTP/2 stream windows beyond the existing 10 MiB cap.
Changes:
- Caps rate-limited windows while preserving smaller limits.
- Adds and registers a regression test using
--limit-rate 1500M.
| File | Description |
|---|---|
| tests/data/test1717 | Tests an HTTP/2 download with a high rate limit. |
| tests/data/Makefile.am | Registers test 1717. |
| lib/http2.c | Caps the rate-limited stream window. |
Review effort: Balanced
| # A rate limit above 1 GB/s used to set a stream window larger than the | ||
| # HTTP/2 window maximum allows after the update, failing the transfer. | ||
| <command option="no-include"> | ||
| http://%HOSTIP:%HTTP2PORT/%TESTNUMBER --http2-prior-knowledge --limit-rate 1500M |
There was a problem hiding this comment.
I question the usefulness of this auto-generated test. Can it be merged into
an existing one, or drop? We don't need to run this a million times, I think.
There was a problem hiding this comment.
I merged it into test 1700 (added --limit-rate 1500M) and dropped the new test in this PR. Can revert if you think it is not a good approach
|
Analysis of PR #23472 at a9a78aec: Test ../../tests/http/test_60_h3_proxy.py::TestH3Proxy::test_60_12_quic_session_resumption failed, but it has been permanently failing lately, so it's probably NOT a fault of the PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). Note that this CI job has had a number of other flaky tests recently (4, to be specific) so it may be that this failure is rather a systemic issue with this job and not with this specific PR. Generated by Testclutch |
cf_h2_get_desired_local_win() used the rate limiter's available bytes as the stream window whenever they fit an int32, so a high download rate limit gave a much larger window than no limit at all (up to 2 GB instead of H2_STREAM_WINDOW_SIZE_MAX). With --limit-rate between ~1024M and 2047M the window update then exceeded the HTTP/2 maximum and the transfer failed at once with "Flow control error". Cap the rate-limited window at H2_STREAM_WINDOW_SIZE_MAX, so that a rate limit can only reduce the window. Extend test 1700 with --limit-rate 1500M to verify.
a9a78ae to
60f353a
Compare
|
Thanks! |
With a download rate limit,
cf_h2_get_desired_local_win()uses the rate limiter's available bytes as the HTTP/2 stream window whenever they fit in an int32. A high limit therefore gives a much larger window (up to ~2 GB instead ofH2_STREAM_WINDOW_SIZE_MAX, 10 MiB).With
--limit-ratebetween ~1024M and 2047M this breaks the transfer: the window update exceeds the HTTP/2 maximum window size and nghttp2 rejects it, so the download fails immediately:At most 1000M works because the resulting window still fits, and at least 2048M works because the available bytes no longer fit an int32 and the default window is used.
This caps the rate-limited window at
H2_STREAM_WINDOW_SIZE_MAX, so a rate limit can only reduce the window. Downloads at 1100M, 1500M, and 2047M now complete, and lower limits (5M to 100M) behave as before.Test 1717 does an HTTP/2 GET with
--limit-rate 1500Mand fails without the change.Side note:
cf_h2_update_local_win()calls bothnghttp2_session_set_local_window_size()andnghttp2_submit_window_update()when growing the window, which raises it twice; that is why ~1 GB is already enough to overflow.I left that unchanged since curl handles window updates manually.
Tested with nghttp2 1.40.0.
This issue was found by an LLM-Enhanced Static Analysis Engine and verified manually.