When we release an ip, get the interface name from the kernel
[ctdb.git] / 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),