]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: listener: set the QUIC xprt layer immediately after parsing the args
authorWilly Tarreau <w@1wt.eu>
Fri, 20 May 2022 15:10:00 +0000 (17:10 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 20 May 2022 16:41:55 +0000 (18:41 +0200)
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.

src/cfgparse.c
src/listener.c

index 3fb0fb4a279196ed2c59d61eba2aa9163a189806..703147881005d9d30f66b5071a97a3cd84a81e7f 100644 (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;
index e5cb867ba984bd1b8358d8dc1f33d886acfcc354..3efe6c1c83a3051e9bd5d3a30ccf44349da9d456 100644 (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;
 }