HTTP/2: add debug logging of SETTINGS frame and its parameters. Change-Id: If9e34b47f73cab9da1d246c942efe3045345f685 Signed-off-by: Piotr Sikora <piotrsikora@google.com> Reviewed-on: https://nginx-review.googlesource.com/2922 Reviewed-by: Feng Li <fengli@google.com> Reviewed-by: Lizan Zhou <zlizan@google.com>
diff --git a/src/http/v2/ngx_http_v2.c b/src/http/v2/ngx_http_v2.c index 4910ad8..5b55a5c 100644 --- a/src/http/v2/ngx_http_v2.c +++ b/src/http/v2/ngx_http_v2.c
@@ -44,6 +44,7 @@ #define NGX_HTTP_V2_MAX_STREAMS_SETTING 0x3 #define NGX_HTTP_V2_INIT_WINDOW_SIZE_SETTING 0x4 #define NGX_HTTP_V2_MAX_FRAME_SIZE_SETTING 0x5 +#define NGX_HTTP_V2_HEADER_LIST_SIZE_SETTING 0x6 #define NGX_HTTP_V2_FRAME_BUFFER_SIZE 24 @@ -1985,8 +1986,9 @@ return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR); } - ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, - "http2 SETTINGS frame ack:0"); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, + "http2 SETTINGS frame params:%uz", + h2c->state.length / NGX_HTTP_V2_SETTINGS_PARAM_SIZE); ngx_http_v2_send_settings(h2c, 1); @@ -2013,6 +2015,13 @@ switch (id) { + case NGX_HTTP_V2_HEADER_TABLE_SIZE_SETTING: + + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, + "http2 SETTINGS frame HEADER_TABLE_SIZE:%ui " + "(ignored)", value); + break; + case NGX_HTTP_V2_ENABLE_PUSH_SETTING: if (value != 0 && value != 1) { @@ -2024,6 +2033,16 @@ NGX_HTTP_V2_PROTOCOL_ERROR); } + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, + "http2 SETTINGS frame ENABLE_PUSH:%ui " + "(ignored)", value); + break; + + case NGX_HTTP_V2_MAX_STREAMS_SETTING: + + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, + "http2 SETTINGS frame MAX_CONCURRENT_STREAMS:%ui " + "(ignored)", value); break; case NGX_HTTP_V2_INIT_WINDOW_SIZE_SETTING: @@ -2037,6 +2056,10 @@ NGX_HTTP_V2_FLOW_CTRL_ERROR); } + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, + "http2 SETTINGS frame INITIAL_WINDOW_SIZE:%ui", + value); + if (ngx_http_v2_adjust_windows(h2c, value - h2c->init_window) != NGX_OK) { @@ -2060,10 +2083,25 @@ NGX_HTTP_V2_PROTOCOL_ERROR); } + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, + "http2 SETTINGS frame MAX_FRAME_SIZE:%ui", + value); + h2c->frame_size = value; break; + case NGX_HTTP_V2_HEADER_LIST_SIZE_SETTING: + + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, + "http2 SETTINGS frame MAX_HEADER_LIST_SIZE:%ui " + "(ignored)", value); + break; + default: + + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, + "http2 SETTINGS frame 0x%Xi:%ui " + "(ignored)", id, value); break; } @@ -2511,8 +2549,18 @@ ngx_http_v2_srv_conf_t *h2scf; ngx_http_v2_out_frame_t *frame; - ngx_log_debug1(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, - "http2 send SETTINGS frame ack:%ui", ack); + if (ack) { + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, + "http2 send SETTINGS frame ack:1"); + + len = 0; + + } else { + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, + "http2 send SETTINGS frame params:3"); + + len = NGX_HTTP_V2_SETTINGS_PARAM_SIZE * 3; + } frame = ngx_palloc(h2c->pool, sizeof(ngx_http_v2_out_frame_t)); if (frame == NULL) { @@ -2524,8 +2572,6 @@ return NGX_ERROR; } - len = ack ? 0 : (sizeof(uint16_t) + sizeof(uint32_t)) * 3; - buf = ngx_create_temp_buf(h2c->pool, NGX_HTTP_V2_FRAME_HEADER_SIZE + len); if (buf == NULL) { return NGX_ERROR; @@ -2556,15 +2602,27 @@ h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, ngx_http_v2_module); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, + "http2 send SETTINGS frame MAX_CONCURRENT_STREAMS:%ui", + h2scf->concurrent_streams); + buf->last = ngx_http_v2_write_uint16(buf->last, NGX_HTTP_V2_MAX_STREAMS_SETTING); buf->last = ngx_http_v2_write_uint32(buf->last, h2scf->concurrent_streams); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, + "http2 send SETTINGS frame INITIAL_WINDOW_SIZE:%uz", + h2scf->preread_size); + buf->last = ngx_http_v2_write_uint16(buf->last, NGX_HTTP_V2_INIT_WINDOW_SIZE_SETTING); buf->last = ngx_http_v2_write_uint32(buf->last, h2scf->preread_size); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, + "http2 send SETTINGS frame MAX_FRAME_SIZE:%ud", + NGX_HTTP_V2_MAX_FRAME_SIZE); + buf->last = ngx_http_v2_write_uint16(buf->last, NGX_HTTP_V2_MAX_FRAME_SIZE_SETTING); buf->last = ngx_http_v2_write_uint32(buf->last,