ctdb-daemon: Move and improve public IP duplicate checking
authorMartin Schwenke <martin@meltin.net>
Sat, 20 Aug 2016 10:21:34 +0000 (20:21 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 8 Sep 2016 04:57:20 +0000 (06:57 +0200)
This also moves the interface validation down, making more obvious
that it can be consolidated.

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

index f2330d1336094162e02985bde71b1c65b2226b4c..66bf92c8d9d2c03f0b173d492eb9b6699086c9dd 100644 (file)
@@ -1048,6 +1048,16 @@ static int ctdb_add_public_address(struct ctdb_context *ctdb,
        int i;
        int ret;
 
+       /* Verify that we don't have an entry for this IP yet */
+       for (vnn = ctdb->vnn; vnn != NULL; vnn = vnn->next) {
+               if (ctdb_same_sockaddr(addr, &vnn->public_address)) {
+                       DEBUG(DEBUG_ERR,
+                             ("Duplicate public IP address '%s'\n",
+                              ctdb_addr_to_str(addr)));
+                       return -1;
+               }
+       }
+
        tmp = strdup(ifaces);
        for (iface = strtok(tmp, ","); iface; iface = strtok(NULL, ",")) {
                if (!ctdb_sys_check_iface_exists(iface)) {
@@ -1058,15 +1068,6 @@ static int ctdb_add_public_address(struct ctdb_context *ctdb,
        }
        free(tmp);
 
-       /* Verify that we don't have an entry for this ip yet */
-       for (vnn=ctdb->vnn;vnn;vnn=vnn->next) {
-               if (ctdb_same_sockaddr(addr, &vnn->public_address)) {
-                       DEBUG(DEBUG_CRIT,("Same ip '%s' specified multiple times in the public address list \n", 
-                               ctdb_addr_to_str(addr)));
-                       return -1;
-               }               
-       }
-
        /* create a new vnn structure for this ip address */
        vnn = talloc_zero(ctdb, struct ctdb_vnn);
        CTDB_NO_MEMORY_FATAL(ctdb, vnn);