From: Willy Tarreau Date: Fri, 20 May 2022 15:10:00 +0000 (+0200) Subject: MINOR: listener: set the QUIC xprt layer immediately after parsing the args X-Git-Tag: v2.6-dev11~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78d0dcd5196fd630190998cb420cdcf1e8a215d7;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/cfgparse.c b/src/cfgparse.c index 3fb0fb4a27..7031478810 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -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; diff --git a/src/listener.c b/src/listener.c index e5cb867ba9..3efe6c1c83 100644 --- a/src/listener.c +++ b/src/listener.c @@ -36,6 +36,7 @@ #include #include #include +#include /* 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; }