]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: check: report error on incompatible proto
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 13 Nov 2020 11:34:57 +0000 (12:34 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 13 Nov 2020 15:26:10 +0000 (16:26 +0100)
If the check mux has been explicitly defined but is incompatible with
the selected check type (tcp-check vs http-check), report a warning and
prevent haproxy startup.

src/check.c

index fe9f8be0e56bd507d57974af33bcf34be582c7ae..0203e3ec98a87b9e37657fd9399d9233984982b6 100644 (file)
@@ -1260,6 +1260,15 @@ static int init_srv_check(struct server *srv)
             (srv->mux_proto->mode == PROTO_MODE_TCP && check_type != TCPCHK_RULES_HTTP_CHK))) {
                srv->check.mux_proto = srv->mux_proto;
        }
+       /* test that check proto is valid if explicitly defined */
+       else if (srv->check.mux_proto &&
+                ((srv->check.mux_proto->mode == PROTO_MODE_HTTP && check_type != TCPCHK_RULES_HTTP_CHK) ||
+                 (srv->check.mux_proto->mode == PROTO_MODE_TCP && check_type == TCPCHK_RULES_HTTP_CHK))) {
+               ha_alert("config: %s '%s': server '%s' uses an incompatible MUX protocol for the selected check type\n",
+                        proxy_type_str(srv->proxy), srv->proxy->id, srv->id);
+               ret |= ERR_ALERT | ERR_FATAL;
+               goto out;
+       }
 
        /* validate <srv> server health-check settings */