Lines 10-16
Link Here
|
10 |
#include <afsconfig.h> |
10 |
#include <afsconfig.h> |
11 |
#include <afs/param.h> |
11 |
#include <afs/param.h> |
12 |
|
12 |
|
13 |
|
|
|
14 |
#include <stdio.h> |
13 |
#include <stdio.h> |
15 |
#include <errno.h> |
14 |
#include <errno.h> |
16 |
#include <string.h> |
15 |
#include <string.h> |
Lines 503-517
h_Release_r(register struct host *host)
Link Here
|
503 |
if (!h_OtherHolds_r(host)) { |
502 |
if (!h_OtherHolds_r(host)) { |
504 |
/* must avoid masking this until after h_OtherHolds_r runs |
503 |
/* must avoid masking this until after h_OtherHolds_r runs |
505 |
* but it should be run before h_TossStuff_r */ |
504 |
* but it should be run before h_TossStuff_r */ |
506 |
(host)->holds[h_holdSlot()] &= ~h_holdbit(); |
505 |
h_Decrement_r(host); |
507 |
if ((host->hostFlags & HOSTDELETED) |
506 |
if ((host->hostFlags & HOSTDELETED) |
508 |
|| (host->hostFlags & CLIENTDELETED)) { |
507 |
|| (host->hostFlags & CLIENTDELETED)) { |
509 |
h_TossStuff_r(host); |
508 |
h_TossStuff_r(host); |
510 |
} |
509 |
} |
511 |
} else |
510 |
} else { |
512 |
(host)->holds[h_holdSlot()] &= ~h_holdbit(); |
511 |
h_Decrement_r(host); |
513 |
} else |
512 |
} |
514 |
(host)->holds[h_holdSlot()] &= ~h_holdbit(); |
513 |
} else { |
|
|
514 |
h_Decrement_r(host); |
515 |
} |
515 |
|
516 |
|
516 |
return 0; |
517 |
return 0; |
517 |
} |
518 |
} |
Lines 766-772
h_Alloc_r(register struct rx_connection *r_con)
Link Here
|
766 |
host->host = rxr_HostOf(r_con); |
767 |
host->host = rxr_HostOf(r_con); |
767 |
host->port = rxr_PortOf(r_con); |
768 |
host->port = rxr_PortOf(r_con); |
768 |
|
769 |
|
769 |
hashInsert_r(host->host, host->port, host); |
770 |
h_AddHostToAddrHashTable_r(host->host, host->port, host); |
770 |
|
771 |
|
771 |
if (consolePort == 0) { /* find the portal number for console */ |
772 |
if (consolePort == 0) { /* find the portal number for console */ |
772 |
#if defined(AFS_OSF_ENV) |
773 |
#if defined(AFS_OSF_ENV) |
Lines 887-898
h_LookupUuid_r(afsUUID * uuidp)
Link Here
|
887 |
assert(host); |
888 |
assert(host); |
888 |
if (!(host->hostFlags & HOSTDELETED) && host->interface |
889 |
if (!(host->hostFlags & HOSTDELETED) && host->interface |
889 |
&& afs_uuid_equal(&host->interface->uuid, uuidp)) { |
890 |
&& afs_uuid_equal(&host->interface->uuid, uuidp)) { |
890 |
break; |
891 |
return host; |
891 |
} |
892 |
} |
892 |
host = NULL; |
|
|
893 |
} |
893 |
} |
894 |
return host; |
894 |
return NULL; |
895 |
|
|
|
896 |
} /*h_Lookup */ |
895 |
} /*h_Lookup */ |
897 |
|
896 |
|
898 |
|
897 |
|
Lines 913-935
h_TossStuff_r(register struct host *host)
Link Here
|
913 |
{ |
912 |
{ |
914 |
register struct client **cp, *client; |
913 |
register struct client **cp, *client; |
915 |
int i; |
914 |
int i; |
|
|
915 |
int code; |
916 |
|
916 |
|
917 |
/* if somebody still has this host held */ |
917 |
/* make sure host doesn't go away over h_NBLock_r */ |
918 |
for (i = 0; (i < h_maxSlots) && (!(host)->holds[i]); i++); |
918 |
h_Hold_r(host); |
919 |
if (i != h_maxSlots) |
919 |
|
920 |
return; |
920 |
code = h_NBLock_r(host); |
|
|
921 |
|
922 |
/* don't use h_Release_r, since that may call h_TossStuff_r again */ |
923 |
h_Decrement_r(host); |
921 |
|
924 |
|
922 |
/* if somebody still has this host locked */ |
925 |
/* if somebody still has this host locked */ |
923 |
if (h_NBLock_r(host) != 0) { |
926 |
if (code != 0) { |
924 |
char hoststr[16]; |
927 |
char hoststr[16]; |
925 |
ViceLog(0, |
928 |
ViceLog(0, |
926 |
("Warning: h_TossStuff_r failed; Host %s:%d was locked.\n", |
929 |
("Warning: h_TossStuff_r failed; Host 0x%lx (%s:%d) was locked.\n", |
927 |
afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); |
930 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); |
928 |
return; |
931 |
return; |
929 |
} else { |
932 |
} else { |
930 |
h_Unlock_r(host); |
933 |
h_Unlock_r(host); |
931 |
} |
934 |
} |
932 |
|
935 |
|
|
|
936 |
/* if somebody still has this host held */ |
937 |
/* we must check this _after_ h_NBLock_r, since h_NBLock_r can drop and |
938 |
* reacquire H_LOCK */ |
939 |
for (i = 0; (i < h_maxSlots) && (!(host)->holds[i]); i++); |
940 |
if (i != h_maxSlots) { |
941 |
char hoststr[16]; |
942 |
ViceLog(0, |
943 |
("Warning: h_TossStuff_r failed; Host 0x%lx (%s:%d) was held.\n", |
944 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); |
945 |
return; |
946 |
} |
947 |
|
933 |
/* ASSUMPTION: rxi_FreeConnection() does not yield */ |
948 |
/* ASSUMPTION: rxi_FreeConnection() does not yield */ |
934 |
for (cp = &host->FirstClient; (client = *cp);) { |
949 |
for (cp = &host->FirstClient; (client = *cp);) { |
935 |
if ((host->hostFlags & HOSTDELETED) || client->deleted) { |
950 |
if ((host->hostFlags & HOSTDELETED) || client->deleted) { |
Lines 938-945
h_TossStuff_r(register struct host *host)
Link Here
|
938 |
if (code < 0) { |
953 |
if (code < 0) { |
939 |
char hoststr[16]; |
954 |
char hoststr[16]; |
940 |
ViceLog(0, |
955 |
ViceLog(0, |
941 |
("Warning: h_TossStuff_r failed: Host %s:%d client %x was locked.\n", |
956 |
("Warning: h_TossStuff_r failed: Host 0x%lx (%s:%d) client %x was locked.\n", |
942 |
afs_inet_ntoa_r(host->host, hoststr), |
957 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), |
943 |
ntohs(host->port), client)); |
958 |
ntohs(host->port), client)); |
944 |
return; |
959 |
return; |
945 |
} |
960 |
} |
Lines 947-954
h_TossStuff_r(register struct host *host)
Link Here
|
947 |
if (client->refCount) { |
962 |
if (client->refCount) { |
948 |
char hoststr[16]; |
963 |
char hoststr[16]; |
949 |
ViceLog(0, |
964 |
ViceLog(0, |
950 |
("Warning: h_TossStuff_r failed: Host %s:%d client %x refcount %d.\n", |
965 |
("Warning: h_TossStuff_r failed: Host 0x%lx (%s:%d) client %x refcount %d.\n", |
951 |
afs_inet_ntoa_r(host->host, hoststr), |
966 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), |
952 |
ntohs(host->port), client, client->refCount)); |
967 |
ntohs(host->port), client, client->refCount)); |
953 |
/* This is the same thing we do if the host is locked */ |
968 |
/* This is the same thing we do if the host is locked */ |
954 |
ReleaseWriteLock(&client->lock); |
969 |
ReleaseWriteLock(&client->lock); |
Lines 970-978
h_TossStuff_r(register struct host *host)
Link Here
|
970 |
host->hostFlags &= ~CLIENTDELETED; |
985 |
host->hostFlags &= ~CLIENTDELETED; |
971 |
|
986 |
|
972 |
if (host->hostFlags & HOSTDELETED) { |
987 |
if (host->hostFlags & HOSTDELETED) { |
973 |
register struct h_AddrHashChain **ahp, *ath; |
|
|
974 |
register struct rx_connection *rxconn; |
988 |
register struct rx_connection *rxconn; |
975 |
afsUUID *uuidp; |
|
|
976 |
struct AddrPort hostAddrPort; |
989 |
struct AddrPort hostAddrPort; |
977 |
int i; |
990 |
int i; |
978 |
|
991 |
|
Lines 991-1034
h_TossStuff_r(register struct host *host)
Link Here
|
991 |
|
1004 |
|
992 |
/* if alternate addresses do not exist */ |
1005 |
/* if alternate addresses do not exist */ |
993 |
if (!(host->interface)) { |
1006 |
if (!(host->interface)) { |
994 |
for (ahp = &hostAddrHashTable[h_HashIndex(host->host)]; (ath = *ahp); |
1007 |
h_DeleteHostFromAddrHashTable_r(host->host, host->port, host); |
995 |
ahp = &ath->next) { |
|
|
996 |
assert(ath->hostPtr); |
997 |
if (ath->hostPtr == host) { |
998 |
*ahp = ath->next; |
999 |
free(ath); |
1000 |
break; |
1001 |
} |
1002 |
} |
1003 |
} else { |
1008 |
} else { |
1004 |
register struct h_UuidHashChain **uhp, *uth; |
1009 |
h_DeleteHostFromUuidHashTable_r(host); |
1005 |
/* delete the hash entry for the UUID */ |
1010 |
h_DeleteHostFromAddrHashTable_r(host->host, host->port, host); |
1006 |
uuidp = &host->interface->uuid; |
1011 |
/* delete the hash entry for each valid alternate addresses */ |
1007 |
for (uhp = &hostUuidHashTable[h_UuidHashIndex(uuidp)]; (uth = *uhp); |
|
|
1008 |
uhp = &uth->next) { |
1009 |
assert(uth->hostPtr); |
1010 |
if (uth->hostPtr == host) { |
1011 |
*uhp = uth->next; |
1012 |
free(uth); |
1013 |
break; |
1014 |
} |
1015 |
} |
1016 |
/* delete the hash entry for each alternate addresses */ |
1017 |
for (i = 0; i < host->interface->numberOfInterfaces; i++) { |
1012 |
for (i = 0; i < host->interface->numberOfInterfaces; i++) { |
1018 |
hostAddrPort = host->interface->interface[i]; |
1013 |
hostAddrPort = host->interface->interface[i]; |
1019 |
|
1014 |
/* |
1020 |
if (!hostAddrPort.valid) |
1015 |
* if the interface addr/port is the primary, we already |
1021 |
continue; |
1016 |
* removed it. If the addr/port is not valid, its not |
1022 |
|
1017 |
* in the hash table. |
1023 |
for (ahp = &hostAddrHashTable[h_HashIndex(hostAddrPort.addr)]; (ath = *ahp); |
1018 |
*/ |
1024 |
ahp = &ath->next) { |
1019 |
if (hostAddrPort.valid && |
1025 |
assert(ath->hostPtr); |
1020 |
(host->host != hostAddrPort.addr || |
1026 |
if (ath->hostPtr == host) { |
1021 |
host->port != hostAddrPort.port)) |
1027 |
*ahp = ath->next; |
1022 |
h_DeleteHostFromAddrHashTable_r(hostAddrPort.addr, hostAddrPort.port, host); |
1028 |
free(ath); |
|
|
1029 |
break; |
1030 |
} |
1031 |
} |
1032 |
} |
1023 |
} |
1033 |
free(host->interface); |
1024 |
free(host->interface); |
1034 |
host->interface = NULL; |
1025 |
host->interface = NULL; |
Lines 1184-1248
h_Enumerate_r(int (*proc) (), struct host *enumstart, char *param)
Link Here
|
1184 |
|
1175 |
|
1185 |
/* inserts a new HashChain structure corresponding to this UUID */ |
1176 |
/* inserts a new HashChain structure corresponding to this UUID */ |
1186 |
void |
1177 |
void |
1187 |
hashInsertUuid_r(struct afsUUID *uuid, struct host *host) |
1178 |
h_AddHostToUuidHashTable_r(struct afsUUID *uuid, struct host *host) |
1188 |
{ |
1179 |
{ |
1189 |
int index; |
1180 |
int index; |
1190 |
struct h_UuidHashChain *chain; |
1181 |
struct h_UuidHashChain *chain; |
|
|
1182 |
char uuid1[128], uuid2[128]; |
1183 |
char hoststr[16]; |
1191 |
|
1184 |
|
1192 |
/* hash into proper bucket */ |
1185 |
/* hash into proper bucket */ |
1193 |
index = h_UuidHashIndex(uuid); |
1186 |
index = h_UuidHashIndex(uuid); |
1194 |
|
1187 |
|
1195 |
/* don't add the same entry multiple times */ |
1188 |
/* don't add the same entry multiple times */ |
1196 |
for (chain = hostUuidHashTable[index]; chain; chain = chain->next) { |
1189 |
for (chain = hostUuidHashTable[index]; chain; chain = chain->next) { |
|
|
1190 |
if (!chain->hostPtr) |
1191 |
continue; |
1192 |
|
1197 |
if (chain->hostPtr->interface && |
1193 |
if (chain->hostPtr->interface && |
1198 |
afs_uuid_equal(&chain->hostPtr->interface->uuid, uuid)) |
1194 |
afs_uuid_equal(&chain->hostPtr->interface->uuid, uuid)) { |
|
|
1195 |
if (LogLevel >= 125) { |
1196 |
afsUUID_to_string(&chain->hostPtr->interface->uuid, uuid1, 127); |
1197 |
afsUUID_to_string(uuid, uuid2, 127); |
1198 |
ViceLog(125, ("h_AddHostToUuidHashTable_r: host 0x%lx (uuid %s) exists as %s:%d (uuid %s)\n", |
1199 |
(unsigned long) host, uuid1, |
1200 |
afs_inet_ntoa_r(chain->hostPtr->host, hoststr), |
1201 |
ntohs(chain->hostPtr->port), uuid2)); |
1202 |
} |
1199 |
return; |
1203 |
return; |
|
|
1204 |
} |
1200 |
} |
1205 |
} |
1201 |
|
1206 |
|
1202 |
/* insert into beginning of list for this bucket */ |
1207 |
/* insert into beginning of list for this bucket */ |
1203 |
chain = (struct h_UuidHashChain *)malloc(sizeof(struct h_UuidHashChain)); |
1208 |
chain = (struct h_UuidHashChain *)malloc(sizeof(struct h_UuidHashChain)); |
1204 |
if (!chain) { |
1209 |
if (!chain) { |
1205 |
ViceLog(0, ("Failed malloc in hashInsertUuid_r\n")); |
1210 |
ViceLog(0, ("Failed malloc in h_AddHostToUuidHashTable_r\n")); |
1206 |
assert(0); |
1211 |
assert(0); |
1207 |
} |
1212 |
} |
1208 |
assert(chain); |
|
|
1209 |
chain->hostPtr = host; |
1213 |
chain->hostPtr = host; |
1210 |
chain->next = hostUuidHashTable[index]; |
1214 |
chain->next = hostUuidHashTable[index]; |
1211 |
hostUuidHashTable[index] = chain; |
1215 |
hostUuidHashTable[index] = chain; |
|
|
1216 |
if (LogLevel < 125) |
1217 |
return; |
1218 |
afsUUID_to_string(uuid, uuid2, 127); |
1219 |
ViceLog(125, |
1220 |
("h_AddHostToUuidHashTable_r: host 0x%lx (%s:%d) added as uuid %s\n", |
1221 |
(unsigned long) host, afs_inet_ntoa_r(chain->hostPtr->host, hoststr), |
1222 |
ntohs(chain->hostPtr->port), uuid2)); |
1212 |
} |
1223 |
} |
1213 |
|
1224 |
|
|
|
1225 |
/* deletes a HashChain structure corresponding to this host */ |
1226 |
int |
1227 |
h_DeleteHostFromUuidHashTable_r(struct host *host) |
1228 |
{ |
1229 |
int index; |
1230 |
register struct h_UuidHashChain **uhp, *uth; |
1231 |
char uuid1[128]; |
1232 |
char hoststr[16]; |
1233 |
|
1234 |
if (!host->interface) |
1235 |
return 0; |
1236 |
|
1237 |
/* hash into proper bucket */ |
1238 |
index = h_UuidHashIndex(&host->interface->uuid); |
1239 |
|
1240 |
if (LogLevel >= 125) |
1241 |
afsUUID_to_string(&host->interface->uuid, uuid1, 127); |
1242 |
for (uhp = &hostUuidHashTable[index]; (uth = *uhp); uhp = &uth->next) { |
1243 |
assert(uth->hostPtr); |
1244 |
if (uth->hostPtr == host) { |
1245 |
ViceLog(125, |
1246 |
("h_DeleteHostFromUuidHashTable_r: host 0x%lx (uuid %s %s:%d)\n", |
1247 |
(unsigned long) host, uuid1, afs_inet_ntoa_r(host->host, hoststr), |
1248 |
ntohs(host->port))); |
1249 |
*uhp = uth->next; |
1250 |
free(uth); |
1251 |
return 1; |
1252 |
} |
1253 |
} |
1254 |
ViceLog(125, |
1255 |
("h_DeleteHostFromUuidHashTable_r: host 0x%lx (uuid %s %s:%d) not found\n", |
1256 |
(unsigned long) host, uuid1, afs_inet_ntoa_r(host->host, hoststr), |
1257 |
ntohs(host->port))); |
1258 |
return 0; |
1259 |
} |
1214 |
|
1260 |
|
1215 |
/* inserts a new HashChain structure corresponding to this address */ |
1261 |
/* inserts a new HashChain structure corresponding to this address */ |
1216 |
void |
1262 |
void |
1217 |
hashInsert_r(afs_uint32 addr, afs_uint16 port, struct host *host) |
1263 |
h_AddHostToAddrHashTable_r(afs_uint32 addr, afs_uint16 port, struct host *host) |
1218 |
{ |
1264 |
{ |
1219 |
int index; |
1265 |
int index; |
1220 |
struct h_AddrHashChain *chain; |
1266 |
struct h_AddrHashChain *chain; |
1221 |
int found = 0; |
1267 |
int found = 0; |
1222 |
char hoststr[16]; |
1268 |
char hoststr[16], hoststr2[16]; |
1223 |
|
1269 |
|
1224 |
/* hash into proper bucket */ |
1270 |
/* hash into proper bucket */ |
1225 |
index = h_HashIndex(addr); |
1271 |
index = h_HashIndex(addr); |
1226 |
|
1272 |
|
1227 |
/* don't add the same entry multiple times */ |
1273 |
/* don't add the same entry multiple times */ |
1228 |
for (chain = hostAddrHashTable[index]; chain; chain = chain->next) { |
1274 |
for (chain = hostAddrHashTable[index]; chain; chain = chain->next) { |
1229 |
if (chain->addr == addr && chain->port == port) { |
1275 |
if (chain->hostPtr == host) { |
1230 |
if (chain->hostPtr == host) |
1276 |
if (chain->addr != addr || chain->port != port) { |
1231 |
found = 1; |
1277 |
ViceLog(0, |
1232 |
else if (!(host->hostFlags & HOSTDELETED)) |
1278 |
("h_AddHostToAddrHashTable_r: host 0x%lx exists as %s:%d when adding %s:%d\n", |
1233 |
ViceLog(125, ("Addr %s:%d assigned to %x and %x.\n", |
1279 |
(unsigned long) host, afs_inet_ntoa_r(chain->addr, hoststr), |
1234 |
afs_inet_ntoa_r(addr, hoststr), ntohs(port), |
1280 |
ntohs(chain->port), afs_inet_ntoa_r(addr, hoststr2), |
1235 |
host, chain)); |
1281 |
ntohs(port))); |
|
|
1282 |
} else |
1283 |
ViceLog(125, |
1284 |
("h_AddHostToAddrHashTable_r: host 0x%lx (%s:%d) already hashed\n", |
1285 |
(unsigned long) host, afs_inet_ntoa_r(chain->addr, hoststr), |
1286 |
ntohs(chain->port))); |
1287 |
|
1288 |
return; |
1236 |
} |
1289 |
} |
1237 |
} |
1290 |
} |
1238 |
|
1291 |
|
1239 |
if (found) |
|
|
1240 |
return; |
1241 |
|
1242 |
/* insert into beginning of list for this bucket */ |
1292 |
/* insert into beginning of list for this bucket */ |
1243 |
chain = (struct h_AddrHashChain *)malloc(sizeof(struct h_AddrHashChain)); |
1293 |
chain = (struct h_AddrHashChain *)malloc(sizeof(struct h_AddrHashChain)); |
1244 |
if (!chain) { |
1294 |
if (!chain) { |
1245 |
ViceLog(0, ("Failed malloc in hashInsert_r\n")); |
1295 |
ViceLog(0, ("Failed malloc in h_AddHostToAddrHashTable_r\n")); |
1246 |
assert(0); |
1296 |
assert(0); |
1247 |
} |
1297 |
} |
1248 |
chain->hostPtr = host; |
1298 |
chain->hostPtr = host; |
Lines 1250-1262
hashInsert_r(afs_uint32 addr, afs_uint16 port, struct host *host)
Link Here
|
1250 |
chain->addr = addr; |
1300 |
chain->addr = addr; |
1251 |
chain->port = port; |
1301 |
chain->port = port; |
1252 |
hostAddrHashTable[index] = chain; |
1302 |
hostAddrHashTable[index] = chain; |
|
|
1303 |
ViceLog(125, ("h_AddHostToAddrHashTable_r: host 0x%lx added as %s:%d\n", |
1304 |
(unsigned long) host, afs_inet_ntoa_r(addr, hoststr), ntohs(port))); |
1253 |
} |
1305 |
} |
1254 |
|
1306 |
|
1255 |
/* |
1307 |
/* |
1256 |
* This is called with host locked and held. At this point, the |
1308 |
* This is called with host locked and held. |
1257 |
* hostAddrHashTable should not have entries for the alternate |
1309 |
* It is called to either validate or add an additional interface |
1258 |
* interfaces. This function has to insert these entries in the |
1310 |
* address/port on the specified host. |
1259 |
* hostAddrHashTable. |
|
|
1260 |
* |
1311 |
* |
1261 |
* All addresses are in network byte order. |
1312 |
* All addresses are in network byte order. |
1262 |
*/ |
1313 |
*/ |
Lines 1279-1300
addInterfaceAddr_r(struct host *host, afs_uint32 addr, afs_uint16 port)
Link Here
|
1279 |
for (i = 0; i < number; i++) { |
1330 |
for (i = 0; i < number; i++) { |
1280 |
if (host->interface->interface[i].addr == addr && |
1331 |
if (host->interface->interface[i].addr == addr && |
1281 |
host->interface->interface[i].port == port) { |
1332 |
host->interface->interface[i].port == port) { |
1282 |
ViceLog(125, ("addInterfaceAddr : host %x (%s:%d) addr %s:%d : found, valid: %d\n", |
1333 |
ViceLog(125, |
1283 |
host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port), |
1334 |
("addInterfaceAddr : found host 0x%lx (%s:%d) adding %s:%d%s\n", |
1284 |
afs_inet_ntoa_r(addr, hoststr2), ntohs(port), |
1335 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), |
1285 |
host->interface->interface[i].valid)); |
1336 |
ntohs(host->port), afs_inet_ntoa_r(addr, hoststr2), |
|
|
1337 |
ntohs(port), host->interface->interface[i].valid ? "" : |
1338 |
", validating")); |
1286 |
|
1339 |
|
1287 |
if (host->interface->interface[i].valid == 0) { |
1340 |
if (host->interface->interface[i].valid == 0) { |
1288 |
hashInsert_r(addr, port, host); |
|
|
1289 |
host->interface->interface[i].valid = 1; |
1341 |
host->interface->interface[i].valid = 1; |
|
|
1342 |
h_AddHostToAddrHashTable_r(addr, port, host); |
1290 |
} |
1343 |
} |
1291 |
return 0; |
1344 |
return 0; |
1292 |
} |
1345 |
} |
1293 |
} |
1346 |
} |
1294 |
|
1347 |
|
1295 |
ViceLog(125, ("addInterfaceAddr : host %x (%s:%d) addr %s:%d : not found, adding\n", |
1348 |
ViceLog(125, ("addInterfaceAddr : host 0x%lx (%s:%d) adding %s:%d\n", |
1296 |
host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port), |
1349 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), |
1297 |
afs_inet_ntoa_r(addr, hoststr2), ntohs(port))); |
1350 |
ntohs(host->port), afs_inet_ntoa_r(addr, hoststr2), |
|
|
1351 |
ntohs(port))); |
1298 |
|
1352 |
|
1299 |
interface = (struct Interface *) |
1353 |
interface = (struct Interface *) |
1300 |
malloc(sizeof(struct Interface) + (sizeof(struct AddrPort) * number)); |
1354 |
malloc(sizeof(struct Interface) + (sizeof(struct AddrPort) * number)); |
Lines 1306-1314
addInterfaceAddr_r(struct host *host, afs_uint32 addr, afs_uint16 port)
Link Here
|
1306 |
interface->uuid = host->interface->uuid; |
1360 |
interface->uuid = host->interface->uuid; |
1307 |
for (i = 0; i < number; i++) |
1361 |
for (i = 0; i < number; i++) |
1308 |
interface->interface[i] = host->interface->interface[i]; |
1362 |
interface->interface[i] = host->interface->interface[i]; |
|
|
1363 |
|
1364 |
/* Add the new valid interface */ |
1309 |
interface->interface[number].addr = addr; |
1365 |
interface->interface[number].addr = addr; |
1310 |
interface->interface[number].port = port; |
1366 |
interface->interface[number].port = port; |
1311 |
interface->interface[number].valid = 1; |
1367 |
interface->interface[number].valid = 1; |
|
|
1368 |
h_AddHostToAddrHashTable_r(addr, port, host); |
1312 |
free(host->interface); |
1369 |
free(host->interface); |
1313 |
host->interface = interface; |
1370 |
host->interface = interface; |
1314 |
|
1371 |
|
Lines 1317-1326
addInterfaceAddr_r(struct host *host, afs_uint32 addr, afs_uint16 port)
Link Here
|
1317 |
|
1374 |
|
1318 |
|
1375 |
|
1319 |
/* |
1376 |
/* |
1320 |
* This is called with host locked and held. At this point, the |
1377 |
* This is called with host locked and held. |
1321 |
* hostAddrHashTable should not be having entries for the alternate |
|
|
1322 |
* interfaces. This function has to insert these entries in the |
1323 |
* hostAddrHashTable. |
1324 |
* |
1378 |
* |
1325 |
* All addresses are in network byte order. |
1379 |
* All addresses are in network byte order. |
1326 |
*/ |
1380 |
*/ |
Lines 1329-1344
removeInterfaceAddr_r(struct host *host, afs_uint32 addr, afs_uint16 port)
Link Here
|
1329 |
{ |
1383 |
{ |
1330 |
int i; |
1384 |
int i; |
1331 |
int number; |
1385 |
int number; |
1332 |
int found; |
|
|
1333 |
struct Interface *interface; |
1386 |
struct Interface *interface; |
1334 |
char hoststr[16], hoststr2[16]; |
1387 |
char hoststr[16], hoststr2[16]; |
1335 |
|
1388 |
|
1336 |
assert(host); |
1389 |
assert(host); |
1337 |
assert(host->interface); |
1390 |
assert(host->interface); |
1338 |
|
1391 |
|
1339 |
ViceLog(125, ("removeInterfaceAddr : host %x (%s:%d) addr %s:%d\n", |
1392 |
ViceLog(125, ("removeInterfaceAddr : host 0x%lx (%s:%d) addr %s:%d\n", |
1340 |
host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port), |
1393 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), |
1341 |
afs_inet_ntoa_r(addr, hoststr2), ntohs(port))); |
1394 |
ntohs(host->port), afs_inet_ntoa_r(addr, hoststr2), |
|
|
1395 |
ntohs(port))); |
1342 |
|
1396 |
|
1343 |
/* |
1397 |
/* |
1344 |
* Make sure this address is on the list of known addresses |
1398 |
* Make sure this address is on the list of known addresses |
Lines 1346-1371
removeInterfaceAddr_r(struct host *host, afs_uint32 addr, afs_uint16 port)
Link Here
|
1346 |
*/ |
1400 |
*/ |
1347 |
interface = host->interface; |
1401 |
interface = host->interface; |
1348 |
number = host->interface->numberOfInterfaces; |
1402 |
number = host->interface->numberOfInterfaces; |
1349 |
for (i = 0, found = 0; i < number && !found; i++) { |
1403 |
for (i = 0; i < number; i++) { |
1350 |
if (interface->interface[i].addr == addr && |
1404 |
if (interface->interface[i].addr == addr && |
1351 |
interface->interface[i].port == port) { |
1405 |
interface->interface[i].port == port) { |
1352 |
found = 1; |
1406 |
if (interface->interface[i].valid) |
1353 |
interface->interface[i].valid = 0; |
1407 |
h_DeleteHostFromAddrHashTable_r(addr, port, host); |
1354 |
} |
1408 |
number--; |
1355 |
} |
1409 |
for (; i < number; i++) { |
1356 |
if (found) { |
1410 |
interface->interface[i] = interface->interface[i+1]; |
1357 |
number--; |
1411 |
} |
1358 |
for (; i < number; i++) { |
1412 |
interface->numberOfInterfaces = number; |
1359 |
interface->interface[i] = interface->interface[i+1]; |
1413 |
return 0; |
1360 |
} |
1414 |
} |
1361 |
interface->numberOfInterfaces = number; |
1415 |
} |
1362 |
} |
1416 |
/* not found */ |
|
|
1417 |
return 0; |
1418 |
} |
1419 |
|
1420 |
/* |
1421 |
* This is called with host locked and held. |
1422 |
* |
1423 |
* All addresses are in network byte order. |
1424 |
*/ |
1425 |
int |
1426 |
invalidateInterfaceAddr_r(struct host *host, afs_uint32 addr, afs_uint16 port) |
1427 |
{ |
1428 |
int i; |
1429 |
int number; |
1430 |
struct Interface *interface; |
1431 |
char hoststr[16], hoststr2[16]; |
1432 |
|
1433 |
assert(host); |
1434 |
assert(host->interface); |
1435 |
|
1436 |
ViceLog(125, ("invalidateInterfaceAddr : host 0x%lx (%s:%d) addr %s:%d\n", |
1437 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), |
1438 |
ntohs(host->port), afs_inet_ntoa_r(addr, hoststr2), |
1439 |
ntohs(port))); |
1363 |
|
1440 |
|
1364 |
/* |
1441 |
/* |
1365 |
* Remove the hash table entry for this address |
1442 |
* Make sure this address is on the list of known addresses |
|
|
1443 |
* for this host. |
1366 |
*/ |
1444 |
*/ |
1367 |
hashDelete_r(addr, port, host); |
1445 |
interface = host->interface; |
1368 |
|
1446 |
number = host->interface->numberOfInterfaces; |
|
|
1447 |
for (i = 0; i < number; i++) { |
1448 |
if (interface->interface[i].addr == addr && |
1449 |
interface->interface[i].port == port) { |
1450 |
if (interface->interface[i].valid) { |
1451 |
h_DeleteHostFromAddrHashTable_r(addr, port, host); |
1452 |
interface->interface[i].valid = 0; |
1453 |
} |
1454 |
return 0; |
1455 |
} |
1456 |
} |
1457 |
|
1458 |
/* not found */ |
1369 |
return 0; |
1459 |
return 0; |
1370 |
} |
1460 |
} |
1371 |
|
1461 |
|
Lines 1383-1444
removeAddress_r(struct host *host, afs_uint32 addr, afs_uint16 port)
Link Here
|
1383 |
{ |
1473 |
{ |
1384 |
int i; |
1474 |
int i; |
1385 |
char hoststr[16], hoststr2[16]; |
1475 |
char hoststr[16], hoststr2[16]; |
|
|
1476 |
struct rx_connection *rxconn; |
1386 |
|
1477 |
|
1387 |
if (!host->interface) { |
1478 |
if (!host->interface || host->interface->numberOfInterfaces == 1) { |
1388 |
if (host->host == addr && host->port == port) { |
1479 |
if (host->host == addr && host->port == port) { |
1389 |
ViceLog(25, |
1480 |
ViceLog(25, |
1390 |
("Removing only address for host %x (%s:%d), deleting host.\n", |
1481 |
("Removing only address for host 0x%lx (%s:%d), deleting host.\n", |
1391 |
host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); |
1482 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); |
1392 |
host->hostFlags |= HOSTDELETED; |
1483 |
host->hostFlags |= HOSTDELETED; |
|
|
1484 |
/* |
1485 |
* Do not remove the primary addr/port from the hash table. |
1486 |
* It will be ignored due to the HOSTDELETED flag and will |
1487 |
* be removed when h_TossStuff_r() cleans up the HOSTDELETED |
1488 |
* host. Removing it here will only result in a search for |
1489 |
* the host/addr/port in the hash chain which will fail. |
1490 |
*/ |
1491 |
} else { |
1492 |
ViceLog(0, |
1493 |
("Removing address that does not belong to host 0x%lx (%s:%d).\n", |
1494 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); |
1393 |
} |
1495 |
} |
1394 |
} else { |
1496 |
} else { |
1395 |
removeInterfaceAddr_r(host, host->host, host->port); |
1497 |
if (host->host == addr && host->port == port) { |
1396 |
if (host->interface->numberOfInterfaces == 0) { |
1498 |
removeInterfaceAddr_r(host, addr, port); |
1397 |
ViceLog(25, |
|
|
1398 |
("Removed only address for host %x (%s:%d), no alternate interfaces, deleting host.\n", |
1399 |
host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); |
1400 |
host->hostFlags |= HOSTDELETED; |
1401 |
} else { |
1402 |
|
1499 |
|
1403 |
for (i=0; i < host->interface->numberOfInterfaces; i++) { |
1500 |
for (i=0; i < host->interface->numberOfInterfaces; i++) { |
1404 |
if (host->interface->interface[i].valid) { |
1501 |
if (host->interface->interface[i].valid) { |
1405 |
ViceLog(25, |
1502 |
ViceLog(25, |
1406 |
("Removed address for host %x (%s:%d), new primary interface %s:%d.\n", |
1503 |
("Removed address for host 0x%lx (%s:%d), new primary interface %s:%d.\n", |
1407 |
host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port), |
1504 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port), |
1408 |
afs_inet_ntoa_r(host->interface->interface[i].addr, hoststr2), |
1505 |
afs_inet_ntoa_r(host->interface->interface[i].addr, hoststr2), |
1409 |
ntohs(host->interface->interface[i].port))); |
1506 |
ntohs(host->interface->interface[i].port))); |
1410 |
host->host = host->interface->interface[i].addr; |
1507 |
host->host = host->interface->interface[i].addr; |
1411 |
host->port = host->interface->interface[i].port; |
1508 |
host->port = host->interface->interface[i].port; |
1412 |
hashInsert_r(host->host, host->port, host); |
1509 |
h_AddHostToAddrHashTable_r(host->host, host->port, host); |
1413 |
break; |
1510 |
break; |
1414 |
} |
1511 |
} |
1415 |
} |
1512 |
} |
1416 |
|
1513 |
|
1417 |
if (i == host->interface->numberOfInterfaces) { |
1514 |
if (i == host->interface->numberOfInterfaces) { |
1418 |
ViceLog(25, |
1515 |
ViceLog(25, |
1419 |
("Removed only address for host %x (%s:%d), no valid alternate interfaces, deleting host.\n", |
1516 |
("Removed only address for host 0x%lx (%s:%d), no valid alternate interfaces, deleting host.\n", |
1420 |
host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); |
1517 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); |
1421 |
host->hostFlags |= HOSTDELETED; |
1518 |
host->hostFlags |= HOSTDELETED; |
|
|
1519 |
/* addr/port was removed from the hash table */ |
1520 |
host->host = 0; |
1521 |
host->port = 0; |
1422 |
} else { |
1522 |
} else { |
1423 |
struct rx_connection *rxconn; |
|
|
1424 |
|
1425 |
rxconn = host->callback_rxcon; |
1426 |
host->callback_rxcon = NULL; |
1427 |
|
1428 |
if (rxconn) { |
1429 |
struct client *client; |
1430 |
/* |
1431 |
* If rx_DestroyConnection calls h_FreeConnection we will |
1432 |
* deadlock on the host_glock_mutex. Work around the problem |
1433 |
* by unhooking the client from the connection before |
1434 |
* destroying the connection. |
1435 |
*/ |
1436 |
client = rx_GetSpecific(rxconn, rxcon_client_key); |
1437 |
rx_SetSpecific(rxconn, rxcon_client_key, (void *)0); |
1438 |
rx_DestroyConnection(rxconn); |
1439 |
rxconn = NULL; |
1440 |
} |
1441 |
|
1442 |
if (!sc) |
1523 |
if (!sc) |
1443 |
sc = rxnull_NewClientSecurityObject(); |
1524 |
sc = rxnull_NewClientSecurityObject(); |
1444 |
host->callback_rxcon = |
1525 |
host->callback_rxcon = |
Lines 1446-1451
removeAddress_r(struct host *host, afs_uint32 addr, afs_uint16 port)
Link Here
|
1446 |
rx_SetConnDeadTime(host->callback_rxcon, 50); |
1527 |
rx_SetConnDeadTime(host->callback_rxcon, 50); |
1447 |
rx_SetConnHardDeadTime(host->callback_rxcon, AFS_HARDDEADTIME); |
1528 |
rx_SetConnHardDeadTime(host->callback_rxcon, AFS_HARDDEADTIME); |
1448 |
} |
1529 |
} |
|
|
1530 |
} else { |
1531 |
/* not the primary addr/port, just invalidate it */ |
1532 |
invalidateInterfaceAddr_r(host, addr, port); |
1449 |
} |
1533 |
} |
1450 |
} |
1534 |
} |
1451 |
|
1535 |
|
Lines 1527-1534
h_GetHost_r(struct rx_connection *tcon, int *heldp)
Link Here
|
1527 |
* waited for the lock. */ |
1611 |
* waited for the lock. */ |
1528 |
h_Unlock_r(host); |
1612 |
h_Unlock_r(host); |
1529 |
ViceLog(125, |
1613 |
ViceLog(125, |
1530 |
("Host %s:%d starting h_Lookup again\n", |
1614 |
("Host 0x%lx (%s:%d) starting h_Lookup again\n", |
1531 |
afs_inet_ntoa_r(host->host, hoststr), |
1615 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), |
1532 |
ntohs(host->port))); |
1616 |
ntohs(host->port))); |
1533 |
if (!*heldp) |
1617 |
if (!*heldp) |
1534 |
h_Release_r(host); |
1618 |
h_Release_r(host); |
Lines 1594-1601
h_GetHost_r(struct rx_connection *tcon, int *heldp)
Link Here
|
1594 |
* that we maintain some extra callback state information */ |
1678 |
* that we maintain some extra callback state information */ |
1595 |
if (host->interface) { |
1679 |
if (host->interface) { |
1596 |
ViceLog(0, |
1680 |
ViceLog(0, |
1597 |
("Host %x (%s:%d) used to support WhoAreYou, deleting.\n", |
1681 |
("Host 0x%lx (%s:%d) used to support WhoAreYou, deleting.\n", |
1598 |
host, |
1682 |
(unsigned long) host, |
1599 |
afs_inet_ntoa_r(host->host, hoststr), |
1683 |
afs_inet_ntoa_r(host->host, hoststr), |
1600 |
ntohs(host->port))); |
1684 |
ntohs(host->port))); |
1601 |
host->hostFlags |= HOSTDELETED; |
1685 |
host->hostFlags |= HOSTDELETED; |
Lines 1646-1653
h_GetHost_r(struct rx_connection *tcon, int *heldp)
Link Here
|
1646 |
removeAddress_r(host, haddr, hport); |
1730 |
removeAddress_r(host, haddr, hport); |
1647 |
} else { |
1731 |
} else { |
1648 |
ViceLog(25, |
1732 |
ViceLog(25, |
1649 |
("Uuid doesn't match host %x (%s:%d).\n", |
1733 |
("Uuid doesn't match host 0x%lx (%s:%d).\n", |
1650 |
host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); |
1734 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); |
1651 |
|
1735 |
|
1652 |
removeAddress_r(host, host->host, host->port); |
1736 |
removeAddress_r(host, host->host, host->port); |
1653 |
} |
1737 |
} |
Lines 1684-1691
h_GetHost_r(struct rx_connection *tcon, int *heldp)
Link Here
|
1684 |
* callback connection, and destroy the old one. |
1768 |
* callback connection, and destroy the old one. |
1685 |
*/ |
1769 |
*/ |
1686 |
struct rx_connection *rxconn; |
1770 |
struct rx_connection *rxconn; |
1687 |
ViceLog(0,("CB: ProbeUuid for host %x (%s:%d) failed %d\n", |
1771 |
ViceLog(0,("CB: ProbeUuid for host 0x%lx (%s:%d) failed %d\n", |
1688 |
host, |
1772 |
(unsigned long) host, |
1689 |
afs_inet_ntoa_r(host->host, hoststr), |
1773 |
afs_inet_ntoa_r(host->host, hoststr), |
1690 |
ntohs(host->port),code2)); |
1774 |
ntohs(host->port),code2)); |
1691 |
/* |
1775 |
/* |
Lines 1736-1743
h_GetHost_r(struct rx_connection *tcon, int *heldp)
Link Here
|
1736 |
goto gethost_out; |
1820 |
goto gethost_out; |
1737 |
} else { |
1821 |
} else { |
1738 |
ViceLog(0, |
1822 |
ViceLog(0, |
1739 |
("CB: WhoAreYou failed for host %x (%s:%d), error %d\n", |
1823 |
("CB: WhoAreYou failed for host 0x%lx (%s:%d), error %d\n", |
1740 |
host, afs_inet_ntoa_r(host->host, hoststr), |
1824 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), |
1741 |
ntohs(host->port), code)); |
1825 |
ntohs(host->port), code)); |
1742 |
host->hostFlags |= VENUSDOWN; |
1826 |
host->hostFlags |= VENUSDOWN; |
1743 |
} |
1827 |
} |
Lines 1754-1767
h_GetHost_r(struct rx_connection *tcon, int *heldp)
Link Here
|
1754 |
if (!(host->hostFlags & ALTADDR)) { |
1838 |
if (!(host->hostFlags & ALTADDR)) { |
1755 |
/* another thread is doing the initialisation */ |
1839 |
/* another thread is doing the initialisation */ |
1756 |
ViceLog(125, |
1840 |
ViceLog(125, |
1757 |
("Host %s:%d waiting for host-init to complete\n", |
1841 |
("Host 0x%lx (%s:%d) waiting for host-init to complete\n", |
1758 |
afs_inet_ntoa_r(host->host, hoststr), |
1842 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), |
1759 |
ntohs(host->port))); |
1843 |
ntohs(host->port))); |
1760 |
h_Lock_r(host); |
1844 |
h_Lock_r(host); |
1761 |
h_Unlock_r(host); |
1845 |
h_Unlock_r(host); |
1762 |
ViceLog(125, |
1846 |
ViceLog(125, |
1763 |
("Host %s:%d starting h_Lookup again\n", |
1847 |
("Host 0x%lx (%s:%d) starting h_Lookup again\n", |
1764 |
afs_inet_ntoa_r(host->host, hoststr), |
1848 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), |
1765 |
ntohs(host->port))); |
1849 |
ntohs(host->port))); |
1766 |
if (!*heldp) |
1850 |
if (!*heldp) |
1767 |
h_Release_r(host); |
1851 |
h_Release_r(host); |
Lines 1782-1789
h_GetHost_r(struct rx_connection *tcon, int *heldp)
Link Here
|
1782 |
if (host->interface) |
1866 |
if (host->interface) |
1783 |
afsUUID_to_string(&host->interface->uuid, uuid2, 127); |
1867 |
afsUUID_to_string(&host->interface->uuid, uuid2, 127); |
1784 |
ViceLog(0, |
1868 |
ViceLog(0, |
1785 |
("CB: new identity for host %s:%d, deleting(%x %x %s %s)\n", |
1869 |
("CB: new identity for host 0x%lx (%s:%d), deleting(%x %x %s %s)\n", |
1786 |
afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port), |
1870 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port), |
1787 |
identP->valid, host->interface, |
1871 |
identP->valid, host->interface, |
1788 |
identP->valid ? uuid1 : "", |
1872 |
identP->valid ? uuid1 : "", |
1789 |
host->interface ? uuid2 : "")); |
1873 |
host->interface ? uuid2 : "")); |
Lines 1829-1836
h_GetHost_r(struct rx_connection *tcon, int *heldp)
Link Here
|
1829 |
if (!pident) |
1913 |
if (!pident) |
1830 |
rx_SetSpecific(tcon, rxcon_ident_key, identP); |
1914 |
rx_SetSpecific(tcon, rxcon_ident_key, identP); |
1831 |
ViceLog(25, |
1915 |
ViceLog(25, |
1832 |
("Host %s:%d does not support WhoAreYou.\n", |
1916 |
("Host 0x%lx (%s:%d) does not support WhoAreYou.\n", |
1833 |
afs_inet_ntoa_r(host->host, hoststr), |
1917 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), |
1834 |
ntohs(host->port))); |
1918 |
ntohs(host->port))); |
1835 |
code = 0; |
1919 |
code = 0; |
1836 |
} else if (code == 0) { |
1920 |
} else if (code == 0) { |
Lines 1850-1857
h_GetHost_r(struct rx_connection *tcon, int *heldp)
Link Here
|
1850 |
if (!pident) |
1934 |
if (!pident) |
1851 |
rx_SetSpecific(tcon, rxcon_ident_key, identP); |
1935 |
rx_SetSpecific(tcon, rxcon_ident_key, identP); |
1852 |
ViceLog(25, |
1936 |
ViceLog(25, |
1853 |
("WhoAreYou success on %s:%d\n", |
1937 |
("WhoAreYou success on 0x%lx (%s:%d)\n", |
1854 |
afs_inet_ntoa_r(host->host, hoststr), |
1938 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), |
1855 |
ntohs(host->port))); |
1939 |
ntohs(host->port))); |
1856 |
} |
1940 |
} |
1857 |
if (code == 0 && !identP->valid) { |
1941 |
if (code == 0 && !identP->valid) { |
Lines 1906-1913
h_GetHost_r(struct rx_connection *tcon, int *heldp)
Link Here
|
1906 |
* MultiProbeAlternateAddress_r() will remove the |
1990 |
* MultiProbeAlternateAddress_r() will remove the |
1907 |
* alternate interfaces that do not have the same |
1991 |
* alternate interfaces that do not have the same |
1908 |
* Uuid. */ |
1992 |
* Uuid. */ |
1909 |
ViceLog(0,("CB: ProbeUuid for %s:%d failed %d\n", |
1993 |
ViceLog(0,("CB: ProbeUuid for 0x%lx (%s:%d) failed %d\n", |
1910 |
afs_inet_ntoa_r(oldHost->host, hoststr), |
1994 |
(unsigned long) oldHost, afs_inet_ntoa_r(oldHost->host, hoststr), |
1911 |
ntohs(oldHost->port),code2)); |
1995 |
ntohs(oldHost->port),code2)); |
1912 |
MultiProbeAlternateAddress_r(oldHost); |
1996 |
MultiProbeAlternateAddress_r(oldHost); |
1913 |
probefail = 1; |
1997 |
probefail = 1; |
Lines 1927-1934
h_GetHost_r(struct rx_connection *tcon, int *heldp)
Link Here
|
1927 |
struct rx_connection *rxconn; |
2011 |
struct rx_connection *rxconn; |
1928 |
|
2012 |
|
1929 |
ViceLog(25, |
2013 |
ViceLog(25, |
1930 |
("CB: Host %x (%s:%d) has new addr %s:%d\n", |
2014 |
("CB: Host 0x%lx (%s:%d) has new addr %s:%d\n", |
1931 |
oldHost, |
2015 |
(unsigned long) oldHost, |
1932 |
afs_inet_ntoa_r(oldHost->host, hoststr2), |
2016 |
afs_inet_ntoa_r(oldHost->host, hoststr2), |
1933 |
ntohs(oldHost->port), |
2017 |
ntohs(oldHost->port), |
1934 |
afs_inet_ntoa_r(haddr, hoststr), |
2018 |
afs_inet_ntoa_r(haddr, hoststr), |
Lines 1947-1969
h_GetHost_r(struct rx_connection *tcon, int *heldp)
Link Here
|
1947 |
*/ |
2031 |
*/ |
1948 |
removeInterfaceAddr_r(oldHost, oldHost->host, oldHost->port); |
2032 |
removeInterfaceAddr_r(oldHost, oldHost->host, oldHost->port); |
1949 |
} else { |
2033 |
} else { |
1950 |
int i, found; |
2034 |
int i; |
1951 |
struct Interface *interface = oldHost->interface; |
2035 |
struct Interface *interface = oldHost->interface; |
1952 |
int number = oldHost->interface->numberOfInterfaces; |
2036 |
int number = oldHost->interface->numberOfInterfaces; |
1953 |
for (i = 0, found = 0; i < number; i++) { |
2037 |
for (i = 0; i < number; i++) { |
1954 |
if (interface->interface[i].addr == haddr && |
2038 |
if (interface->interface[i].addr == haddr && |
1955 |
interface->interface[i].port != hport) { |
2039 |
interface->interface[i].port != hport) { |
1956 |
found = 1; |
2040 |
/* |
|
|
2041 |
* We have just been contacted by a client |
2042 |
* that has been seen from behind a NAT |
2043 |
* and at least one other address. |
2044 |
*/ |
2045 |
removeInterfaceAddr_r(oldHost, haddr, |
2046 |
interface->interface[i].port); |
1957 |
break; |
2047 |
break; |
1958 |
} |
2048 |
} |
1959 |
} |
2049 |
} |
1960 |
if (found) { |
|
|
1961 |
/* We have just been contacted by a client that has been |
1962 |
* seen from behind a NAT and at least one other address. |
1963 |
*/ |
1964 |
removeInterfaceAddr_r(oldHost, haddr, interface->interface[i].port); |
1965 |
} |
1966 |
} |
2050 |
} |
|
|
2051 |
h_AddHostToAddrHashTable_r(haddr, hport, oldHost); |
1967 |
oldHost->host = haddr; |
2052 |
oldHost->host = haddr; |
1968 |
oldHost->port = hport; |
2053 |
oldHost->port = hport; |
1969 |
rxconn = oldHost->callback_rxcon; |
2054 |
rxconn = oldHost->callback_rxcon; |
Lines 1982-1988
h_GetHost_r(struct rx_connection *tcon, int *heldp)
Link Here
|
1982 |
/* the new host is held and locked */ |
2067 |
/* the new host is held and locked */ |
1983 |
} else { |
2068 |
} else { |
1984 |
/* This really is a new host */ |
2069 |
/* This really is a new host */ |
1985 |
hashInsertUuid_r(&identP->uuid, host); |
2070 |
h_AddHostToUuidHashTable_r(&identP->uuid, host); |
1986 |
cb_conn = host->callback_rxcon; |
2071 |
cb_conn = host->callback_rxcon; |
1987 |
rx_GetConnection(cb_conn); |
2072 |
rx_GetConnection(cb_conn); |
1988 |
H_UNLOCK; |
2073 |
H_UNLOCK; |
Lines 1994-2001
h_GetHost_r(struct rx_connection *tcon, int *heldp)
Link Here
|
1994 |
H_LOCK; |
2079 |
H_LOCK; |
1995 |
if (code == 0) { |
2080 |
if (code == 0) { |
1996 |
ViceLog(25, |
2081 |
ViceLog(25, |
1997 |
("InitCallBackState3 success on %s:%d\n", |
2082 |
("InitCallBackState3 success on 0x%lx (%s:%d)\n", |
1998 |
afs_inet_ntoa_r(host->host, hoststr), |
2083 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), |
1999 |
ntohs(host->port))); |
2084 |
ntohs(host->port))); |
2000 |
assert(interfValid == 1); |
2085 |
assert(interfValid == 1); |
2001 |
initInterfaceAddr_r(host, &interf); |
2086 |
initInterfaceAddr_r(host, &interf); |
Lines 2004-2016
h_GetHost_r(struct rx_connection *tcon, int *heldp)
Link Here
|
2004 |
} |
2089 |
} |
2005 |
if (code) { |
2090 |
if (code) { |
2006 |
ViceLog(0, |
2091 |
ViceLog(0, |
2007 |
("CB: RCallBackConnectBack failed for host %x (%s:%d)\n", |
2092 |
("CB: RCallBackConnectBack failed for host 0x%lx (%s:%d)\n", |
2008 |
host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); |
2093 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); |
2009 |
host->hostFlags |= VENUSDOWN; |
2094 |
host->hostFlags |= VENUSDOWN; |
2010 |
} else { |
2095 |
} else { |
2011 |
ViceLog(125, |
2096 |
ViceLog(125, |
2012 |
("CB: RCallBackConnectBack succeeded for host %x (%s:%d)\n", |
2097 |
("CB: RCallBackConnectBack succeeded for host 0x%lx (%s:%d)\n", |
2013 |
host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); |
2098 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); |
2014 |
host->hostFlags |= RESETDONE; |
2099 |
host->hostFlags |= RESETDONE; |
2015 |
} |
2100 |
} |
2016 |
} |
2101 |
} |
Lines 2358-2365
h_FindClient_r(struct rx_connection *tcon)
Link Here
|
2358 |
if (code) { |
2443 |
if (code) { |
2359 |
char hoststr[16]; |
2444 |
char hoststr[16]; |
2360 |
ViceLog(0, |
2445 |
ViceLog(0, |
2361 |
("pr_GetCPS failed(%d) for user %d, host %s:%d\n", |
2446 |
("pr_GetCPS failed(%d) for user %d, host 0x%lx (%s:%d)\n", |
2362 |
code, viceid, afs_inet_ntoa_r(client->host->host, |
2447 |
code, viceid, (unsigned long) client->host, afs_inet_ntoa_r(client->host->host, |
2363 |
hoststr), |
2448 |
hoststr), |
2364 |
ntohs(client->host->port))); |
2449 |
ntohs(client->host->port))); |
2365 |
|
2450 |
|
Lines 2582-2589
h_PrintClient(register struct host *host, int held, StreamHandle_t * file)
Link Here
|
2582 |
char tmpStr[256]; |
2667 |
char tmpStr[256]; |
2583 |
char tbuffer[32]; |
2668 |
char tbuffer[32]; |
2584 |
char hoststr[16]; |
2669 |
char hoststr[16]; |
|
|
2670 |
time_t LastCall, expTime; |
2585 |
|
2671 |
|
2586 |
H_LOCK; |
2672 |
H_LOCK; |
|
|
2673 |
LastCall = host->LastCall; |
2587 |
if (host->hostFlags & HOSTDELETED) { |
2674 |
if (host->hostFlags & HOSTDELETED) { |
2588 |
H_UNLOCK; |
2675 |
H_UNLOCK; |
2589 |
return held; |
2676 |
return held; |
Lines 2592-2602
h_PrintClient(register struct host *host, int held, StreamHandle_t * file)
Link Here
|
2592 |
"Host %s:%d down = %d, LastCall %s", |
2679 |
"Host %s:%d down = %d, LastCall %s", |
2593 |
afs_inet_ntoa_r(host->host, hoststr), |
2680 |
afs_inet_ntoa_r(host->host, hoststr), |
2594 |
ntohs(host->port), (host->hostFlags & VENUSDOWN), |
2681 |
ntohs(host->port), (host->hostFlags & VENUSDOWN), |
2595 |
afs_ctime((time_t *) & host->LastCall, tbuffer, |
2682 |
afs_ctime(&LastCall, tbuffer, |
2596 |
sizeof(tbuffer))); |
2683 |
sizeof(tbuffer))); |
2597 |
(void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file); |
2684 |
(void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file); |
2598 |
for (client = host->FirstClient; client; client = client->next) { |
2685 |
for (client = host->FirstClient; client; client = client->next) { |
2599 |
if (!client->deleted) { |
2686 |
if (!client->deleted) { |
|
|
2687 |
expTime = client->expTime; |
2600 |
(void)afs_snprintf(tmpStr, sizeof tmpStr, |
2688 |
(void)afs_snprintf(tmpStr, sizeof tmpStr, |
2601 |
" user id=%d, name=%s, sl=%s till %s", |
2689 |
" user id=%d, name=%s, sl=%s till %s", |
2602 |
client->ViceId, h_UserName(client), |
2690 |
client->ViceId, h_UserName(client), |
Lines 2604-2611
h_PrintClient(register struct host *host, int held, StreamHandle_t * file)
Link Here
|
2604 |
authClass ? "Authenticated" : |
2692 |
authClass ? "Authenticated" : |
2605 |
"Not authenticated", |
2693 |
"Not authenticated", |
2606 |
client-> |
2694 |
client-> |
2607 |
authClass ? afs_ctime((time_t *) & client-> |
2695 |
authClass ? afs_ctime(&expTime, tbuffer, |
2608 |
expTime, tbuffer, |
|
|
2609 |
sizeof(tbuffer)) |
2696 |
sizeof(tbuffer)) |
2610 |
: "No Limit\n"); |
2697 |
: "No Limit\n"); |
2611 |
(void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file); |
2698 |
(void)STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file); |
Lines 3012-3018
CheckHost(register struct host *host, int held)
Link Here
|
3012 |
* back state, because break delayed callbacks (called when a |
3099 |
* back state, because break delayed callbacks (called when a |
3013 |
* message is received from the workstation) will always send a |
3100 |
* message is received from the workstation) will always send a |
3014 |
* break all call backs to the workstation if there is no |
3101 |
* break all call backs to the workstation if there is no |
3015 |
*callback. |
3102 |
* callback. |
3016 |
*/ |
3103 |
*/ |
3017 |
} |
3104 |
} |
3018 |
} else { |
3105 |
} else { |
Lines 3105-3111
CheckHost_r(register struct host *host, int held, char *dummy)
Link Here
|
3105 |
* back state, because break delayed callbacks (called when a |
3192 |
* back state, because break delayed callbacks (called when a |
3106 |
* message is received from the workstation) will always send a |
3193 |
* message is received from the workstation) will always send a |
3107 |
* break all call backs to the workstation if there is no |
3194 |
* break all call backs to the workstation if there is no |
3108 |
*callback. |
3195 |
* callback. |
3109 |
*/ |
3196 |
*/ |
3110 |
} |
3197 |
} |
3111 |
} else { |
3198 |
} else { |
Lines 3178-3186
h_CheckHosts()
Link Here
|
3178 |
|
3265 |
|
3179 |
/* |
3266 |
/* |
3180 |
* This is called with host locked and held. At this point, the |
3267 |
* This is called with host locked and held. At this point, the |
3181 |
* hostAddrHashTable should not have any entries for the alternate |
3268 |
* hostAddrHashTable has an entry for the primary addr/port inserted |
3182 |
* interfaces. This function has to insert these entries in the |
3269 |
* by h_Alloc_r(). No other interfaces should be considered valid. |
3183 |
* hostAddrHashTable. |
|
|
3184 |
* |
3270 |
* |
3185 |
* The addresses in the interfaceAddr list are in host byte order. |
3271 |
* The addresses in the interfaceAddr list are in host byte order. |
3186 |
*/ |
3272 |
*/ |
Lines 3298-3304
initInterfaceAddr_r(struct host *host, struct interfaceAddr *interf)
Link Here
|
3298 |
* are coming from fully connected hosts (no NAT/PATs) |
3384 |
* are coming from fully connected hosts (no NAT/PATs) |
3299 |
*/ |
3385 |
*/ |
3300 |
interface->interface[i].port = port7001; |
3386 |
interface->interface[i].port = port7001; |
3301 |
interface->interface[i].valid = 1; /* valid until a conflict is found */ |
3387 |
interface->interface[i].valid = |
|
|
3388 |
(interf->addr_in[i] == myAddr && port7001 == myPort) ? 1 : 0; |
3302 |
} |
3389 |
} |
3303 |
|
3390 |
|
3304 |
interface->uuid = interf->uuid; |
3391 |
interface->uuid = interf->uuid; |
Lines 3306-3318
initInterfaceAddr_r(struct host *host, struct interfaceAddr *interf)
Link Here
|
3306 |
assert(!host->interface); |
3393 |
assert(!host->interface); |
3307 |
host->interface = interface; |
3394 |
host->interface = interface; |
3308 |
|
3395 |
|
3309 |
afsUUID_to_string(&interface->uuid, uuidstr, 127); |
3396 |
if (LogLevel >= 125) { |
3310 |
|
3397 |
afsUUID_to_string(&interface->uuid, uuidstr, 127); |
3311 |
ViceLog(125, ("--- uuid %s\n", uuidstr)); |
3398 |
|
3312 |
for (i = 0; i < host->interface->numberOfInterfaces; i++) { |
3399 |
ViceLog(125, ("--- uuid %s\n", uuidstr)); |
3313 |
ViceLog(125, ("--- alt address %s:%d\n", |
3400 |
for (i = 0; i < host->interface->numberOfInterfaces; i++) { |
3314 |
afs_inet_ntoa_r(host->interface->interface[i].addr, hoststr), |
3401 |
ViceLog(125, ("--- alt address %s:%d\n", |
3315 |
ntohs(host->interface->interface[i].port))); |
3402 |
afs_inet_ntoa_r(host->interface->interface[i].addr, hoststr), |
|
|
3403 |
ntohs(host->interface->interface[i].port))); |
3404 |
} |
3316 |
} |
3405 |
} |
3317 |
|
3406 |
|
3318 |
return 0; |
3407 |
return 0; |
Lines 3321-3344
initInterfaceAddr_r(struct host *host, struct interfaceAddr *interf)
Link Here
|
3321 |
/* deleted a HashChain structure for this address and host */ |
3410 |
/* deleted a HashChain structure for this address and host */ |
3322 |
/* returns 1 on success */ |
3411 |
/* returns 1 on success */ |
3323 |
int |
3412 |
int |
3324 |
hashDelete_r(afs_uint32 addr, afs_uint16 port, struct host * |
3413 |
h_DeleteHostFromAddrHashTable_r(afs_uint32 addr, afs_uint16 port, |
3325 |
host) |
3414 |
struct host *host) |
3326 |
{ |
3415 |
{ |
3327 |
int flag = 0; |
3416 |
char hoststr[16]; |
3328 |
register struct h_AddrHashChain **hp, *th; |
3417 |
register struct h_AddrHashChain **hp, *th; |
3329 |
|
3418 |
|
3330 |
for (hp = &hostAddrHashTable[h_HashIndex(addr)]; (th = *hp);) { |
3419 |
if (addr == 0 && port == 0) |
|
|
3420 |
return 1; |
3421 |
|
3422 |
for (hp = &hostAddrHashTable[h_HashIndex(addr)]; (th = *hp); |
3423 |
hp = &th->next) { |
3331 |
assert(th->hostPtr); |
3424 |
assert(th->hostPtr); |
3332 |
if (th->hostPtr == host && th->addr == addr && th->port == port) { |
3425 |
if (th->hostPtr == host && th->addr == addr && th->port == port) { |
|
|
3426 |
ViceLog(125, ("h_DeleteHostFromAddrHashTable_r: host 0x%lx (%s:%d)\n", |
3427 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), |
3428 |
ntohs(host->port))); |
3333 |
*hp = th->next; |
3429 |
*hp = th->next; |
3334 |
free(th); |
3430 |
free(th); |
3335 |
flag = 1; |
3431 |
return 1; |
3336 |
break; |
3432 |
} |
3337 |
} else { |
|
|
3338 |
hp = &th->next; |
3339 |
} |
3340 |
} |
3433 |
} |
3341 |
return flag; |
3434 |
ViceLog(125, |
|
|
3435 |
("h_DeleteHostFromAddrHashTable_r: host 0x%lx (%s:%d) not found\n", |
3436 |
(unsigned long) host, afs_inet_ntoa_r(host->host, hoststr), |
3437 |
ntohs(host->port))); |
3438 |
return 0; |
3342 |
} |
3439 |
} |
3343 |
|
3440 |
|
3344 |
|
3441 |
|
Lines 3355-3363
printInterfaceAddr(struct host *host, int level)
Link Here
|
3355 |
if (host->interface) { |
3452 |
if (host->interface) { |
3356 |
/* check alternate addresses */ |
3453 |
/* check alternate addresses */ |
3357 |
number = host->interface->numberOfInterfaces; |
3454 |
number = host->interface->numberOfInterfaces; |
3358 |
if (number == 0) |
3455 |
if (number == 0) { |
3359 |
ViceLog(level, ("no-addresses ")); |
3456 |
ViceLog(level, ("no-addresses ")); |
3360 |
else { |
3457 |
} else { |
3361 |
for (i = 0; i < number; i++) |
3458 |
for (i = 0; i < number; i++) |
3362 |
ViceLog(level, ("%s:%d ", afs_inet_ntoa_r(host->interface->interface[i].addr, hoststr), |
3459 |
ViceLog(level, ("%s:%d ", afs_inet_ntoa_r(host->interface->interface[i].addr, hoststr), |
3363 |
ntohs(host->interface->interface[i].port))); |
3460 |
ntohs(host->interface->interface[i].port))); |