From 747a8c0642aeaef814d953d16968fb5026e1ec69 Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Tue, 29 Dec 2009 13:40:15 -0500 Subject: [PATCH] viced: allow alternate addresses on the same hash chain again Revert the logic meant to prevent duplicate entries in the host address hash table so hosts with multiple addresses can be stored in the same hash bucket again. Add a new log message to show when the host cannot be stored in the hash table because of an address-port pair collision with a host already in the hash table. Change-Id: I24bf48b912dcf3062201691b446372d78de9bc14 Reviewed-on: http://gerrit.openafs.org/1046 Reviewed-by: Andrew Deason Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/viced/host.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/viced/host.c b/src/viced/host.c index 7fc2e45ff..1aaeff45a 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -1164,27 +1164,29 @@ h_AddHostToAddrHashTable_r(afs_uint32 addr, afs_uint16 port, struct host *host) { int index; struct h_AddrHashChain *chain; - char hoststr[16], hoststr2[16]; + char hoststr[16]; /* hash into proper bucket */ index = h_HashIndex(addr); - /* don't add the same entry multiple times */ + /* don't add the same address:port pair entry multiple times */ for (chain = hostAddrHashTable[index]; chain; chain = chain->next) { - if (chain->hostPtr == host) { - if (chain->addr != addr || chain->port != port) { - ViceLog(0, - ("h_AddHostToAddrHashTable_r: host %" AFS_PTR_FMT " exists as %s:%d when adding %s:%d\n", - host, afs_inet_ntoa_r(chain->addr, hoststr), - ntohs(chain->port), afs_inet_ntoa_r(addr, hoststr2), - ntohs(port))); - } else - ViceLog(125, - ("h_AddHostToAddrHashTable_r: host %" AFS_PTR_FMT " (%s:%d) already hashed\n", - host, afs_inet_ntoa_r(chain->addr, hoststr), - ntohs(chain->port))); - - return; + if (chain->addr == addr && chain->port == port) { + if (chain->hostPtr == host) { + ViceLog(125, + ("h_AddHostToAddrHashTable_r: host %" AFS_PTR_FMT " (%s:%d) already hashed\n", + host, afs_inet_ntoa_r(chain->addr, hoststr), + ntohs(chain->port))); + return; + } + if (!(chain->hostPtr->hostFlags & HOSTDELETED)) { + ViceLog(0, + ("h_AddHostToAddrHashTable_r: refusing to hash host %" AFS_PTR_FMT ", %" + AFS_PTR_FMT " (%s:%d) already hashed\n", + host, chain->hostPtr, afs_inet_ntoa_r(chain->addr, hoststr), + ntohs(chain->port))); + return; + } } } -- 2.39.5