ctdb-daemon: Use release_ip_post() when releasing all IP addresses
authorMartin Schwenke <martin@meltin.net>
Thu, 11 Aug 2016 04:07:44 +0000 (14:07 +1000)
committerMartin Schwenke <martins@samba.org>
Wed, 17 Aug 2016 21:00:26 +0000 (23:00 +0200)
This has the advantage of using common code.  Also, if there was
previously a failed attempt to release the IP address as part of a
delete, then this will finish processing the delete.

Extra care needs to be taken when a VNN is actually deleted.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12158

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_takeover.c

index 1687bb495200ed1f8a8f3f6d354feea66b9b1429..3871799c77340884fdc03efa8d36a3360ac30b11 100644 (file)
@@ -2121,15 +2121,17 @@ void ctdb_takeover_client_destructor_hook(struct ctdb_client *client)
 
 void ctdb_release_all_ips(struct ctdb_context *ctdb)
 {
-       struct ctdb_vnn *vnn;
+       struct ctdb_vnn *vnn, *next;
        int count = 0;
-       TDB_DATA data;
 
        if (ctdb->tunable.disable_ip_failover == 1) {
                return;
        }
 
-       for (vnn=ctdb->vnn;vnn;vnn=vnn->next) {
+       for (vnn = ctdb->vnn; vnn != NULL; vnn = next) {
+               /* vnn can be freed below in release_ip_post() */
+               next = vnn->next;
+
                if (!ctdb_sys_have_ip(&vnn->public_address)) {
                        ctdb_vnn_unassign_iface(ctdb, vnn);
                        continue;
@@ -2171,13 +2173,10 @@ void ctdb_release_all_ips(struct ctdb_context *ctdb)
                        continue;
                }
 
-               data.dptr = (uint8_t *)ctdb_addr_to_str(&vnn->public_address);
-               data.dsize = strlen((char *)data.dptr) + 1;
-               ctdb_daemon_send_message(ctdb, ctdb->pnn,
-                                        CTDB_SRVID_RELEASE_IP, data);
-
-               ctdb_vnn_unassign_iface(ctdb, vnn);
-               vnn->update_in_flight = false;
+               vnn = release_ip_post(ctdb, vnn, &vnn->public_address);
+               if (vnn != NULL) {
+                       vnn->update_in_flight = false;
+               }
                count++;
        }