diff --git a/include/haproxy/connection.h b/include/haproxy/connection.h index a4bef3df7..49f5d3f0f 100644 --- a/include/haproxy/connection.h +++ b/include/haproxy/connection.h @@ -76,7 +76,8 @@ int conn_notify_mux(struct connection *conn, int old_flags, int forced_wake); int conn_upgrade_mux_fe(struct connection *conn, void *ctx, struct buffer *buf, struct ist mux_proto, int mode); int conn_install_mux_fe(struct connection *conn, void *ctx); -int conn_install_mux_be(struct connection *conn, void *ctx, struct session *sess); +int conn_install_mux_be(struct connection *conn, void *ctx, struct session *sess, + const struct mux_ops *force_mux_ops); int conn_install_mux_chk(struct connection *conn, void *ctx, struct session *sess); void conn_delete_from_tree(struct ebmb_node *node); diff --git a/src/backend.c b/src/backend.c index ee6e2b840..ae63d937e 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1645,7 +1645,7 @@ skip_reuse: * fail, and flag the connection as CO_FL_ERROR. */ if (init_mux) { - if (conn_install_mux_be(srv_conn, srv_cs, s->sess) < 0) { + if (conn_install_mux_be(srv_conn, srv_cs, s->sess, NULL) < 0) { conn_full_close(srv_conn); return SF_ERR_INTERNAL; } diff --git a/src/connection.c b/src/connection.c index a1472f681..270ae11a1 100644 --- a/src/connection.c +++ b/src/connection.c @@ -70,7 +70,7 @@ int conn_create_mux(struct connection *conn) if (conn_install_mux_chk(conn, conn->ctx, sess) < 0) goto fail; } - else if (conn_install_mux_be(conn, conn->ctx, sess) < 0) + else if (conn_install_mux_be(conn, conn->ctx, sess, NULL) < 0) goto fail; srv = objt_server(conn->target); @@ -247,10 +247,14 @@ int conn_install_mux_fe(struct connection *conn, void *ctx) } /* installs the best mux for outgoing connection using the upper context - * . If the mux protocol is forced, we use it to find the best mux. Returns - * < 0 on error. + * . If the server mux protocol is forced, we use it to find the best mux. + * It's also possible to specify an alternative mux protocol , + * in which case it will be used instead of the default server mux protocol. + * + * Returns < 0 on error. */ -int conn_install_mux_be(struct connection *conn, void *ctx, struct session *sess) +int conn_install_mux_be(struct connection *conn, void *ctx, struct session *sess, + const struct mux_ops *force_mux_ops) { struct server *srv = objt_server(conn->target); struct proxy *prx = objt_proxy(conn->target); @@ -262,8 +266,12 @@ int conn_install_mux_be(struct connection *conn, void *ctx, struct session *sess if (!prx) // target must be either proxy or server return -1; - if (srv && srv->mux_proto) + if (srv && srv->mux_proto && likely(!force_mux_ops)) { mux_ops = srv->mux_proto->mux; + } + else if (srv && unlikely(force_mux_ops)) { + mux_ops = force_mux_ops; + } else { struct ist mux_proto; const char *alpn_str = NULL;