From 9754c4e15fb9073ed9f95d5d4242d311eb65d717 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 16 Feb 2012 16:20:16 -0600 Subject: [PATCH] viced: Delete dup host before probing old host Currently, when the fileserver gets a new connection from an address not on the addr hash table, we allocate a new host structure and add that host to the addr hash table. If we then find that that host's uuid matches the uuid of an extant host, we do the following: - probe the old host with the uuid, and MultiProbeAlternateAddress_r if the probe fails - mark the duplicate host as HOSTDELETED - manipulate the interface lists Consider, for example, that we have an extant host ('oldHost') with address 1.2.3.4:7001, but with 5.6.7.8:7001 on its alternate interface list. At some point, the 1.2.3.4:7001 interface goes away or becomes unreachable. A new connection comes in from that same host on 5.6.7.8:7001. What will happen is we create a new host for address 5.6.7.8:7001, and then detect the uuid collision. When we try to probe the old address of 1.2.3.4:7001, it will fail, and we will try to MultiProbeAlternateAddress_r. MultiProbeAlternateAddress_r will determine that the alternate address 5.6.7.8:7001 responds successfully to the probe, and it tries to set 5.6.7.8:7001 to be the primary address of 'oldHost', and add 'oldHost' to the addr hash table under 5.6.7.8:7001. But the "new" host from the incoming connection is already hashed on the address hash table under 5.6.7.8:7001, so the h_AddHostToAddrHashTable_r call in MultiProbeAlternateAddress_r fails. Since we later delete the new duplicate host, this results in 5.6.7.8:7001 being the primary address for the host, but that address is not anywhere in the address hash table. This behavior can be seen by the following pair of FileLog messages: Wed Feb 1 11:02:38 2012 CB: ProbeUuid for 0xdeadbeefdead (1.2.3.4:7001) failed -01 Wed Feb 1 11:02:38 2012 h_AddHostToAddrHashTable_r: refusing to hash host beefdead, baadcafe (5.6.7.8:7001) already hashed While those message do not necessarily indicate this problem, this problem will result in those messages. To fix this, mark the duplicate host as HOSTDELETED before we do any probing on 'oldHost'. This way, if MultiProbeAlternateAddress_r tries to add 'oldHost' to the addr hash table under 5.6.7.8:7001, it will be able to do so successfully, since the old duplicate host is deleted. Change-Id: Id3aaab0718425492dca1deba892725160677b85f Reviewed-on: http://gerrit.openafs.org/6726 Reviewed-by: Jeffrey Altman Reviewed-by: Derrick Brashear Reviewed-by: Alistair Ferguson Tested-by: BuildBot --- src/viced/host.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/viced/host.c b/src/viced/host.c index 08632b082..9b946d7cc 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -2001,6 +2001,17 @@ h_GetHost_r(struct rx_connection *tcon) if (oldHost) { int probefail = 0; + /* This is a new address for an existing host. Update + * the list of interfaces for the existing host and + * delete the host structure we just allocated. */ + + /* mark the duplicate host as deleted before we do + * anything. The probing code below may try to change + * "oldHost" to the same IP address as "host" currently + * has, and we do not want a pseudo-"collision" to be + * noticed. */ + host->hostFlags |= HOSTDELETED; + oldHost->hostFlags |= HWHO_INPROGRESS; if (oldHost->interface) { @@ -2034,13 +2045,6 @@ h_GetHost_r(struct rx_connection *tcon) probefail = 1; } - /* This is a new address for an existing host. Update - * the list of interfaces for the existing host and - * delete the host structure we just allocated. */ - - /* prevent warnings while manipulating interface lists */ - host->hostFlags |= HOSTDELETED; - if (oldHost->host != haddr || oldHost->port != hport) { struct rx_connection *rxconn; -- 2.39.5