server: ban ourself if the ctdb and kernel knowledge of a public ip differs
authorStefan Metzmacher <metze@samba.org>
Mon, 18 Jan 2010 14:04:32 +0000 (15:04 +0100)
committerStefan Metzmacher <metze@samba.org>
Wed, 20 Jan 2010 10:11:04 +0000 (11:11 +0100)
metze

server/ctdb_takeover.c

index b9ba445c9143b1b42a32deb4aae57f4783fb7d8b..cc74739df43a2bf9467f9d3d4dac85ecbd668c91 100644 (file)
@@ -575,11 +575,9 @@ int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
                        ctdb_addr_to_str(&pip->addr)));
                return 0;
        }
-       vnn->pnn = pip->pnn;
 
        have_ip = ctdb_sys_have_ip(&pip->addr);
        best_iface = ctdb_vnn_best_iface(ctdb, vnn);
-
        if (best_iface == NULL) {
                DEBUG(DEBUG_ERR,("takeoverip of IP %s/%u failed to find"
                                 "a usable interface (old %s, have_ip %d)\n",
@@ -590,6 +588,25 @@ int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
                return -1;
        }
 
+       if (vnn->iface == NULL && have_ip) {
+               DEBUG(DEBUG_CRIT,(__location__ " takeoverip of IP %s is known to the kernel, "
+                                 "but we have no interface assigned, has someone manually configured it?"
+                                 "banning ourself\n",
+                                ctdb_addr_to_str(&vnn->public_address)));
+               ctdb_ban_self(ctdb);
+               return -1;
+       }
+
+       if (vnn->pnn != ctdb->pnn && have_ip) {
+               DEBUG(DEBUG_CRIT,(__location__ " takeoverip of IP %s is known to the kernel, "
+                                 "and we have it on iface[%s], but it was assigned to node %d"
+                                 "and we are node %d, banning ourself\n",
+                                ctdb_addr_to_str(&vnn->public_address),
+                                ctdb_vnn_iface_string(vnn), vnn->pnn, ctdb->pnn));
+               ctdb_ban_self(ctdb);
+               return -1;
+       }
+
        if (vnn->iface) {
                if (vnn->iface->link_up) {
                        /* only move when the rebalance gains something */
@@ -763,6 +780,15 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
                return 0;
        }
 
+       if (vnn->iface == NULL) {
+               DEBUG(DEBUG_CRIT,(__location__ " release_ip of IP %s is known to the kernel, "
+                                 "but we have no interface assigned, has someone manually configured it?"
+                                 "banning ourself\n",
+                                ctdb_addr_to_str(&vnn->public_address)));
+               ctdb_ban_self(ctdb);
+               return -1;
+       }
+
        DEBUG(DEBUG_NOTICE,("Release of IP %s/%u on interface %s  node:%d\n",
                ctdb_addr_to_str(&pip->addr),
                vnn->public_netmask_bits,