]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: connection: define mux flag for reverse support
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 29 Sep 2023 14:03:51 +0000 (16:03 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 29 Sep 2023 16:09:08 +0000 (18:09 +0200)
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.

include/haproxy/connection-t.h
src/connection.c
src/mux_h2.c

index 5b25772d8296ae63acd02ea5cdb218ff99f0fd79..3bee5fd43a6000f4775d3314662b7186f55f723c 100644 (file)
@@ -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 */
index 8eb72ec79e461f2a15049a2c30f598f9e58cd1ff..ba29a678f83cef1773c75459826ebe786074a9e6 100644 (file)
@@ -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);
 }
 
index 6a315092b8b7c709635936c1a14a24af4c723a9b..ae7276423ebe71706f6b0543280dd6f77a577f84 100644 (file)
@@ -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",
 };