diff options
Diffstat (limited to 'src/http')
| -rw-r--r-- | src/http/ngx_http_request.c | 5 | ||||
| -rw-r--r-- | src/http/v3/ngx_http_v3.h | 5 | ||||
| -rw-r--r-- | src/http/v3/ngx_http_v3_module.c | 182 |
3 files changed, 189 insertions, 3 deletions
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index 687de931c..6c9fdc543 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -341,11 +341,14 @@ ngx_http_init_connection(ngx_connection_t *c) #if (NGX_HTTP_V3) if (hc->quic) { + ngx_http_v3_srv_conf_t *v3cf; ngx_http_ssl_srv_conf_t *sscf; + v3cf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_v3_module); sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_ssl_module); - ngx_quic_run(c, &sscf->ssl, c->listening->post_accept_timeout, + ngx_quic_run(c, &sscf->ssl, &v3cf->quic, + c->listening->post_accept_timeout, ngx_http_quic_stream_handler); return; } diff --git a/src/http/v3/ngx_http_v3.h b/src/http/v3/ngx_http_v3.h index fc1cadd79..2c63f544e 100644 --- a/src/http/v3/ngx_http_v3.h +++ b/src/http/v3/ngx_http_v3.h @@ -40,6 +40,11 @@ typedef struct { + ngx_quic_tp_t quic; +} ngx_http_v3_srv_conf_t; + + +typedef struct { ngx_http_connection_t hc; ngx_array_t *dynamic; diff --git a/src/http/v3/ngx_http_v3_module.c b/src/http/v3/ngx_http_v3_module.c index af310bd44..6d3f34d41 100644 --- a/src/http/v3/ngx_http_v3_module.c +++ b/src/http/v3/ngx_http_v3_module.c @@ -11,10 +11,100 @@ static ngx_command_t ngx_http_v3_commands[] = { + + { ngx_string("quic_max_idle_timeout"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, + ngx_conf_set_msec_slot, + NGX_HTTP_SRV_CONF_OFFSET, + offsetof(ngx_http_v3_srv_conf_t, quic.max_idle_timeout), + NULL }, + + { ngx_string("quic_max_ack_delay"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, + ngx_conf_set_msec_slot, + NGX_HTTP_SRV_CONF_OFFSET, + offsetof(ngx_http_v3_srv_conf_t, quic.max_ack_delay), + NULL }, + + { ngx_string("quic_max_packet_size"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, + ngx_conf_set_num_slot, + NGX_HTTP_SRV_CONF_OFFSET, + offsetof(ngx_http_v3_srv_conf_t, quic.max_packet_size), + NULL }, + + { ngx_string("quic_initial_max_data"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, + ngx_conf_set_num_slot, + NGX_HTTP_SRV_CONF_OFFSET, + offsetof(ngx_http_v3_srv_conf_t, quic.initial_max_data), + NULL }, + + { ngx_string("quic_initial_max_stream_data_bidi_local"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, + ngx_conf_set_num_slot, + NGX_HTTP_SRV_CONF_OFFSET, + offsetof(ngx_http_v3_srv_conf_t, quic.initial_max_stream_data_bidi_local), + NULL }, + + { ngx_string("quic_initial_max_stream_data_bidi_remote"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, + ngx_conf_set_num_slot, + NGX_HTTP_SRV_CONF_OFFSET, + offsetof(ngx_http_v3_srv_conf_t, quic.initial_max_stream_data_bidi_remote), + NULL }, + + { ngx_string("quic_initial_max_stream_data_uni"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, + ngx_conf_set_num_slot, + NGX_HTTP_SRV_CONF_OFFSET, + offsetof(ngx_http_v3_srv_conf_t, quic.initial_max_stream_data_uni), + NULL }, + + { ngx_string("quic_initial_max_streams_bidi"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, + ngx_conf_set_num_slot, + NGX_HTTP_SRV_CONF_OFFSET, + offsetof(ngx_http_v3_srv_conf_t, quic.initial_max_streams_bidi), + NULL }, + + { ngx_string("quic_initial_max_streams_uni"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, + ngx_conf_set_num_slot, + NGX_HTTP_SRV_CONF_OFFSET, + offsetof(ngx_http_v3_srv_conf_t, quic.initial_max_streams_uni), + NULL }, + + { ngx_string("quic_ack_delay_exponent"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, + ngx_conf_set_num_slot, + NGX_HTTP_SRV_CONF_OFFSET, + offsetof(ngx_http_v3_srv_conf_t, quic.ack_delay_exponent), + NULL }, + + { ngx_string("quic_active_migration"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, + ngx_conf_set_num_slot, + NGX_HTTP_SRV_CONF_OFFSET, + offsetof(ngx_http_v3_srv_conf_t, quic.disable_active_migration), + NULL }, + + { ngx_string("quic_active_connection_id_limit"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, + ngx_conf_set_num_slot, + NGX_HTTP_SRV_CONF_OFFSET, + offsetof(ngx_http_v3_srv_conf_t, quic.active_connection_id_limit), + NULL }, + ngx_null_command }; +static void *ngx_http_v3_create_srv_conf(ngx_conf_t *cf); +static char *ngx_http_v3_merge_srv_conf(ngx_conf_t *cf, + void *parent, void *child); + + static ngx_http_module_t ngx_http_v3_module_ctx = { NULL, /* preconfiguration */ NULL, /* postconfiguration */ @@ -22,8 +112,8 @@ static ngx_http_module_t ngx_http_v3_module_ctx = { NULL, /* create main configuration */ NULL, /* init main configuration */ - NULL, /* create server configuration */ - NULL, /* merge server configuration */ + ngx_http_v3_create_srv_conf, /* create server configuration */ + ngx_http_v3_merge_srv_conf, /* merge server configuration */ NULL, /* create location configuration */ NULL /* merge location configuration */ @@ -44,3 +134,91 @@ ngx_module_t ngx_http_v3_module = { NULL, /* exit master */ NGX_MODULE_V1_PADDING }; + + +static void * +ngx_http_v3_create_srv_conf(ngx_conf_t *cf) +{ + ngx_http_v3_srv_conf_t *v3cf; + + v3cf = ngx_pcalloc(cf->pool, sizeof(ngx_http_v3_srv_conf_t)); + if (v3cf == NULL) { + return NULL; + } + + /* + * set by ngx_pcalloc(): + * v3cf->quic.original_connection_id = 0; + * v3cf->quic.stateless_reset_token = { 0 } + * conf->quic.preferred_address = NULL + */ + + v3cf->quic.max_idle_timeout = NGX_CONF_UNSET_MSEC; + v3cf->quic.max_ack_delay = NGX_CONF_UNSET_MSEC; + + v3cf->quic.max_packet_size = NGX_CONF_UNSET_UINT; + v3cf->quic.initial_max_data = NGX_CONF_UNSET_UINT; + v3cf->quic.initial_max_stream_data_bidi_local = NGX_CONF_UNSET_UINT; + v3cf->quic.initial_max_stream_data_bidi_remote = NGX_CONF_UNSET_UINT; + v3cf->quic.initial_max_stream_data_uni = NGX_CONF_UNSET_UINT; + v3cf->quic.initial_max_streams_bidi = NGX_CONF_UNSET_UINT; + v3cf->quic.initial_max_streams_uni = NGX_CONF_UNSET_UINT; + v3cf->quic.ack_delay_exponent = NGX_CONF_UNSET_UINT; + v3cf->quic.disable_active_migration = NGX_CONF_UNSET_UINT; + v3cf->quic.active_connection_id_limit = NGX_CONF_UNSET_UINT; + + return v3cf; +} + + +static char * +ngx_http_v3_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) +{ + ngx_http_v3_srv_conf_t *prev = parent; + ngx_http_v3_srv_conf_t *conf = child; + + ngx_conf_merge_msec_value(conf->quic.max_idle_timeout, + prev->quic.max_idle_timeout, 10000); + + // > 2 ^ 14 is invalid + ngx_conf_merge_msec_value(conf->quic.max_ack_delay, + prev->quic.max_ack_delay, 25); + + // < 1200 is invalid + ngx_conf_merge_uint_value(conf->quic.max_packet_size, + prev->quic.max_packet_size, 65527); + + ngx_conf_merge_uint_value(conf->quic.initial_max_data, + prev->quic.initial_max_data, 10000000); + + ngx_conf_merge_uint_value(conf->quic.initial_max_stream_data_bidi_local, + prev->quic.initial_max_stream_data_bidi_local, + 255); + + ngx_conf_merge_uint_value(conf->quic.initial_max_stream_data_bidi_remote, + prev->quic.initial_max_stream_data_bidi_remote, + 255); + + ngx_conf_merge_uint_value(conf->quic.initial_max_stream_data_uni, + prev->quic.initial_max_stream_data_uni, 255); + + ngx_conf_merge_uint_value(conf->quic.initial_max_streams_bidi, + prev->quic.initial_max_streams_bidi, 16); + + ngx_conf_merge_uint_value(conf->quic.initial_max_streams_uni, + prev->quic.initial_max_streams_uni, 16); + + // > 20 is invalid + ngx_conf_merge_uint_value(conf->quic.ack_delay_exponent, + prev->quic.ack_delay_exponent, 3); + + ngx_conf_merge_uint_value(conf->quic.disable_active_migration, + prev->quic.disable_active_migration, 1); + + // < 2 is invalid + ngx_conf_merge_uint_value(conf->quic.active_connection_id_limit, + prev->quic.active_connection_id_limit, 2); + + return NGX_CONF_OK; +} + |
