]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: config: detect and report mux and transport incompatibilities
authorWilly Tarreau <w@1wt.eu>
Fri, 20 May 2022 15:53:32 +0000 (17:53 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 20 May 2022 16:41:55 +0000 (18:41 +0200)
Till now, placing "proto h1" or "proto h2" on a "quic" bind or placing
"proto quic" on a TCP line would parse fine but would crash when traffic
arrived. The reason is that there's a strong binding between the QUIC
mux and QUIC transport and that they're not expected to be called with
other types at all.

Now that we have the mux's type and we know the type of the protocol used
on the bind conf, we can perform such checks. This now returns:

  [ALERT]    (16978) : config : frontend 'decrypt' : stream-based MUX protocol 'h2' is incompatible with framed transport of 'bind quic4@:4448' at [quic-mini.cfg:27].
  [ALERT]    (16978) : config : frontend 'decrypt' : frame-based MUX protocol 'quic' is incompatible with stream transport of 'bind :4448' at [quic-mini.cfg:29].

This config tightening is only tagged MINOR since while such a config,
despite not reporting error, cannot work at all so even if it breaks
experimental configs, they were just waiting for a single connection
to crash.

src/cfgparse.c

index 703147881005d9d30f66b5071a97a3cd84a81e7f..b2426639d68d6ad7c956e4ba9658b4b03665546f 100644 (file)
@@ -3769,6 +3769,23 @@ out_uri_auth_compat:
                                         bind_conf->mux_proto->token.ptr,
                                         bind_conf->arg, bind_conf->file, bind_conf->line);
                                cfgerr++;
+                       } else {
+                               if ((mux_ent->mux->flags & MX_FL_FRAMED) && !(bind_conf->options & BC_O_USE_SOCK_DGRAM)) {
+                                       ha_alert("%s '%s' : frame-based MUX protocol '%.*s' is incompatible with stream transport of 'bind %s' at [%s:%d].\n",
+                                                proxy_type_str(curproxy), curproxy->id,
+                                                (int)bind_conf->mux_proto->token.len,
+                                                bind_conf->mux_proto->token.ptr,
+                                                bind_conf->arg, bind_conf->file, bind_conf->line);
+                                       cfgerr++;
+                               }
+                               else if (!(mux_ent->mux->flags & MX_FL_FRAMED) && !(bind_conf->options & BC_O_USE_SOCK_STREAM)) {
+                                       ha_alert("%s '%s' : stream-based MUX protocol '%.*s' is incompatible with framed transport of 'bind %s' at [%s:%d].\n",
+                                                proxy_type_str(curproxy), curproxy->id,
+                                                (int)bind_conf->mux_proto->token.len,
+                                                bind_conf->mux_proto->token.ptr,
+                                                bind_conf->arg, bind_conf->file, bind_conf->line);
+                                       cfgerr++;
+                               }
                        }
 
                        /* update the mux */