Mercurial > hg > nginx-quic
annotate src/http/v3/ngx_http_v3_tables.c @ 8352:0a0b1de9ccab quic
QUIC: fixed expected TLS codepoint with final draft and BoringSSL.
A reasonable codepoint is always set[1] explicitly so that it doesn't
depend on the default library value that may change[2] in the future.
[1] https://boringssl.googlesource.com/boringssl/+/3d8b8c3d
[2] https://boringssl.googlesource.com/boringssl/+/c47bfce0
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 16 Mar 2021 13:48:28 +0300 |
parents | 279ad36f2f4b |
children | 70701edfc5d4 |
rev | line source |
---|---|
7681 | 1 |
2 /* | |
3 * Copyright (C) Roman Arutyunyan | |
4 * Copyright (C) Nginx, Inc. | |
5 */ | |
6 | |
7 | |
8 #include <ngx_config.h> | |
9 #include <ngx_core.h> | |
10 #include <ngx_http.h> | |
11 | |
12 | |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
13 #define ngx_http_v3_table_entry_size(n, v) ((n)->len + (v)->len + 32) |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
14 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
15 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
16 static ngx_int_t ngx_http_v3_evict(ngx_connection_t *c, size_t need); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
17 static void ngx_http_v3_cleanup_table(void *data); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
18 static void ngx_http_v3_unblock(void *data); |
7681 | 19 static ngx_int_t ngx_http_v3_new_header(ngx_connection_t *c); |
20 | |
21 | |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
22 typedef struct { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
23 ngx_queue_t queue; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
24 ngx_connection_t *connection; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
25 ngx_uint_t *nblocked; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
26 } ngx_http_v3_block_t; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
27 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
28 |
7681 | 29 static ngx_http_v3_header_t ngx_http_v3_static_table[] = { |
30 | |
31 { ngx_string(":authority"), ngx_string("") }, | |
7762
f11b7981a03d
HTTP/3: static table cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7692
diff
changeset
|
32 { ngx_string(":path"), ngx_string("/") }, |
7681 | 33 { ngx_string("age"), ngx_string("0") }, |
34 { ngx_string("content-disposition"), ngx_string("") }, | |
35 { ngx_string("content-length"), ngx_string("0") }, | |
36 { ngx_string("cookie"), ngx_string("") }, | |
37 { ngx_string("date"), ngx_string("") }, | |
38 { ngx_string("etag"), ngx_string("") }, | |
39 { ngx_string("if-modified-since"), ngx_string("") }, | |
40 { ngx_string("if-none-match"), ngx_string("") }, | |
41 { ngx_string("last-modified"), ngx_string("") }, | |
42 { ngx_string("link"), ngx_string("") }, | |
43 { ngx_string("location"), ngx_string("") }, | |
44 { ngx_string("referer"), ngx_string("") }, | |
45 { ngx_string("set-cookie"), ngx_string("") }, | |
46 { ngx_string(":method"), ngx_string("CONNECT") }, | |
47 { ngx_string(":method"), ngx_string("DELETE") }, | |
48 { ngx_string(":method"), ngx_string("GET") }, | |
49 { ngx_string(":method"), ngx_string("HEAD") }, | |
50 { ngx_string(":method"), ngx_string("OPTIONS") }, | |
51 { ngx_string(":method"), ngx_string("POST") }, | |
52 { ngx_string(":method"), ngx_string("PUT") }, | |
53 { ngx_string(":scheme"), ngx_string("http") }, | |
54 { ngx_string(":scheme"), ngx_string("https") }, | |
55 { ngx_string(":status"), ngx_string("103") }, | |
56 { ngx_string(":status"), ngx_string("200") }, | |
57 { ngx_string(":status"), ngx_string("304") }, | |
58 { ngx_string(":status"), ngx_string("404") }, | |
59 { ngx_string(":status"), ngx_string("503") }, | |
60 { ngx_string("accept"), ngx_string("*/*") }, | |
61 { ngx_string("accept"), | |
7762
f11b7981a03d
HTTP/3: static table cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7692
diff
changeset
|
62 ngx_string("application/dns-message") }, |
f11b7981a03d
HTTP/3: static table cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7692
diff
changeset
|
63 { ngx_string("accept-encoding"), ngx_string("gzip, deflate, br") }, |
7681 | 64 { ngx_string("accept-ranges"), ngx_string("bytes") }, |
65 { ngx_string("access-control-allow-headers"), | |
66 ngx_string("cache-control") }, | |
67 { ngx_string("access-control-allow-headers"), | |
68 ngx_string("content-type") }, | |
69 { ngx_string("access-control-allow-origin"), | |
70 ngx_string("*") }, | |
71 { ngx_string("cache-control"), ngx_string("max-age=0") }, | |
72 { ngx_string("cache-control"), ngx_string("max-age=2592000") }, | |
73 { ngx_string("cache-control"), ngx_string("max-age=604800") }, | |
74 { ngx_string("cache-control"), ngx_string("no-cache") }, | |
75 { ngx_string("cache-control"), ngx_string("no-store") }, | |
76 { ngx_string("cache-control"), | |
7762
f11b7981a03d
HTTP/3: static table cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7692
diff
changeset
|
77 ngx_string("public, max-age=31536000") }, |
7681 | 78 { ngx_string("content-encoding"), ngx_string("br") }, |
79 { ngx_string("content-encoding"), ngx_string("gzip") }, | |
80 { ngx_string("content-type"), | |
81 ngx_string("application/dns-message") }, | |
82 { ngx_string("content-type"), | |
83 ngx_string("application/javascript") }, | |
84 { ngx_string("content-type"), ngx_string("application/json") }, | |
85 { ngx_string("content-type"), | |
86 ngx_string("application/x-www-form-urlencoded") }, | |
87 { ngx_string("content-type"), ngx_string("image/gif") }, | |
88 { ngx_string("content-type"), ngx_string("image/jpeg") }, | |
89 { ngx_string("content-type"), ngx_string("image/png") }, | |
90 { ngx_string("content-type"), ngx_string("text/css") }, | |
91 { ngx_string("content-type"), | |
92 ngx_string("text/html;charset=utf-8") }, | |
93 { ngx_string("content-type"), ngx_string("text/plain") }, | |
94 { ngx_string("content-type"), | |
95 ngx_string("text/plain;charset=utf-8") }, | |
96 { ngx_string("range"), ngx_string("bytes=0-") }, | |
97 { ngx_string("strict-transport-security"), | |
98 ngx_string("max-age=31536000") }, | |
99 { ngx_string("strict-transport-security"), | |
100 ngx_string("max-age=31536000;includesubdomains") }, | |
101 { ngx_string("strict-transport-security"), | |
102 ngx_string("max-age=31536000;includesubdomains;preload") }, | |
103 { ngx_string("vary"), ngx_string("accept-encoding") }, | |
104 { ngx_string("vary"), ngx_string("origin") }, | |
7762
f11b7981a03d
HTTP/3: static table cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7692
diff
changeset
|
105 { ngx_string("x-content-type-options"), |
f11b7981a03d
HTTP/3: static table cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7692
diff
changeset
|
106 ngx_string("nosniff") }, |
7681 | 107 { ngx_string("x-xss-protection"), ngx_string("1;mode=block") }, |
108 { ngx_string(":status"), ngx_string("100") }, | |
109 { ngx_string(":status"), ngx_string("204") }, | |
110 { ngx_string(":status"), ngx_string("206") }, | |
111 { ngx_string(":status"), ngx_string("302") }, | |
112 { ngx_string(":status"), ngx_string("400") }, | |
113 { ngx_string(":status"), ngx_string("403") }, | |
114 { ngx_string(":status"), ngx_string("421") }, | |
115 { ngx_string(":status"), ngx_string("425") }, | |
116 { ngx_string(":status"), ngx_string("500") }, | |
117 { ngx_string("accept-language"), ngx_string("") }, | |
118 { ngx_string("access-control-allow-credentials"), | |
119 ngx_string("FALSE") }, | |
120 { ngx_string("access-control-allow-credentials"), | |
121 ngx_string("TRUE") }, | |
122 { ngx_string("access-control-allow-headers"), | |
123 ngx_string("*") }, | |
124 { ngx_string("access-control-allow-methods"), | |
125 ngx_string("get") }, | |
126 { ngx_string("access-control-allow-methods"), | |
127 ngx_string("get, post, options") }, | |
128 { ngx_string("access-control-allow-methods"), | |
129 ngx_string("options") }, | |
130 { ngx_string("access-control-expose-headers"), | |
131 ngx_string("content-length") }, | |
132 { ngx_string("access-control-request-headers"), | |
133 ngx_string("content-type") }, | |
134 { ngx_string("access-control-request-method"), | |
135 ngx_string("get") }, | |
136 { ngx_string("access-control-request-method"), | |
137 ngx_string("post") }, | |
138 { ngx_string("alt-svc"), ngx_string("clear") }, | |
7762
f11b7981a03d
HTTP/3: static table cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7692
diff
changeset
|
139 { ngx_string("authorization"), ngx_string("") }, |
7681 | 140 { ngx_string("content-security-policy"), |
7762
f11b7981a03d
HTTP/3: static table cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7692
diff
changeset
|
141 ngx_string("script-src 'none';object-src 'none';base-uri 'none'") }, |
7681 | 142 { ngx_string("early-data"), ngx_string("1") }, |
143 { ngx_string("expect-ct"), ngx_string("") }, | |
144 { ngx_string("forwarded"), ngx_string("") }, | |
145 { ngx_string("if-range"), ngx_string("") }, | |
146 { ngx_string("origin"), ngx_string("") }, | |
147 { ngx_string("purpose"), ngx_string("prefetch") }, | |
148 { ngx_string("server"), ngx_string("") }, | |
149 { ngx_string("timing-allow-origin"), ngx_string("*") }, | |
150 { ngx_string("upgrade-insecure-requests"), | |
151 ngx_string("1") }, | |
152 { ngx_string("user-agent"), ngx_string("") }, | |
153 { ngx_string("x-forwarded-for"), ngx_string("") }, | |
154 { ngx_string("x-frame-options"), ngx_string("deny") }, | |
155 { ngx_string("x-frame-options"), ngx_string("sameorigin") } | |
156 }; | |
157 | |
158 | |
159 ngx_int_t | |
160 ngx_http_v3_ref_insert(ngx_connection_t *c, ngx_uint_t dynamic, | |
161 ngx_uint_t index, ngx_str_t *value) | |
162 { | |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
163 ngx_str_t name; |
7681 | 164 |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
165 if (dynamic) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
166 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
167 "http3 ref insert dynamic[%ui] \"%V\"", index, value); |
7681 | 168 |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
169 if (ngx_http_v3_lookup(c, index, &name, NULL) != NGX_OK) { |
7955
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
7951
diff
changeset
|
170 return NGX_HTTP_V3_ERR_ENCODER_STREAM_ERROR; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
171 } |
7886
26cb2f3259b1
HTTP/3: reallocate strings inserted into the dynamic table.
Roman Arutyunyan <arut@nginx.com>
parents:
7762
diff
changeset
|
172 |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
173 } else { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
174 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
175 "http3 ref insert static[%ui] \"%V\"", index, value); |
7681 | 176 |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
177 if (ngx_http_v3_lookup_static(c, index, &name, NULL) != NGX_OK) { |
7955
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
7951
diff
changeset
|
178 return NGX_HTTP_V3_ERR_ENCODER_STREAM_ERROR; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
179 } |
7681 | 180 } |
181 | |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
182 return ngx_http_v3_insert(c, &name, value); |
7681 | 183 } |
184 | |
185 | |
186 ngx_int_t | |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
187 ngx_http_v3_insert(ngx_connection_t *c, ngx_str_t *name, ngx_str_t *value) |
7681 | 188 { |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
189 u_char *p; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
190 size_t size; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
191 ngx_http_v3_header_t *h; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
192 ngx_http_v3_connection_t *h3c; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
193 ngx_http_v3_dynamic_table_t *dt; |
7681 | 194 |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
195 size = ngx_http_v3_table_entry_size(name, value); |
7681 | 196 |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
197 if (ngx_http_v3_evict(c, size) != NGX_OK) { |
7955
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
7951
diff
changeset
|
198 return NGX_HTTP_V3_ERR_ENCODER_STREAM_ERROR; |
7681 | 199 } |
200 | |
8200
279ad36f2f4b
QUIC: renamed c->qs to c->quic.
Roman Arutyunyan <arut@nginx.com>
parents:
8010
diff
changeset
|
201 h3c = c->quic->parent->data; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
202 dt = &h3c->table; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
203 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
204 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
205 "http3 insert [%ui] \"%V\":\"%V\", size:%uz", |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
206 dt->base + dt->nelts, name, value, size); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
207 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
208 p = ngx_alloc(sizeof(ngx_http_v3_header_t) + name->len + value->len, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
209 c->log); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
210 if (p == NULL) { |
7681 | 211 return NGX_ERROR; |
212 } | |
213 | |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
214 h = (ngx_http_v3_header_t *) p; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
215 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
216 h->name.data = p + sizeof(ngx_http_v3_header_t); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
217 h->name.len = name->len; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
218 h->value.data = ngx_cpymem(h->name.data, name->data, name->len); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
219 h->value.len = value->len; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
220 ngx_memcpy(h->value.data, value->data, value->len); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
221 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
222 dt->elts[dt->nelts++] = h; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
223 dt->size += size; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
224 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
225 /* TODO increment can be sent less often */ |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
226 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
227 if (ngx_http_v3_client_inc_insert_count(c, 1) != NGX_OK) { |
7886
26cb2f3259b1
HTTP/3: reallocate strings inserted into the dynamic table.
Roman Arutyunyan <arut@nginx.com>
parents:
7762
diff
changeset
|
228 return NGX_ERROR; |
26cb2f3259b1
HTTP/3: reallocate strings inserted into the dynamic table.
Roman Arutyunyan <arut@nginx.com>
parents:
7762
diff
changeset
|
229 } |
26cb2f3259b1
HTTP/3: reallocate strings inserted into the dynamic table.
Roman Arutyunyan <arut@nginx.com>
parents:
7762
diff
changeset
|
230 |
7681 | 231 if (ngx_http_v3_new_header(c) != NGX_OK) { |
232 return NGX_ERROR; | |
233 } | |
234 | |
235 return NGX_OK; | |
236 } | |
237 | |
238 | |
239 ngx_int_t | |
240 ngx_http_v3_set_capacity(ngx_connection_t *c, ngx_uint_t capacity) | |
241 { | |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
242 ngx_uint_t max, prev_max; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
243 ngx_connection_t *pc; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
244 ngx_pool_cleanup_t *cln; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
245 ngx_http_v3_header_t **elts; |
8010
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
7955
diff
changeset
|
246 ngx_http_v3_srv_conf_t *h3scf; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
247 ngx_http_v3_connection_t *h3c; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
248 ngx_http_v3_dynamic_table_t *dt; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
249 |
7681 | 250 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
251 "http3 set capacity %ui", capacity); | |
252 | |
8200
279ad36f2f4b
QUIC: renamed c->qs to c->quic.
Roman Arutyunyan <arut@nginx.com>
parents:
8010
diff
changeset
|
253 pc = c->quic->parent; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
254 h3c = pc->data; |
8010
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
7955
diff
changeset
|
255 h3scf = ngx_http_get_module_srv_conf(h3c->hc.conf_ctx, ngx_http_v3_module); |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
256 |
8010
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
7955
diff
changeset
|
257 if (capacity > h3scf->max_table_capacity) { |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
258 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
259 "client exceeded http3_max_table_capacity limit"); |
7955
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
7951
diff
changeset
|
260 return NGX_HTTP_V3_ERR_ENCODER_STREAM_ERROR; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
261 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
262 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
263 dt = &h3c->table; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
264 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
265 if (dt->size > capacity) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
266 if (ngx_http_v3_evict(c, dt->size - capacity) != NGX_OK) { |
7955
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
7951
diff
changeset
|
267 return NGX_HTTP_V3_ERR_ENCODER_STREAM_ERROR; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
268 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
269 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
270 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
271 max = capacity / 32; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
272 prev_max = dt->capacity / 32; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
273 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
274 if (max > prev_max) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
275 elts = ngx_alloc(max * sizeof(void *), c->log); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
276 if (elts == NULL) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
277 return NGX_ERROR; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
278 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
279 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
280 if (dt->elts == NULL) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
281 cln = ngx_pool_cleanup_add(pc->pool, 0); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
282 if (cln == NULL) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
283 return NGX_ERROR; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
284 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
285 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
286 cln->handler = ngx_http_v3_cleanup_table; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
287 cln->data = dt; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
288 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
289 } else { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
290 ngx_memcpy(elts, dt->elts, dt->nelts * sizeof(void *)); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
291 ngx_free(dt->elts); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
292 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
293 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
294 dt->elts = elts; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
295 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
296 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
297 dt->capacity = capacity; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
298 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
299 return NGX_OK; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
300 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
301 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
302 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
303 static void |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
304 ngx_http_v3_cleanup_table(void *data) |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
305 { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
306 ngx_http_v3_dynamic_table_t *dt = data; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
307 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
308 ngx_uint_t n; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
309 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
310 for (n = 0; n < dt->nelts; n++) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
311 ngx_free(dt->elts[n]); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
312 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
313 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
314 ngx_free(dt->elts); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
315 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
316 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
317 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
318 static ngx_int_t |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
319 ngx_http_v3_evict(ngx_connection_t *c, size_t need) |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
320 { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
321 size_t size, target; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
322 ngx_uint_t n; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
323 ngx_http_v3_header_t *h; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
324 ngx_http_v3_connection_t *h3c; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
325 ngx_http_v3_dynamic_table_t *dt; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
326 |
8200
279ad36f2f4b
QUIC: renamed c->qs to c->quic.
Roman Arutyunyan <arut@nginx.com>
parents:
8010
diff
changeset
|
327 h3c = c->quic->parent->data; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
328 dt = &h3c->table; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
329 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
330 if (need > dt->capacity) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
331 ngx_log_error(NGX_LOG_ERR, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
332 "not enough dynamic table capacity"); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
333 return NGX_ERROR; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
334 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
335 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
336 target = dt->capacity - need; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
337 n = 0; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
338 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
339 while (dt->size > target) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
340 h = dt->elts[n++]; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
341 size = ngx_http_v3_table_entry_size(&h->name, &h->value); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
342 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
343 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
344 "http3 evict [%ui] \"%V\":\"%V\" size:%uz", |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
345 dt->base, &h->name, &h->value, size); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
346 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
347 ngx_free(h); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
348 dt->size -= size; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
349 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
350 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
351 if (n) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
352 dt->nelts -= n; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
353 dt->base += n; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
354 ngx_memmove(dt->elts, &dt->elts[n], dt->nelts * sizeof(void *)); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
355 } |
7681 | 356 |
357 return NGX_OK; | |
358 } | |
359 | |
360 | |
361 ngx_int_t | |
362 ngx_http_v3_duplicate(ngx_connection_t *c, ngx_uint_t index) | |
363 { | |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
364 ngx_str_t name, value; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
365 ngx_http_v3_connection_t *h3c; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
366 ngx_http_v3_dynamic_table_t *dt; |
7681 | 367 |
368 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 duplicate %ui", index); | |
369 | |
8200
279ad36f2f4b
QUIC: renamed c->qs to c->quic.
Roman Arutyunyan <arut@nginx.com>
parents:
8010
diff
changeset
|
370 h3c = c->quic->parent->data; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
371 dt = &h3c->table; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
372 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
373 if (dt->base + dt->nelts <= index) { |
7955
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
7951
diff
changeset
|
374 return NGX_HTTP_V3_ERR_ENCODER_STREAM_ERROR; |
7681 | 375 } |
376 | |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
377 index = dt->base + dt->nelts - 1 - index; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
378 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
379 if (ngx_http_v3_lookup(c, index, &name, &value) != NGX_OK) { |
7955
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
7951
diff
changeset
|
380 return NGX_HTTP_V3_ERR_ENCODER_STREAM_ERROR; |
7681 | 381 } |
382 | |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
383 return ngx_http_v3_insert(c, &name, &value); |
7681 | 384 } |
385 | |
386 | |
387 ngx_int_t | |
388 ngx_http_v3_ack_header(ngx_connection_t *c, ngx_uint_t stream_id) | |
389 { | |
390 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
391 "http3 ack header %ui", stream_id); | |
392 | |
393 /* XXX */ | |
394 | |
395 return NGX_OK; | |
396 } | |
397 | |
398 | |
399 ngx_int_t | |
400 ngx_http_v3_cancel_stream(ngx_connection_t *c, ngx_uint_t stream_id) | |
401 { | |
402 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
403 "http3 cancel stream %ui", stream_id); | |
404 | |
405 /* XXX */ | |
406 | |
407 return NGX_OK; | |
408 } | |
409 | |
410 | |
411 ngx_int_t | |
412 ngx_http_v3_inc_insert_count(ngx_connection_t *c, ngx_uint_t inc) | |
413 { | |
414 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
415 "http3 increment insert count %ui", inc); | |
416 | |
417 /* XXX */ | |
418 | |
419 return NGX_OK; | |
420 } | |
421 | |
422 | |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
423 ngx_int_t |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
424 ngx_http_v3_lookup_static(ngx_connection_t *c, ngx_uint_t index, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
425 ngx_str_t *name, ngx_str_t *value) |
7681 | 426 { |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
427 ngx_uint_t nelts; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
428 ngx_http_v3_header_t *h; |
7681 | 429 |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
430 nelts = sizeof(ngx_http_v3_static_table) |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
431 / sizeof(ngx_http_v3_static_table[0]); |
7681 | 432 |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
433 if (index >= nelts) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
434 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
435 "http3 static[%ui] lookup out of bounds: %ui", |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
436 index, nelts); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
437 return NGX_ERROR; |
7681 | 438 } |
439 | |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
440 h = &ngx_http_v3_static_table[index]; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
441 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
442 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
443 "http3 static[%ui] lookup \"%V\":\"%V\"", |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
444 index, &h->name, &h->value); |
7681 | 445 |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
446 if (name) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
447 *name = h->name; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
448 } |
7681 | 449 |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
450 if (value) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
451 *value = h->value; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
452 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
453 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
454 return NGX_OK; |
7681 | 455 } |
456 | |
457 | |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
458 ngx_int_t |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
459 ngx_http_v3_lookup(ngx_connection_t *c, ngx_uint_t index, ngx_str_t *name, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
460 ngx_str_t *value) |
7681 | 461 { |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
462 ngx_http_v3_header_t *h; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
463 ngx_http_v3_connection_t *h3c; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
464 ngx_http_v3_dynamic_table_t *dt; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
465 |
8200
279ad36f2f4b
QUIC: renamed c->qs to c->quic.
Roman Arutyunyan <arut@nginx.com>
parents:
8010
diff
changeset
|
466 h3c = c->quic->parent->data; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
467 dt = &h3c->table; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
468 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
469 if (index < dt->base || index - dt->base >= dt->nelts) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
470 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
471 "http3 dynamic[%ui] lookup out of bounds: [%ui,%ui]", |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
472 index, dt->base, dt->base + dt->nelts); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
473 return NGX_ERROR; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
474 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
475 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
476 h = dt->elts[index - dt->base]; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
477 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
478 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
479 "http3 dynamic[%ui] lookup \"%V\":\"%V\"", |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
480 index, &h->name, &h->value); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
481 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
482 if (name) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
483 *name = h->name; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
484 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
485 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
486 if (value) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
487 *value = h->value; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
488 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
489 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
490 return NGX_OK; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
491 } |
7681 | 492 |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
493 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
494 ngx_int_t |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
495 ngx_http_v3_decode_insert_count(ngx_connection_t *c, ngx_uint_t *insert_count) |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
496 { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
497 ngx_uint_t max_entries, full_range, max_value, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
498 max_wrapped, req_insert_count; |
8010
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
7955
diff
changeset
|
499 ngx_http_v3_srv_conf_t *h3scf; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
500 ngx_http_v3_connection_t *h3c; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
501 ngx_http_v3_dynamic_table_t *dt; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
502 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
503 /* QPACK 4.5.1.1. Required Insert Count */ |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
504 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
505 if (*insert_count == 0) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
506 return NGX_OK; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
507 } |
7681 | 508 |
8200
279ad36f2f4b
QUIC: renamed c->qs to c->quic.
Roman Arutyunyan <arut@nginx.com>
parents:
8010
diff
changeset
|
509 h3c = c->quic->parent->data; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
510 dt = &h3c->table; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
511 |
8010
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
7955
diff
changeset
|
512 h3scf = ngx_http_get_module_srv_conf(h3c->hc.conf_ctx, ngx_http_v3_module); |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
513 |
8010
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
7955
diff
changeset
|
514 max_entries = h3scf->max_table_capacity / 32; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
515 full_range = 2 * max_entries; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
516 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
517 if (*insert_count > full_range) { |
7955
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
7951
diff
changeset
|
518 return NGX_HTTP_V3_ERR_DECOMPRESSION_FAILED; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
519 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
520 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
521 max_value = dt->base + dt->nelts + max_entries; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
522 max_wrapped = (max_value / full_range) * full_range; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
523 req_insert_count = max_wrapped + *insert_count - 1; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
524 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
525 if (req_insert_count > max_value) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
526 if (req_insert_count <= full_range) { |
7955
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
7951
diff
changeset
|
527 return NGX_HTTP_V3_ERR_DECOMPRESSION_FAILED; |
7681 | 528 } |
529 | |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
530 req_insert_count -= full_range; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
531 } |
7681 | 532 |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
533 if (req_insert_count == 0) { |
7955
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
7951
diff
changeset
|
534 return NGX_HTTP_V3_ERR_DECOMPRESSION_FAILED; |
7681 | 535 } |
536 | |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
537 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
538 "http3 decode insert_count %ui -> %ui", |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
539 *insert_count, req_insert_count); |
7681 | 540 |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
541 *insert_count = req_insert_count; |
7681 | 542 |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
543 return NGX_OK; |
7681 | 544 } |
545 | |
546 | |
547 ngx_int_t | |
548 ngx_http_v3_check_insert_count(ngx_connection_t *c, ngx_uint_t insert_count) | |
549 { | |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
550 size_t n; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
551 ngx_connection_t *pc; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
552 ngx_pool_cleanup_t *cln; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
553 ngx_http_v3_block_t *block; |
8010
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
7955
diff
changeset
|
554 ngx_http_v3_srv_conf_t *h3scf; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
555 ngx_http_v3_connection_t *h3c; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
556 ngx_http_v3_dynamic_table_t *dt; |
7681 | 557 |
8200
279ad36f2f4b
QUIC: renamed c->qs to c->quic.
Roman Arutyunyan <arut@nginx.com>
parents:
8010
diff
changeset
|
558 pc = c->quic->parent; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
559 h3c = pc->data; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
560 dt = &h3c->table; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
561 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
562 n = dt->base + dt->nelts; |
7681 | 563 |
564 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
565 "http3 check insert count req:%ui, have:%ui", |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
566 insert_count, n); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
567 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
568 if (n >= insert_count) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
569 return NGX_OK; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
570 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
571 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
572 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 block stream"); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
573 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
574 block = NULL; |
7681 | 575 |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
576 for (cln = c->pool->cleanup; cln; cln = cln->next) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
577 if (cln->handler == ngx_http_v3_unblock) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
578 block = cln->data; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
579 break; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
580 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
581 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
582 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
583 if (block == NULL) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
584 cln = ngx_pool_cleanup_add(c->pool, sizeof(ngx_http_v3_block_t)); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
585 if (cln == NULL) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
586 return NGX_ERROR; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
587 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
588 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
589 cln->handler = ngx_http_v3_unblock; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
590 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
591 block = cln->data; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
592 block->queue.prev = NULL; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
593 block->connection = c; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
594 block->nblocked = &h3c->nblocked; |
7681 | 595 } |
596 | |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
597 if (block->queue.prev == NULL) { |
8010
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
7955
diff
changeset
|
598 h3scf = ngx_http_get_module_srv_conf(h3c->hc.conf_ctx, |
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
7955
diff
changeset
|
599 ngx_http_v3_module); |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
600 |
8010
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
7955
diff
changeset
|
601 if (h3c->nblocked == h3scf->max_blocked_streams) { |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
602 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
603 "client exceeded http3_max_blocked_streams limit"); |
7955
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
7951
diff
changeset
|
604 return NGX_HTTP_V3_ERR_DECOMPRESSION_FAILED; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
605 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
606 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
607 h3c->nblocked++; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
608 ngx_queue_insert_tail(&h3c->blocked, &block->queue); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
609 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
610 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
611 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
612 "http3 blocked:%ui", h3c->nblocked); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
613 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
614 return NGX_BUSY; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
615 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
616 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
617 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
618 static void |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
619 ngx_http_v3_unblock(void *data) |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
620 { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
621 ngx_http_v3_block_t *block = data; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
622 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
623 if (block->queue.prev) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
624 ngx_queue_remove(&block->queue); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
625 block->queue.prev = NULL; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
626 (*block->nblocked)--; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
627 } |
7681 | 628 } |
629 | |
630 | |
631 static ngx_int_t | |
632 ngx_http_v3_new_header(ngx_connection_t *c) | |
633 { | |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
634 ngx_queue_t *q; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
635 ngx_connection_t *bc; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
636 ngx_http_v3_block_t *block; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
637 ngx_http_v3_connection_t *h3c; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
638 |
8200
279ad36f2f4b
QUIC: renamed c->qs to c->quic.
Roman Arutyunyan <arut@nginx.com>
parents:
8010
diff
changeset
|
639 h3c = c->quic->parent->data; |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
640 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
641 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
642 "http3 new dynamic header, blocked:%ui", h3c->nblocked); |
7681 | 643 |
7951
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
644 while (!ngx_queue_empty(&h3c->blocked)) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
645 q = ngx_queue_head(&h3c->blocked); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
646 block = (ngx_http_v3_block_t *) q; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
647 bc = block->connection; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
648 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
649 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, bc->log, 0, "http3 unblock stream"); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
650 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
651 ngx_http_v3_unblock(block); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
652 ngx_post_event(bc->read, &ngx_posted_events); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
7886
diff
changeset
|
653 } |
7681 | 654 |
655 return NGX_OK; | |
656 } | |
7692
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
657 |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
658 |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
659 ngx_int_t |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
660 ngx_http_v3_set_param(ngx_connection_t *c, uint64_t id, uint64_t value) |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
661 { |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
662 switch (id) { |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
663 |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
664 case NGX_HTTP_V3_PARAM_MAX_TABLE_CAPACITY: |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
665 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
666 "http3 param QPACK_MAX_TABLE_CAPACITY:%uL", value); |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
667 break; |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
668 |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
669 case NGX_HTTP_V3_PARAM_MAX_HEADER_LIST_SIZE: |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
670 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
671 "http3 param SETTINGS_MAX_HEADER_LIST_SIZE:%uL", value); |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
672 break; |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
673 |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
674 case NGX_HTTP_V3_PARAM_BLOCKED_STREAMS: |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
675 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
676 "http3 param QPACK_BLOCKED_STREAMS:%uL", value); |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
677 break; |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
678 |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
679 default: |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
680 |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
681 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
682 "http3 param #%uL:%uL", id, value); |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
683 } |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
684 |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
685 return NGX_OK; |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
7681
diff
changeset
|
686 } |