diff --git a/include/haproxy/connection-t.h b/include/haproxy/connection-t.h index 5b25772d8..3bee5fd43 100644 --- a/include/haproxy/connection-t.h +++ b/include/haproxy/connection-t.h @@ -310,6 +310,7 @@ enum { MX_FL_HOL_RISK = 0x00000002, /* set if the protocol is subject the to head-of-line blocking on server */ MX_FL_NO_UPG = 0x00000004, /* set if mux does not support any upgrade */ MX_FL_FRAMED = 0x00000008, /* mux working on top of a framed transport layer (QUIC) */ + MX_FL_REVERSABLE = 0x00000010, /* mux supports connection reversal */ }; /* PROTO token registration */ diff --git a/src/connection.c b/src/connection.c index 8eb72ec79..ba29a678f 100644 --- a/src/connection.c +++ b/src/connection.c @@ -282,6 +282,15 @@ int conn_install_mux_fe(struct connection *conn, void *ctx) if (!mux_ops) return -1; } + + /* Ensure a valid protocol is selected if connection is targetted by a + * tcp-request session attach-srv rule. + */ + if (conn->reverse.target && !(mux_ops->flags & MX_FL_REVERSABLE)) { + conn->err_code = CO_ER_REVERSE; + return -1; + } + return conn_install_mux(conn, mux_ops, ctx, bind_conf->frontend, conn->owner); } diff --git a/src/mux_h2.c b/src/mux_h2.c index 6a315092b..ae7276423 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -7158,7 +7158,7 @@ static const struct mux_ops h2_ops = { .show_fd = h2_show_fd, .show_sd = h2_show_sd, .takeover = h2_takeover, - .flags = MX_FL_HTX|MX_FL_HOL_RISK|MX_FL_NO_UPG, + .flags = MX_FL_HTX|MX_FL_HOL_RISK|MX_FL_NO_UPG|MX_FL_REVERSABLE, .name = "H2", };