QUIC: the "quic_gso" directive.

The directive enables usage of UDP segmentation offloading by quic.
By default, gso is disabled since it is not always operational when
detected (depends on interface configuration).
This commit is contained in:
Vladimir Homutov 2021-07-20 12:37:12 +03:00
parent 31fe966e71
commit 6157d0b5c1
4 changed files with 25 additions and 2 deletions

View File

@ -59,6 +59,7 @@ typedef struct {
ngx_ssl_t *ssl; ngx_ssl_t *ssl;
ngx_quic_tp_t tp; ngx_quic_tp_t tp;
ngx_flag_t retry; ngx_flag_t retry;
ngx_flag_t gso_enabled;
ngx_flag_t require_alpn; ngx_flag_t require_alpn;
ngx_str_t host_key; ngx_str_t host_key;
u_char av_token_key[NGX_QUIC_AV_KEY_LEN]; u_char av_token_key[NGX_QUIC_AV_KEY_LEN];

View File

@ -212,13 +212,17 @@ ngx_quic_allow_segmentation(ngx_connection_t *c, ngx_quic_socket_t *qsock)
ngx_quic_send_ctx_t *ctx; ngx_quic_send_ctx_t *ctx;
ngx_quic_connection_t *qc; ngx_quic_connection_t *qc;
qc = ngx_quic_get_connection(c);
if (!qc->conf->gso_enabled) {
return 0;
}
if (qsock->path->state != NGX_QUIC_PATH_VALIDATED) { if (qsock->path->state != NGX_QUIC_PATH_VALIDATED) {
/* don't even try to be faster on non-validated paths */ /* don't even try to be faster on non-validated paths */
return 0; return 0;
} }
qc = ngx_quic_get_connection(c);
ctx = ngx_quic_get_send_ctx(qc, ssl_encryption_initial); ctx = ngx_quic_get_send_ctx(qc, ssl_encryption_initial);
if (!ngx_queue_empty(&ctx->frames)) { if (!ngx_queue_empty(&ctx->frames)) {
return 0; return 0;

View File

@ -126,6 +126,13 @@ static ngx_command_t ngx_http_quic_commands[] = {
offsetof(ngx_quic_conf_t, retry), offsetof(ngx_quic_conf_t, retry),
NULL }, NULL },
{ ngx_string("quic_gso"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
ngx_conf_set_flag_slot,
NGX_HTTP_SRV_CONF_OFFSET,
offsetof(ngx_quic_conf_t, gso_enabled),
NULL },
{ ngx_string("quic_host_key"), { ngx_string("quic_host_key"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
ngx_http_quic_host_key, ngx_http_quic_host_key,
@ -290,6 +297,7 @@ ngx_http_quic_create_srv_conf(ngx_conf_t *cf)
conf->tp.active_connection_id_limit = NGX_CONF_UNSET_UINT; conf->tp.active_connection_id_limit = NGX_CONF_UNSET_UINT;
conf->retry = NGX_CONF_UNSET; conf->retry = NGX_CONF_UNSET;
conf->gso_enabled = NGX_CONF_UNSET;
conf->require_alpn = 1; conf->require_alpn = 1;
return conf; return conf;
@ -348,6 +356,7 @@ ngx_http_quic_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
prev->tp.active_connection_id_limit, 2); prev->tp.active_connection_id_limit, 2);
ngx_conf_merge_value(conf->retry, prev->retry, 0); ngx_conf_merge_value(conf->retry, prev->retry, 0);
ngx_conf_merge_value(conf->gso_enabled, prev->gso_enabled, 0);
ngx_conf_merge_str_value(conf->host_key, prev->host_key, ""); ngx_conf_merge_str_value(conf->host_key, prev->host_key, "");

View File

@ -128,6 +128,13 @@ static ngx_command_t ngx_stream_quic_commands[] = {
offsetof(ngx_quic_conf_t, retry), offsetof(ngx_quic_conf_t, retry),
NULL }, NULL },
{ ngx_string("quic_gso"),
NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_FLAG,
ngx_conf_set_flag_slot,
NGX_STREAM_SRV_CONF_OFFSET,
offsetof(ngx_quic_conf_t, gso_enabled),
NULL },
{ ngx_string("quic_host_key"), { ngx_string("quic_host_key"),
NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_FLAG, NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_FLAG,
ngx_stream_quic_host_key, ngx_stream_quic_host_key,
@ -251,6 +258,7 @@ ngx_stream_quic_create_srv_conf(ngx_conf_t *cf)
conf->tp.active_connection_id_limit = NGX_CONF_UNSET_UINT; conf->tp.active_connection_id_limit = NGX_CONF_UNSET_UINT;
conf->retry = NGX_CONF_UNSET; conf->retry = NGX_CONF_UNSET;
conf->gso_enabled = NGX_CONF_UNSET;
return conf; return conf;
} }
@ -308,6 +316,7 @@ ngx_stream_quic_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
prev->tp.active_connection_id_limit, 2); prev->tp.active_connection_id_limit, 2);
ngx_conf_merge_value(conf->retry, prev->retry, 0); ngx_conf_merge_value(conf->retry, prev->retry, 0);
ngx_conf_merge_value(conf->gso_enabled, prev->gso_enabled, 0);
ngx_conf_merge_str_value(conf->host_key, prev->host_key, ""); ngx_conf_merge_str_value(conf->host_key, prev->host_key, "");