Skip to content

Commit a6504c9

Browse files
committed
MINOR: quic: use dynamic cc_algo on bind_conf
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.
1 parent 796446a commit a6504c9

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/cfgparse-quic.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,16 @@ static unsigned long parse_window_size(const char *kw, char *value,
7373
static int bind_parse_quic_cc_algo(char **args, int cur_arg, struct proxy *px,
7474
struct bind_conf *conf, char **err)
7575
{
76-
struct quic_cc_algo *cc_algo;
76+
struct quic_cc_algo *cc_algo = NULL;
7777
const char *algo = NULL;
7878
char *arg;
7979

80+
cc_algo = calloc(1, sizeof(struct quic_cc_algo));
81+
if (!cc_algo) {
82+
memprintf(err, "'%s' : out of memory", args[cur_arg]);
83+
goto fail;
84+
}
85+
8086
if (!*args[cur_arg + 1]) {
8187
memprintf(err, "'%s' : missing control congestion algorithm", args[cur_arg]);
8288
goto fail;
@@ -86,13 +92,13 @@ static int bind_parse_quic_cc_algo(char **args, int cur_arg, struct proxy *px,
8692
if (strncmp(arg, QUIC_CC_NEWRENO_STR, strlen(QUIC_CC_NEWRENO_STR)) == 0) {
8793
/* newreno */
8894
algo = QUIC_CC_NEWRENO_STR;
89-
cc_algo = &quic_cc_algo_nr;
95+
*cc_algo = quic_cc_algo_nr;
9096
arg += strlen(QUIC_CC_NEWRENO_STR);
9197
}
9298
else if (strncmp(arg, QUIC_CC_CUBIC_STR, strlen(QUIC_CC_CUBIC_STR)) == 0) {
9399
/* cubic */
94100
algo = QUIC_CC_CUBIC_STR;
95-
cc_algo = &quic_cc_algo_cubic;
101+
*cc_algo = quic_cc_algo_cubic;
96102
arg += strlen(QUIC_CC_CUBIC_STR);
97103
}
98104
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,
104110
}
105111

106112
algo = QUIC_CC_NO_CC_STR;
107-
cc_algo = &quic_cc_algo_nocc;
113+
*cc_algo = quic_cc_algo_nocc;
108114
arg += strlen(QUIC_CC_NO_CC_STR);
109115
}
110116
else {
@@ -132,6 +138,7 @@ static int bind_parse_quic_cc_algo(char **args, int cur_arg, struct proxy *px,
132138
return 0;
133139

134140
fail:
141+
free(cc_algo);
135142
return ERR_ALERT | ERR_FATAL;
136143
}
137144

src/proxy.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,9 @@ void free_proxy(struct proxy *p)
387387
LIST_DELETE(&bind_conf->by_fe);
388388
free(bind_conf->guid_prefix);
389389
free(bind_conf->rhttp_srvname);
390+
#ifdef USE_QUIC
391+
free(bind_conf->quic_cc_algo);
392+
#endif
390393
free(bind_conf);
391394
}
392395

0 commit comments

Comments
 (0)