]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cfg-quic: define tune.quic.conn-buf-limit
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 19 Apr 2022 16:26:55 +0000 (18:26 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 21 Apr 2022 10:04:04 +0000 (12:04 +0200)
Add a new global configuration option to set the limit of buffers per
QUIC connection. By default, this value is set to 30.

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

index a3f3e461869ca694ee2a4785fc7ab33917fea0c8..1acc5607baa48583ee8d4e296da76430c22136f1 100644 (file)
@@ -1109,6 +1109,7 @@ The following keywords are supported in the "global" section :
    - tune.pipesize
    - tune.pool-high-fd-ratio
    - tune.pool-low-fd-ratio
+   - tune.quic.conn-buf-limit
    - tune.rcvbuf.client
    - tune.rcvbuf.server
    - tune.recv_enough
@@ -2788,6 +2789,16 @@ tune.pool-low-fd-ratio <number>
   use before we stop putting connection into the idle pool for reuse. The
   default is 20.
 
+tune.quic.conn-buf-limit <number>
+  Warning: QUIC support in HAProxy is currently experimental. Configuration may
+  change without deprecation in the future.
+
+  This settings defines the maximum number of buffers allocated for a QUIC
+  connection on data emission. By default, it is set to 30. QUIC buffers are
+  drained on ACK reception. This setting has a direct impact on the throughput
+  and memory consumption and can be adjusted according to an estimated round
+  time-trip.
+
 tune.rcvbuf.client <number>
 tune.rcvbuf.server <number>
   Forces the kernel socket receive buffer size on the client or the server side
index 27707d20c5c7a31dad206809a5df6eae0f251acb..186968d45a0f7dd1f7d162ba4245c47d803a6735 100644 (file)
@@ -154,6 +154,9 @@ struct global {
                int pool_low_count;   /* max number of opened fd before we stop using new idle connections */
                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_streams_buf;
+#endif /* USE_QUIC */
        } tune;
        struct {
                char *prefix;           /* path prefix of unix bind socket */
index 4a94bb31d014f7b3ca6baaf905f0a12ac0a8bbe3..deaa13ffe175f86771dda2404d8d5492ffc9af07 100644 (file)
@@ -1,6 +1,9 @@
 #include <haproxy/api.h>
+#include <haproxy/cfgparse.h>
+#include <haproxy/global-t.h>
 #include <haproxy/listener.h>
 #include <haproxy/proxy-t.h>
+#include <haproxy/tools.h>
 
 static int bind_parse_quic_force_retry(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
 {
@@ -14,3 +17,33 @@ 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)
+{
+       unsigned int arg = 0;
+
+       if (too_many_args(1, args, err, NULL))
+               return -1;
+
+       if (*(args[1]) != 0)
+               arg = atoi(args[1]);
+
+       if (arg < 1) {
+               memprintf(err, "'%s' expects a positive integer.", args[0]);
+               return -1;
+       }
+
+       global.tune.quic_streams_buf = arg;
+
+       return 0;
+}
+
+static struct cfg_kw_list cfg_kws = {ILH, {
+       { CFG_GLOBAL, "tune.quic.conn-buf-limit", cfg_parse_quic_conn_buf_limit },
+       { 0, NULL, NULL }
+}};
+
+INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
index a26c8f33d2447954f134f92595328e504654630d..0187bc6419752aad374ce1cf77ca2436d32c5493 100644 (file)
@@ -203,6 +203,9 @@ struct global global = {
 #else
                .idle_timer = 1000, /* 1 second */
 #endif
+#ifdef USE_QUIC
+               .quic_streams_buf = 30,
+#endif /* USE_QUIC */
        },
 #ifdef USE_OPENSSL
 #ifdef DEFAULT_MAXSSLCONN
index 839efd0868956ba49b97e211c93b2259a28e741f..e5998ef1ff690ae6fdc52947ea9628c6563c2fc4 100644 (file)
@@ -208,8 +208,7 @@ struct buffer *qc_stream_buf_get(struct qc_stream_desc *stream)
  */
 static int qc_stream_buf_avail(struct quic_conn *qc)
 {
-       /* TODO use a global tune settings for max */
-       return qc->stream_buf_count < 30;
+       return qc->stream_buf_count < global.tune.quic_streams_buf;
 }
 
 /* Allocate a new current buffer for <stream>. The buffer limit count for the