viced: allow alternate addresses on the same hash chain again
authorMichael Meffie <mmeffie@sinenomine.net>
Tue, 29 Dec 2009 18:40:15 +0000 (13:40 -0500)
committerDerrick Brashear <shadow|account-1000005@unknown>
Tue, 5 Jan 2010 18:18:44 +0000 (10:18 -0800)
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 <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/viced/host.c

index 7fc2e45..1aaeff4 100644 (file)
@@ -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;
+           }
        }
     }