Mercurial > hg > nginx
comparison src/http/v3/ngx_http_v3_module.c @ 8247:e9891e8ee975 quic
Configurable transport parameters.
- integer parameters can be configured using the following directives:
quic_max_idle_timeout
quic_max_ack_delay
quic_max_packet_size
quic_initial_max_data
quic_initial_max_stream_data_bidi_local
quic_initial_max_stream_data_bidi_remote
quic_initial_max_stream_data_uni
quic_initial_max_streams_bidi
quic_initial_max_streams_uni
quic_ack_delay_exponent
quic_active_migration
quic_active_connection_id_limit
- only following parameters are actually sent:
active_connection_id_limit
initial_max_streams_uni
initial_max_streams_bidi
initial_max_stream_data_bidi_local
initial_max_stream_data_bidi_remote
initial_max_stream_data_uni
(other parameters are to be added into ngx_quic_create_transport_params()
function as needed, should be easy now)
- draft 24 and draft 27 are now supported
(at compile-time using quic_version macro)
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Fri, 20 Mar 2020 13:47:44 +0300 |
parents | 38c0898b6df7 |
children | abb7c1a4c9d5 |
comparison
equal
deleted
inserted
replaced
8246:0d9bc77ae30d | 8247:e9891e8ee975 |
---|---|
9 #include <ngx_core.h> | 9 #include <ngx_core.h> |
10 #include <ngx_http.h> | 10 #include <ngx_http.h> |
11 | 11 |
12 | 12 |
13 static ngx_command_t ngx_http_v3_commands[] = { | 13 static ngx_command_t ngx_http_v3_commands[] = { |
14 | |
15 { ngx_string("quic_max_idle_timeout"), | |
16 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | |
17 ngx_conf_set_msec_slot, | |
18 NGX_HTTP_SRV_CONF_OFFSET, | |
19 offsetof(ngx_http_v3_srv_conf_t, quic.max_idle_timeout), | |
20 NULL }, | |
21 | |
22 { ngx_string("quic_max_ack_delay"), | |
23 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | |
24 ngx_conf_set_msec_slot, | |
25 NGX_HTTP_SRV_CONF_OFFSET, | |
26 offsetof(ngx_http_v3_srv_conf_t, quic.max_ack_delay), | |
27 NULL }, | |
28 | |
29 { ngx_string("quic_max_packet_size"), | |
30 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | |
31 ngx_conf_set_num_slot, | |
32 NGX_HTTP_SRV_CONF_OFFSET, | |
33 offsetof(ngx_http_v3_srv_conf_t, quic.max_packet_size), | |
34 NULL }, | |
35 | |
36 { ngx_string("quic_initial_max_data"), | |
37 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | |
38 ngx_conf_set_num_slot, | |
39 NGX_HTTP_SRV_CONF_OFFSET, | |
40 offsetof(ngx_http_v3_srv_conf_t, quic.initial_max_data), | |
41 NULL }, | |
42 | |
43 { ngx_string("quic_initial_max_stream_data_bidi_local"), | |
44 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | |
45 ngx_conf_set_num_slot, | |
46 NGX_HTTP_SRV_CONF_OFFSET, | |
47 offsetof(ngx_http_v3_srv_conf_t, quic.initial_max_stream_data_bidi_local), | |
48 NULL }, | |
49 | |
50 { ngx_string("quic_initial_max_stream_data_bidi_remote"), | |
51 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | |
52 ngx_conf_set_num_slot, | |
53 NGX_HTTP_SRV_CONF_OFFSET, | |
54 offsetof(ngx_http_v3_srv_conf_t, quic.initial_max_stream_data_bidi_remote), | |
55 NULL }, | |
56 | |
57 { ngx_string("quic_initial_max_stream_data_uni"), | |
58 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | |
59 ngx_conf_set_num_slot, | |
60 NGX_HTTP_SRV_CONF_OFFSET, | |
61 offsetof(ngx_http_v3_srv_conf_t, quic.initial_max_stream_data_uni), | |
62 NULL }, | |
63 | |
64 { ngx_string("quic_initial_max_streams_bidi"), | |
65 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | |
66 ngx_conf_set_num_slot, | |
67 NGX_HTTP_SRV_CONF_OFFSET, | |
68 offsetof(ngx_http_v3_srv_conf_t, quic.initial_max_streams_bidi), | |
69 NULL }, | |
70 | |
71 { ngx_string("quic_initial_max_streams_uni"), | |
72 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | |
73 ngx_conf_set_num_slot, | |
74 NGX_HTTP_SRV_CONF_OFFSET, | |
75 offsetof(ngx_http_v3_srv_conf_t, quic.initial_max_streams_uni), | |
76 NULL }, | |
77 | |
78 { ngx_string("quic_ack_delay_exponent"), | |
79 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | |
80 ngx_conf_set_num_slot, | |
81 NGX_HTTP_SRV_CONF_OFFSET, | |
82 offsetof(ngx_http_v3_srv_conf_t, quic.ack_delay_exponent), | |
83 NULL }, | |
84 | |
85 { ngx_string("quic_active_migration"), | |
86 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | |
87 ngx_conf_set_num_slot, | |
88 NGX_HTTP_SRV_CONF_OFFSET, | |
89 offsetof(ngx_http_v3_srv_conf_t, quic.disable_active_migration), | |
90 NULL }, | |
91 | |
92 { ngx_string("quic_active_connection_id_limit"), | |
93 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | |
94 ngx_conf_set_num_slot, | |
95 NGX_HTTP_SRV_CONF_OFFSET, | |
96 offsetof(ngx_http_v3_srv_conf_t, quic.active_connection_id_limit), | |
97 NULL }, | |
98 | |
14 ngx_null_command | 99 ngx_null_command |
15 }; | 100 }; |
101 | |
102 | |
103 static void *ngx_http_v3_create_srv_conf(ngx_conf_t *cf); | |
104 static char *ngx_http_v3_merge_srv_conf(ngx_conf_t *cf, | |
105 void *parent, void *child); | |
16 | 106 |
17 | 107 |
18 static ngx_http_module_t ngx_http_v3_module_ctx = { | 108 static ngx_http_module_t ngx_http_v3_module_ctx = { |
19 NULL, /* preconfiguration */ | 109 NULL, /* preconfiguration */ |
20 NULL, /* postconfiguration */ | 110 NULL, /* postconfiguration */ |
21 | 111 |
22 NULL, /* create main configuration */ | 112 NULL, /* create main configuration */ |
23 NULL, /* init main configuration */ | 113 NULL, /* init main configuration */ |
24 | 114 |
25 NULL, /* create server configuration */ | 115 ngx_http_v3_create_srv_conf, /* create server configuration */ |
26 NULL, /* merge server configuration */ | 116 ngx_http_v3_merge_srv_conf, /* merge server configuration */ |
27 | 117 |
28 NULL, /* create location configuration */ | 118 NULL, /* create location configuration */ |
29 NULL /* merge location configuration */ | 119 NULL /* merge location configuration */ |
30 }; | 120 }; |
31 | 121 |
42 NULL, /* exit thread */ | 132 NULL, /* exit thread */ |
43 NULL, /* exit process */ | 133 NULL, /* exit process */ |
44 NULL, /* exit master */ | 134 NULL, /* exit master */ |
45 NGX_MODULE_V1_PADDING | 135 NGX_MODULE_V1_PADDING |
46 }; | 136 }; |
137 | |
138 | |
139 static void * | |
140 ngx_http_v3_create_srv_conf(ngx_conf_t *cf) | |
141 { | |
142 ngx_http_v3_srv_conf_t *v3cf; | |
143 | |
144 v3cf = ngx_pcalloc(cf->pool, sizeof(ngx_http_v3_srv_conf_t)); | |
145 if (v3cf == NULL) { | |
146 return NULL; | |
147 } | |
148 | |
149 /* | |
150 * set by ngx_pcalloc(): | |
151 * v3cf->quic.original_connection_id = 0; | |
152 * v3cf->quic.stateless_reset_token = { 0 } | |
153 * conf->quic.preferred_address = NULL | |
154 */ | |
155 | |
156 v3cf->quic.max_idle_timeout = NGX_CONF_UNSET_MSEC; | |
157 v3cf->quic.max_ack_delay = NGX_CONF_UNSET_MSEC; | |
158 | |
159 v3cf->quic.max_packet_size = NGX_CONF_UNSET_UINT; | |
160 v3cf->quic.initial_max_data = NGX_CONF_UNSET_UINT; | |
161 v3cf->quic.initial_max_stream_data_bidi_local = NGX_CONF_UNSET_UINT; | |
162 v3cf->quic.initial_max_stream_data_bidi_remote = NGX_CONF_UNSET_UINT; | |
163 v3cf->quic.initial_max_stream_data_uni = NGX_CONF_UNSET_UINT; | |
164 v3cf->quic.initial_max_streams_bidi = NGX_CONF_UNSET_UINT; | |
165 v3cf->quic.initial_max_streams_uni = NGX_CONF_UNSET_UINT; | |
166 v3cf->quic.ack_delay_exponent = NGX_CONF_UNSET_UINT; | |
167 v3cf->quic.disable_active_migration = NGX_CONF_UNSET_UINT; | |
168 v3cf->quic.active_connection_id_limit = NGX_CONF_UNSET_UINT; | |
169 | |
170 return v3cf; | |
171 } | |
172 | |
173 | |
174 static char * | |
175 ngx_http_v3_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) | |
176 { | |
177 ngx_http_v3_srv_conf_t *prev = parent; | |
178 ngx_http_v3_srv_conf_t *conf = child; | |
179 | |
180 ngx_conf_merge_msec_value(conf->quic.max_idle_timeout, | |
181 prev->quic.max_idle_timeout, 10000); | |
182 | |
183 // > 2 ^ 14 is invalid | |
184 ngx_conf_merge_msec_value(conf->quic.max_ack_delay, | |
185 prev->quic.max_ack_delay, 25); | |
186 | |
187 // < 1200 is invalid | |
188 ngx_conf_merge_uint_value(conf->quic.max_packet_size, | |
189 prev->quic.max_packet_size, 65527); | |
190 | |
191 ngx_conf_merge_uint_value(conf->quic.initial_max_data, | |
192 prev->quic.initial_max_data, 10000000); | |
193 | |
194 ngx_conf_merge_uint_value(conf->quic.initial_max_stream_data_bidi_local, | |
195 prev->quic.initial_max_stream_data_bidi_local, | |
196 255); | |
197 | |
198 ngx_conf_merge_uint_value(conf->quic.initial_max_stream_data_bidi_remote, | |
199 prev->quic.initial_max_stream_data_bidi_remote, | |
200 255); | |
201 | |
202 ngx_conf_merge_uint_value(conf->quic.initial_max_stream_data_uni, | |
203 prev->quic.initial_max_stream_data_uni, 255); | |
204 | |
205 ngx_conf_merge_uint_value(conf->quic.initial_max_streams_bidi, | |
206 prev->quic.initial_max_streams_bidi, 16); | |
207 | |
208 ngx_conf_merge_uint_value(conf->quic.initial_max_streams_uni, | |
209 prev->quic.initial_max_streams_uni, 16); | |
210 | |
211 // > 20 is invalid | |
212 ngx_conf_merge_uint_value(conf->quic.ack_delay_exponent, | |
213 prev->quic.ack_delay_exponent, 3); | |
214 | |
215 ngx_conf_merge_uint_value(conf->quic.disable_active_migration, | |
216 prev->quic.disable_active_migration, 1); | |
217 | |
218 // < 2 is invalid | |
219 ngx_conf_merge_uint_value(conf->quic.active_connection_id_limit, | |
220 prev->quic.active_connection_id_limit, 2); | |
221 | |
222 return NGX_CONF_OK; | |
223 } | |
224 |