comparison src/http/v3/ngx_http_v3.h @ 8456:c9538aef3211 quic

HTTP/3: refactored dynamic table implementation. Previously dynamic table was not functional because of zero limit on its size set by default. Now the following changes enable it: - new directives to set SETTINGS_QPACK_MAX_TABLE_CAPACITY and SETTINGS_QPACK_BLOCKED_STREAMS - send settings with SETTINGS_QPACK_MAX_TABLE_CAPACITY and SETTINGS_QPACK_BLOCKED_STREAMS to the client - send Insert Count Increment to the client - send Header Acknowledgement to the client - evict old dynamic table entries on overflow - decode Required Insert Count from client - block stream if Required Insert Count is not reached
author Roman Arutyunyan <arut@nginx.com>
date Thu, 02 Jul 2020 15:34:05 +0300
parents 032cb35ce758
children 1ed698947172
comparison
equal deleted inserted replaced
8455:b0e81f49d7c0 8456:c9538aef3211
46 #define NGX_HTTP_V3_STREAM_CLIENT_DECODER 4 46 #define NGX_HTTP_V3_STREAM_CLIENT_DECODER 4
47 #define NGX_HTTP_V3_STREAM_SERVER_DECODER 5 47 #define NGX_HTTP_V3_STREAM_SERVER_DECODER 5
48 #define NGX_HTTP_V3_MAX_KNOWN_STREAM 6 48 #define NGX_HTTP_V3_MAX_KNOWN_STREAM 6
49 49
50 #define NGX_HTTP_V3_DEFAULT_MAX_FIELD_SIZE 4096 50 #define NGX_HTTP_V3_DEFAULT_MAX_FIELD_SIZE 4096
51 51 #define NGX_HTTP_V3_DEFAULT_MAX_TABLE_CAPACITY 16384
52 52 #define NGX_HTTP_V3_DEFAULT_MAX_BLOCKED_STREAMS 16
53 typedef struct {
54 ngx_quic_tp_t quic;
55 size_t max_field_size;
56 } ngx_http_v3_srv_conf_t;
57
58
59 typedef struct {
60 ngx_http_connection_t hc;
61
62 ngx_array_t *dynamic;
63 ngx_connection_t *known_streams[NGX_HTTP_V3_MAX_KNOWN_STREAM];
64 } ngx_http_v3_connection_t;
65 53
66 54
67 #define ngx_http_v3_get_module_srv_conf(c, module) \ 55 #define ngx_http_v3_get_module_srv_conf(c, module) \
68 ngx_http_get_module_srv_conf( \ 56 ngx_http_get_module_srv_conf( \
69 ((ngx_http_v3_connection_t *) c->qs->parent->data)->hc.conf_ctx, \ 57 ((ngx_http_v3_connection_t *) c->qs->parent->data)->hc.conf_ctx, \
70 module) 58 module)
71 59
72 60
73 typedef struct { 61 typedef struct {
74 ngx_str_t name; 62 ngx_quic_tp_t quic;
75 ngx_str_t value; 63 size_t max_field_size;
64 size_t max_table_capacity;
65 ngx_uint_t max_blocked_streams;
66 } ngx_http_v3_srv_conf_t;
67
68
69 typedef struct {
70 ngx_str_t name;
71 ngx_str_t value;
76 } ngx_http_v3_header_t; 72 } ngx_http_v3_header_t;
73
74
75 typedef struct {
76 ngx_http_v3_header_t **elts;
77 ngx_uint_t nelts;
78 ngx_uint_t base;
79 size_t size;
80 size_t capacity;
81 } ngx_http_v3_dynamic_table_t;
82
83
84 typedef struct {
85 ngx_http_connection_t hc;
86 ngx_http_v3_dynamic_table_t table;
87 ngx_queue_t blocked;
88 ngx_uint_t nblocked;
89 ngx_uint_t settings_sent;
90 /* unsigned settings_sent:1; */
91 ngx_connection_t *known_streams[NGX_HTTP_V3_MAX_KNOWN_STREAM];
92 } ngx_http_v3_connection_t;
77 93
78 94
79 ngx_int_t ngx_http_v3_parse_request(ngx_http_request_t *r, ngx_buf_t *b); 95 ngx_int_t ngx_http_v3_parse_request(ngx_http_request_t *r, ngx_buf_t *b);
80 ngx_int_t ngx_http_v3_parse_header(ngx_http_request_t *r, ngx_buf_t *b, 96 ngx_int_t ngx_http_v3_parse_header(ngx_http_request_t *r, ngx_buf_t *b,
81 ngx_uint_t allow_underscores); 97 ngx_uint_t allow_underscores);
86 102
87 uintptr_t ngx_http_v3_encode_varlen_int(u_char *p, uint64_t value); 103 uintptr_t ngx_http_v3_encode_varlen_int(u_char *p, uint64_t value);
88 uintptr_t ngx_http_v3_encode_prefix_int(u_char *p, uint64_t value, 104 uintptr_t ngx_http_v3_encode_prefix_int(u_char *p, uint64_t value,
89 ngx_uint_t prefix); 105 ngx_uint_t prefix);
90 106
107 ngx_int_t ngx_http_v3_send_settings(ngx_connection_t *c);
91 void ngx_http_v3_handle_client_uni_stream(ngx_connection_t *c); 108 void ngx_http_v3_handle_client_uni_stream(ngx_connection_t *c);
92 109
93 ngx_int_t ngx_http_v3_ref_insert(ngx_connection_t *c, ngx_uint_t dynamic, 110 ngx_int_t ngx_http_v3_ref_insert(ngx_connection_t *c, ngx_uint_t dynamic,
94 ngx_uint_t index, ngx_str_t *value); 111 ngx_uint_t index, ngx_str_t *value);
95 ngx_int_t ngx_http_v3_insert(ngx_connection_t *c, ngx_str_t *name, 112 ngx_int_t ngx_http_v3_insert(ngx_connection_t *c, ngx_str_t *name,
97 ngx_int_t ngx_http_v3_set_capacity(ngx_connection_t *c, ngx_uint_t capacity); 114 ngx_int_t ngx_http_v3_set_capacity(ngx_connection_t *c, ngx_uint_t capacity);
98 ngx_int_t ngx_http_v3_duplicate(ngx_connection_t *c, ngx_uint_t index); 115 ngx_int_t ngx_http_v3_duplicate(ngx_connection_t *c, ngx_uint_t index);
99 ngx_int_t ngx_http_v3_ack_header(ngx_connection_t *c, ngx_uint_t stream_id); 116 ngx_int_t ngx_http_v3_ack_header(ngx_connection_t *c, ngx_uint_t stream_id);
100 ngx_int_t ngx_http_v3_cancel_stream(ngx_connection_t *c, ngx_uint_t stream_id); 117 ngx_int_t ngx_http_v3_cancel_stream(ngx_connection_t *c, ngx_uint_t stream_id);
101 ngx_int_t ngx_http_v3_inc_insert_count(ngx_connection_t *c, ngx_uint_t inc); 118 ngx_int_t ngx_http_v3_inc_insert_count(ngx_connection_t *c, ngx_uint_t inc);
102 ngx_http_v3_header_t *ngx_http_v3_lookup_table(ngx_connection_t *c, 119 ngx_int_t ngx_http_v3_lookup_static(ngx_connection_t *c, ngx_uint_t index,
103 ngx_uint_t dynamic, ngx_uint_t index); 120 ngx_str_t *name, ngx_str_t *value);
121 ngx_int_t ngx_http_v3_lookup(ngx_connection_t *c, ngx_uint_t index,
122 ngx_str_t *name, ngx_str_t *value);
123 ngx_int_t ngx_http_v3_decode_insert_count(ngx_connection_t *c,
124 ngx_uint_t *insert_count);
104 ngx_int_t ngx_http_v3_check_insert_count(ngx_connection_t *c, 125 ngx_int_t ngx_http_v3_check_insert_count(ngx_connection_t *c,
105 ngx_uint_t insert_count); 126 ngx_uint_t insert_count);
106 ngx_int_t ngx_http_v3_set_param(ngx_connection_t *c, uint64_t id, 127 ngx_int_t ngx_http_v3_set_param(ngx_connection_t *c, uint64_t id,
107 uint64_t value); 128 uint64_t value);
108 129