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)
committerMichael Adam <obnox@samba.org>
Fri, 6 Jun 2014 13:00:39 +0000 (15:00 +0200)
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)

server/ctdb_takeover.c

index 8503359b4c5fc4c8df000a5a0098b89ec4ede1a9..ea60e38d2c18448840221fd57b6cd3c55172131d 100644 (file)
@@ -788,6 +788,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);
@@ -812,24 +813,18 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
                        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)));
-                       return 0;
-               }
-
-       } else if (vnn->iface == NULL) {
-               DEBUG(DEBUG_ERR, ("No interface found for IP %s.\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);
@@ -846,9 +841,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),