]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: config: make sure never to mix dgram and stream protocols on a bind line
authorWilly Tarreau <w@1wt.eu>
Tue, 26 Apr 2022 12:40:30 +0000 (14:40 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 13 May 2022 15:00:09 +0000 (17:00 +0200)
It is absolutely not possible to use the same "bind" line to listen to
both quic and tcp for example, because no single transport layer would
fit both modes and we'll need the type to choose one then to choose a
mux. Let's make sure this does not happen. This may be relaxed in the
future if we manage to instantiate transport layers on the fly, but the
SSL vs quic part might be tricky to handle.

src/cfgparse.c

index 13fda2d962c61e56cc0c883986bbc0ed40584e09..32b4cb3663f1e74674c6379be0542f6fd3b4454d 100644 (file)
@@ -3776,6 +3776,23 @@ out_uri_auth_compat:
                list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) {
                        int mode = (1 << (curproxy->mode == PR_MODE_HTTP));
                        const struct mux_proto_list *mux_ent;
+                       const struct listener *l;
+                       int types = 0;
+
+                       /* check that the mux is compatible with all listeners'
+                        * protocol types (dgram or stream).
+                        */
+                       list_for_each_entry(l, &bind_conf->listeners, by_bind)
+                               types |= 1 << l->rx.proto->proto_type;
+
+                       if (atleast2(types)) {
+                               ha_alert("%s '%s' : cannot mix datagram and stream protocols "
+                                        "for 'bind %s' at [%s:%d].\n",
+                                        proxy_type_str(curproxy), curproxy->id,
+                                        bind_conf->arg, bind_conf->file, bind_conf->line);
+                               cfgerr++;
+                               continue;
+                       }
 
                        if (!bind_conf->mux_proto)
                                continue;