]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Tunable "max_idle_timeout" transport parameter
authorFrédéric Lécaille <flecaille@haproxy.com>
Mon, 23 May 2022 14:38:14 +0000 (16:38 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 30 May 2022 07:59:26 +0000 (09:59 +0200)
Add two tunable settings both for backends and frontends "max_idle_timeout"
QUIC transport parameter, "tune.quic.frontend.max-idle-timeout" and
"tune.quic.backend.max-idle-timeout" respectively.
cfg_parse_quic_time() has been implemented to parse a time value thanks
to parse_time_err(). It should be reused for any tunable time value to be
parsed.
Add the documentation for this tunable setting only for frontend.

doc/configuration.txt
include/haproxy/global-t.h
include/haproxy/quic_tp-t.h
src/cfgparse-quic.c
src/haproxy.c
src/quic_tp.c

index ac5f866bd9eae594442c3f70bae0c9db84ecbf28..d95b0f348d117ef55110d4a93a61a1e9a62fd8fb 100644 (file)
@@ -1119,6 +1119,7 @@ The following keywords are supported in the "global" section :
    - tune.pool-high-fd-ratio
    - tune.pool-low-fd-ratio
    - tune.quic.conn-buf-limit
+   - tune.quic.frontend.max-idle-timeout
    - tune.quic.retry-threshold
    - tune.rcvbuf.client
    - tune.rcvbuf.server
@@ -2939,6 +2940,20 @@ tune.quic.conn-buf-limit <number>
   and memory consumption and can be adjusted according to an estimated round
   time-trip.
 
+tune.quic.frontend.max-idle-timeout <timeout>
+  Warning: QUIC support in HAProxy is currently experimental. Configuration may
+  change without deprecation in the future.
+
+  Sets the QUIC max_idle_timeout transport parameters in milliseconds for
+  frontends which determines the period of time after which a connection silently
+  closes if it has remained inactive during an effective period of time deduced
+  from the two max_idle_timeout values announced by the two endpoints:
+    - the minimum of the two values if both are not null,
+    - the maximum if only one of them is not null,
+    - if both values are null, this feature is disabled.
+
+  The default value is 30000.
+
 tune.quic.retry-threshold <number>
   Warning: QUIC support in HAProxy is currently experimental. Configuration may
   change without deprecation in the future.
index 3544622d3d0dd29aedfaccbc3945560f48ea4773..b32950a7e3f58db7ae3802f6d56adc9839752b18 100644 (file)
@@ -158,6 +158,8 @@ 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_backend_max_idle_timeout;
+               unsigned int quic_frontend_max_idle_timeout;
                unsigned int quic_retry_threshold;
                unsigned int quic_streams_buf;
 #endif /* USE_QUIC */
index 36dd376518aadda8d69ce60bb458871f62a12428..6648c6cf92bd5edb2604f7ad9f07d446aeb33360 100644 (file)
@@ -30,6 +30,8 @@ struct tp_preferred_address {
 #define QUIC_DFLT_MAX_UDP_PAYLOAD_SIZE   65527 /* bytes */
 #define QUIC_DFLT_ACK_DELAY_COMPONENT        3 /* milliseconds */
 #define QUIC_DFLT_MAX_ACK_DELAY             25 /* milliseconds */
+#define QUIC_DFLT_FRONT_MAX_IDLE_TIMEOUT 30000 /* milliseconds */
+#define QUIC_DFLT_BACK_MAX_IDLE_TIMEOUT  30000 /* milliseconds */
 #define QUIC_ACTIVE_CONNECTION_ID_LIMIT      2 /* number of connections */
 
 /* Types of QUIC transport parameters */
index db637e0800d7e5e141f96bc1d77083a3531bbba8..f4ded90d5a3387586f01951c2b88bb28fff8cd91 100644 (file)
@@ -1,3 +1,5 @@
+#include <string.h>
+
 #include <haproxy/api.h>
 #include <haproxy/cfgparse.h>
 #include <haproxy/global-t.h>
@@ -18,6 +20,52 @@ static struct bind_kw_list bind_kws = { "QUIC", { }, {
 
 INITCALL1(STG_REGISTER, bind_register_keywords, &bind_kws);
 
+/* Must be used to parse tune.quic.* setting which requires a time
+ * as value.
+ * Return -1 on alert, or 0 if succeeded.
+ */
+static int cfg_parse_quic_time(char **args, int section_type,
+                               struct proxy *curpx,
+                               const struct proxy *defpx,
+                               const char *file, int line, char **err)
+{
+       unsigned int time;
+       const char *res, *name, *value;
+       int prefix_len = strlen("tune.quic.");
+
+       if (too_many_args(1, args, err, NULL))
+               return -1;
+
+       name = args[0];
+       value = args[1];
+       res = parse_time_err(value, &time, TIME_UNIT_MS);
+       if (res == PARSE_TIME_OVER) {
+               memprintf(err, "timer overflow in argument '%s' to '%s' "
+                         "(maximum value is 2147483647 ms or ~24.8 days)", value, name);
+               return -1;
+       }
+       else if (res == PARSE_TIME_UNDER) {
+               memprintf(err, "timer underflow in argument '%s' to '%s' "
+                         "(minimum non-null value is 1 ms)", value, name);
+               return -1;
+       }
+       else if (res) {
+               memprintf(err, "unexpected character '%c' in '%s'", *res, name);
+               return -1;
+       }
+
+       if (strcmp(name + prefix_len, "frontend.max-idle-timeout") == 0)
+               global.tune.quic_frontend_max_idle_timeout = time;
+       else if (strcmp(name + prefix_len, "backend.max-idle-timeout") == 0)
+               global.tune.quic_backend_max_idle_timeout = time;
+       else {
+               memprintf(err, "'%s' keyword not unhandled (please report this bug).", args[0]);
+               return -1;
+       }
+
+       return 0;
+}
+
 /* Parse any tune.quic.* setting with strictly positive integer values.
  * Return -1 on alert, or 0 if succeeded.
  */
@@ -53,7 +101,9 @@ static int cfg_parse_quic_tune_setting(char **args, int section_type,
 }
 
 static struct cfg_kw_list cfg_kws = {ILH, {
+       { CFG_GLOBAL, "tune.quic.backend.max-idle-timeou", cfg_parse_quic_time },
        { CFG_GLOBAL, "tune.quic.conn-buf-limit", cfg_parse_quic_tune_setting },
+       { CFG_GLOBAL, "tune.quic.frontend.max-idle-timeout", cfg_parse_quic_time },
        { CFG_GLOBAL, "tune.quic.retry-threshold", cfg_parse_quic_tune_setting },
        { 0, NULL, NULL }
 }};
index 203897b73740ab7f3ba533110fe1e1020372364c..a112c233a4435df44c2d9d465ec72280c5f77648 100644 (file)
 #include <haproxy/namespace.h>
 #include <haproxy/net_helper.h>
 #include <haproxy/openssl-compat.h>
+#include <haproxy/quic_tp-t.h>
 #include <haproxy/pattern.h>
 #include <haproxy/peers.h>
 #include <haproxy/pool.h>
@@ -205,6 +206,8 @@ struct global global = {
                .idle_timer = 1000, /* 1 second */
 #endif
 #ifdef USE_QUIC
+               .quic_backend_max_idle_timeout = QUIC_DFLT_BACK_MAX_IDLE_TIMEOUT,
+               .quic_frontend_max_idle_timeout = QUIC_DFLT_FRONT_MAX_IDLE_TIMEOUT,
                .quic_retry_threshold = QUIC_DFLT_RETRY_THRESHOLD,
                .quic_streams_buf = 30,
 #endif /* USE_QUIC */
index 23a1ff72552b85eccd6ccd1c8eda2710088b1809..c1e8437f7fc3794a9621cf541328cec8287b0cb1 100644 (file)
@@ -51,7 +51,10 @@ void quic_transport_params_init(struct quic_transport_params *p, int server)
        /* Set RFC default values for unspecified parameters. */
        quic_dflt_transport_params_cpy(p);
 
-       p->max_idle_timeout                    = 30000;
+       if (server)
+               p->max_idle_timeout = global.tune.quic_frontend_max_idle_timeout;
+       else
+               p->max_idle_timeout = global.tune.quic_backend_max_idle_timeout;
 
        p->initial_max_streams_bidi            = max_streams_bidi;
        p->initial_max_streams_uni             = max_streams_uni;