ctdbd: Fix ctdb_control_release_ip() on local daemons
authorMartin Schwenke <martin@meltin.net>
Mon, 2 Jul 2012 04:09:32 +0000 (14:09 +1000)
committerMichael Adam <obnox@samba.org>
Fri, 6 Jun 2014 13:00:39 +0000 (15:00 +0200)
When running on local daemons no IPs are actually assigned to
interfaces.  Commit 9a806dec8687e2ec08a308853b61af6aed5e5d1e broke
ctdb_control_release_ip() for local daemons because it asks the system
which interface the given IP is on, instead of the old behaviour of
trusting CTDB's internal records.

For local deamons (i.e. !ctdb->do_checkpublicip) revert to the old
behaviour of looking up the interface internally.  This is good
enough, given that the tests don't tend to misconfigure the addresses.

Signed-off-by: Martin Schwenke <martin@meltin.net>
(cherry picked from commit 38e8651b955afdbaf0ae87c24c55c052f8209290)

server/ctdb_takeover.c

index ea60e38d2c18448840221fd57b6cd3c55172131d..9826d632a21b4425ccc0ee200932682599278438 100644 (file)
@@ -813,12 +813,20 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
                        ctdb_vnn_unassign_iface(ctdb, vnn);
                        return 0;
                }
-       }
 
-       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;
+               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;
+               }
+       } else {
+               if (vnn->iface == NULL) {
+                       DEBUG(DEBUG_DEBUG,("Redundant release of IP %s/%u (ip not held)\n",
+                                          ctdb_addr_to_str(&pip->addr),
+                                          vnn->public_netmask_bits));
+                       return 0;
+               }
+               iface = strdup(ctdb_vnn_iface_string(vnn));
        }
 
        DEBUG(DEBUG_NOTICE,("Release of IP %s/%u on interface %s  node:%d\n",