comparison src/http/v3/ngx_http_v3_request.c @ 8826:c35b255d80dc quic

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.
author Roman Arutyunyan <arut@nginx.com>
date Thu, 29 Jul 2021 16:01:37 +0300
parents 0ac25efb2da3
children 0d35b1ff6af5
comparison
equal deleted inserted replaced
8825:59d2d47ad3c6 8826:c35b255d80dc
79 79
80 hc = c->data; 80 hc = c->data;
81 81
82 clcf = ngx_http_get_module_loc_conf(hc->conf_ctx, ngx_http_core_module); 82 clcf = ngx_http_get_module_loc_conf(hc->conf_ctx, ngx_http_core_module);
83 83
84 n = c->quic->id >> 2;
85
86 if (n >= clcf->keepalive_requests * 2) {
87 ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_EXCESSIVE_LOAD,
88 "too many requests per connection");
89 ngx_http_close_connection(c);
90 return;
91 }
92
84 h3c = ngx_http_v3_get_session(c); 93 h3c = ngx_http_v3_get_session(c);
85 94
86 if (h3c->goaway) { 95 if (h3c->goaway) {
87 ngx_quic_reset_stream(c, NGX_HTTP_V3_ERR_REQUEST_REJECTED); 96 ngx_quic_reset_stream(c, NGX_HTTP_V3_ERR_REQUEST_REJECTED);
88 ngx_http_close_connection(c); 97 ngx_http_close_connection(c);
89 return; 98 return;
90 } 99 }
91
92 n = c->quic->id >> 2;
93 100
94 if (n + 1 == clcf->keepalive_requests 101 if (n + 1 == clcf->keepalive_requests
95 || ngx_current_msec - c->quic->parent->start_time 102 || ngx_current_msec - c->quic->parent->start_time
96 > clcf->keepalive_time) 103 > clcf->keepalive_time)
97 { 104 {