September 10, 2019 10:38AM
details: https://hg.nginx.org/nginx/rev/29b2dc731503
branches:
changeset: 7564:29b2dc731503
user: Ruslan Ermilov <ru@nginx.com>
date: Tue Sep 10 15:33:37 2019 +0300
description:
HTTP/2: close connection on frames with self-dependency.

Don't waste server resources by sending RST_STREAM frames. Instead,
reject HEADERS and PRIORITY frames with self-dependency by closing
connection with PROTOCOL_ERROR.

diffstat:

src/http/v2/ngx_http_v2.c | 40 +++++++++-------------------------------
1 files changed, 9 insertions(+), 31 deletions(-)

diffs (64 lines):

diff -r a7e8f953408e -r 29b2dc731503 src/http/v2/ngx_http_v2.c
--- a/src/http/v2/ngx_http_v2.c Wed Sep 04 13:33:51 2019 +0300
+++ b/src/http/v2/ngx_http_v2.c Tue Sep 10 15:33:37 2019 +0300
@@ -1107,6 +1107,14 @@ ngx_http_v2_state_headers(ngx_http_v2_co
return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR);
}

+ if (depend == h2c->state.sid) {
+ ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
+ "client sent HEADERS frame for stream %ui "
+ "with incorrect dependency", h2c->state.sid);
+
+ return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR);
+ }
+
h2c->last_sid = h2c->state.sid;

h2c->state.pool = ngx_create_pool(1024, h2c->connection->log);
@@ -1114,15 +1122,6 @@ ngx_http_v2_state_headers(ngx_http_v2_co
return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR);
}

- if (depend == h2c->state.sid) {
- ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
- "client sent HEADERS frame for stream %ui "
- "with incorrect dependency", h2c->state.sid);
-
- status = NGX_HTTP_V2_PROTOCOL_ERROR;
- goto rst_stream;
- }
-
h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx,
ngx_http_v2_module);

@@ -1849,28 +1848,7 @@ ngx_http_v2_state_priority(ngx_http_v2_c
"client sent PRIORITY frame for stream %ui "
"with incorrect dependency", h2c->state.sid);

- node = ngx_http_v2_get_node_by_id(h2c, h2c->state.sid, 0);
-
- if (node && node->stream) {
- if (ngx_http_v2_terminate_stream(h2c, node->stream,
- NGX_HTTP_V2_PROTOCOL_ERROR)
- == NGX_ERROR)
- {
- return ngx_http_v2_connection_error(h2c,
- NGX_HTTP_V2_INTERNAL_ERROR);
- }
-
- } else {
- if (ngx_http_v2_send_rst_stream(h2c, h2c->state.sid,
- NGX_HTTP_V2_PROTOCOL_ERROR)
- == NGX_ERROR)
- {
- return ngx_http_v2_connection_error(h2c,
- NGX_HTTP_V2_INTERNAL_ERROR);
- }
- }
-
- return ngx_http_v2_state_complete(h2c, pos, end);
+ return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR);
}

node = ngx_http_v2_get_node_by_id(h2c, h2c->state.sid, 1);
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] HTTP/2: close connection on frames with self-dependency.

ru@nginx.com 86 September 10, 2019 10:38AM



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

Online Users

Guests: 109
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready