]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MAJOR: muxes: Use the HTX mode to find the best mux for HTTP proxies only
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 24 Apr 2019 13:01:22 +0000 (15:01 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 24 Apr 2019 13:40:02 +0000 (15:40 +0200)
Since the commit 1d2b586cd ("MAJOR: htx: Enable the HTX mode by default for all
proxies"), the HTX is enabled by default for all proxies, HTTP and TCP, but also
CLI and HEALTH proxies. But when the best mux is retrieved, only HTTP and TCP
modes are checked. If the TCP mode is not explicitly set, it is considered as an
HTTP proxy. It is an hidden bug introduced when the option "http-use-htx" was
added. It has no effect until the commit 1d2b586cd. But now, when a stats socket
is created for the master process, the mux h1 is installed on all incoming
connections to the CLI proxy, leading to segfaults because HTX operations are
performed on raw buffers.

So to fix the buf, when a mux is installed, all proxies are considered as TCP
proxies, except HTTP ones. This way, CLI and HEALTH proxies will be handled as
TCP proxies.

This patch must be backported to 1.9 although it has no effect. It is safer to
not keep hidden bugs.

include/proto/connection.h

index f0a484152673e42283b560a798a4984b1a3616c6..0db7c47d00782b542db1270b08c64a40fe3876a8 100644 (file)
@@ -1098,12 +1098,10 @@ static inline int conn_install_mux_fe(struct connection *conn, void *ctx)
                int alpn_len = 0;
                int mode;
 
-               if (bind_conf->frontend->mode == PR_MODE_TCP)
-                       mode = PROTO_MODE_TCP;
-               else if (bind_conf->frontend->options2 & PR_O2_USE_HTX)
-                       mode = PROTO_MODE_HTX;
+               if (bind_conf->frontend->mode == PR_MODE_HTTP)
+                       mode = ((bind_conf->frontend->options2 & PR_O2_USE_HTX) ? PROTO_MODE_HTX : PROTO_MODE_HTTP);
                else
-                       mode = PROTO_MODE_HTTP;
+                       mode = PROTO_MODE_TCP;
 
                conn_get_alpn(conn, &alpn_str, &alpn_len);
                mux_proto = ist2(alpn_str, alpn_len);
@@ -1138,12 +1136,10 @@ static inline int conn_install_mux_be(struct connection *conn, void *ctx, struct
                int alpn_len = 0;
                int mode;
 
-               if (prx->mode == PR_MODE_TCP)
-                       mode = PROTO_MODE_TCP;
-               else if (prx->options2 & PR_O2_USE_HTX)
-                       mode = PROTO_MODE_HTX;
+               if (prx->mode == PR_MODE_HTTP)
+                       mode = ((prx->options2 & PR_O2_USE_HTX) ? PROTO_MODE_HTX : PROTO_MODE_HTTP);
                else
-                       mode = PROTO_MODE_HTTP;
+                       mode = PROTO_MODE_TCP;
 
                conn_get_alpn(conn, &alpn_str, &alpn_len);
                mux_proto = ist2(alpn_str, alpn_len);