While trying to fix some consistency problem with the config file/cli
(e.g. check-port cli command does not set the flag), we realised
checkport flag was not necessarily needed. Indeed tcpcheck uses service
port as the last choice if check.port is zero. So we can assume if
check.port is zero, it means it was never set by the user, regardless if
it is by the cli or config file.  In the longterm this will avoid to
introduce a new consistency issue if we forget to set the flag.

Signed-off-by: William Dauchy <wdau...@gmail.com>
---
 include/haproxy/server-t.h | 1 -
 src/check.c                | 1 -
 src/dns.c                  | 3 +--
 src/server.c               | 7 ++-----
 4 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/include/haproxy/server-t.h b/include/haproxy/server-t.h
index e42b1c7ed..131b97cb6 100644
--- a/include/haproxy/server-t.h
+++ b/include/haproxy/server-t.h
@@ -139,7 +139,6 @@ enum srv_initaddr {
 #define SRV_F_USE_NS_FROM_PP 0x0008      /* use namespace associated with 
connection if present */
 #define SRV_F_FORCED_ID    0x0010        /* server's ID was forced in the 
configuration */
 #define SRV_F_CHECKADDR    0x0020        /* this server has a check addr 
configured */
-#define SRV_F_CHECKPORT    0x0040        /* this server has a check port 
configured */
 #define SRV_F_AGENTADDR    0x0080        /* this server has a agent addr 
configured */
 #define SRV_F_COOKIESET    0x0100        /* this server has a cookie 
configured, so don't generate dynamic cookies */
 #define SRV_F_FASTOPEN     0x0200        /* Use TCP Fast Open to connect to 
server */
diff --git a/src/check.c b/src/check.c
index 879fe84ce..f4b11fc46 100644
--- a/src/check.c
+++ b/src/check.c
@@ -2050,7 +2050,6 @@ static int srv_parse_check_port(char **args, int 
*cur_arg, struct proxy *curpx,
 
        global.maxsock++;
        srv->check.port = atol(args[*cur_arg+1]);
-       srv->flags |= SRV_F_CHECKPORT;
 
   out:
        return err_code;
diff --git a/src/dns.c b/src/dns.c
index 8c97df46b..8fc9089e7 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -712,8 +712,7 @@ static void dns_check_dns_response(struct dns_resolution 
*res)
 
                                srv->svc_port = item->port;
                                srv->flags   &= ~SRV_F_MAPPORTS;
-                               if ((srv->check.state & CHK_ST_CONFIGURED) &&
-                                   !(srv->flags & SRV_F_CHECKPORT))
+                               if (!srv->check.port)
                                        srv->check.port = item->port;
 
                                if (!srv->dns_opts.ignore_weight) {
diff --git a/src/server.c b/src/server.c
index d8216058f..1fd71e403 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1660,8 +1660,6 @@ static void srv_settings_cpy(struct server *srv, struct 
server *src, int srv_tmp
        srv->flags                   |= src->flags;
        srv->do_check                 = src->do_check;
        srv->do_agent                 = src->do_agent;
-       if (srv->check.port)
-               srv->flags |= SRV_F_CHECKPORT;
        srv->check.inter              = src->check.inter;
        srv->check.fastinter          = src->check.fastinter;
        srv->check.downinter          = src->check.downinter;
@@ -2985,8 +2983,7 @@ static void srv_update_state(struct server *srv, int 
version, char **params)
                                }
 
                                /* configure check.port accordingly */
-                               if ((srv->check.state & CHK_ST_CONFIGURED) &&
-                                   !(srv->flags & SRV_F_CHECKPORT))
+                               if (!srv->check.port)
                                        srv->check.port = port_check;
 
                                /* Unset SRV_F_MAPPORTS for SRV records.
@@ -3673,7 +3670,7 @@ const char *update_server_addr_port(struct server *s, 
const char *addr, const ch
                                 * we're switching from a fixed port to a 
SRV_F_MAPPORTS (mapped) port
                                 * prevent PORT change if check doesn't have 
it's dedicated port while switching
                                 * to port mapping */
-                               if ((s->check.state & CHK_ST_CONFIGURED) && 
!(s->flags & SRV_F_CHECKPORT)) {
+                               if (!s->check.port) {
                                        chunk_appendf(msg, "can't change <port> 
to port map because it is incompatible with current health check port 
configuration (use 'port' statement from the 'server' directive.");
                                        goto out;
                                }
-- 
2.29.2


Reply via email to