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>
void ctdb_release_all_ips(struct ctdb_context *ctdb)
{
void ctdb_release_all_ips(struct ctdb_context *ctdb)
{
+ struct ctdb_vnn *vnn, *next;
if (ctdb->tunable.disable_ip_failover == 1) {
return;
}
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;
if (!ctdb_sys_have_ip(&vnn->public_address)) {
ctdb_vnn_unassign_iface(ctdb, vnn);
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;
+ }