When assigning the single-public-ip during startup,
[metze/ctdb/wip.git] / server / ctdb_takeover.c
index d4958079d7c41c1edec98cf142f8f295ab82bbbd..e3e6787c86974572e44b0ffe5ba1217faf582ee1 100644 (file)
@@ -611,6 +611,15 @@ int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
                return -1;
        }
 
+       if (vnn->pnn == -1 && have_ip) {
+               vnn->pnn = ctdb->pnn;
+               DEBUG(DEBUG_CRIT,(__location__ " takeoverip of IP %s is known to the kernel, "
+                                 "and we already have it on iface[%s], update local daemon\n",
+                                ctdb_addr_to_str(&vnn->public_address),
+                                 ctdb_vnn_iface_string(vnn)));
+               return 0;
+       }
+
        if (vnn->iface) {
                if (vnn->iface->link_up) {
                        /* only move when the rebalance gains something */
@@ -991,6 +1000,7 @@ int ctdb_set_single_public_ip(struct ctdb_context *ctdb,
                              const char *ip)
 {
        struct ctdb_vnn *svnn;
+       struct ctdb_iface *cur = NULL;
        bool ok;
        int ret;
 
@@ -1019,6 +1029,14 @@ int ctdb_set_single_public_ip(struct ctdb_context *ctdb,
                return -1;
        }
 
+       /* assume the single public ip interface is initially "good" */
+       cur = ctdb_find_iface(ctdb, iface);
+       if (cur == NULL) {
+               DEBUG(DEBUG_CRIT,("Can not find public interface %s used by --single-public-ip", iface));
+               return -1;
+       }
+       cur->link_up = true;
+
        ret = ctdb_vnn_assign_iface(ctdb, svnn);
        if (ret != 0) {
                talloc_free(svnn);