-
Notifications
You must be signed in to change notification settings - Fork 5.5k
codec: Raise max_request_headers_kb limit to 96 KiB #5859
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
Changes from 20 commits
fdd1442
932eaf0
999b247
6e2e092
1ba5e19
51e8fb7
37d6900
8c1be4a
d3e146d
d14f019
7fae643
6c6cd5c
87cd65b
12cb34d
2370471
7aba9ea
dc0b47e
e241e35
cff066e
358fd16
bbf0df2
c8b006e
8bb762c
3bcfbdf
56644a1
7ece1c7
5210dda
0f7911c
9bce125
7fb8701
19d10a2
b55c483
6473a65
e084dc7
c7ec56b
f520e89
4a5d64e
9a20bb5
bfbeed4
e28fcdb
be85a3f
b5ba8ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,13 +134,15 @@ message HttpConnectionManager { | |
| string server_name = 10; | ||
|
|
||
| // The maximum request headers size for incoming connections. The default max | ||
| // is 60K, based on default settings for http codecs. For HTTP1, the current | ||
| // limit set by http_parser is 80K. for HTTP2, the default allowed header | ||
| // block in nghttp2 is 64K. The max configurable setting is 64K in order to | ||
| // is 60 KiB, based on default settings for http codecs. For HTTP1, the currentB | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given the new changes, are these sizes still correct/relevant? Isn't is basically fully configurable now on both codecs or at least up to 96KiB max below? Can you potentially simplify the docs?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| // limit set by http_parser is 80 KiB. for HTTP2, the default allowed header | ||
| // block in nghttp2 is 64 KiB. The max configurable setting is 64K in order to | ||
| // stay under both codec limits. | ||
| // The maximum per-header limit, i.e. for each key-value pair, is 64 KiB in | ||
| // http2. | ||
| // Requests that exceed this size will receive a 431 response. | ||
| google.protobuf.UInt32Value max_request_headers_kb = 29 | ||
| [(validate.rules).uint32.gt = 0, (validate.rules).uint32.lte = 64]; | ||
| [(validate.rules).uint32.gt = 0, (validate.rules).uint32.lte = 96]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Worth commenting on the new max?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a note in the API.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, worth commenting the reasons behind the max?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ummmm, a prior version had more detail about the reason behind the max, but I removed the detail because it wasn't really a "public API" reason. basically 96 kb is the highest I could get it to go without triggering a different nghttp2 bug, but I stopped trying to debug at that point so I don't know what actually breaks.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think documenting somewhere that we can't go above 96 and have nghttp2 work is worthwhile.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry to come back to this, but can you say something like "The max configurable limit is 96 KiB which is gated by the current implementation details." And then put a comment about whatever nghttp2 issues you had somewhere in the code? I don't think nghttp2 should show up in the docs, it's not relevant to the end user. If you want to put the comment here you can also put in a doc comment (see other examples) which won't get rendered.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 - that works for me as a compromise There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alyssawilk could you please describe a bit why such hard limit has been chosen?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See the comment thread above. IIRC there was some problem getting higher limits to work either in the tests or in prod code which would need debugging to allow raising the limits higher. I agree from a product perspective we should allow higher limits. |
||
|
|
||
| // The idle timeout for connections managed by the connection manager. The | ||
| // idle timeout is defined as the period in which there are no active | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ cc_library( | |
| "http_parser.h", | ||
| ], | ||
| hdrs = ["http_parser.h"], | ||
| copts = ["-DHTTP_MAX_HEADER_SIZE=0x7fffffff"], | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a comment on why we set this and why it's safe (we have checks elsewhere, etc.)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, don't you need HTTP/1 codec changes now to check the current header map size on each new header as we do with HTTP/2? I'm not sure how this is safe otherwise?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done on the comment, working on the http1 codec check
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also as an aside, when this lands please ping the googlers on current and next import duty as this will almost certainly need custom tweaks on import.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ack
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually sorry, on second thought I'm having a moment of paranoia. We don't have anywhere else in the Envoy code base where we use http_parser so this is 100% OK today but what do we think of adding a limit just in case? If we added a 200KB limit or some such it'd be very safely above our window such that we should never hit the http_parser limits in the codec, without allowing total infinite memory if someone else uses http parser.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed it to 0xfffffff, i.e. ~2 gb -> ~300 mb. |
||
| includes = ["."], | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -867,6 +867,8 @@ ConnectionImpl::Http2Options::Http2Options(const Http2Settings& http2_settings) | |
| // of kept alive HTTP/2 connections. | ||
| nghttp2_option_set_no_closed_streams(options_, 1); | ||
| nghttp2_option_set_no_auto_window_update(options_, 1); | ||
| nghttp2_option_set_max_send_header_block_length(options_, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this the setting for the size of an individual header frame? I think we want to change the total allowed headers, not the per-frame limits.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC this is not very well named, but I think this does actually set the header send limit, and the library will chunk it into frames using continuation frames if necessary. @auni53 to check me here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be. I'm not seeing any other size-related fields to tweak. I'd checked
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh,
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeeee, I'm pretty certain this is the right call. Also because I did this TDD-style and the testing behaviour checks out. |
||
| NGHTTP2_MAX_SEND_HEADER_BLOCK_LENGTH * 1024); | ||
|
|
||
| if (http2_settings.hpack_table_size_ != NGHTTP2_DEFAULT_HEADER_TABLE_SIZE) { | ||
| nghttp2_option_set_max_deflate_dynamic_table_size(options_, http2_settings.hpack_table_size_); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -433,6 +433,7 @@ gregs | |
| gzip | ||
| hacky | ||
| handshaker | ||
| hd | ||
| hdr | ||
| healths | ||
| healthz | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.