]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: server: explicitly set "none" init-addr for dynamic servers
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 10 Jun 2021 15:34:10 +0000 (17:34 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 10 Jun 2021 15:44:05 +0000 (17:44 +0200)
Define srv.init_addr_methods to SRV_IADDR_NONE on 'add server' CLI
handler. This explicitly states that no resolution will be made on the
server creation.

This is not a real bug as the default value (SRV_IADDR_END) has the same
effect in practice. However the intent is clearer and prevent to use the
default "libc,last" by mistake which cannot execute on runtime (blocking
call + file access via gethostbyname/getaddrinfo).

The doc is also updated to reflect this limitation.

This should be backported up to 2.4.

doc/management.txt
src/server.c

index 91c0340a2f23031a27a3f9d81408da9eee77e08d..932981bfc2a8698f895822e1716a8a7811a66190 100644 (file)
@@ -1466,6 +1466,10 @@ add server <backend>/<server> [args]*
   used to configure the server behavior. Also note that no settings will be
   reused from an hypothetical 'default-server' statement in the same backend.
 
+  Currently a dynamic server is statically initialized with the "none"
+  init-addr method. This means that no resolution will be undertaken if a FQDN
+  is specified as an address, even if the server creation will be validated.
+
   Here is the list of the currently supported keywords :
 
   - backup
index 043857478a31f1f5671723a1b9be3fb37b0385fb..62f0bcb89fad1c746d28616ada1d68bbad1db18a 100644 (file)
@@ -4375,6 +4375,13 @@ static int cli_parse_add_server(char **args, char *payload, struct appctx *appct
        if (errcode)
                goto out;
 
+       /* A dynamic server does not currently support resolution.
+        *
+        * Initialize it explicitly to the "none" method to ensure no
+        * resolution will ever be executed.
+        */
+       srv->init_addr_methods = SRV_IADDR_NONE;
+
        if (srv->mux_proto) {
                if (!conn_get_best_mux_entry(srv->mux_proto->token, PROTO_SIDE_BE, be->mode)) {
                        ha_alert("MUX protocol is not usable for server.\n");