]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Add tune.quic.retry-threshold keyword
authorFrédéric Lécaille <flecaille@haproxy.com>
Fri, 20 May 2022 14:29:10 +0000 (16:29 +0200)
committerFrédéric Lécaille <flecaille@haproxy.com>
Fri, 20 May 2022 15:11:13 +0000 (17:11 +0200)
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.

include/haproxy/global-t.h
include/haproxy/xprt_quic-t.h
src/cfgparse-quic.c
src/haproxy.c

index fbbc88da33db4276ec327201feefa4370624e815..3544622d3d0dd29aedfaccbc3945560f48ea4773 100644 (file)
@@ -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;
index 5ea31189f1ce3878009fadbb18ee940677da6c11..a85b47c46a8651eca8cf57fa50e13486e9ad9ef5 100644 (file)
@@ -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
index deaa13ffe175f86771dda2404d8d5492ffc9af07..03f4178259c3bc43e507a9e9639d9ede53ca63a4 100644 (file)
@@ -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 }
 }};
 
index f3cf30ec9c9076aa3f29222184eb713e869da76e..1d6612619e2e3607b28752bf842893022eba8e17 100644 (file)
 #include <haproxy/uri_auth-t.h>
 #include <haproxy/vars.h>
 #include <haproxy/version.h>
+#include <haproxy/xprt_quic-t.h>
 
 
 /* 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 */
        },