When we release an ip, get the interface name from the kernel
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 20 Jun 2012 00:08:11 +0000 (10:08 +1000)
committerMartin Schwenke <martin@meltin.net>
Thu, 12 Jul 2012 03:49:20 +0000 (13:49 +1000)
instead of using the interface where ctdb thinks the ip is hosted at.
The difference is that this now allows us to handle cases where we want to release an ip   but ctdbd does not know which interface the ip is assigned on.
(user has used 'ip addr add...'  and manually assigned an ip to the wrong interface)

server/ctdb_takeover.c

index 3dc1e46cfe7bc812a1d6b7852c3f712ea3285e96..e04ea6ae1aa055585d7cd3e62ffe16da7cf87d0e 100644 (file)
@@ -784,6 +784,7 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
        struct takeover_callback_state *state;
        struct ctdb_public_ip *pip = (struct ctdb_public_ip *)indata.dptr;
        struct ctdb_vnn *vnn;
+       char *iface;
 
        /* update our vnn list */
        vnn = find_public_ip_vnn(ctdb, &pip->addr);
@@ -807,17 +808,16 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
                return 0;
        }
 
-       if (vnn->iface == NULL) {
-               DEBUG(DEBUG_ERR,(__location__ " release_ip of IP %s is known to the kernel, "
-                                "but we have no interface assigned, has someone manually configured it? Ignore for now.\n",
-                                ctdb_addr_to_str(&vnn->public_address)));
+       iface = ctdb_sys_find_ifname(&pip->addr);
+       if (iface == NULL) {
+               DEBUG(DEBUG_ERR, ("Could not find which interface the ip address is hosted on. can not release it\n"));
                return 0;
        }
 
        DEBUG(DEBUG_NOTICE,("Release of IP %s/%u on interface %s  node:%d\n",
                ctdb_addr_to_str(&pip->addr),
-               vnn->public_netmask_bits, 
-               ctdb_vnn_iface_string(vnn),
+               vnn->public_netmask_bits,
+               iface,
                pip->pnn));
 
        state = talloc(ctdb, struct takeover_callback_state);
@@ -834,9 +834,10 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
                                         false,
                                         CTDB_EVENT_RELEASE_IP,
                                         "%s %s %u",
-                                        ctdb_vnn_iface_string(vnn),
+                                        iface,
                                         ctdb_addr_to_str(&pip->addr),
                                         vnn->public_netmask_bits);
+       free(iface);
        if (ret != 0) {
                DEBUG(DEBUG_ERR,(__location__ " Failed to release IP %s on interface %s\n",
                        ctdb_addr_to_str(&pip->addr),