aboutsummaryrefslogtreecommitdiff
path: root/src/http/v3/ngx_http_v3_request.c
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2021-07-29 16:01:37 +0300
committerRoman Arutyunyan <arut@nginx.com>2021-07-29 16:01:37 +0300
commite1ad576f960ab2b455b4d12869f69cb648feba42 (patch)
tree75e697be3aab7793ae1db09fba34e717f2fcdd60 /src/http/v3/ngx_http_v3_request.c
parentb93ae5d0670f265bec60cd616dd42b0ce96d8e2d (diff)
downloadnginx-e1ad576f960ab2b455b4d12869f69cb648feba42.tar.gz
nginx-e1ad576f960ab2b455b4d12869f69cb648feba42.zip
HTTP/3: close connection on keepalive_requests * 2.
After receiving GOAWAY, client is not supposed to create new streams. However, until client reads this frame, we allow it to create new streams, which are gracefully rejected. To prevent client from abusing this algorithm, a new limit is introduced. Upon reaching keepalive_requests * 2, server now closes the entire QUIC connection claiming excessive load.
Diffstat (limited to 'src/http/v3/ngx_http_v3_request.c')
-rw-r--r--src/http/v3/ngx_http_v3_request.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/http/v3/ngx_http_v3_request.c b/src/http/v3/ngx_http_v3_request.c
index 5fc6e233b..f45a7b95e 100644
--- a/src/http/v3/ngx_http_v3_request.c
+++ b/src/http/v3/ngx_http_v3_request.c
@@ -81,6 +81,15 @@ ngx_http_v3_init(ngx_connection_t *c)
clcf = ngx_http_get_module_loc_conf(hc->conf_ctx, ngx_http_core_module);
+ n = c->quic->id >> 2;
+
+ if (n >= clcf->keepalive_requests * 2) {
+ ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_EXCESSIVE_LOAD,
+ "too many requests per connection");
+ ngx_http_close_connection(c);
+ return;
+ }
+
h3c = ngx_http_v3_get_session(c);
if (h3c->goaway) {
@@ -89,8 +98,6 @@ ngx_http_v3_init(ngx_connection_t *c)
return;
}
- n = c->quic->id >> 2;
-
if (n + 1 == clcf->keepalive_requests
|| ngx_current_msec - c->quic->parent->start_time
> clcf->keepalive_time)