From 63840e2e57c74c9bd204d130dc8124138e2066fe Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Wed, 23 Dec 2009 16:38:57 -0500 Subject: [PATCH] viced: add then remove when changing addresses When changing a host address, be sure to add the new interface before removing the old to avoid having the host marked as deleted if we removed the only valid address. This change was pulled out of commit ca613599a2537756462a420ae1a632747a433226 viced-host-uuid-and-addr-hashing-corrections-20090530 by Jeffrey Altman. LICENSE IPL10 FIXES 124634 Change-Id: Ie65e762c4be6205eb654566403f0d5088b7ebdee Reviewed-on: http://gerrit.openafs.org/1026 Tested-by: Derrick Brashear Reviewed-by: Derrick Brashear --- src/viced/host.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/viced/host.c b/src/viced/host.c index 153e6baf9..60d1a6cbe 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -1629,9 +1629,13 @@ h_GetHost_r(struct rx_connection *tcon, int *heldp) host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port),code2)); - - removeInterfaceAddr_r(host, host->host, host->port); + /* + * make sure we add and then remove. otherwise, we + * might end up with no valid interfaces after the + * remove and the host will have been marked deleted. + */ addInterfaceAddr_r(host, haddr, hport); + removeInterfaceAddr_r(host, host->host, host->port); host->host = haddr; host->port = hport; rxconn = host->callback_rxcon; @@ -1870,6 +1874,11 @@ h_GetHost_r(struct rx_connection *tcon, int *heldp) ntohs(oldHost->port), afs_inet_ntoa_r(haddr, hoststr), ntohs(hport))); + /* + * add then remove. otherwise the host may get marked + * deleted if we removed the only valid address. + */ + addInterfaceAddr_r(oldHost, haddr, hport); if (probefail || oldHost->host == haddr) { /* The probe failed which means that the old address is * either unreachable or is not the same host we were just @@ -1896,7 +1905,6 @@ h_GetHost_r(struct rx_connection *tcon, int *heldp) removeInterfaceAddr_r(oldHost, haddr, interface->interface[i].port); } } - addInterfaceAddr_r(oldHost, haddr, hport); hashInsert_r(haddr, hport, oldHost); oldHost->host = haddr; oldHost->port = hport; -- 2.39.5