ctdb-daemon: Move interface addition into interface parsing
authorMartin Schwenke <martin@meltin.net>
Wed, 24 Aug 2016 06:55:15 +0000 (16:55 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 8 Sep 2016 04:57:20 +0000 (06:57 +0200)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_takeover.c

index 786eb3c4dbbc3035818e9359abc9651bcf15577a..f34803217f0b3b79c28e5920eda7199a2929bc5f 100644 (file)
@@ -1052,7 +1052,6 @@ static int ctdb_add_public_address(struct ctdb_context *ctdb,
        uint32_t num = 0;
        char *tmp;
        const char *iface;
-       int i;
        int ret;
 
        /* Verify that we don't have an entry for this IP yet */
@@ -1091,6 +1090,17 @@ static int ctdb_add_public_address(struct ctdb_context *ctdb,
                        talloc_free(vnn);
                        return -1;
                }
+
+               ret = ctdb_add_local_iface(ctdb, iface);
+               if (ret != 0) {
+                       DEBUG(DEBUG_ERR,
+                             ("Failed to add interface '%s' "
+                              "for public address %s\n",
+                              iface, ctdb_addr_to_str(addr)));
+                       talloc_free(vnn);
+                       return -1;
+               }
+
                vnn->ifaces = talloc_realloc(vnn, vnn->ifaces, const char *, num + 2);
                if (vnn->ifaces == NULL) {
                        DEBUG(DEBUG_ERR, (__location__ " out of memory\n"));
@@ -1111,17 +1121,6 @@ static int ctdb_add_public_address(struct ctdb_context *ctdb,
        vnn->public_netmask_bits = mask;
        vnn->pnn                 = -1;
 
-       for (i=0; vnn->ifaces[i]; i++) {
-               ret = ctdb_add_local_iface(ctdb, vnn->ifaces[i]);
-               if (ret != 0) {
-                       DEBUG(DEBUG_CRIT, (__location__ " failed to add iface[%s] "
-                                          "for public_address[%s]\n",
-                                          vnn->ifaces[i], ctdb_addr_to_str(addr)));
-                       talloc_free(vnn);
-                       return -1;
-               }
-       }
-
        DLIST_ADD(ctdb->vnn, vnn);
 
        return 0;