summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2019-06-22 05:53:15 +1000
committerKarolin Seeger <kseeger@samba.org>2019-08-28 07:36:30 +0000
commita309b862e8f0c33ff4b75311de68b099a96b11e6 (patch)
tree4ac71154a57629501f1956e888ddbc8b32d9ae9b /ctdb
parentb74fde880dee22e66d77f04d3df31d2f89e08b8e (diff)
downloadsamba-a309b862e8f0c33ff4b75311de68b099a96b11e6.tar.gz
ctdb-daemon: Replace function ctdb_ip_to_nodeid() with ctdb_ip_to_pnn()
Node ID is a poorly defined concept, indicating the slot in the node map where the IP address was found. This signed value also ends up compared to num_nodes, which is unsigned, producing unwanted warnings. Just return the PNN because this what both callers really want. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> (cherry picked from commit 010c1d77cd7e192b1fff39b7b91fccbdbbf4a786)
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/include/ctdb_private.h3
-rw-r--r--ctdb/server/ctdb_daemon.c11
-rw-r--r--ctdb/server/ctdb_server.c14
-rw-r--r--ctdb/tcp/tcp_connect.c10
4 files changed, 18 insertions, 20 deletions
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index ea00bb12128..b6d0d0c678a 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -841,7 +841,8 @@ void ctdb_stop_recoverd(struct ctdb_context *ctdb);
int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport);
-int ctdb_ip_to_nodeid(struct ctdb_context *ctdb, const ctdb_sock_addr *nodeip);
+uint32_t ctdb_ip_to_pnn(struct ctdb_context *ctdb,
+ const ctdb_sock_addr *nodeip);
void ctdb_load_nodes_file(struct ctdb_context *ctdb);
diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c
index ca98be6a100..d79634c3b54 100644
--- a/ctdb/server/ctdb_daemon.c
+++ b/ctdb/server/ctdb_daemon.c
@@ -1251,21 +1251,18 @@ static void ctdb_initialise_vnn_map(struct ctdb_context *ctdb)
static void ctdb_set_my_pnn(struct ctdb_context *ctdb)
{
- int nodeid;
-
if (ctdb->address == NULL) {
ctdb_fatal(ctdb,
"Can not determine PNN - node address is not set\n");
}
- nodeid = ctdb_ip_to_nodeid(ctdb, ctdb->address);
- if (nodeid == -1) {
+ ctdb->pnn = ctdb_ip_to_pnn(ctdb, ctdb->address);
+ if (ctdb->pnn == CTDB_UNKNOWN_PNN) {
ctdb_fatal(ctdb,
- "Can not determine PNN - node address not found in node list\n");
+ "Can not determine PNN - unknown node address\n");
}
- ctdb->pnn = ctdb->nodes[nodeid]->pnn;
- DEBUG(DEBUG_NOTICE, ("PNN is %u\n", ctdb->pnn));
+ D_NOTICE("PNN is %u\n", ctdb->pnn);
}
/*
diff --git a/ctdb/server/ctdb_server.c b/ctdb/server/ctdb_server.c
index c991b85d99b..6973a0b6056 100644
--- a/ctdb/server/ctdb_server.c
+++ b/ctdb/server/ctdb_server.c
@@ -45,24 +45,22 @@ int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport)
return 0;
}
-/*
- Check whether an ip is a valid node ip
- Returns the node id for this ip address or -1
-*/
-int ctdb_ip_to_nodeid(struct ctdb_context *ctdb, const ctdb_sock_addr *nodeip)
+/* 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)
{
- int nodeid;
+ unsigned int nodeid;
for (nodeid=0;nodeid<ctdb->num_nodes;nodeid++) {
if (ctdb->nodes[nodeid]->flags & NODE_FLAGS_DELETED) {
continue;
}
if (ctdb_same_ip(&ctdb->nodes[nodeid]->address, nodeip)) {
- return nodeid;
+ return ctdb->nodes[nodeid]->pnn;
}
}
- return -1;
+ return CTDB_UNKNOWN_PNN;
}
/* Load a nodes list file into a nodes array */
diff --git a/ctdb/tcp/tcp_connect.c b/ctdb/tcp/tcp_connect.c
index 385547e0e78..ccd7c044fb2 100644
--- a/ctdb/tcp/tcp_connect.c
+++ b/ctdb/tcp/tcp_connect.c
@@ -244,7 +244,8 @@ static void ctdb_listen_event(struct tevent_context *ev, struct tevent_fd *fde,
struct ctdb_tcp *ctcp = talloc_get_type(ctdb->private_data, struct ctdb_tcp);
ctdb_sock_addr addr;
socklen_t len;
- int fd, nodeid;
+ int fd;
+ uint32_t pnn;
struct ctdb_incoming *in;
int one = 1;
int ret;
@@ -255,10 +256,11 @@ static void ctdb_listen_event(struct tevent_context *ev, struct tevent_fd *fde,
if (fd == -1) return;
smb_set_close_on_exec(fd);
- nodeid = ctdb_ip_to_nodeid(ctdb, &addr);
+ pnn = ctdb_ip_to_pnn(ctdb, &addr);
- if (nodeid == -1) {
- DEBUG(DEBUG_ERR, ("Refused connection from unknown node %s\n", ctdb_addr_to_str(&addr)));
+ if (pnn == CTDB_UNKNOWN_PNN) {
+ D_ERR("Refused connection from unknown node %s\n",
+ ctdb_addr_to_str(&addr));
close(fd);
return;
}