From: Amaury Denoyelle Date: Fri, 29 Sep 2023 14:03:51 +0000 (+0200) Subject: MINOR: connection: define mux flag for reverse support X-Git-Tag: v2.9-dev7~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=337c71423f56489d99e29dc7df8fd02a26ea86df;p=thirdparty%2Fhaproxy.git MINOR: connection: define mux flag for reverse support Add a new MUX flag MX_FL_REVERSABLE. This value is used to indicate that MUX instance supports connection reversal. For the moment, only HTTP/2 multiplexer is flagged with it. This allows to dynamically check if reversal can be completed during MUX installation. This will allow to relax requirement on config writing for 'tcp-request session attach-srv' which currently cannot be used mixed with non-http/2 listener instances, even if used conditionnally with an ACL. --- diff --git a/include/haproxy/connection-t.h b/include/haproxy/connection-t.h index 5b25772d82..3bee5fd43a 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 8eb72ec79e..ba29a678f8 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 6a315092b8..ae7276423e 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", };