]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: check: fix the condition to validate a port-less server
authorWilly Tarreau <w@1wt.eu>
Thu, 22 Jul 2021 09:06:41 +0000 (11:06 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 22 Jul 2021 09:21:33 +0000 (11:21 +0200)
A config like the below fails to validate because of a bogus test:

  backend b1
      tcp-check connect port 1234
      option tcp-check
      server s1 1.2.3.4 check

[ALERT] (18887) : config : config: proxy 'b1': server 's1' has neither
                  service port nor check port, and a tcp_check rule
                  'connect' with no port information.

A || instead of a && only validates the connect rule when both the
address *and* the port are set. A work around is to set the rule like
this:

      tcp-check connect addr 0:1234 port 1234

This needs to be backported as far as 2.2 (2.0 is OK).

src/check.c

index aef1a151d205aa8a82eb2846d68d174f878bbe44..2d8a3bc4cc6c367dc1e8cb5b7c553100ce2d0626 100644 (file)
@@ -1629,7 +1629,7 @@ static int init_srv_check(struct server *srv)
 
        /* scan the tcp-check ruleset to ensure a port has been configured */
        list_for_each_entry(r, srv->proxy->tcpcheck_rules.list, list) {
-               if ((r->action == TCPCHK_ACT_CONNECT) && (!r->connect.port || !get_host_port(&r->connect.addr))) {
+               if ((r->action == TCPCHK_ACT_CONNECT) && (!r->connect.port && !get_host_port(&r->connect.addr))) {
                        ha_alert("config: %s '%s': server '%s' has neither service port nor check port, "
                                 "and a tcp_check rule 'connect' with no port information.\n",
                                 proxy_type_str(srv->proxy), srv->proxy->id, srv->id);