QUIC: removed redundant "app" flag from ngx_quic_close_frame_t.

The flag was introduced to create type-aware CONNECTION_CLOSE frames,
and now is replaced with frame type information, directly accessible.
Notably, this fixes type logging for received frames in b3d9e57d0f62.
This commit is contained in:
Sergey Kandaurov 2021-02-03 12:39:41 +03:00
parent 365c8b7914
commit b51d010029
3 changed files with 15 additions and 16 deletions

View File

@ -522,7 +522,8 @@ ngx_quic_log_frame(ngx_log_t *log, ngx_quic_frame_t *f, ngx_uint_t tx)
case NGX_QUIC_FT_CONNECTION_CLOSE: case NGX_QUIC_FT_CONNECTION_CLOSE:
case NGX_QUIC_FT_CONNECTION_CLOSE_APP: case NGX_QUIC_FT_CONNECTION_CLOSE_APP:
p = ngx_slprintf(p, last, "CONNECTION_CLOSE%s err:%ui", p = ngx_slprintf(p, last, "CONNECTION_CLOSE%s err:%ui",
f->u.close.app ? "_APP" : "", f->u.close.error_code); f->type == NGX_QUIC_FT_CONNECTION_CLOSE ? "" : "_APP",
f->u.close.error_code);
if (f->u.close.reason.len) { if (f->u.close.reason.len) {
p = ngx_slprintf(p, last, " %V", &f->u.close.reason); p = ngx_slprintf(p, last, " %V", &f->u.close.reason);
@ -3251,10 +3252,10 @@ ngx_quic_send_cc(ngx_connection_t *c)
} }
frame->level = qc->error_level; frame->level = qc->error_level;
frame->type = NGX_QUIC_FT_CONNECTION_CLOSE; frame->type = qc->error_app ? NGX_QUIC_FT_CONNECTION_CLOSE_APP
: NGX_QUIC_FT_CONNECTION_CLOSE;
frame->u.close.error_code = qc->error; frame->u.close.error_code = qc->error;
frame->u.close.frame_type = qc->error_ftype; frame->u.close.frame_type = qc->error_ftype;
frame->u.close.app = qc->error_app;
if (qc->error_reason) { if (qc->error_reason) {
frame->u.close.reason.len = ngx_strlen(qc->error_reason); frame->u.close.reason.len = ngx_strlen(qc->error_reason);

View File

@ -116,7 +116,7 @@ static size_t ngx_quic_create_new_connection_id(u_char *p,
ngx_quic_new_conn_id_frame_t *rcid); ngx_quic_new_conn_id_frame_t *rcid);
static size_t ngx_quic_create_retire_connection_id(u_char *p, static size_t ngx_quic_create_retire_connection_id(u_char *p,
ngx_quic_retire_cid_frame_t *rcid); ngx_quic_retire_cid_frame_t *rcid);
static size_t ngx_quic_create_close(u_char *p, ngx_quic_close_frame_t *cl); static size_t ngx_quic_create_close(u_char *p, ngx_quic_frame_t *f);
static ngx_int_t ngx_quic_parse_transport_param(u_char *p, u_char *end, static ngx_int_t ngx_quic_parse_transport_param(u_char *p, u_char *end,
uint16_t id, ngx_quic_tp_t *dst); uint16_t id, ngx_quic_tp_t *dst);
@ -1249,7 +1249,7 @@ ngx_quic_create_frame(u_char *p, ngx_quic_frame_t *f)
case NGX_QUIC_FT_CONNECTION_CLOSE: case NGX_QUIC_FT_CONNECTION_CLOSE:
case NGX_QUIC_FT_CONNECTION_CLOSE_APP: case NGX_QUIC_FT_CONNECTION_CLOSE_APP:
f->need_ack = 0; f->need_ack = 0;
return ngx_quic_create_close(p, &f->u.close); return ngx_quic_create_close(p, f);
case NGX_QUIC_FT_MAX_STREAMS: case NGX_QUIC_FT_MAX_STREAMS:
return ngx_quic_create_max_streams(p, &f->u.max_streams); return ngx_quic_create_max_streams(p, &f->u.max_streams);
@ -1956,20 +1956,19 @@ ngx_quic_create_transport_params(u_char *pos, u_char *end, ngx_quic_tp_t *tp,
static size_t static size_t
ngx_quic_create_close(u_char *p, ngx_quic_close_frame_t *cl) ngx_quic_create_close(u_char *p, ngx_quic_frame_t *f)
{ {
size_t len; size_t len;
u_char *start; u_char *start;
ngx_uint_t type; ngx_quic_close_frame_t *cl;
type = cl->app ? NGX_QUIC_FT_CONNECTION_CLOSE_APP cl = &f->u.close;
: NGX_QUIC_FT_CONNECTION_CLOSE;
if (p == NULL) { if (p == NULL) {
len = ngx_quic_varint_len(type); len = ngx_quic_varint_len(f->type);
len += ngx_quic_varint_len(cl->error_code); len += ngx_quic_varint_len(cl->error_code);
if (!cl->app) { if (f->type != NGX_QUIC_FT_CONNECTION_CLOSE_APP) {
len += ngx_quic_varint_len(cl->frame_type); len += ngx_quic_varint_len(cl->frame_type);
} }
@ -1981,10 +1980,10 @@ ngx_quic_create_close(u_char *p, ngx_quic_close_frame_t *cl)
start = p; start = p;
ngx_quic_build_int(&p, type); ngx_quic_build_int(&p, f->type);
ngx_quic_build_int(&p, cl->error_code); ngx_quic_build_int(&p, cl->error_code);
if (!cl->app) { if (f->type != NGX_QUIC_FT_CONNECTION_CLOSE_APP) {
ngx_quic_build_int(&p, cl->frame_type); ngx_quic_build_int(&p, cl->frame_type);
} }

View File

@ -197,7 +197,6 @@ typedef struct {
uint64_t error_code; uint64_t error_code;
uint64_t frame_type; uint64_t frame_type;
ngx_str_t reason; ngx_str_t reason;
ngx_uint_t app; /* unsigned app:1; */
} ngx_quic_close_frame_t; } ngx_quic_close_frame_t;