Maxim Dounin
February 11, 2021 02:58PM
details: https://hg.nginx.org/nginx/rev/827202ca1269
branches:
changeset: 7774:827202ca1269
user: Maxim Dounin <mdounin@mdounin.ru>
date: Thu Feb 11 21:52:26 2021 +0300
description:
HTTP/2: removed http2_max_field_size and http2_max_header_size.

Instead, size of one large_client_header_buffers buffer and all large
client header buffers are used.

diffstat:

src/http/v2/ngx_http_v2.c | 29 +++++++++++++++++------------
src/http/v2/ngx_http_v2_module.c | 32 ++++++++++++++++----------------
src/http/v2/ngx_http_v2_module.h | 2 --
3 files changed, 33 insertions(+), 30 deletions(-)

diffs (149 lines):

diff -r b64f553b1291 -r 827202ca1269 src/http/v2/ngx_http_v2.c
--- a/src/http/v2/ngx_http_v2.c Thu Feb 11 21:52:24 2021 +0300
+++ b/src/http/v2/ngx_http_v2.c Thu Feb 11 21:52:26 2021 +0300
@@ -1198,6 +1198,7 @@ ngx_http_v2_state_headers(ngx_http_v2_co
ngx_http_v2_node_t *node;
ngx_http_v2_stream_t *stream;
ngx_http_v2_srv_conf_t *h2scf;
+ ngx_http_core_srv_conf_t *cscf;
ngx_http_core_loc_conf_t *clcf;

padded = h2c->state.flags & NGX_HTTP_V2_PADDED_FLAG;
@@ -1299,11 +1300,15 @@ ngx_http_v2_state_headers(ngx_http_v2_co
return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR);
}

+ cscf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx,
+ ngx_http_core_module);
+
+ h2c->state.header_limit = cscf->large_client_header_buffers.size
+ * cscf->large_client_header_buffers.num;
+
h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx,
ngx_http_v2_module);

- h2c->state.header_limit = h2scf->max_header_size;
-
if (h2c->processing >= h2scf->concurrent_streams) {
ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
"concurrent streams exceeded %ui", h2c->processing);
@@ -1485,10 +1490,10 @@ static u_char *
ngx_http_v2_state_field_len(ngx_http_v2_connection_t *h2c, u_char *pos,
u_char *end)
{
- size_t alloc;
- ngx_int_t len;
- ngx_uint_t huff;
- ngx_http_v2_srv_conf_t *h2scf;
+ size_t alloc;
+ ngx_int_t len;
+ ngx_uint_t huff;
+ ngx_http_core_srv_conf_t *cscf;

if (!(h2c->state.flags & NGX_HTTP_V2_END_HEADERS_FLAG)
&& h2c->state.length < NGX_HTTP_V2_INT_OCTETS)
@@ -1535,12 +1540,12 @@ ngx_http_v2_state_field_len(ngx_http_v2_
"http2 %s string, len:%i",
huff ? "encoded" : "raw", len);

- h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx,
- ngx_http_v2_module);
-
- if ((size_t) len > h2scf->max_field_size) {
+ cscf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx,
+ ngx_http_core_module);
+
+ if ((size_t) len > cscf->large_client_header_buffers.size) {
ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
- "client exceeded http2_max_field_size limit");
+ "client sent too large header field");

return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_ENHANCE_YOUR_CALM);
}
@@ -1755,7 +1760,7 @@ ngx_http_v2_state_process_header(ngx_htt

if (len > h2c->state.header_limit) {
ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
- "client exceeded http2_max_header_size limit");
+ "client sent too large header");

return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_ENHANCE_YOUR_CALM);
}
diff -r b64f553b1291 -r 827202ca1269 src/http/v2/ngx_http_v2_module.c
--- a/src/http/v2/ngx_http_v2_module.c Thu Feb 11 21:52:24 2021 +0300
+++ b/src/http/v2/ngx_http_v2_module.c Thu Feb 11 21:52:26 2021 +0300
@@ -52,6 +52,14 @@ static ngx_conf_deprecated_t ngx_http_v
ngx_conf_deprecated, "http2_max_requests", "keepalive_requests"
};

+static ngx_conf_deprecated_t ngx_http_v2_max_field_size_deprecated = {
+ ngx_conf_deprecated, "http2_max_field_size", "large_client_header_buffers"
+};
+
+static ngx_conf_deprecated_t ngx_http_v2_max_header_size_deprecated = {
+ ngx_conf_deprecated, "http2_max_header_size", "large_client_header_buffers"
+};
+

static ngx_conf_post_t ngx_http_v2_recv_buffer_size_post =
{ ngx_http_v2_recv_buffer_size };
@@ -104,17 +112,17 @@ static ngx_command_t ngx_http_v2_comman

{ ngx_string("http2_max_field_size"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_size_slot,
- NGX_HTTP_SRV_CONF_OFFSET,
- offsetof(ngx_http_v2_srv_conf_t, max_field_size),
- NULL },
+ ngx_http_v2_obsolete,
+ 0,
+ 0,
+ &ngx_http_v2_max_field_size_deprecated },

{ ngx_string("http2_max_header_size"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_size_slot,
- NGX_HTTP_SRV_CONF_OFFSET,
- offsetof(ngx_http_v2_srv_conf_t, max_header_size),
- NULL },
+ ngx_http_v2_obsolete,
+ 0,
+ 0,
+ &ngx_http_v2_max_header_size_deprecated },

{ ngx_string("http2_body_preread_size"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
@@ -311,9 +319,6 @@ ngx_http_v2_create_srv_conf(ngx_conf_t *
h2scf->concurrent_streams = NGX_CONF_UNSET_UINT;
h2scf->concurrent_pushes = NGX_CONF_UNSET_UINT;

- h2scf->max_field_size = NGX_CONF_UNSET_SIZE;
- h2scf->max_header_size = NGX_CONF_UNSET_SIZE;
-
h2scf->preread_size = NGX_CONF_UNSET_SIZE;

h2scf->streams_index_mask = NGX_CONF_UNSET_UINT;
@@ -335,11 +340,6 @@ ngx_http_v2_merge_srv_conf(ngx_conf_t *c
ngx_conf_merge_uint_value(conf->concurrent_pushes,
prev->concurrent_pushes, 10);

- ngx_conf_merge_size_value(conf->max_field_size, prev->max_field_size,
- 4096);
- ngx_conf_merge_size_value(conf->max_header_size, prev->max_header_size,
- 16384);
-
ngx_conf_merge_size_value(conf->preread_size, prev->preread_size, 65536);

ngx_conf_merge_uint_value(conf->streams_index_mask,
diff -r b64f553b1291 -r 827202ca1269 src/http/v2/ngx_http_v2_module.h
--- a/src/http/v2/ngx_http_v2_module.h Thu Feb 11 21:52:24 2021 +0300
+++ b/src/http/v2/ngx_http_v2_module.h Thu Feb 11 21:52:26 2021 +0300
@@ -24,8 +24,6 @@ typedef struct {
size_t pool_size;
ngx_uint_t concurrent_streams;
ngx_uint_t concurrent_pushes;
- size_t max_field_size;
- size_t max_header_size;
size_t preread_size;
ngx_uint_t streams_index_mask;
} ngx_http_v2_srv_conf_t;
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] HTTP/2: removed http2_max_field_size and http2_max_header_size.

Maxim Dounin 305 February 11, 2021 02:58PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 241
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready