From 766e6d35c48408f0e105c5745b5ad8dcb06256d0 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Thu, 25 Jul 2024 14:40:18 +1000 Subject: [PATCH] ctdb-daemon: Store public address string in VNN 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 Reviewed-by: Anoop C S --- ctdb/server/ctdb_takeover.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index e55d9df4769..fd1f7251781 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -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"); -- 2.47.3