From: Frédéric Lécaille Date: Fri, 20 May 2022 14:29:10 +0000 (+0200) Subject: MINOR: quic: Add tune.quic.retry-threshold keyword X-Git-Tag: v2.6-dev11~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9286210aa85ec16190b913d27f733fa8df4bdf20;p=thirdparty%2Fhaproxy.git MINOR: quic: Add tune.quic.retry-threshold keyword This QUIC specific keyword may be used to set the theshold, in number of connection openings, beyond which QUIC Retry feature will be automatically enabled. Its default value is 100. --- diff --git a/include/haproxy/global-t.h b/include/haproxy/global-t.h index fbbc88da33..3544622d3d 100644 --- a/include/haproxy/global-t.h +++ b/include/haproxy/global-t.h @@ -158,6 +158,7 @@ struct global { int pool_high_count; /* max number of opened fd before we start killing idle connections when creating new connections */ unsigned short idle_timer; /* how long before an empty buffer is considered idle (ms) */ #ifdef USE_QUIC + unsigned int quic_retry_threshold; unsigned int quic_streams_buf; #endif /* USE_QUIC */ } tune; diff --git a/include/haproxy/xprt_quic-t.h b/include/haproxy/xprt_quic-t.h index 5ea31189f1..a85b47c46a 100644 --- a/include/haproxy/xprt_quic-t.h +++ b/include/haproxy/xprt_quic-t.h @@ -92,6 +92,8 @@ typedef unsigned long long ull; #define QUIC_RETRY_TOKEN_SALTLEN 16 /* bytes */ /* Retry token duration */ #define QUIC_RETRY_DURATION_MS 10000 +/* Default Retry threshold */ +#define QUIC_DFLT_RETRY_THRESHOLD 100 /* in connection openings */ /* * 0 1 2 3 diff --git a/src/cfgparse-quic.c b/src/cfgparse-quic.c index deaa13ffe1..03f4178259 100644 --- a/src/cfgparse-quic.c +++ b/src/cfgparse-quic.c @@ -18,12 +18,16 @@ static struct bind_kw_list bind_kws = { "QUIC", { }, { INITCALL1(STG_REGISTER, bind_register_keywords, &bind_kws); -static int cfg_parse_quic_conn_buf_limit(char **args, int section_type, - struct proxy *curpx, - const struct proxy *defpx, - const char *file, int line, char **err) +/* Parse any tune.quic.* setting with strictly positive integer values. + * Return -1 on alert, or 0 if succeeded. + */ +static int cfg_parse_quic_tune_setting(char **args, int section_type, + struct proxy *curpx, + const struct proxy *defpx, + const char *file, int line, char **err) { unsigned int arg = 0; + int prefix_len = strlen("tune.quic."); if (too_many_args(1, args, err, NULL)) return -1; @@ -36,13 +40,21 @@ static int cfg_parse_quic_conn_buf_limit(char **args, int section_type, return -1; } - global.tune.quic_streams_buf = arg; + if (strcmp(args[0] + prefix_len, "conn-buf-limit") == 0) + global.tune.quic_streams_buf = arg; + else if (strcmp(args[0] + prefix_len, "retry-threshold") == 0) + global.tune.quic_retry_threshold = arg; + else { + memprintf(err, "'%s' keyword not unhandled (please report this bug).", args[0]); + return -1; + } return 0; } static struct cfg_kw_list cfg_kws = {ILH, { - { CFG_GLOBAL, "tune.quic.conn-buf-limit", cfg_parse_quic_conn_buf_limit }, + { CFG_GLOBAL, "tune.quic.conn-buf-limit", cfg_parse_quic_tune_setting }, + { CFG_GLOBAL, "tune.quic.retry-threshold", cfg_parse_quic_tune_setting }, { 0, NULL, NULL } }}; diff --git a/src/haproxy.c b/src/haproxy.c index f3cf30ec9c..1d6612619e 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -138,6 +138,7 @@ #include #include #include +#include /* array of init calls for older platforms */ @@ -204,6 +205,7 @@ struct global global = { .idle_timer = 1000, /* 1 second */ #endif #ifdef USE_QUIC + .quic_retry_threshold = QUIC_DFLT_RETRY_THRESHOLD, .quic_streams_buf = 30, #endif /* USE_QUIC */ },