]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-daemon: Store public address string in VNN
authorMartin Schwenke <mschwenke@ddn.com>
Thu, 25 Jul 2024 04:40:18 +0000 (14:40 +1000)
committerAnoop C S <anoopcs@samba.org>
Tue, 8 Oct 2024 05:34:30 +0000 (05:34 +0000)
These are currently converted to strings constantly in log messages
and other places.  This clutters the code and probably has a minor
performance impact.

Add a new string field to the VNN structure.  Populate it when a
public address is added and the VNN structure is allocated.  This is
consistent with how node addresses are handled.

Don't use it yet, or this commit becomes huge.

A short-term goal is that each VNN public address will be converted to
a string only once.  A longer-term goal is to reduce use of
ctdb_addr_to_str().

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
ctdb/server/ctdb_takeover.c

index e55d9df4769c0a6e0653349554589e55bd8a6a65..fd1f7251781a910cf512e392ae0bf4d8f5a4b2f1 100644 (file)
@@ -74,6 +74,7 @@ struct ctdb_vnn {
        struct vnn_interface *ifaces;
        ctdb_sock_addr public_address;
        uint8_t public_netmask_bits;
+       const char *name;
 
        /*
         * The node number that is serving this public address - set
@@ -1072,6 +1073,14 @@ static int ctdb_add_public_address(struct ctdb_context *ctdb,
                DBG_ERR("Memory allocation error\n");
                return -1;
        }
+
+       vnn->name = ctdb_sock_addr_to_string(vnn, addr, false);
+       if (vnn->name == NULL) {
+               DBG_ERR("Memory allocation error\n");
+               talloc_free(vnn);
+               return -1;
+       }
+
        tmp = talloc_strdup(vnn, ifaces);
        if (tmp == NULL) {
                DBG_ERR("Memory allocation error\n");