ctdb-ipalloc: Do not use node count or PNNs from CTDB context
[obnox/samba/samba-obnox.git] / ctdb / server / ctdb_takeover.c
index cb431b3846d20430cf6f42cd4d64819e5606d008..bb548910dd04224bdd18ffb759a31e419a31ae83 100644 (file)
@@ -1240,16 +1240,12 @@ create_merged_ip_list(struct ctdb_context *ctdb, struct ipalloc_state *ipalloc_s
        TALLOC_FREE(ctdb->ip_tree);
        ctdb->ip_tree = trbt_create(ctdb, 0);
 
-       for (i=0; i < ctdb->num_nodes; i++) {
-
-               if (ctdb->nodes[i]->flags & NODE_FLAGS_DELETED) {
-                       continue;
-               }
+       if (ipalloc_state->known_public_ips == NULL) {
+               DEBUG(DEBUG_ERR, ("Known public IPs not set\n"));
+               return NULL;
+       }
 
-               /* there were no public ips for this node */
-               if (ipalloc_state->known_public_ips == NULL) {
-                       continue;
-               }
+       for (i=0; i < ipalloc_state->num; i++) {
 
                public_ips = &ipalloc_state->known_public_ips[i];
 
@@ -1260,7 +1256,7 @@ create_merged_ip_list(struct ctdb_context *ctdb, struct ipalloc_state *ipalloc_s
                        CTDB_NO_MEMORY_NULL(ctdb, tmp_ip);
                        /* Do not use information about IP addresses hosted
                         * on other nodes, it may not be accurate */
-                       if (public_ips->ip[j].pnn == ctdb->nodes[i]->pnn) {
+                       if (public_ips->ip[j].pnn == i) {
                                tmp_ip->pnn = public_ips->ip[j].pnn;
                        } else {
                                tmp_ip->pnn = -1;