summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2019-08-08 16:20:44 +1000
committerKarolin Seeger <kseeger@samba.org>2019-08-28 09:12:16 +0000
commit0b4a99c22f5e72d2bc6e2770b070e964866db148 (patch)
treea066e950d9dcf0bc47b358028d221420cdc20d07 /ctdb
parent53b0fd2216dfd93ae0379f48e712294137e9b5b6 (diff)
downloadsamba-0b4a99c22f5e72d2bc6e2770b070e964866db148.tar.gz
ctdb-daemon: Add function ctdb_ip_to_node()
This is the core logic from ctdb_ip_to_pnn(), so re-implement that that function using ctdb_ip_to_node(). Something similar (ctdb_ip_to_nodeid()) was recently removed in commit 010c1d77cd7e192b1fff39b7b91fccbdbbf4a786 because it wasn't required. Now there is a use case. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14084 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> (cherry picked from commit 3acb8e9d1c854b577d6be282257269df83055d31)
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/include/ctdb_private.h2
-rw-r--r--ctdb/server/ctdb_server.c24
2 files changed, 21 insertions, 5 deletions
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 2bcc7c94156..1e9619faddf 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -831,6 +831,8 @@ void ctdb_stop_recoverd(struct ctdb_context *ctdb);
int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport);
+struct ctdb_node *ctdb_ip_to_node(struct ctdb_context *ctdb,
+ const ctdb_sock_addr *nodeip);
uint32_t ctdb_ip_to_pnn(struct ctdb_context *ctdb,
const ctdb_sock_addr *nodeip);
diff --git a/ctdb/server/ctdb_server.c b/ctdb/server/ctdb_server.c
index dcd761a2961..9724d1fe0a8 100644
--- a/ctdb/server/ctdb_server.c
+++ b/ctdb/server/ctdb_server.c
@@ -45,9 +45,9 @@ int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport)
return 0;
}
-/* Return the PNN for nodeip, CTDB_UNKNOWN_PNN if nodeip is invalid */
-uint32_t ctdb_ip_to_pnn(struct ctdb_context *ctdb,
- const ctdb_sock_addr *nodeip)
+/* Return the node structure for nodeip, NULL if nodeip is invalid */
+struct ctdb_node *ctdb_ip_to_node(struct ctdb_context *ctdb,
+ const ctdb_sock_addr *nodeip)
{
unsigned int nodeid;
@@ -56,11 +56,25 @@ uint32_t ctdb_ip_to_pnn(struct ctdb_context *ctdb,
continue;
}
if (ctdb_same_ip(&ctdb->nodes[nodeid]->address, nodeip)) {
- return ctdb->nodes[nodeid]->pnn;
+ return ctdb->nodes[nodeid];
}
}
- return CTDB_UNKNOWN_PNN;
+ return NULL;
+}
+
+/* Return the PNN for nodeip, CTDB_UNKNOWN_PNN if nodeip is invalid */
+uint32_t ctdb_ip_to_pnn(struct ctdb_context *ctdb,
+ const ctdb_sock_addr *nodeip)
+{
+ struct ctdb_node *node;
+
+ node = ctdb_ip_to_node(ctdb, nodeip);
+ if (node == NULL) {
+ return CTDB_UNKNOWN_PNN;
+ }
+
+ return node->pnn;
}
/* Load a nodes list file into a nodes array */