]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: connection/mux: take care of serverless proxies
authorWilly Tarreau <w@1wt.eu>
Wed, 8 Aug 2018 16:40:44 +0000 (18:40 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 8 Aug 2018 16:44:43 +0000 (18:44 +0200)
Commit 7ce0c89 ("MEDIUM: mux: Use the mux protocol specified on
bind/server lines") assumed a bit too strongly that we could only have
servers on the connect side :-) It segfaults under this config :

    defaults
        contimeout      5s
        clitimeout      5s
        srvtimeout      5s
        mode http

    listen test1
        bind :8001
        dispatch 127.0.0.1:8002

    frontend test2
        mode http
        bind :8002
        redirect location /

No backport needed.

include/proto/connection.h

index 3b25fc5c693ac8eccd26bf6db1bc7d5b1f3f7cc8..8261d57602d8478969dd19e2e7e0df4f2e6fe7f5 100644 (file)
@@ -1068,14 +1068,21 @@ static inline int conn_install_mux_fe(struct connection *conn, void *ctx)
 static inline int conn_install_mux_be(struct connection *conn, void *ctx)
 {
        struct server *srv = objt_server(conn->target);
+       struct proxy  *prx = objt_proxy(conn->target);
        const struct mux_ops *mux_ops;
 
-       if (srv->mux_proto)
+       if (srv)
+               prx = srv->proxy;
+
+       if (!prx) // target must be either proxy or server
+               return -1;
+
+       if (srv && srv->mux_proto)
                mux_ops = srv->mux_proto->mux;
        else {
                int mode;
 
-               mode = (1 << (srv->proxy->mode == PR_MODE_HTTP));
+               mode = (1 << (prx->mode == PR_MODE_HTTP));
                mux_ops = conn_get_best_mux(conn, ist(NULL), PROTO_SIDE_BE, mode);
                if (!mux_ops)
                        return -1;