]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: use dynamic cc_algo on bind_conf
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 19 Nov 2024 09:12:27 +0000 (10:12 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 19 Nov 2024 15:16:48 +0000 (16:16 +0100)
A QUIC congestion algorithm can be specified on the bind line via
keyword quic-cc-algo. As such, bind_conf structure has a member
quic_cc_algo.

Previously, if quic-cc-algo was set, bind_conf member was initialized to
one of the globally defined CC algo structure. This patch changes
bind_conf quic_cc_algo initialization to point to a dynamically
allocated copy of CC algo structure.

With this change, it will be possible to tweak individually each CC algo
of a bind line. This will be used to activate pacing on top of the
congestion algorithm.

As bind_conf member is dynamically allocated now, its member is now
freed via free_proxy() to prevent any leak.

src/cfgparse-quic.c
src/proxy.c

index a33c05e239a46c32b6011f25cfff71c7fc40669e..7d870625bc67a51cd5856e7eba7ddc635d53a306 100644 (file)
@@ -73,10 +73,16 @@ static unsigned long parse_window_size(const char *kw, char *value,
 static int bind_parse_quic_cc_algo(char **args, int cur_arg, struct proxy *px,
                                    struct bind_conf *conf, char **err)
 {
-       struct quic_cc_algo *cc_algo;
+       struct quic_cc_algo *cc_algo = NULL;
        const char *algo = NULL;
        char *arg;
 
+       cc_algo = calloc(1, sizeof(struct quic_cc_algo));
+       if (!cc_algo) {
+               memprintf(err, "'%s' : out of memory", args[cur_arg]);
+               goto fail;
+       }
+
        if (!*args[cur_arg + 1]) {
                memprintf(err, "'%s' : missing control congestion algorithm", args[cur_arg]);
                goto fail;
@@ -86,13 +92,13 @@ static int bind_parse_quic_cc_algo(char **args, int cur_arg, struct proxy *px,
        if (strncmp(arg, QUIC_CC_NEWRENO_STR, strlen(QUIC_CC_NEWRENO_STR)) == 0) {
                /* newreno */
                algo = QUIC_CC_NEWRENO_STR;
-               cc_algo = &quic_cc_algo_nr;
+               *cc_algo = quic_cc_algo_nr;
                arg += strlen(QUIC_CC_NEWRENO_STR);
        }
        else if (strncmp(arg, QUIC_CC_CUBIC_STR, strlen(QUIC_CC_CUBIC_STR)) == 0) {
                /* cubic */
                algo = QUIC_CC_CUBIC_STR;
-               cc_algo = &quic_cc_algo_cubic;
+               *cc_algo = quic_cc_algo_cubic;
                arg += strlen(QUIC_CC_CUBIC_STR);
        }
        else if (strncmp(arg, QUIC_CC_NO_CC_STR, strlen(QUIC_CC_NO_CC_STR)) == 0) {
@@ -104,7 +110,7 @@ static int bind_parse_quic_cc_algo(char **args, int cur_arg, struct proxy *px,
                }
 
                algo = QUIC_CC_NO_CC_STR;
-               cc_algo = &quic_cc_algo_nocc;
+               *cc_algo = quic_cc_algo_nocc;
                arg += strlen(QUIC_CC_NO_CC_STR);
        }
        else {
@@ -132,6 +138,7 @@ static int bind_parse_quic_cc_algo(char **args, int cur_arg, struct proxy *px,
        return 0;
 
  fail:
+       free(cc_algo);
        return ERR_ALERT | ERR_FATAL;
 }
 
index 357704209fc9e03951d87c8131355aeab648e83f..d968e7579520c3dd4df4d7099dd50e29c39afc1c 100644 (file)
@@ -387,6 +387,9 @@ void free_proxy(struct proxy *p)
                LIST_DELETE(&bind_conf->by_fe);
                free(bind_conf->guid_prefix);
                free(bind_conf->rhttp_srvname);
+#ifdef USE_QUIC
+               free(bind_conf->quic_cc_algo);
+#endif
                free(bind_conf);
        }