Skip to content

Add runtime flag to cap oghttp2 outbound DATA frame payloads at 16 KiB. - #48514

Merged
yanavlasov merged 1 commit into
envoyproxy:mainfrom
prateekdceit06:window-update-oghttp2
Oct 23, 2026
Merged

yanavlasov merged 1 commit into
envoyproxy:mainfrom
prateekdceit06:window-update-oghttp2

Conversation

@prateekdceit06

Copy link
Copy Markdown
Contributor

Commit Message: http2: cap oghttp2 outbound DATA frames at 16 KiB to match nghttp2 to avoid WINDOW_UPDATE frame flood

Additional Description:
When a client advertises a large SETTINGS_MAX_FRAME_SIZE, oghttp2 sizes outbound DATA frames up to that limit, while nghttp2 always caps DATA payloads at 16 KiB (NGHTTP2_DATA_PAYLOADLEN). Envoy's WINDOW_UPDATE flood protection (ProtocolConstraints) budgets inbound WINDOW_UPDATE frames as 5 + 2 * (streams + 10 * outbound_data_frames), so a well-behaved client that acknowledges a large response in small increments receives far fewer DATA frames under oghttp2, exceeds the budget, and is disconnected with http2.inbound_window_update_frames_flood.

This change sets the new QUICHE option OgHttp2Session::Options::max_outbound_data_frame_payload to 16 KiB when envoy.reloadable_features.http2_oghttp2_cap_data_frame_payload is enabled, so oghttp2 produces the same DATA framing as nghttp2 and the window update flood behavior is identical under both codecs. Only affects connections using oghttp2 (envoy.reloadable_features.http2_use_oghttp2); nghttp2 behaviour is unchanged. Requires the QUICHE roll to 9e60ac2 (#48104), which adds OgHttp2Session::Options::max_outbound_data_frame_payload.

Risk Level: Low. Only changes how oghttp2 fragments response bodies into DATA frames (never larger than the RFC 9113 default frame size); no wire-protocol or API change. Guarded by a runtime flag.
Testing:

  • Updated the existing integration test Http2FloodMitigationTest.WindowUpdateAfterLargeResponseRealisticClient: with the runtime guard enabled (the default) oghttp2 now sends 64 x 16 KiB DATA frames for a 1 MiB response, no WINDOW_UPDATE flood is detected, and the connection accepts a subsequent request -- identical to nghttp2.

Docs Changes: N/A
Release Notes:
behavior_changes:

  • area: http2
    change: |
    When using oghttp2 (envoy.reloadable_features.http2_use_oghttp2), outbound DATA frame payloads are now capped at 16 KiB regardless of the peer's SETTINGS_MAX_FRAME_SIZE, matching nghttp2. This prevents legitimate flow-control WINDOW_UPDATE traffic from being misclassified as a flood (http2.inbound_window_update_frames_flood). This behavior can be reverted by setting the runtime guard envoy.reloadable_features.http2_oghttp2_cap_data_frame_payload to false.
    Platform Specific Features: N/A
    [Optional Runtime guard:] envoy.reloadable_features.http2_oghttp2_cap_data_frame_payload
    [Optional Fixes #Issue]
    [Optional Fixes commit #PR or SHA]
    [Optional Deprecated:]
    [Optional API Considerations:]

@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/runtime-guard-changes: FYI only for changes made to (source/common/runtime/runtime_features.cc).

🐱

Caused by: #48514 was opened by prateekdceit06.

see: more, trace.

@prateekdceit06

Copy link
Copy Markdown
Contributor Author

/retest

@yanavlasov

Copy link
Copy Markdown
Contributor

Runtime features are removed after 6 months. Will this bug come back after that?

/wait-any

@reubent-goog

Copy link
Copy Markdown
Contributor

Runtime features are removed after 6 months. Will this bug come back after that?

/wait-any

@yanavlasov If, when the guard is removed, the code it guarded is also removed then yes the bug would come back but I assume that og_options_.max_outbound_data_frame_payload = 16u * 1024u; will not also be removed after 6 months. Is that the right assumption?

@yanavlasov
yanavlasov merged commit 11c7dc2 into envoyproxy:main Oct 23, 2026
27 checks passed
@prateekdceit06
prateekdceit06 deleted the window-update-oghttp2 branch October 23, 2026 20:41
botengyao pushed a commit that referenced this pull request Oct 30, 2026
Commit Message: http2: deflake
WindowUpdateAfterLargeResponseRealisticClient

The test opens the client's window once `upstream_rq_completed` reaches
1, on the assumption that the whole 1 MiB body is buffered in the
downstream codec by then. The router charges that counter on the
upstream response headers, not at the end of the body, so the window
could open while the body was still streaming in. Envoy then sends
whatever is pending as one frame and each later upstream chunk as its
own, and CI saw 42, 50 or 64 DATA frames where the oghttp2 branch
expects 1.

This waits for `http2.pending_send_bytes` to reach the body size
instead. #48514's 16 KiB cap made the count come out at 64 either way,
which hid the race on the default path, but the branch with
`http2_oghttp2_cap_data_frame_payload` disabled still asserts a single
frame.

Additional Description:
It failed on 10 changes between 10-11 and 10-23, on msan and tsan,
always at the `data_frames` check. It hasn't failed since #48514 landed,
because no CI job runs with the cap disabled, so this fixes the wait
rather than a flake CI can still hit.

To reproduce, I had the autonomous upstream send the 1 MiB body 500ms
after the headers, from another thread, with the cap disabled. With the
old wait, `pending_send_bytes` was 0 when the wait returned and oghttp2
sent 64 frames, failing every run. With the new wait the test waits out
the delay, gets 1 frame, and passes 12/12.

AI Disclaimer: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- delayed-body repro above, cap disabled: fails on both oghttp2 params
before, 12/12 pass after
- `bazel test //test/integration:http2_flood_integration_test
--runs_per_test=5`: pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>
phlax pushed a commit to phlax/envoy that referenced this pull request Nov 12, 2026
…oxy#48790)

Commit Message: http2: deflake
WindowUpdateAfterLargeResponseRealisticClient

The test opens the client's window once `upstream_rq_completed` reaches
1, on the assumption that the whole 1 MiB body is buffered in the
downstream codec by then. The router charges that counter on the
upstream response headers, not at the end of the body, so the window
could open while the body was still streaming in. Envoy then sends
whatever is pending as one frame and each later upstream chunk as its
own, and CI saw 42, 50 or 64 DATA frames where the oghttp2 branch
expects 1.

This waits for `http2.pending_send_bytes` to reach the body size
instead. envoyproxy#48514's 16 KiB cap made the count come out at 64 either way,
which hid the race on the default path, but the branch with
`http2_oghttp2_cap_data_frame_payload` disabled still asserts a single
frame.

Additional Description:
It failed on 10 changes between 10-11 and 10-23, on msan and tsan,
always at the `data_frames` check. It hasn't failed since envoyproxy#48514 landed,
because no CI job runs with the cap disabled, so this fixes the wait
rather than a flake CI can still hit.

To reproduce, I had the autonomous upstream send the 1 MiB body 500ms
after the headers, from another thread, with the cap disabled. With the
old wait, `pending_send_bytes` was 0 when the wait returned and oghttp2
sent 64 frames, failing every run. With the new wait the test waits out
the delay, gets 1 frame, and passes 12/12.

AI Disclaimer: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- delayed-body repro above, cap disabled: fails on both oghttp2 params
before, 12/12 pass after
- `bazel test //test/integration:http2_flood_integration_test
--runs_per_test=5`: pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>
Signed-off-by: Ryan Northey <[email protected]>
jwendell pushed a commit that referenced this pull request Nov 12, 2026
Commit Message: http2: deflake
WindowUpdateAfterLargeResponseRealisticClient

The test opens the client's window once `upstream_rq_completed` reaches
1, on the assumption that the whole 1 MiB body is buffered in the
downstream codec by then. The router charges that counter on the
upstream response headers, not at the end of the body, so the window
could open while the body was still streaming in. Envoy then sends
whatever is pending as one frame and each later upstream chunk as its
own, and CI saw 42, 50 or 64 DATA frames where the oghttp2 branch
expects 1.

This waits for `http2.pending_send_bytes` to reach the body size
instead. #48514's 16 KiB cap made the count come out at 64 either way,
which hid the race on the default path, but the branch with
`http2_oghttp2_cap_data_frame_payload` disabled still asserts a single
frame.

Additional Description:
It failed on 10 changes between 10-11 and 10-23, on msan and tsan,
always at the `data_frames` check. It hasn't failed since #48514 landed,
because no CI job runs with the cap disabled, so this fixes the wait
rather than a flake CI can still hit.

To reproduce, I had the autonomous upstream send the 1 MiB body 500ms
after the headers, from another thread, with the cap disabled. With the
old wait, `pending_send_bytes` was 0 when the wait returned and oghttp2
sent 64 frames, failing every run. With the new wait the test waits out
the delay, gets 1 frame, and passes 12/12.

AI Disclaimer: code change created with AI assistance, fully reviewed by
me prior to opening.

Risk Level: Low (test only)
Testing:
- delayed-body repro above, cap disabled: fails on both oghttp2 params
before, 12/12 pass after
- `bazel test //test/integration:http2_flood_integration_test
--runs_per_test=5`: pass (macOS arm64, fastbuild)
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Derek Argueta <[email protected]>
Signed-off-by: Ryan Northey <[email protected]>
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.

4 participants