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>
Mon, 6 May 2013 23:36:30 +0000 (09:36 +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)

(cherry picked from commit c6bf22ba5c01001b7febed73dd16a03bd3fd2bed)

Conflicts:
server/ctdb_takeover.c

server/ctdb_takeover.c

index 1e8dc757c5dafc0a26f4a59bc51a5ec9f862dff4..affc3cea499cbf8edce0f9e70ef445b5a68cfc0e 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);
@@ -801,23 +802,22 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
        if (!ctdb_sys_have_ip(&pip->addr)) {
                DEBUG(DEBUG_DEBUG,("Redundant release of IP %s/%u on interface %s (ip not held)\n", 
                        ctdb_addr_to_str(&pip->addr),
-                       vnn->public_netmask_bits, 
+                       vnn->public_netmask_bits,
                        ctdb_vnn_iface_string(vnn)));
                ctdb_vnn_unassign_iface(ctdb, vnn);
                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),