]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: checks: Use the mux protocol specified on the server line
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 23 Apr 2020 13:50:18 +0000 (15:50 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 27 Apr 2020 08:46:28 +0000 (10:46 +0200)
First, when a server health check is initialized, it inherits the mux protocol
from the server if it is not already specified. Because there is no option to
specify the mux protocol for the checks, it is always inherited from the server
for now.

Then, if the connect rule is configured to use the server options, the mux
protocol of the check is used, if defined. Of course, if a mux protocol is
already defined for the connect rule, it is used in priority. But for now, it is
not possible.

Thus, if a server is configured to use, for instance, the h2 protocol, it is
possible to do the same for the health-checks.

No backport needed.

src/checks.c

index 7dff7e959d9d78409166e8d616b48bbc6ab75f47..0bd84c0e9e8d28d30e4738a06f33f3654840ae98 100644 (file)
@@ -1743,12 +1743,13 @@ static enum tcpcheck_eval_ret tcpcheck_eval_connect(struct check *check, struct
         * check (email alerts) or if there is a mux proto specified or if there
         * is no alpn.
         */
-       if (!s || connect->mux_proto || check->mux_proto || (!connect->alpn && !check->alpn_str)) {
+       if (!s || ((connect->options & TCPCHK_OPT_DEFAULT_CONNECT) && check->mux_proto) ||
+           connect->mux_proto || (!connect->alpn && !check->alpn_str)) {
                const struct mux_ops *mux_ops;
 
                if (connect->mux_proto)
                        mux_ops = connect->mux_proto->mux;
-               else if (check->mux_proto)
+               else if ((connect->options & TCPCHK_OPT_DEFAULT_CONNECT) && check->mux_proto)
                        mux_ops = check->mux_proto->mux;
                else {
                        int mode = ((check->tcpcheck_rules->flags & TCPCHK_RULES_PROTO_CHK) == TCPCHK_RULES_HTTP_CHK
@@ -4724,6 +4725,12 @@ static int init_srv_check(struct server *srv)
                srv->check.send_proxy |= (srv->pp_opts);
        }
 
+       /* Inherit the mux protocol from the server if not already defined for
+        * the check
+        */
+       if (srv->mux_proto && !srv->check.mux_proto)
+               srv->check.mux_proto = srv->mux_proto;
+
        /* validate <srv> server health-check settings */
 
        /* We need at least a service port, a check port or the first tcp-check