ctdb-ipalloc: Whether IPs can be hosted need not depend on merged IP list
authorMartin Schwenke <martin@meltin.net>
Mon, 12 Sep 2016 05:49:03 +0000 (15:49 +1000)
committerMartin Schwenke <martins@samba.org>
Wed, 14 Sep 2016 06:39:29 +0000 (08:39 +0200)
Merged IP list won't be available here...

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12254

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ipalloc.c

index 4f86d6e243d2769ea335e0c507825a378a13760e..ccd12e77b284051aade23e9380af391bf633dd1f 100644 (file)
@@ -245,14 +245,18 @@ bool ipalloc_set_public_ips(struct ipalloc_state *ipalloc_state,
 bool ipalloc_can_host_ips(struct ipalloc_state *ipalloc_state)
 {
        int i;
-       struct public_ip_list *ip_list;
-
 
-       for (ip_list = ipalloc_state->all_ips;
-            ip_list != NULL;
-            ip_list = ip_list->next) {
-               if (ip_list->pnn != -1) {
-                       return true;
+       for (i=0; i < ipalloc_state->num; i++) {
+               struct ctdb_public_ip_list *ips =
+                       ipalloc_state->known_public_ips;
+               if (ips[i].num != 0) {
+                       int j;
+                       /* Succeed if an address is hosted on node i */
+                       for (j=0; j < ips[i].num; j++) {
+                               if (ips[i].ip[j].pnn == i) {
+                                       return true;
+                               }
+                       }
                }
        }