MINOR: listener: set the QUIC xprt layer immediately after parsing the args

It used to be set when parsing the listeners' addresses but this comes
with some difficulties in that other places have to be careful not to
replace it (e.g. the "ssl" keyword parser).

Now we know what protocols a bind_conf line relies on, we can set it
after having parsed the whole line.
This commit is contained in:
Willy Tarreau 2022-05-20 17:10:00 +02:00
parent 64306ccd97
commit 78d0dcd519
2 changed files with 17 additions and 10 deletions

View File

@ -165,16 +165,6 @@ int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf,
else
bind_conf->options |= BC_O_USE_XPRT_STREAM;
#ifdef USE_QUIC
/* The transport layer automatically switches to QUIC when QUIC
* is selected, regardless of bind_conf settings. We then need
* to initialize QUIC params.
*/
if (proto->proto_type == PROTO_TYPE_DGRAM && proto->xprt_type == PROTO_TYPE_STREAM) {
bind_conf->xprt = xprt_get(XPRT_QUIC);
quic_transport_params_init(&bind_conf->quic_params, 1);
}
#endif
if (!create_listeners(bind_conf, ss2, port, end, fd, proto, err)) {
memprintf(err, "%s for address '%s'.\n", *err, str);
goto fail;

View File

@ -36,6 +36,7 @@
#include <haproxy/task.h>
#include <haproxy/ticks.h>
#include <haproxy/tools.h>
#include <haproxy/xprt_quic.h>
/* List head of all known bind keywords */
@ -1640,6 +1641,22 @@ int bind_parse_args_list(struct bind_conf *bind_conf, char **args, int cur_arg,
goto out;
}
/* The transport layer automatically switches to QUIC when QUIC is
* selected, regardless of bind_conf settings. We then need to
* initialize QUIC params.
*/
if ((bind_conf->options & (BC_O_USE_SOCK_DGRAM|BC_O_USE_XPRT_STREAM)) == (BC_O_USE_SOCK_DGRAM|BC_O_USE_XPRT_STREAM)) {
#ifdef USE_QUIC
bind_conf->xprt = xprt_get(XPRT_QUIC);
quic_transport_params_init(&bind_conf->quic_params, 1);
#else
ha_alert("parsing [%s:%d] : '%s %s' in section '%s' : QUIC protocol selected but support not compiled in (check build options).\n",
file, linenum, args[0], args[1], section);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
#endif
}
out:
return err_code;
}