bringing-rx-into-21st-century-20060504

Large series of changes to replace the use of afs_uint32 for IP address
with struct sockaddr_storage in Rx.  May even work with IPv6, but only
tested with IPv4.  Significant change to internal APIs; existing external
APIs kept, new ones added that take struct sockaddr_storage arguments.
This commit is contained in:
Ken Hornstein 2006-05-04 22:23:17 +00:00
parent ea3ed375e8
commit 9b6343e203
21 changed files with 575 additions and 361 deletions

View File

@ -99,7 +99,8 @@ afs_MarinerLogFetch(register struct vcache *avc, register afs_int32 off,
dvec.iov_base = tp1;
dvec.iov_len = len;
AFS_GUNLOCK();
(void)osi_NetSend(afs_server->socket, &taddr, &dvec, 1, len, 0);
(void)osi_NetSend(afs_server->socket, &taddr, sizeof(taddr), &dvec, 1,
len, 0);
AFS_GLOCK();
osi_FreeSmallSpace(tp1);
} /*afs_MarinerLogFetch */
@ -132,7 +133,8 @@ afs_MarinerLog(register char *astring, register struct vcache *avc)
dvec.iov_base = buf;
dvec.iov_len = tp - buf;
AFS_GUNLOCK();
(void)osi_NetSend(afs_server->socket, &taddr, &dvec, 1, tp - buf, 0);
(void)osi_NetSend(afs_server->socket, &taddr, sizeof(taddr), &dvec, 1,
tp - buf, 0);
AFS_GLOCK();
osi_FreeSmallSpace(buf);
} /*afs_MarinerLog */

View File

@ -32,6 +32,6 @@ BC_Print(acall, acode, aflags, amessage)
tconn = rx_ConnectionOf(acall);
tpeer = rx_PeerOf(tconn);
printf("From %08x: %s <%d>\n", tpeer->host, amessage, acode);
printf("From %s: %s <%d>\n", rx_AddrStringOf(tpeer), amessage, acode);
return 0;
}

View File

@ -536,7 +536,7 @@ Unlock(struct cmd_syndesc *as, char *arock)
{
afs_int32 code, rcode = 0;
afs_int32 count;
afs_int32 server;
char *server;
char name[MAXKTCNAMELEN];
char instance[MAXKTCNAMELEN];
@ -552,16 +552,14 @@ Unlock(struct cmd_syndesc *as, char *arock)
code = ubik_CallIter(KAM_Unlock, conn, 0, &count, (long) name, (long) instance,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
if (code && (code != UNOSERVERS)) {
server = 0;
server = "<unknown>";
if (conn && conn->conns[count - 1]
&& conn->conns[count - 1]->peer) {
server = conn->conns[count - 1]->peer->host;
server = rx_AddrStringOf(conn->conns[count - 1]->peer);
}
com_err(whoami, code,
"so %s.%s may still be locked (on server %d.%d.%d.%d)",
name, instance, ((server >> 24) & 0xFF),
((server >> 16) & 0xFF), ((server >> 8) & 0xFF),
(server & 0xFF));
"so %s.%s may still be locked (on server %s)",
name, instance, server);
if (!rcode) {
rcode = code;

View File

@ -60,9 +60,9 @@ kalog_Init()
}
/* log a ticket usage */
kalog_log(principal, instance, sprincipal, sinstance, realm, hostaddr, type)
char *principal, *instance, *sprincipal, *sinstance, *realm;
int hostaddr, type;
void
kalog_log(char *principal, char *instance, char *sprincipal, char *sinstance,
char *realm, int hostaddr, int type)
{
char keybuf[512]; /* not random! 63 . 63 , 63 . 63 max key */
datum key, data;
@ -128,7 +128,7 @@ kalog_log(principal, instance, sprincipal, sinstance, realm, hostaddr, type)
dbm_store(kalog_db, key, data, DBM_REPLACE);
ViceLog(verbose_track, ("%s from %x\n", keybuf, hostaddr));
ViceLog(verbose_track, ("%s from %s\n", keybuf, afs_inet_ntoa(hostaddr)));
}
@ -191,5 +191,5 @@ ka_log(char *principal, char *instance, char *sprincipal, char *sinstance,
break;
}
ViceLog(verbose_track, ("%s from %x\n", logbuf, hostaddr));
ViceLog(verbose_track, ("%s from %s\n", logbuf, afs_inet_ntoa(hostaddr)));
}

View File

@ -46,7 +46,11 @@ typedef struct {
#endif
#endif /* AUTH_DBM_LOG */
void ka_log(char *principal, char *instance, char *sprincipal, char *sinstance,
char *realm, int hostaddr, int type);
#ifdef AUTH_DBM_LOG
void kalog_log(char *principal, char *instance, char *sprincipal,
char *sinstance, char *realm, int hostaddr, int type);
#define KALOG(a,b,c,d,e,f,g) kalog_log(a,b,c,d,e,f,g)
#else
#define KALOG(a,b,c,d,e,f,g) ka_log(a,b,c,d,e,f,g)

View File

@ -659,7 +659,8 @@ kamCreateUser(call, aname, ainstance, ainitpw)
return code;
}
code = ubik_EndTrans(tt);
KALOG(aname, ainstance, NULL, NULL, NULL, call->conn->peer->host,
KALOG(aname, ainstance, NULL, NULL, NULL,
rx_HostOf(rx_PeerOf(rx_ConnectionOf(call))),
LOG_CRUSER);
return code;
}
@ -957,8 +958,8 @@ kamSetPassword(call, aname, ainstance, akvno, apassword)
goto abort;
code = ubik_EndTrans(tt);
KALOG(aname, ainstance, NULL, NULL, NULL, call->conn->peer->host,
LOG_CHPASSWD);
KALOG(aname, ainstance, NULL, NULL, NULL,
rx_HostOf(rx_PeerOf(rx_ConnectionOf(call))), LOG_CHPASSWD);
return code;
abort:
@ -1295,15 +1296,15 @@ Authenticate(version, call, aname, ainstance, start, end, arequest, oanswer)
des_pcbc_encrypt(oanswer->SeqBody, oanswer->SeqBody, oanswer->SeqLen,
user_schedule, &tentry.key, ENCRYPT);
code = ubik_EndTrans(tt);
KALOG(aname, ainstance, sname, sinst, NULL, call->conn->peer->host,
LOG_AUTHENTICATE);
KALOG(aname, ainstance, sname, sinst, NULL,
rx_HostOf(rx_PeerOf(rx_ConnectionOf(call))), LOG_AUTHENTICATE);
return code;
abort:
COUNT_ABO;
ubik_AbortTrans(tt);
KALOG(aname, ainstance, sname, sinst, NULL, call->conn->peer->host,
LOG_AUTHFAILED);
KALOG(aname, ainstance, sname, sinst, NULL,
rx_HostOf(rx_PeerOf(rx_ConnectionOf(call))), LOG_AUTHFAILED);
return code;
}
@ -1522,8 +1523,8 @@ kamSetFields(call, aname, ainstance, aflags, aexpiration, alifetime,
goto abort;
code = ubik_EndTrans(tt);
KALOG(aname, ainstance, NULL, NULL, NULL, call->conn->peer->host,
LOG_SETFIELDS);
KALOG(aname, ainstance, NULL, NULL, NULL,
rx_HostOf(rx_PeerOf(rx_ConnectionOf(call))), LOG_SETFIELDS);
return code;
abort:
@ -1601,8 +1602,8 @@ kamDeleteUser(call, aname, ainstance)
goto abort;
code = ubik_EndTrans(tt);
KALOG(aname, ainstance, NULL, NULL, NULL, call->conn->peer->host,
LOG_DELUSER);
KALOG(aname, ainstance, NULL, NULL, NULL,
rx_HostOf(rx_PeerOf(rx_ConnectionOf(call))), LOG_DELUSER);
return code;
}
@ -2011,7 +2012,7 @@ GetTicket(version, call, kvno, authDomain, aticket, sname, sinstance, atimes,
schedule, &authSessionKey, ENCRYPT);
code = ubik_EndTrans(tt);
KALOG(name, instance, sname, sinstance, (import ? authDomain : NULL),
call->conn->peer->host, LOG_GETTICKET);
rx_HostOf(rx_PeerOf(rx_ConnectionOf(call))), LOG_GETTICKET);
return code;
abort:
@ -2358,8 +2359,8 @@ SKAM_Unlock(call, aname, ainstance, spare1, spare2, spare3, spare4)
kaux_write(to, 0, 0); /* zero failure counters at this offset */
code = ubik_EndTrans(tt);
KALOG(aname, ainstance, NULL, NULL, NULL, call->conn->peer->host,
LOG_UNLOCK);
KALOG(aname, ainstance, NULL, NULL, NULL,
rx_HostOf(rx_PeerOf(rx_ConnectionOf(call))), LOG_UNLOCK);
goto exit;
abort:

View File

@ -20,13 +20,12 @@ RCSID
#endif
int
osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
int nvecs, int *alength)
osi_NetReceive(osi_socket so, struct sockaddr_storage *saddr, int *slen,
struct iovec *dvec, int nvecs, int *alength)
{
#ifdef AFS_DARWIN80_ENV
socket_t asocket = (socket_t)so;
struct msghdr msg;
struct sockaddr_storage ss;
int rlen;
mbuf_t m;
#else
@ -56,9 +55,9 @@ osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
#if 1
resid = *alength;
memset(&msg, 0, sizeof(struct msghdr));
msg.msg_name = &ss;
msg.msg_name = saddr;
msg.msg_namelen = sizeof(struct sockaddr_storage);
sa =(struct sockaddr *) &ss;
sa =(struct sockaddr *) saddr;
code = sock_receivembuf(asocket, &msg, &m, 0, alength);
if (!code) {
size_t offset=0,sz;
@ -122,11 +121,7 @@ osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
return code;
*alength -= resid;
if (sa) {
if (sa->sa_family == AF_INET) {
if (addr)
*addr = *(struct sockaddr_in *)sa;
} else
printf("Unknown socket family %d in NetReceive\n", sa->sa_family);
*slen = sa->sa_len;
FREE(sa, M_SONAME);
}
return code;
@ -153,8 +148,8 @@ osi_StopListener(void)
}
int
osi_NetSend(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
int nvecs, afs_int32 alength, int istack)
osi_NetSend(osi_socket so, struct sockaddr_storage *saddr, int salen,
struct iovec *dvec, int nvecs, afs_int32 alength, int istack)
{
#ifdef AFS_DARWIN80_ENV
socket_t asocket = (socket_t)so;
@ -176,7 +171,8 @@ osi_NetSend(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
for (i = 0; i < nvecs; i++)
iov[i] = dvec[i];
addr->sin_len = sizeof(struct sockaddr_in);
saddr->ss_len = saddr->ss_family == AF_INET6 ?
sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in);
if (haveGlock)
AFS_GUNLOCK();
@ -185,8 +181,8 @@ osi_NetSend(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
#endif
#ifdef AFS_DARWIN80_ENV
memset(&msg, 0, sizeof(struct msghdr));
msg.msg_name = addr;
msg.msg_namelen = ((struct sockaddr *)addr)->sa_len;
msg.msg_name = saddr;
msg.msg_namelen = saddr->ss_len;
msg.msg_iov = &iov[0];
msg.msg_iovlen = nvecs;
code = sock_send(asocket, &msg, 0, &slen);

View File

@ -344,7 +344,7 @@ osi_FreeSocket(register osi_socket *asocket)
dvec.iov_len = 1;
while (rxk_ListenerPid) {
osi_NetSend(rx_socket, &taddr, &dvec, 1, 1, 0);
osi_NetSend(rx_socket, &taddr, sizeof(taddr), &dvec, 1, 1, 0);
afs_osi_Sleep(&rxk_ListenerPid);
}
@ -357,8 +357,8 @@ osi_FreeSocket(register osi_socket *asocket)
}
int
osi_NetSend(osi_socket asocket, struct sockaddr_in *addr, struct iovec *dvec,
int nvecs, afs_int32 asize, int istack)
osi_NetSend(osi_socket asocket, struct sockaddr_storage *saddr, int slen,
struct iovec *dvec, int nvecs, afs_int32 asize, int istack)
{
struct sonode *so = (struct sonode *)asocket;
struct nmsghdr msg;
@ -371,8 +371,8 @@ osi_NetSend(osi_socket asocket, struct sockaddr_in *addr, struct iovec *dvec,
osi_Panic("osi_NetSend: %d: Too many iovecs.\n", nvecs);
}
msg.msg_name = (struct sockaddr *)addr;
msg.msg_namelen = sizeof(struct sockaddr_in);
msg.msg_name = (struct sockaddr *) saddr;
msg.msg_namelen = slen;
msg.msg_iov = dvec;
msg.msg_iovlen = nvecs;
msg.msg_control = NULL;
@ -397,8 +397,8 @@ osi_NetSend(osi_socket asocket, struct sockaddr_in *addr, struct iovec *dvec,
}
int
osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
int nvecs, int *alength)
osi_NetReceive(osi_socket so, struct sockaddr_storage *saddr, int *slen,
struct iovec *dvec, int nvecs, int *alength)
{
struct sonode *asocket = (struct sonode *)so;
struct nmsghdr msg;
@ -412,7 +412,7 @@ osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
}
msg.msg_name = NULL;
msg.msg_namelen = sizeof(struct sockaddr_in);
msg.msg_namelen = *slen;
msg.msg_iov = NULL;
msg.msg_iovlen = 0;
msg.msg_control = NULL;
@ -436,7 +436,8 @@ osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
if (msg.msg_name == NULL) {
error = -1;
} else {
memcpy(addr, msg.msg_name, msg.msg_namelen);
memcpy(saddr, msg.msg_name, msg.msg_namelen);
*slen = msg.msg_namelen;
kmem_free(msg.msg_name, msg.msg_namelen);
*alength = *alength - uio.uio_resid;
}

View File

@ -279,8 +279,8 @@ osi_StopListener(void)
}
int
osi_NetSend(osi_socket sockp, struct sockaddr_in *addr, struct iovec *iov,
int nio, afs_int32 size, int stack)
osi_NetSend(osi_socket sockp, struct sockaddr_storage *addr, int addrlen,
struct iovec *iov, int nio, afs_int32 size, int stack)
{
int rc;
int i;
@ -300,7 +300,7 @@ osi_NetSend(osi_socket sockp, struct sockaddr_in *addr, struct iovec *iov,
memset(&msg, 0, sizeof(msg));
msg.msg_name = (void *)addr;
msg.msg_namelen = sizeof(struct sockaddr_in);
msg.msg_namelen = addrlen;
msg.msg_iov = &tmpiov[0];
msg.msg_iovlen = nio;

View File

@ -373,8 +373,46 @@ static int rxinit_status = 1;
#define UNLOCK_RX_INIT
#endif
/*
* Now, rx_InitHost is just a stub for rx_InitAddrs
*/
int
rx_InitHost(u_int host, u_int port)
{
struct sockaddr_storage saddr;
int type = SOCK_DGRAM, len = sizeof(struct sockaddr_in);
memset((void *) &saddr, 0, sizeof(saddr));
rx_ssfamily(&saddr) = AF_INET;
((struct sockaddr_in *) &saddr)->sin_addr.s_addr = host;
((struct sockaddr_in *) &saddr)->sin_port = htons(port);
#ifdef STRUCT_SOCKADDR_HAS_SA_LEN
((struct sockaddr_in *) &saddr)->sin_len = sizeof(struct sockaddr_in);
#endif
return rx_InitAddrs(&saddr, &type, &len, 1);
}
/*
* New API: rx_InitAddrs(struct sockaddr_storage *, int *, int)
*
* Arguments:
*
* struct sockaddr_storage - array of struct sockaddr_storage elements,
* each one listing an interface/protocol to
* be listened on.
* int * - array of integers listing the socket type
* (SOCK_STREAM or SOCK_DGRAM) to be used
* by the corresponding struct sockaddr_storage
* int * - array of integers listing saddr sizes
* int - Number of elements in sockaddr_storage array.
*
* Note that in general only servers should call this function; clients
* should (for now) continue to call rx_Init().
*/
int rx_InitAddrs(struct sockaddr_storage *saddrs, int *types, int *salens,
int nelem)
{
#ifdef KERNEL
osi_timeval_t tv;
@ -382,7 +420,7 @@ rx_InitHost(u_int host, u_int port)
struct timeval tv;
#endif /* KERNEL */
char *htable, *ptable;
int tmp_status;
int tmp_status, i;
#if defined(AFS_DJGPP_ENV) && !defined(DEBUG)
__djgpp_set_quiet_socket(1);
@ -415,12 +453,26 @@ rx_InitHost(u_int host, u_int port)
/* Allocate and initialize a socket for client and perhaps server
* connections. */
rx_socket = -1;
rx_port = 0;
for (i = 0; i < nelem; i++) {
switch (types[i]) {
case SOCK_DGRAM:
rx_socket = rxi_GetHostUDPSocket(&saddrs[i], salens[i]);
if (rx_socket == OSI_NULLSOCKET) {
UNLOCK_RX_INIT;
return RX_ADDRINUSE;
}
rx_port = rx_ss2pn(&saddrs[i]);
break;
default:
return RX_INVALID_OPERATION;
}
rx_socket = rxi_GetHostUDPSocket(host, (u_short) port);
if (rx_socket == OSI_NULLSOCKET) {
UNLOCK_RX_INIT;
return RX_ADDRINUSE;
}
#ifdef RX_ENABLE_LOCKS
#ifdef RX_LOCKS_DB
rxdb_init();
@ -483,20 +535,19 @@ rx_InitHost(u_int host, u_int port)
#else
osi_GetTime(&tv);
#endif
if (port) {
rx_port = port;
} else {
if (! rx_port) {
#if defined(KERNEL) && !defined(UKERNEL)
/* Really, this should never happen in a real kernel */
rx_port = 0;
#else
struct sockaddr_in addr;
int addrlen = sizeof(addr);
if (getsockname((int)rx_socket, (struct sockaddr *)&addr, &addrlen)) {
struct sockaddr_storage sn;
socklen_t addrlen = sizeof(sn);
if (getsockname((int)rx_socket, (struct sockaddr *)&sn, &addrlen)) {
rx_Finalize();
return -1;
}
rx_port = addr.sin_port;
rx_port = rx_ss2pn(&sn);
#endif
}
rx_stats.minRtt.sec = 9999999;
@ -550,6 +601,7 @@ rx_Init(u_int port)
return rx_InitHost(htonl(INADDR_ANY), port);
}
/* called with unincremented nRequestsRunning to see if it is OK to start
* a new thread in this service. Could be "no" for two reasons: over the
* max quota, or would prevent others from reaching their min quota.
@ -739,22 +791,50 @@ rx_StartServer(int donateMe)
return;
}
/* Create a new client connection to the specified service, using the
* specified security object to implement the security model for this
* connection. */
/*
* Now, rx_NewConnection is just a stub for rx_NewConnectionAddrs()
*/
struct rx_connection *
rx_NewConnection(register afs_uint32 shost, u_short sport, u_short sservice,
register struct rx_securityClass *securityObject,
int serviceSecurityIndex)
{
int hashindex;
struct sockaddr_in sin;
int len = sizeof(sin), type = SOCK_DGRAM;
memset((void *) &sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = shost;
sin.sin_port = sport;
return rx_NewConnectionAddrs((struct sockaddr_storage *) &sin, &type,
&len, 1, sservice, securityObject,
serviceSecurityIndex);
}
/* Create a new client connection to the specified service, using the
* specified security object to implement the security model for this
* connection
*
* This follows the same logic as rx_InitAddrs() for the first four
* arguments.
*/
struct rx_connection *
rx_NewConnectionAddrs(struct sockaddr_storage *saddr, int *type, int *slen,
int nelem, u_short sservice,
struct rx_securityClass *securityObject,
int serviceSecurityIndex)
{
int hashindex, i;
afs_int32 cid;
register struct rx_connection *conn;
SPLVAR;
clock_NewTime();
dpf(("rx_NewConnection(host %x, port %u, service %u, securityObject %x, serviceSecurityIndex %d)\n", ntohl(shost), ntohs(sport), sservice, securityObject, serviceSecurityIndex));
dpf(("rx_NewConnection(host %x, port %u, service %u, securityObject %x, serviceSecurityIndex %d)\n", ntohl(rx_ss2v4addr(saddr)), ntohs(rx_ss2pn(saddr)), sservice, securityObject, serviceSecurityIndex));
/* Vasilsi said: "NETPRI protects Cid and Alloc", but can this be true in
* the case of kmem_alloc? */
@ -770,7 +850,16 @@ rx_NewConnection(register afs_uint32 shost, u_short sport, u_short sservice,
conn->type = RX_CLIENT_CONNECTION;
conn->cid = cid;
conn->epoch = rx_epoch;
conn->peer = rxi_FindPeer(shost, sport, 0, 1);
/*
* Right now we're going to just call rxi_FindPeer for UDP connections
* We're only going to support one.
*/
for (i = 0; i < nelem; i++) {
if (type[i] == SOCK_DGRAM) {
conn->peer = rxi_FindPeer(&saddr[i], slen[i], type[i], 0, 1);
break;
}
}
conn->serviceId = sservice;
conn->securityObject = securityObject;
/* This doesn't work in all compilers with void (they're buggy), so fake it
@ -1313,7 +1402,17 @@ rx_NewService(u_short port, u_short serviceId, char *serviceName,
if (socket == OSI_NULLSOCKET) {
/* If we don't already have a socket (from another
* service on same port) get a new one */
socket = rxi_GetHostUDPSocket(htonl(INADDR_ANY), port);
struct sockaddr_in sin;
memset((void *) &sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = htonl(INADDR_ANY);
sin.sin_port = port;
#ifdef STRUCT_SOCKADDR_HAS_SA_LEN
sin.sin_len = sizeof(sin);
#endif
socket = rxi_GetHostUDPSocket((struct sockaddr_storage *) &sin,
sizeof(sin));
if (socket == OSI_NULLSOCKET) {
USERPRI;
rxi_FreeService(tservice);
@ -2251,22 +2350,60 @@ rxi_Free(void *addr, register size_t size)
* refcount will be be decremented. This is used to replace the peer
* structure hanging off a connection structure */
struct rx_peer *
rxi_FindPeer(register afs_uint32 host, register u_short port,
rxi_FindPeer(struct sockaddr_storage *saddr, int slen, int stype,
struct rx_peer *origPeer, int create)
{
register struct rx_peer *pp;
int hashIndex;
hashIndex = PEER_HASH(host, port);
int hashIndex, i, j;
for (i = 0, j = 0; i < slen; i++)
j += ((unsigned char *) saddr)[i];
hashIndex = j % rx_hashTableSize;
MUTEX_ENTER(&rx_peerHashTable_lock);
for (pp = rx_peerHashTable[hashIndex]; pp; pp = pp->next) {
if ((pp->host == host) && (pp->port == port))
if (memcmp(saddr, &pp->saddr, slen) == 0 && stype == pp->socktype)
break;
}
if (!pp) {
if (create) {
pp = rxi_AllocPeer(); /* This bzero's *pp */
pp->host = host; /* set here or in InitPeerParams is zero */
pp->port = port;
memcpy(&pp->saddr, saddr, slen);
pp->saddrlen = slen;
pp->socktype = stype;
switch (rx_ssfamily(saddr)) {
case AF_INET:
/*
* Should be enough storage for a dotted quad
*/
sprintf(pp->addrstring, "%d.%d.%d.%d",
rx_ss2addrp(saddr)[0], rx_ss2addrp(saddr)[1],
rx_ss2addrp(saddr)[2], rx_ss2addrp(saddr)[3]);
break;
#ifdef AF_INET6
case AF_INET6:
/*
* This gets more complicated, unfortunately
*/
if (IN6_IS_ADDR_V4COMPAT(&(rx_ss2sin6(saddr)->sin6_addr))) {
sprintf(pp->addrstring, "%d.%d.%d.%d",
rx_ss2addrp(saddr)[12], rx_ss2addrp(saddr)[13],
rx_ss2addrp(saddr)[14], rx_ss2addrp(saddr)[15]);
} else {
sprintf(pp->addrstring, "%x:%x:%x:%x:%x:%x:%x:%x",
ntohs(rx_ss2addrp6(saddr)[0]),
ntohs(rx_ss2addrp6(saddr)[1]),
ntohs(rx_ss2addrp6(saddr)[2]),
ntohs(rx_ss2addrp6(saddr)[3]),
ntohs(rx_ss2addrp6(saddr)[4]),
ntohs(rx_ss2addrp6(saddr)[5]),
ntohs(rx_ss2addrp6(saddr)[6]),
ntohs(rx_ss2addrp6(saddr)[7]));
}
break;
#endif /* AF_INET6 */
default:
strcpy(pp->addrstring, "??.??.??.??");
break;
}
MUTEX_INIT(&pp->peer_lock, "peer_lock", MUTEX_DEFAULT, 0);
queue_Init(&pp->congestionQueue);
queue_Init(&pp->rpcStats);
@ -2301,8 +2438,8 @@ rxi_FindPeer(register afs_uint32 host, register u_short port,
* server connection is created, it will be created using the supplied
* index, if the index is valid for this service */
struct rx_connection *
rxi_FindConnection(osi_socket socket, register afs_int32 host,
register u_short port, u_short serviceId, afs_uint32 cid,
rxi_FindConnection(osi_socket socket, struct sockaddr_storage *saddr,
int slen, int socktype, u_short serviceId, afs_uint32 cid,
afs_uint32 epoch, int type, u_int securityIndex)
{
int hashindex, flag;
@ -2324,9 +2461,11 @@ rxi_FindConnection(osi_socket socket, register afs_int32 host,
MUTEX_EXIT(&rx_connHashTable_lock);
return (struct rx_connection *)0;
}
if (pp->host == host && pp->port == port)
if (memcmp(&pp->saddr, saddr, slen) == 0 &&
socktype == pp->socktype)
break;
if (type == RX_CLIENT_CONNECTION && pp->port == port)
if (type == RX_CLIENT_CONNECTION &&
rx_ss2pn(&pp->saddr) == rx_ss2pn(saddr))
break;
/* So what happens when it's a callback connection? */
if ( /*type == RX_CLIENT_CONNECTION && */
@ -2359,7 +2498,7 @@ rxi_FindConnection(osi_socket socket, register afs_int32 host,
CV_INIT(&conn->conn_call_cv, "conn call cv", CV_DEFAULT, 0);
conn->next = rx_connHashTable[hashindex];
rx_connHashTable[hashindex] = conn;
conn->peer = rxi_FindPeer(host, port, 0, 1);
conn->peer = rxi_FindPeer(saddr, slen, socktype, 0, 1);
conn->type = RX_SERVER_CONNECTION;
conn->lastSendTime = clock_Sec(); /* don't GC immediately */
conn->epoch = epoch;
@ -2413,7 +2552,7 @@ int (*rx_almostSent) () = 0;
struct rx_packet *
rxi_ReceivePacket(register struct rx_packet *np, osi_socket socket,
afs_uint32 host, u_short port, int *tnop,
struct sockaddr_storage *saddr, int slen, int *tnop,
struct rx_call **newcallp)
{
register struct rx_call *call;
@ -2435,36 +2574,29 @@ rxi_ReceivePacket(register struct rx_packet *np, osi_socket socket,
packetType = (np->header.type > 0 && np->header.type < RX_N_PACKET_TYPES)
? rx_packetTypes[np->header.type - 1] : "*UNKNOWN*";
dpf(("R %d %s: %x.%d.%d.%d.%d.%d.%d flags %d, packet %x",
np->header.serial, packetType, ntohl(host), ntohs(port), np->header.serviceId,
np->header.serial, packetType, ntohl(rx_ss2v4addr(saddr)),
ntohs(rx_ss2pn(saddr)), np->header.serviceId,
np->header.epoch, np->header.cid, np->header.callNumber,
np->header.seq, np->header.flags, np));
#endif
if (np->header.type == RX_PACKET_TYPE_VERSION) {
return rxi_ReceiveVersionPacket(np, socket, host, port, 1);
return rxi_ReceiveVersionPacket(np, socket, saddr, slen, 1);
}
if (np->header.type == RX_PACKET_TYPE_DEBUG) {
return rxi_ReceiveDebugPacket(np, socket, host, port, 1);
return rxi_ReceiveDebugPacket(np, socket, saddr, slen, 1);
}
#ifdef RXDEBUG
/* If an input tracer function is defined, call it with the packet and
* network address. Note this function may modify its arguments. */
if (rx_justReceived) {
struct sockaddr_in addr;
struct sockaddr_in *addr = (struct sockaddr_in *) saddr;
int drop;
addr.sin_family = AF_INET;
addr.sin_port = port;
addr.sin_addr.s_addr = host;
#ifdef STRUCT_SOCKADDR_HAS_SA_LEN
addr.sin_len = sizeof(addr);
#endif /* AFS_OSF_ENV */
drop = (*rx_justReceived) (np, &addr);
drop = (*rx_justReceived) (np, addr);
/* drop packet if return value is non-zero */
if (drop)
return np;
port = addr.sin_port; /* in case fcn changed addr */
host = addr.sin_addr.s_addr;
}
#endif
@ -2475,9 +2607,9 @@ rxi_ReceivePacket(register struct rx_packet *np, osi_socket socket,
/* Find the connection (or fabricate one, if we're the server & if
* necessary) associated with this packet */
conn =
rxi_FindConnection(socket, host, port, np->header.serviceId,
np->header.cid, np->header.epoch, type,
np->header.securityIndex);
rxi_FindConnection(socket, saddr, slen, SOCK_DGRAM,
np->header.serviceId, np->header.cid,
np->header.epoch, type, np->header.securityIndex);
if (!conn) {
/* If no connection found or fabricated, just ignore the packet.
@ -2612,7 +2744,7 @@ rxi_ReceivePacket(register struct rx_packet *np, osi_socket socket,
MUTEX_EXIT(&conn->conn_call_lock);
*call->callNumber = np->header.callNumber;
if (np->header.callNumber == 0)
dpf(("RecPacket call 0 %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %lx resend %d.%0.3d len %d", np->header.serial, rx_packetTypes[np->header.type - 1], ntohl(conn->peer->host), ntohs(conn->peer->port), np->header.serial, np->header.epoch, np->header.cid, np->header.callNumber, np->header.seq, np->header.flags, (unsigned long)np, np->retryTime.sec, np->retryTime.usec / 1000, np->length));
dpf(("RecPacket call 0 %d %s: %s.%u.%u.%u.%u.%u.%u flags %d, packet %lx resend %d.%0.3d len %d", np->header.serial, rx_packetTypes[np->header.type - 1], rx_AddrStringOf(conn->peer), ntohs(rx_PortOf(conn->peer)), np->header.serial, np->header.epoch, np->header.cid, np->header.callNumber, np->header.seq, np->header.flags, (unsigned long)np, np->retryTime.sec, np->retryTime.usec / 1000, np->length));
call->state = RX_STATE_PRECALL;
clock_GetTime(&call->queueTime);
@ -2677,7 +2809,7 @@ rxi_ReceivePacket(register struct rx_packet *np, osi_socket socket,
rxi_ResetCall(call, 0);
*call->callNumber = np->header.callNumber;
if (np->header.callNumber == 0)
dpf(("RecPacket call 0 %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %lx resend %d.%0.3d len %d", np->header.serial, rx_packetTypes[np->header.type - 1], ntohl(conn->peer->host), ntohs(conn->peer->port), np->header.serial, np->header.epoch, np->header.cid, np->header.callNumber, np->header.seq, np->header.flags, (unsigned long)np, np->retryTime.sec, np->retryTime.usec / 1000, np->length));
dpf(("RecPacket call 0 %d %s: %s.%u.%u.%u.%u.%u.%u flags %d, packet %lx resend %d.%0.3d len %d", np->header.serial, rx_packetTypes[np->header.type - 1], rx_AddrStringOf(conn->peer), ntohs(rx_PortOf(conn->peer)), np->header.serial, np->header.epoch, np->header.cid, np->header.callNumber, np->header.seq, np->header.flags, (unsigned long)np, np->retryTime.sec, np->retryTime.usec / 1000, np->length));
call->state = RX_STATE_PRECALL;
clock_GetTime(&call->queueTime);
@ -2838,7 +2970,7 @@ rxi_ReceivePacket(register struct rx_packet *np, osi_socket socket,
/* Now do packet type-specific processing */
switch (np->header.type) {
case RX_PACKET_TYPE_DATA:
np = rxi_ReceiveDataPacket(call, np, 1, socket, host, port, tnop,
np = rxi_ReceiveDataPacket(call, np, 1, socket, saddr, slen, tnop,
newcallp);
break;
case RX_PACKET_TYPE_ACK:
@ -3082,8 +3214,8 @@ TryAttach(register struct rx_call *acall, register osi_socket socket,
struct rx_packet *
rxi_ReceiveDataPacket(register struct rx_call *call,
register struct rx_packet *np, int istack,
osi_socket socket, afs_uint32 host, u_short port,
int *tnop, struct rx_call **newcallp)
osi_socket socket, struct sockaddr_storage *saddr,
int slen, int *tnop, struct rx_call **newcallp)
{
int ackNeeded = 0; /* 0 means no, otherwise ack_reason */
int newPackets = 0;
@ -3154,7 +3286,7 @@ rxi_ReceiveDataPacket(register struct rx_call *call,
/* The RX_JUMBO_PACKET is set in all but the last packet in each
* AFS 3.5 jumbogram. */
if (flags & RX_JUMBO_PACKET) {
tnp = rxi_SplitJumboPacket(np, host, port, isFirst);
tnp = rxi_SplitJumboPacket(np, saddr, slen, isFirst);
} else {
tnp = NULL;
}
@ -6286,9 +6418,9 @@ rx_PrintStats(FILE * file)
void
rx_PrintPeerStats(FILE * file, struct rx_peer *peer)
{
fprintf(file, "Peer %x.%d. " "Burst size %d, " "burst wait %u.%d.\n",
/* fprintf(file, "Peer %x.%d. " "Burst size %d, " "burst wait %u.%d.\n",
ntohl(peer->host), (int)peer->port, (int)peer->burstSize,
(int)peer->burstWait.sec, (int)peer->burstWait.usec);
(int)peer->burstWait.sec, (int)peer->burstWait.usec); */
fprintf(file,
" Rtt %d, " "retry time %u.%06d, " "total sent %d, "
@ -6918,7 +7050,7 @@ rxi_AddRpcStat(struct rx_queue *stats, afs_uint32 rxInterface,
afs_uint32 currentFunc, afs_uint32 totalFunc,
struct clock *queueTime, struct clock *execTime,
afs_hyper_t * bytesSent, afs_hyper_t * bytesRcvd, int isServer,
afs_uint32 remoteHost, afs_uint32 remotePort,
struct sockaddr_storage *saddr,
int addToPeerList, unsigned int *counter)
{
int rc = 0;
@ -6956,8 +7088,19 @@ rxi_AddRpcStat(struct rx_queue *stats, afs_uint32 rxInterface,
}
*counter += totalFunc;
for (i = 0; i < totalFunc; i++) {
rpc_stat->stats[i].remote_peer = remoteHost;
rpc_stat->stats[i].remote_port = remotePort;
switch (rx_ssfamily(saddr)) {
case AF_INET:
rpc_stat->stats[i].remote_peer =
rx_ss2sin(saddr)->sin_addr.s_addr;
break;
default:
#ifdef AF_INET6
case AF_INET6:
rpc_stat->stats[i].remote_peer = 0xffffffff;
break;
#endif AF_INET6
}
rpc_stat->stats[i].remote_port = rx_ss2pn(saddr);
rpc_stat->stats[i].remote_is_server = isServer;
rpc_stat->stats[i].interfaceId = rxInterface;
rpc_stat->stats[i].func_total = totalFunc;
@ -7060,13 +7203,18 @@ rx_IncrementTimeAndCount(struct rx_peer *peer, afs_uint32 rxInterface,
if (rxi_monitor_peerStats) {
rxi_AddRpcStat(&peer->rpcStats, rxInterface, currentFunc, totalFunc,
queueTime, execTime, bytesSent, bytesRcvd, isServer,
peer->host, peer->port, 1, &rxi_rpc_peer_stat_cnt);
&peer->saddr, 1, &rxi_rpc_peer_stat_cnt);
}
if (rxi_monitor_processStats) {
struct sockaddr_in sin;
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = 0xffffffff;
sin.sin_port = 0xffff;
rxi_AddRpcStat(&processStats, rxInterface, currentFunc, totalFunc,
queueTime, execTime, bytesSent, bytesRcvd, isServer,
0xffffffff, 0xffffffff, 0, &rxi_rpc_process_stat_cnt);
(struct sockaddr_storage *) &sin, 0,
&rxi_rpc_process_stat_cnt);
}
MUTEX_EXIT(&peer->peer_lock);

View File

@ -96,7 +96,7 @@
#ifndef KERNEL
typedef void (*rx_destructor_t) (void *);
int rx_KeyCreate(rx_destructor_t);
osi_socket rxi_GetHostUDPSocket(u_int host, u_short port);
osi_socket rxi_GetHostUDPSocket(struct sockaddr_storage *saddr, int salen);
osi_socket rxi_GetUDPSocket(u_short port);
#endif /* KERNEL */
@ -108,8 +108,18 @@ int ntoh_syserr_conv(int error);
#define rx_ConnectionOf(call) ((call)->conn)
#define rx_PeerOf(conn) ((conn)->peer)
#define rx_HostOf(peer) ((peer)->host)
#define rx_PortOf(peer) ((peer)->port)
#ifdef AF_INET6
#define rx_HostOf(peer) ((peer)->saddr.ss_family == AF_INET ? \
((struct sockaddr_in *) &(peer)->saddr)->sin_addr.s_addr : \
0xffffffff)
#define rx_PortOf(peer) ((peer)->saddr.ss_family == AF_INET ? \
((struct sockaddr_in *) &(peer)->saddr)->sin_port : \
((struct sockaddr_in6 *) &(peer)->saddr)->sin6_port)
#else /* AF_INET6 */
#define rx_HostOf(peer) (((struct sockaddr_in *) &(peer)->saddr)->sin_addr.saddr)
#define rx_PortOf(peer) (((struct sockaddr_in *) &(peer)->saddr)->sin_port)
#endif /* AF_INET6 */
#define rx_AddrStringOf(peer) ((peer)->addrstring)
#define rx_SetLocalStatus(call, status) ((call)->localStatus = (status))
#define rx_GetLocalStatus(call, status) ((call)->localStatus)
#define rx_GetRemoteStatus(call) ((call)->remoteStatus)
@ -345,6 +355,10 @@ struct rx_serverQueueEntry {
osi_socket *socketp;
};
/* If we don't support IPv6, use this as a fallback */
#ifndef INET6_ADDRSTRLEN
#define INET6_ADDRSTRLEN 46
#endif /* INET6_ADDRSTRLEN */
/* A peer refers to a peer process, specified by a (host,port) pair. There may be more than one peer on a given host. */
#ifdef KDUMP_RX_LOCK
@ -357,8 +371,10 @@ struct rx_peer {
#ifdef RX_ENABLE_LOCKS
afs_kmutex_t peer_lock; /* Lock peer */
#endif /* RX_ENABLE_LOCKS */
afs_uint32 host; /* Remote IP address, in net byte order */
u_short port; /* Remote UDP port, in net byte order */
struct sockaddr_storage saddr; /* Remote address structure */
int saddrlen; /* Length of saddr */
int socktype; /* Socket type (SOCK_DGRAM, etc) */
char addrstring[INET6_ADDRSTRLEN]; /* Printable address format */
/* interface mtu probably used for this host - includes RX Header */
u_short ifMTU; /* doesn't include IP header */
@ -1032,7 +1048,27 @@ typedef struct rx_interface_stat {
#define RX_STATS_SERVICE_ID 409
/*
* Definitions for handling struct sockaddr_storage casts, and IPv6
*/
#ifdef AF_INET6
#define rx_ss2pn(x) ((x)->ss_family == AF_INET6 ? \
((struct sockaddr_in6 *) (x))->sin6_port : \
((struct sockaddr_in *) (x))->sin_port)
#define rx_ss2sin6(x) ((struct sockaddr_in6 *) (x))
#define rx_ssfamily(x) ((x)->ss_family)
#define rx_ss2addrp6(x) ((afs_uint16 *) &(((struct sockaddr_in6 *) (x))->sin6_addr.s6_addr))
#define rx_ss2v4addr(x) ((x)->ss_family == AF_INET ? \
((struct sockaddr_in *) (x))->sin_addr.s_addr : \
0xffffffff)
#else /* AF_INET6 */
#define rx_ss2pn(x) (((struct sockaddr_in *) (x))->sin_port)
#define rx_ssfamily(x) (((struct sockaddr_in *) (x))->sin_family)
#define rx_ss2v4addr(x) (((struct sockaddr_in *) (x))->sin_addr.s_addr)
#endif /* AF_INET6 */
#define rx_ss2sin(x) ((struct sockaddr_in *) (x))
#define rx_ss2addrp(x) ((unsigned char *) &(((struct sockaddr_in *) (x))->sin_addr.s_addr))
#endif /* _RX_ End of rx.h */

View File

@ -487,7 +487,9 @@ EXT afs_kmutex_t rx_connHashTable_lock;
#define CONN_HASH(host, port, cid, epoch, type) ((((cid)>>RX_CIDSHIFT)%rx_hashTableSize))
#if 0
#define PEER_HASH(host, port) ((host ^ port) % rx_hashTableSize)
#endif
/* Forward definitions of internal procedures */
#define rxi_ChallengeOff(conn) rxevent_Cancel((conn)->challengeEvent, (struct rx_call*)0, 0);

View File

@ -30,7 +30,7 @@ int (*rxk_PacketArrivalProc) (struct rx_packet * ahandle, struct sockaddr_in * a
int (*rxk_GetPacketProc) (struct rx_packet **ahandle, int asize);
#endif
osi_socket *rxk_NewSocketHost(afs_uint32 ahost, short aport);
osi_socket *rxk_NewSocketHost(struct sockaddr_storage *saddr, int salen);
extern struct interfaceAddr afs_cb_interface;
rxk_ports_t rxk_ports;
@ -108,20 +108,29 @@ rxk_shutdownPorts(void)
}
osi_socket
rxi_GetHostUDPSocket(u_int host, u_short port)
rxi_GetHostUDPSocket(struct sockaddr_storage *saddr, int salen)
{
osi_socket *sockp;
sockp = (osi_socket *)rxk_NewSocketHost(host, port);
sockp = (osi_socket *)rxk_NewSocketHost(saddr, salen);
if (sockp == (osi_socket *)0)
return OSI_NULLSOCKET;
rxk_AddPort(port, (char *)sockp);
rxk_AddPort(rx_ss2pn(saddr), (char *)sockp);
return (osi_socket) sockp;
}
osi_socket
rxi_GetUDPSocket(u_short port)
{
return rxi_GetHostUDPSocket(htonl(INADDR_ANY), port);
struct sockaddr_storage saddr;
struct sockaddr_in *sin = (struct sockaddr_in *) &saddr;
memset((void *) &saddr, 0, sizeof(saddr));
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = htonl(INADDR_ANY);
sin->sin_port = port;
return rxi_GetHostUDPSocket(&saddr, sizeof(struct sockaddr_in));
}
void
@ -342,9 +351,8 @@ MyArrivalProc(struct rx_packet *ahandle,
ahandle->length = asize - RX_HEADER_SIZE;
rxi_DecodePacketHeader(ahandle);
ahandle =
rxi_ReceivePacket(ahandle, arock,
afrom->sin_addr.s_addr, afrom->sin_port, NULL,
NULL);
rxi_ReceivePacket(ahandle, arock, (struct sockaddr_storage *) afrom,
NULL, NULL);
/* free the packet if it has been returned */
if (ahandle)
@ -375,7 +383,7 @@ rxi_InitPeerParams(register struct rx_peer *pp)
#ifdef ADAPT_MTU
#ifndef AFS_SUN5_ENV
#ifdef AFS_USERSPACE_IP_ADDR
i = rxi_Findcbi(pp->host);
i = rxi_Findcbi(rx_HostOf(pp));
if (i == -1) {
pp->timeout.sec = 3;
/* pp->timeout.usec = 0; */
@ -405,7 +413,7 @@ rxi_InitPeerParams(register struct rx_peer *pp)
(void)rxi_GetIFInfo();
#endif
ifn = rxi_FindIfnet(pp->host, NULL);
ifn = rxi_FindIfnet(rx_HostOf(pp), NULL);
if (ifn) {
pp->timeout.sec = 2;
/* pp->timeout.usec = 0; */
@ -431,7 +439,7 @@ rxi_InitPeerParams(register struct rx_peer *pp)
}
#endif /* else AFS_USERSPACE_IP_ADDR */
#else /* AFS_SUN5_ENV */
mtu = rxi_FindIfMTU(pp->host);
mtu = rxi_FindIfMTU(rx_HostOf(pp));
if (mtu <= 0) {
pp->timeout.sec = 3;
@ -826,7 +834,7 @@ rxi_FindIfnet(afs_uint32 addr, afs_uint32 * maskp)
* in network byte order.
*/
osi_socket *
rxk_NewSocketHost(afs_uint32 ahost, short aport)
rxk_NewSocketHost(struct sockaddr_storage *saddr, int salen)
{
register afs_int32 code;
#ifdef AFS_DARWIN80_ENV
@ -837,7 +845,6 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport)
#if (!defined(AFS_HPUX1122_ENV) && !defined(AFS_FBSD50_ENV))
struct mbuf *nam;
#endif
struct sockaddr_in myaddr;
#ifdef AFS_HPUX110_ENV
/* prototype copied from kernel source file streams/str_proto.h */
extern MBLKP allocb_wait(int, int);
@ -861,7 +868,7 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport)
/* we need a file associated with the socket so sosend in NetSend
* will not fail */
/* blocking socket */
code = socreate(AF_INET, &newSocket, SOCK_DGRAM, 0, 0);
code = socreate(rx_ssfamily(saddr), &newSocket, SOCK_DGRAM, 0, 0);
fp = falloc();
if (!fp)
goto bad;
@ -873,38 +880,32 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport)
newSocket->so_fp = (void *)fp;
#else /* AFS_HPUX110_ENV */
code = socreate(AF_INET, &newSocket, SOCK_DGRAM, 0, SS_NOWAIT);
code = socreate(rx_ssfamilty(saddr), &newSocket, SOCK_DGRAM, 0, SS_NOWAIT);
#endif /* else AFS_HPUX110_ENV */
#elif defined(AFS_SGI65_ENV) || defined(AFS_OBSD_ENV)
code = socreate(AF_INET, &newSocket, SOCK_DGRAM, IPPROTO_UDP);
code = socreate(rx_ssfamily(saddr), &newSocket, SOCK_DGRAM, IPPROTO_UDP);
#elif defined(AFS_FBSD50_ENV)
code = socreate(AF_INET, &newSocket, SOCK_DGRAM, IPPROTO_UDP,
code = socreate(rx_ssfamily(saddr), &newSocket, SOCK_DGRAM, IPPROTO_UDP,
afs_osi_credp, curthread);
#elif defined(AFS_FBSD40_ENV)
code = socreate(AF_INET, &newSocket, SOCK_DGRAM, IPPROTO_UDP, curproc);
code = socreate(rx_ssfamily(saddr), &newSocket, SOCK_DGRAM, IPPROTO_UDP,
curproc);
#elif defined(AFS_DARWIN80_ENV)
code = sock_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP, NULL, NULL, &newSocket);
code = sock_socket(rx_ssfamily(saddr), SOCK_DGRAM, IPPROTO_UDP, NULL, NULL,
&newSocket);
#else
code = socreate(AF_INET, &newSocket, SOCK_DGRAM, 0);
code = socreate(rx_ssfamily(saddr), &newSocket, SOCK_DGRAM, 0);
#endif /* AFS_HPUX102_ENV */
if (code)
goto bad;
memset(&myaddr, 0, sizeof myaddr);
myaddr.sin_family = AF_INET;
myaddr.sin_port = aport;
myaddr.sin_addr.s_addr = ahost;
#ifdef STRUCT_SOCKADDR_HAS_SA_LEN
myaddr.sin_len = sizeof(myaddr);
#endif
#ifdef AFS_HPUX110_ENV
bindnam = allocb_wait((addrsize + SO_MSGOFFSET + 1), BPRI_MED);
if (!bindnam) {
setuerror(ENOBUFS);
goto bad;
}
memcpy((caddr_t) bindnam->b_rptr + SO_MSGOFFSET, (caddr_t) & myaddr,
memcpy((caddr_t) bindnam->b_rptr + SO_MSGOFFSET, (caddr_t) addr,
addrsize);
bindnam->b_wptr = bindnam->b_rptr + (addrsize + SO_MSGOFFSET + 1);
@ -945,11 +946,11 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport)
#endif
#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
#if defined(AFS_FBSD50_ENV)
code = sobind(newSocket, (struct sockaddr *)&myaddr, curthread);
code = sobind(newSocket, (struct sockaddr *) saddr, curthread);
#elif defined(AFS_FBSD40_ENV)
code = sobind(newSocket, (struct sockaddr *)&myaddr, curproc);
code = sobind(newSocket, (struct sockaddr *) saddr, curproc);
#else
code = sobind(newSocket, (struct sockaddr *)&myaddr);
code = sobind(newSocket, (struct sockaddr *) saddr);
#endif
if (code) {
dpf(("sobind fails (%d)\n", (int)code));
@ -969,8 +970,8 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport)
#endif
goto bad;
}
nam->m_len = sizeof(myaddr);
memcpy(mtod(nam, caddr_t), &myaddr, sizeof(myaddr));
nam->m_len = salen;
memcpy(mtod(nam, caddr_t), saddr, salen);
#ifdef AFS_SGI65_ENV
BHV_PDATA(&bhv) = (void *)newSocket;
code = sobind(&bhv, nam);
@ -1006,7 +1007,16 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport)
osi_socket *
rxk_NewSocket(short aport)
{
return rxk_NewSocketHost(0, aport);
struct sockaddr_storage saddr;
struct sockaddr_in *sin = (struct sockaddr_in *) &saddr;
memset((void *) &saddr, 0, sizeof(saddr));
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = 0;
sin->sin_port = aport;
return rxk_NewSocketHost(&saddr, sizeof(struct sockaddr_in));
}
/* free socket allocated by rxk_NewSocket */
@ -1083,10 +1093,10 @@ afs_rxevent_daemon(void)
/* rxk_ReadPacket returns 1 if valid packet, 0 on error. */
int
rxk_ReadPacket(osi_socket so, struct rx_packet *p, int *host, int *port)
rxk_ReadPacket(osi_socket so, struct rx_packet *p,
struct sockaddr_storage *saddr, int *slen)
{
int code;
struct sockaddr_in from;
int nbytes;
afs_int32 rlen;
register afs_int32 tlen;
@ -1122,7 +1132,8 @@ rxk_ReadPacket(osi_socket so, struct rx_packet *p, int *host, int *port)
AFS_GUNLOCK();
}
#endif
code = osi_NetReceive(rx_socket, &from, p->wirevec, p->niovecs, &nbytes);
code = osi_NetReceive(rx_socket, saddr, slen, p->wirevec, p->niovecs,
&nbytes);
#ifdef RX_KERNEL_TRACE
if (ICL_SETACTIVE(afs_iclSetp)) {
@ -1143,18 +1154,26 @@ rxk_ReadPacket(osi_socket so, struct rx_packet *p, int *host, int *port)
else {
MUTEX_ENTER(&rx_stats_mutex);
rx_stats.bogusPacketOnRead++;
rx_stats.bogusHost = from.sin_addr.s_addr;
switch (rx_ssfamily(saddr)) {
case AF_INET:
rx_stats.bogusHost = rx_ss2sin(saddr)->sin_addr.s_addr;
break;
default:
#ifdef AF_INET6
case AF_INET6:
#endif /* AF_INET6 */
rx_stats.bogusHost = 0xffffffff;
}
MUTEX_EXIT(&rx_stats_mutex);
dpf(("B: bogus packet from [%x,%d] nb=%d",
from.sin_addr.s_addr, from.sin_port, nbytes));
ntohl(rx_ss2v4addr(saddr)), ntohs(rx_ss2pn(saddr)),
nbytes));
}
return -1;
} else {
/* Extract packet header. */
rxi_DecodePacketHeader(p);
*host = from.sin_addr.s_addr;
*port = from.sin_port;
if (p->header.type > 0 && p->header.type < RX_N_PACKET_TYPES) {
MUTEX_ENTER(&rx_stats_mutex);
rx_stats.packetsRead[p->header.type - 1]++;
@ -1209,8 +1228,8 @@ rxk_Listener(void)
#endif /* AFS_SUN5_ENV */
{
struct rx_packet *rxp = NULL;
int code;
int host, port;
struct sockaddr_storage saddr;
int code, slen;
#ifdef AFS_LINUX20_ENV
rxk_ListenerPid = current->pid;
@ -1237,8 +1256,8 @@ rxk_Listener(void)
if (!rxp)
osi_Panic("rxk_Listener: No more Rx buffers!\n");
}
if (!(code = rxk_ReadPacket(rx_socket, rxp, &host, &port))) {
rxp = rxi_ReceivePacket(rxp, rx_socket, host, port, 0, 0);
if (!(code = rxk_ReadPacket(rx_socket, rxp, &saddr, &slen))) {
rxp = rxi_ReceivePacket(rxp, rx_socket, &saddr, slen, 0, 0);
}
}

View File

@ -163,8 +163,8 @@ rxi_StartListener(void)
static void
rxi_ListenerProc(fd_set * rfds, int *tnop, struct rx_call **newcallp)
{
afs_uint32 host;
u_short port;
struct sockaddr_storage saddr;
int slen;
register struct rx_packet *p = (struct rx_packet *)0;
osi_socket socket;
struct clock cv;
@ -274,9 +274,10 @@ rxi_ListenerProc(fd_set * rfds, int *tnop, struct rx_call **newcallp)
#ifdef AFS_NT40_ENV
for (i = 0; p && i < rfds->fd_count; i++) {
socket = rfds->fd_array[i];
if (rxi_ReadPacket(socket, p, &host, &port)) {
slen = sizeof(saddr);
if (rxi_ReadPacket(socket, p, &saddr, &slen)) {
*newcallp = NULL;
p = rxi_ReceivePacket(p, socket, host, port, tnop,
p = rxi_ReceivePacket(p, socket, &saddr, slen, tnop,
newcallp);
if (newcallp && *newcallp) {
if (p) {
@ -295,8 +296,9 @@ rxi_ListenerProc(fd_set * rfds, int *tnop, struct rx_call **newcallp)
p && socket <= rx_maxSocketNumber; socket++) {
if (!FD_ISSET(socket, rfds))
continue;
if (rxi_ReadPacket(socket, p, &host, &port)) {
p = rxi_ReceivePacket(p, socket, host, port, tnop,
slen = sizeof(saddr);
if (rxi_ReadPacket(socket, p, &saddr, &slen)) {
p = rxi_ReceivePacket(p, socket, &saddr, slen, tnop,
newcallp);
if (newcallp && *newcallp) {
if (p) {

View File

@ -112,7 +112,7 @@ extern int (*rx_almostSent) ();
static int AllocPacketBufs(int class, int num_pkts, struct rx_queue *q);
static void rxi_SendDebugPacket(struct rx_packet *apacket, osi_socket asocket,
afs_int32 ahost, short aport,
struct sockaddr_storage *saddr, int slen,
afs_int32 istack);
static int rxi_FreeDataBufsToQueue(struct rx_packet *p, int first,
@ -1350,10 +1350,9 @@ CountFDs(register int amax)
* the data length of the packet is stored in the packet structure.
* The header is decoded. */
int
rxi_ReadPacket(osi_socket socket, register struct rx_packet *p, afs_uint32 * host,
u_short * port)
rxi_ReadPacket(osi_socket socket, register struct rx_packet *p,
struct sockaddr_storage *saddr, int *slen)
{
struct sockaddr_in from;
int nbytes;
afs_int32 rlen;
register afs_int32 tlen, savelen;
@ -1383,11 +1382,12 @@ rxi_ReadPacket(osi_socket socket, register struct rx_packet *p, afs_uint32 * hos
p->wirevec[p->niovecs - 1].iov_len += RX_EXTRABUFFERSIZE;
memset((char *)&msg, 0, sizeof(msg));
msg.msg_name = (char *)&from;
msg.msg_namelen = sizeof(struct sockaddr_in);
msg.msg_name = (char *)saddr;
msg.msg_namelen = *slen;
msg.msg_iov = p->wirevec;
msg.msg_iovlen = p->niovecs;
nbytes = rxi_Recvmsg(socket, &msg, 0);
*slen = msg.msg_namelen;
/* restore the vec to its correct state */
p->wirevec[p->niovecs - 1].iov_len = savelen;
@ -1403,10 +1403,20 @@ rxi_ReadPacket(osi_socket socket, register struct rx_packet *p, afs_uint32 * hos
} else {
MUTEX_ENTER(&rx_stats_mutex);
rx_stats.bogusPacketOnRead++;
rx_stats.bogusHost = from.sin_addr.s_addr;
switch (rx_ssfamily(saddr)) {
case AF_INET:
rx_stats.bogusHost = rx_ss2sin(saddr)->sin_addr.s_addr;
break;
default:
#ifdef AF_INET6
case AF_INET6:
#endif /* AF_INET6 */
rx_stats.bogusHost = 0xffffffff;
break;
}
MUTEX_EXIT(&rx_stats_mutex);
dpf(("B: bogus packet from [%x,%d] nb=%d", ntohl(from.sin_addr.s_addr),
ntohs(from.sin_port), nbytes));
dpf(("B: bogus packet from [%x,%d] nb=%d",
ntohl(rx_ss2v4addr(saddr)), ntohs(rx_ss2pn(saddr)), nbytes));
}
return 0;
}
@ -1415,11 +1425,8 @@ rxi_ReadPacket(osi_socket socket, register struct rx_packet *p, afs_uint32 * hos
&& (random() % 100 < rx_intentionallyDroppedOnReadPer100)) {
rxi_DecodePacketHeader(p);
*host = from.sin_addr.s_addr;
*port = from.sin_port;
dpf(("Dropped %d %s: %x.%u.%u.%u.%u.%u.%u flags %d len %d",
p->header.serial, rx_packetTypes[p->header.type - 1], ntohl(*host), ntohs(*port), p->header.serial,
p->header.serial, rx_packetTypes[p->header.type - 1], ntohl(rx_ss2v4addr(saddr)), ntohs(rx_ss2pn(saddr)), p->header.serial,
p->header.epoch, p->header.cid, p->header.callNumber, p->header.seq, p->header.flags,
p->length));
rxi_TrimDataBufs(p, 1);
@ -1430,8 +1437,6 @@ rxi_ReadPacket(osi_socket socket, register struct rx_packet *p, afs_uint32 * hos
/* Extract packet header. */
rxi_DecodePacketHeader(p);
*host = from.sin_addr.s_addr;
*port = from.sin_port;
if (p->header.type > 0 && p->header.type < RX_N_PACKET_TYPES) {
struct rx_peer *peer;
MUTEX_ENTER(&rx_stats_mutex);
@ -1448,7 +1453,7 @@ rxi_ReadPacket(osi_socket socket, register struct rx_packet *p, afs_uint32 * hos
* and this packet was an rxdebug packet, the peer structure would
* never be cleaned up.
*/
peer = rxi_FindPeer(*host, *port, 0, 0);
peer = rxi_FindPeer(saddr, *slen, SOCK_DGRAM, 0, 0);
/* Since this may not be associated with a connection,
* it may have no refCount, meaning we could race with
* ReapConnections
@ -1478,8 +1483,8 @@ rxi_ReadPacket(osi_socket socket, register struct rx_packet *p, afs_uint32 * hos
* last two pad bytes. */
struct rx_packet *
rxi_SplitJumboPacket(register struct rx_packet *p, afs_int32 host, short port,
int first)
rxi_SplitJumboPacket(register struct rx_packet *p,
struct sockaddr_storage *saddr, int slen, int first)
{
struct rx_packet *np;
struct rx_jumboHeader *jp;
@ -1541,8 +1546,8 @@ rxi_SplitJumboPacket(register struct rx_packet *p, afs_int32 host, short port,
#ifndef KERNEL
/* Send a udp datagram */
int
osi_NetSend(osi_socket socket, void *addr, struct iovec *dvec, int nvecs,
int length, int istack)
osi_NetSend(osi_socket socket, void *addr, int addrlen, struct iovec *dvec,
int nvecs, int length, int istack)
{
struct msghdr msg;
int ret;
@ -1551,7 +1556,7 @@ osi_NetSend(osi_socket socket, void *addr, struct iovec *dvec, int nvecs,
msg.msg_iov = dvec;
msg.msg_iovlen = nvecs;
msg.msg_name = addr;
msg.msg_namelen = sizeof(struct sockaddr_in);
msg.msg_namelen = addrlen;
ret = rxi_Sendmsg(socket, &msg, 0);
@ -1709,7 +1714,7 @@ rx_mb_to_packet(amb, free, hdr_len, data_len, phandle)
struct rx_packet *
rxi_ReceiveDebugPacket(register struct rx_packet *ap, osi_socket asocket,
afs_int32 ahost, short aport, int istack)
struct sockaddr_storage *saddr, int slen, int istack)
{
struct rx_debugIn tin;
afs_int32 tl;
@ -1762,7 +1767,7 @@ rxi_ReceiveDebugPacket(register struct rx_packet *ap, osi_socket asocket,
rx_packetwrite(ap, 0, sizeof(struct rx_debugStats),
(char *)&tstat);
ap->length = sizeof(struct rx_debugStats);
rxi_SendDebugPacket(ap, asocket, ahost, aport, istack);
rxi_SendDebugPacket(ap, asocket, saddr, slen, istack);
rx_computelen(ap, ap->length);
}
break;
@ -1803,8 +1808,18 @@ rxi_ReceiveDebugPacket(register struct rx_packet *ap, osi_socket asocket,
for (tc = rx_connHashTable[i]; tc; tc = tc->next) {
if ((all || rxi_IsConnInteresting(tc))
&& tin.index-- <= 0) {
tconn.host = tc->peer->host;
tconn.port = tc->peer->port;
switch (rx_ssfamily(&tc->peer->saddr)) {
case AF_INET:
tconn.host = rx_ss2sin(&tc->peer->saddr)->sin_addr.s_addr;
break;
default:
#ifdef AF_INET6
case AF_INET6:
#endif /* AF_INET6 */
tconn.host = 0xffffffff;
break;
}
tconn.port = rx_ss2pn(&tc->peer->saddr);
tconn.cid = htonl(tc->cid);
tconn.epoch = htonl(tc->epoch);
tconn.serial = htonl(tc->serial);
@ -1855,7 +1870,7 @@ rxi_ReceiveDebugPacket(register struct rx_packet *ap, osi_socket asocket,
(char *)&tconn);
tl = ap->length;
ap->length = sizeof(struct rx_debugConn);
rxi_SendDebugPacket(ap, asocket, ahost, aport,
rxi_SendDebugPacket(ap, asocket, saddr, slen,
istack);
ap->length = tl;
return ap;
@ -1869,7 +1884,7 @@ rxi_ReceiveDebugPacket(register struct rx_packet *ap, osi_socket asocket,
(char *)&tconn);
tl = ap->length;
ap->length = sizeof(struct rx_debugConn);
rxi_SendDebugPacket(ap, asocket, ahost, aport, istack);
rxi_SendDebugPacket(ap, asocket, saddr, slen, istack);
ap->length = tl;
break;
}
@ -1911,8 +1926,18 @@ rxi_ReceiveDebugPacket(register struct rx_packet *ap, osi_socket asocket,
MUTEX_ENTER(&rx_peerHashTable_lock);
for (tp = rx_peerHashTable[i]; tp; tp = tp->next) {
if (tin.index-- <= 0) {
tpeer.host = tp->host;
tpeer.port = tp->port;
switch (rx_ssfamily(&tp->saddr)) {
case AF_INET:
tpeer.host = rx_ss2sin(&tp->saddr)->sin_addr.s_addr;
break;
default:
#ifdef AF_INET6
case AF_INET6:
#endif /* AF_INET6 */
tpeer.host = 0xffffffff;
break;
}
tpeer.port = rx_ss2pn(&tp->saddr);
tpeer.ifMTU = htons(tp->ifMTU);
tpeer.idleWhen = htonl(tp->idleWhen);
tpeer.refCount = htons(tp->refCount);
@ -1949,7 +1974,7 @@ rxi_ReceiveDebugPacket(register struct rx_packet *ap, osi_socket asocket,
(char *)&tpeer);
tl = ap->length;
ap->length = sizeof(struct rx_debugPeer);
rxi_SendDebugPacket(ap, asocket, ahost, aport,
rxi_SendDebugPacket(ap, asocket, saddr, slen,
istack);
ap->length = tl;
return ap;
@ -1963,7 +1988,7 @@ rxi_ReceiveDebugPacket(register struct rx_packet *ap, osi_socket asocket,
(char *)&tpeer);
tl = ap->length;
ap->length = sizeof(struct rx_debugPeer);
rxi_SendDebugPacket(ap, asocket, ahost, aport, istack);
rxi_SendDebugPacket(ap, asocket, saddr, slen, istack);
ap->length = tl;
break;
}
@ -1987,7 +2012,7 @@ rxi_ReceiveDebugPacket(register struct rx_packet *ap, osi_socket asocket,
tl = ap->length;
ap->length = sizeof(rx_stats);
MUTEX_EXIT(&rx_stats_mutex);
rxi_SendDebugPacket(ap, asocket, ahost, aport, istack);
rxi_SendDebugPacket(ap, asocket, saddr, slen, istack);
ap->length = tl;
break;
}
@ -1999,7 +2024,7 @@ rxi_ReceiveDebugPacket(register struct rx_packet *ap, osi_socket asocket,
rx_packetwrite(ap, 0, sizeof(struct rx_debugIn), (char *)&tin);
tl = ap->length;
ap->length = sizeof(struct rx_debugIn);
rxi_SendDebugPacket(ap, asocket, ahost, aport, istack);
rxi_SendDebugPacket(ap, asocket, saddr, slen, istack);
ap->length = tl;
break;
}
@ -2008,7 +2033,7 @@ rxi_ReceiveDebugPacket(register struct rx_packet *ap, osi_socket asocket,
struct rx_packet *
rxi_ReceiveVersionPacket(register struct rx_packet *ap, osi_socket asocket,
afs_int32 ahost, short aport, int istack)
struct sockaddr_storage *saddr, int slen, int istack)
{
afs_int32 tl;
@ -2026,7 +2051,7 @@ rxi_ReceiveVersionPacket(register struct rx_packet *ap, osi_socket asocket,
rx_packetwrite(ap, 0, 65, buf);
tl = ap->length;
ap->length = 65;
rxi_SendDebugPacket(ap, asocket, ahost, aport, istack);
rxi_SendDebugPacket(ap, asocket, saddr, slen, istack);
ap->length = tl;
}
@ -2037,9 +2062,8 @@ rxi_ReceiveVersionPacket(register struct rx_packet *ap, osi_socket asocket,
/* send a debug packet back to the sender */
static void
rxi_SendDebugPacket(struct rx_packet *apacket, osi_socket asocket,
afs_int32 ahost, short aport, afs_int32 istack)
struct sockaddr_storage *saddr, int slen, afs_int32 istack)
{
struct sockaddr_in taddr;
int i;
int nbytes;
int saven = 0;
@ -2048,13 +2072,6 @@ rxi_SendDebugPacket(struct rx_packet *apacket, osi_socket asocket,
int waslocked = ISAFS_GLOCK();
#endif
taddr.sin_family = AF_INET;
taddr.sin_port = aport;
taddr.sin_addr.s_addr = ahost;
#ifdef STRUCT_SOCKADDR_HAS_SA_LEN
taddr.sin_len = sizeof(struct sockaddr_in);
#endif
/* We need to trim the niovecs. */
nbytes = apacket->length;
for (i = 1; i < apacket->niovecs; i++) {
@ -2081,7 +2098,7 @@ rxi_SendDebugPacket(struct rx_packet *apacket, osi_socket asocket,
#endif
#endif
/* debug packets are not reliably delivered, hence the cast below. */
(void)osi_NetSend(asocket, &taddr, apacket->wirevec, apacket->niovecs,
(void)osi_NetSend(asocket, saddr, slen, apacket->wirevec, apacket->niovecs,
apacket->length + RX_HEADER_SIZE, istack);
#ifdef KERNEL
#ifdef RX_KERNEL_TRACE
@ -2115,18 +2132,11 @@ rxi_SendPacket(struct rx_call *call, struct rx_connection *conn,
int waslocked;
#endif
int code;
struct sockaddr_in addr;
register struct rx_peer *peer = conn->peer;
osi_socket socket;
#ifdef RXDEBUG
char deliveryType = 'S';
#endif
/* The address we're sending the packet to */
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = peer->port;
addr.sin_addr.s_addr = peer->host;
/* This stuff should be revamped, I think, so that most, if not
* all, of the header stuff is always added here. We could
* probably do away with the encode/decode routines. XXXXX */
@ -2151,7 +2161,7 @@ rxi_SendPacket(struct rx_call *call, struct rx_connection *conn,
/* If an output tracer function is defined, call it with the packet and
* network address. Note this function may modify its arguments. */
if (rx_almostSent) {
int drop = (*rx_almostSent) (p, &addr);
int drop = (*rx_almostSent) (p, &peer->saddr);
/* drop packet if return value is non-zero? */
if (drop)
deliveryType = 'D'; /* Drop the packet */
@ -2198,8 +2208,9 @@ rxi_SendPacket(struct rx_call *call, struct rx_connection *conn,
#endif
#endif
if ((code =
osi_NetSend(socket, &addr, p->wirevec, p->niovecs,
p->length + RX_HEADER_SIZE, istack)) != 0) {
osi_NetSend(socket, &peer->saddr, peer->saddrlen, p->wirevec,
p->niovecs, p->length + RX_HEADER_SIZE,
istack)) != 0) {
/* send failed, so let's hurry up the resend, eh? */
MUTEX_ENTER(&rx_stats_mutex);
rx_stats.netSendFailures++;
@ -2243,7 +2254,7 @@ rxi_SendPacket(struct rx_call *call, struct rx_connection *conn,
#endif
#ifdef RXDEBUG
}
dpf(("%c %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %lx resend %d.%0.3d len %d", deliveryType, p->header.serial, rx_packetTypes[p->header.type - 1], ntohl(peer->host), ntohs(peer->port), p->header.serial, p->header.epoch, p->header.cid, p->header.callNumber, p->header.seq, p->header.flags, (unsigned long)p, p->retryTime.sec, p->retryTime.usec / 1000, p->length));
dpf(("%c %d %s: %s.%u.%u.%u.%u.%u.%u flags %d, packet %lx resend %d.%0.3d len %d", deliveryType, p->header.serial, rx_packetTypes[p->header.type - 1], rx_AddrStringOf(peer), ntohs(rx_PortOf(peer)), p->header.serial, p->header.epoch, p->header.cid, p->header.callNumber, p->header.seq, p->header.flags, (unsigned long)p, p->retryTime.sec, p->retryTime.usec / 1000, p->length));
#endif
MUTEX_ENTER(&rx_stats_mutex);
rx_stats.packetsSent[p->header.type - 1]++;
@ -2263,7 +2274,6 @@ rxi_SendPacketList(struct rx_call *call, struct rx_connection *conn,
#if defined(AFS_SUN5_ENV) && defined(KERNEL)
int waslocked;
#endif
struct sockaddr_in addr;
register struct rx_peer *peer = conn->peer;
osi_socket socket;
struct rx_packet *p = NULL;
@ -2275,10 +2285,6 @@ rxi_SendPacketList(struct rx_call *call, struct rx_connection *conn,
#ifdef RXDEBUG
char deliveryType = 'S';
#endif
/* The address we're sending the packet to */
addr.sin_family = AF_INET;
addr.sin_port = peer->port;
addr.sin_addr.s_addr = peer->host;
if (len + 1 > RX_MAXIOVECS) {
osi_Panic("rxi_SendPacketList, len > RX_MAXIOVECS\n");
@ -2351,7 +2357,7 @@ rxi_SendPacketList(struct rx_call *call, struct rx_connection *conn,
/* If an output tracer function is defined, call it with the packet and
* network address. Note this function may modify its arguments. */
if (rx_almostSent) {
int drop = (*rx_almostSent) (p, &addr);
int drop = (*rx_almostSent) (p, &peer->saddr);
/* drop packet if return value is non-zero? */
if (drop)
deliveryType = 'D'; /* Drop the packet */
@ -2389,8 +2395,8 @@ rxi_SendPacketList(struct rx_call *call, struct rx_connection *conn,
AFS_GUNLOCK();
#endif
if ((code =
osi_NetSend(socket, &addr, &wirevec[0], len + 1, length,
istack)) != 0) {
osi_NetSend(socket, &peer->saddr, peer->saddrlen, &wirevec[0],
len + 1, length, istack)) != 0) {
/* send failed, so let's hurry up the resend, eh? */
MUTEX_ENTER(&rx_stats_mutex);
rx_stats.netSendFailures++;
@ -2429,7 +2435,7 @@ rxi_SendPacketList(struct rx_call *call, struct rx_connection *conn,
assert(p != NULL);
dpf(("%c %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %lx resend %d.%0.3d len %d", deliveryType, p->header.serial, rx_packetTypes[p->header.type - 1], ntohl(peer->host), ntohs(peer->port), p->header.serial, p->header.epoch, p->header.cid, p->header.callNumber, p->header.seq, p->header.flags, (unsigned long)p, p->retryTime.sec, p->retryTime.usec / 1000, p->length));
dpf(("%c %d %s: %s.%u.%u.%u.%u.%u.%u flags %d, packet %lx resend %d.%0.3d len %d", deliveryType, p->header.serial, rx_packetTypes[p->header.type - 1], rx_AddrStringOf(peer), ntohs(rx_PortOf(peer)), p->header.serial, p->header.epoch, p->header.cid, p->header.callNumber, p->header.seq, p->header.flags, (unsigned long)p, p->retryTime.sec, p->retryTime.usec / 1000, p->length));
#endif
MUTEX_ENTER(&rx_stats_mutex);

View File

@ -14,6 +14,8 @@
extern void rx_SetEpoch(afs_uint32 epoch);
extern int rx_Init(u_int port);
extern int rx_InitHost(u_int host, u_int port);
extern int rx_InitAddrs(struct sockaddr_storage *saddrs, int *types,
int *salens, int nelem);
#ifdef AFS_NT40_ENV
extern void rx_DebugOnOff(int on);
#endif
@ -26,6 +28,11 @@ extern struct rx_connection *rx_NewConnection(register afs_uint32 shost,
register struct rx_securityClass
*securityObject,
int serviceSecurityIndex);
extern struct rx_connection *rx_NewConnectionAddrs(struct sockaddr_storage *,
int *types, int *salens,
int nelem, u_short,
struct rx_securityClass *,
int);
extern void rx_SetConnDeadTime(register struct rx_connection *conn,
register int seconds);
extern void rxi_CleanupConnection(struct rx_connection *conn);
@ -74,26 +81,27 @@ extern void rxi_FreeCall(register struct rx_call *call);
extern char *rxi_Alloc(register size_t size);
extern void rxi_Free(void *addr, register size_t size);
extern struct rx_peer *rxi_FindPeer(register afs_uint32 host,
register u_short port,
struct rx_peer *origPeer, int create);
extern struct rx_peer *rxi_FindPeer(struct sockaddr_storage *saddr, int slen,
int stype, struct rx_peer *origPeer,
int create);
extern struct rx_connection *rxi_FindConnection(osi_socket socket,
register afs_int32 host,
register u_short port,
struct sockaddr_storage *saddr,
int slen, int socktype,
u_short serviceId,
afs_uint32 cid,
afs_uint32 epoch, int type,
u_int securityIndex);
extern struct rx_packet *rxi_ReceivePacket(register struct rx_packet *np,
osi_socket socket, afs_uint32 host,
u_short port, int *tnop,
osi_socket socket,
struct sockaddr_storage *saddr,
int slen, int *tnop,
struct rx_call **newcallp);
extern int rxi_IsConnInteresting(struct rx_connection *aconn);
extern struct rx_packet *rxi_ReceiveDataPacket(register struct rx_call *call,
register struct rx_packet *np,
int istack, osi_socket socket,
afs_uint32 host, u_short port,
int *tnop,
struct sockaddr_storage *saddr,
int slen, int *tnop,
struct rx_call **newcallp);
extern struct rx_packet *rxi_ReceiveAckPacket(register struct rx_call *call,
struct rx_packet *np,
@ -327,7 +335,8 @@ extern int rxk_initDone;
extern int rxk_DelPort(u_short aport);
extern void rxk_shutdownPorts(void);
extern osi_socket rxi_GetUDPSocket(u_short port);
extern osi_socket rxi_GetHostUDPSocket(u_int host, u_short port);
extern osi_socket rxi_GetHostUDPSocket(struct sockaddr_storage *saddr,
int salen);
extern void osi_Panic();
extern int osi_utoa(char *buf, size_t len, unsigned long val);
extern void rxi_InitPeerParams(register struct rx_peer *pp);
@ -346,8 +355,8 @@ extern int rxk_FreeSocket(register struct socket *asocket);
extern osi_socket *rxk_NewSocket(short aport);
#endif
#endif
extern int rxk_ReadPacket(osi_socket so, struct rx_packet *p, int *host,
int *port);
extern int rxk_ReadPacket(osi_socket so, struct rx_packet *p,
struct sockaddr_storage *saddr, int *slen);
#ifdef UKERNEL
extern void rx_ServerProc(void);
#endif
@ -380,12 +389,13 @@ extern void afs_cv_timedwait(afs_kcondvar_t * cv, afs_kmutex_t * l,
/* ARCH/rx_knet.c */
#if defined(KERNEL) && !defined(AFS_SGI_ENV)
extern int osi_NetSend(osi_socket asocket, struct sockaddr_in *addr,
struct iovec *dvec, int nvecs, afs_int32 asize,
int istack);
extern int osi_NetSend(osi_socket asocket, struct sockaddr_storage *addr,
int addrlen, struct iovec *dvec, int nvecs,
afs_int32 asize, int istack);
#endif
extern int osi_NetReceive(osi_socket so, struct sockaddr_in *addr,
struct iovec *dvec, int nvecs, int *lengthp);
extern int osi_NetReceive(osi_socket so, struct sockaddr_storage *saddr,
int *slen, struct iovec *dvec, int nvecs,
int *lengthp);
extern void osi_StopListener(void);
extern int rxi_FindIfMTU(afs_uint32 addr);
#ifndef RXK_LISTENER_ENV
@ -469,22 +479,22 @@ extern int rxi_FreePackets(int num_pkts, struct rx_queue *q);
extern struct rx_packet *rxi_AllocSendPacket(register struct rx_call *call,
int want);
extern int rxi_ReadPacket(osi_socket socket, register struct rx_packet *p,
afs_uint32 * host, u_short * port);
struct sockaddr_storage *saddr, int *slen);
extern struct rx_packet *rxi_SplitJumboPacket(register struct rx_packet *p,
afs_int32 host, short port,
int first);
struct sockaddr_storage *saddr,
int slen, int first);
#ifndef KERNEL
extern int osi_NetSend(osi_socket socket, void *addr, struct iovec *dvec,
int nvecs, int length, int istack);
extern int osi_NetSend(osi_socket socket, void *addr, int addrlen,
struct iovec *dvec, int nvecs, int length, int istack);
#endif
extern struct rx_packet *rxi_ReceiveDebugPacket(register struct rx_packet *ap,
osi_socket asocket,
afs_int32 ahost, short aport,
int istack);
struct sockaddr_storage *saddr,
int slen, int istack);
extern struct rx_packet *rxi_ReceiveVersionPacket(register struct rx_packet
*ap, osi_socket asocket,
afs_int32 ahost,
short aport, int istack);
struct sockaddr_storage *,
int slen, int istack);
extern void rxi_SendPacket(struct rx_call *call, struct rx_connection *conn,
struct rx_packet *p, int istack);
extern void rxi_SendPacketList(struct rx_call *call,

View File

@ -201,8 +201,8 @@ rxi_ReScheduleEvents(void)
static void
rxi_ListenerProc(int sock, int *tnop, struct rx_call **newcallp)
{
unsigned int host;
u_short port;
struct sockaddr_storage saddr;
int slen;
register struct rx_packet *p = (struct rx_packet *)0;
assert(pthread_mutex_lock(&listener_mutex) == 0);
@ -225,9 +225,10 @@ rxi_ListenerProc(int sock, int *tnop, struct rx_call **newcallp)
}
}
if (rxi_ReadPacket(sock, p, &host, &port)) {
slen = sizeof(saddr);
if (rxi_ReadPacket(sock, p, &saddr, &slen)) {
clock_NewTime();
p = rxi_ReceivePacket(p, sock, host, port, tnop, newcallp);
p = rxi_ReceivePacket(p, sock, &saddr, slen, tnop, newcallp);
if (newcallp && *newcallp) {
if (p)
rxi_FreePacket(p);

View File

@ -94,7 +94,7 @@ pthread_mutex_t rx_if_mutex;
* failure. Port must be in network byte order.
*/
osi_socket
rxi_GetHostUDPSocket(u_int ahost, u_short port)
rxi_GetHostUDPSocket(struct sockaddr_storage *saddr, int salen)
{
int binds, code = 0;
osi_socket socketFd = OSI_NULLSOCKET;
@ -104,6 +104,7 @@ rxi_GetHostUDPSocket(u_int ahost, u_short port)
int pmtu=IP_PMTUDISC_DONT;
#endif
#if 0
#if !defined(AFS_NT40_ENV) && !defined(AFS_DJGPP_ENV)
if (ntohs(port) >= IPPORT_RESERVED && ntohs(port) < IPPORT_USERRESERVED) {
/* (osi_Msg "%s*WARNING* port number %d is not a reserved port number. Use port numbers above %d\n", name, port, IPPORT_USERRESERVED);
@ -116,24 +117,19 @@ rxi_GetHostUDPSocket(u_int ahost, u_short port)
goto error;
}
#endif
socketFd = socket(AF_INET, SOCK_DGRAM, 0);
#endif
socketFd = socket(rx_ssfamily(saddr), SOCK_DGRAM, 0);
if (socketFd < 0) {
perror("socket");
goto error;
}
taddr.sin_addr.s_addr = ahost;
taddr.sin_family = AF_INET;
taddr.sin_port = (u_short) port;
#ifdef STRUCT_SOCKADDR_HAS_SA_LEN
taddr.sin_len = sizeof(struct sockaddr_in);
#endif
#define MAX_RX_BINDS 10
for (binds = 0; binds < MAX_RX_BINDS; binds++) {
if (binds)
rxi_Delay(10);
code = bind(socketFd, (struct sockaddr *)&taddr, sizeof(taddr));
code = bind(socketFd, (struct sockaddr *) saddr, salen);
if (!code)
break;
}
@ -209,7 +205,16 @@ rxi_GetHostUDPSocket(u_int ahost, u_short port)
osi_socket
rxi_GetUDPSocket(u_short port)
{
return rxi_GetHostUDPSocket(htonl(INADDR_ANY), port);
struct sockaddr_storage saddr;
struct sockaddr_in *sin = (struct sockaddr_in *) &saddr;
memset((void *) &saddr, 0, sizeof(saddr));
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = htonl(INADDR_ANY);
sin->sin_port = port;
return rxi_GetHostUDPSocket(&saddr, sizeof(struct sockaddr_in));
}
void
@ -634,33 +639,46 @@ rxi_InitPeerParams(struct rx_peer *pp)
#ifdef ADAPT_MTU
/* try to second-guess IP, and identify which link is most likely to
* be used for traffic to/from this host. */
ppaddr = ntohl(pp->host);
switch (rx_ssfamily(&pp->saddr)) {
case AF_INET:
ppaddr = ntohl(((struct sockaddr_in * ) &pp->saddr)->sin_addr.s_addr);
pp->ifMTU = 0;
pp->timeout.sec = 2;
pp->rateFlag = 2; /* start timing after two full packets */
/* I don't initialize these, because I presume they are bzero'd...
* pp->burstSize pp->burst pp->burstWait.sec pp->burstWait.usec
* pp->timeout.usec */
pp->ifMTU = 0;
pp->timeout.sec = 2;
pp->rateFlag = 2; /* start timing after two full packets */
/* I don't initialize these, because I presume they are bzero'd...
* pp->burstSize pp->burst pp->burstWait.sec pp->burstWait.usec
* pp->timeout.usec */
LOCK_IF;
for (ix = 0; ix < rxi_numNetAddrs; ++ix) {
if ((rxi_NetAddrs[ix] & myNetMasks[ix]) == (ppaddr & myNetMasks[ix])) {
LOCK_IF;
for (ix = 0; ix < rxi_numNetAddrs; ++ix) {
if ((rxi_NetAddrs[ix] & myNetMasks[ix]) ==
(ppaddr & myNetMasks[ix])) {
#ifdef IFF_POINTOPOINT
if (myNetFlags[ix] & IFF_POINTOPOINT)
pp->timeout.sec = 4;
if (myNetFlags[ix] & IFF_POINTOPOINT)
pp->timeout.sec = 4;
#endif /* IFF_POINTOPOINT */
rxmtu = myNetMTUs[ix] - RX_IPUDP_SIZE;
if (rxmtu < RX_MIN_PACKET_SIZE)
rxmtu = RX_MIN_PACKET_SIZE;
if (pp->ifMTU < rxmtu)
pp->ifMTU = MIN(rx_MyMaxSendSize, rxmtu);
rxmtu = myNetMTUs[ix] - RX_IPUDP_SIZE;
if (rxmtu < RX_MIN_PACKET_SIZE)
rxmtu = RX_MIN_PACKET_SIZE;
if (pp->ifMTU < rxmtu)
pp->ifMTU = MIN(rx_MyMaxSendSize, rxmtu);
}
}
}
UNLOCK_IF;
if (!pp->ifMTU) { /* not local */
pp->timeout.sec = 3;
pp->ifMTU = MIN(rx_MyMaxSendSize, RX_REMOTE_PACKET_SIZE);
UNLOCK_IF;
if (!pp->ifMTU) { /* not local */
pp->timeout.sec = 3;
pp->ifMTU = MIN(rx_MyMaxSendSize, RX_REMOTE_PACKET_SIZE);
}
break;
#ifdef AF_INET6
case AF_INET6:
#endif
default:
pp->rateFlag = 2; /* start timing after two full packets */
pp->timeout.sec = 2;
pp->ifMTU = MIN(rx_MyMaxSendSize, OLD_MAX_PACKET_SIZE);
break;
}
#else /* ADAPT_MTU */
pp->rateFlag = 2; /* start timing after two full packets */

View File

@ -364,7 +364,7 @@ CallPreamble(register struct rx_call *acall, int activecall,
if (BreakDelayedCallBacks_r(thost)) {
ViceLog(0,
("BreakDelayedCallbacks FAILED for host %s:%d which IS UP. Connection from %s:%d. Possible network or routing failure.\n",
afs_inet_ntoa_r(thost->host, hoststr), ntohs(thost->port), afs_inet_ntoa_r(rxr_HostOf(*tconn), hoststr2),
afs_inet_ntoa_r(thost->host, hoststr), ntohs(thost->port), rxr_AddrStringOf(*tconn),
ntohs(rxr_PortOf(*tconn))));
if (MultiProbeAlternateAddress_r(thost)) {
ViceLog(0,
@ -380,7 +380,7 @@ CallPreamble(register struct rx_call *acall, int activecall,
if (BreakDelayedCallBacks_r(thost)) {
ViceLog(0,
("BreakDelayedCallbacks FAILED AGAIN for host %s:%d which IS UP. Connection from %s:%d. Possible network or routing failure.\n",
afs_inet_ntoa_r(thost->host, hoststr), ntohs(thost->port), afs_inet_ntoa_r(rxr_HostOf(*tconn), hoststr2),
afs_inet_ntoa_r(thost->host, hoststr), ntohs(thost->port), rxr_AddrStringOf(*tconn),
ntohs(rxr_PortOf(*tconn))));
code = -1;
}
@ -2010,7 +2010,6 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid,
struct host *thost;
afs_int32 rights, anyrights; /* rights for this and any user */
struct client *t_client = NULL; /* tmp ptr to client data */
struct in_addr logHostAddr; /* host ip holder for inet_ntoa */
#if FS_STATS_DETAILED
struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
struct fs_stats_xferData *xferP; /* Ptr to this op's byte size struct */
@ -2045,10 +2044,9 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid,
/* Get ptr to client data for user Id for logging */
t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
logHostAddr.s_addr = rxr_HostOf(tcon);
ViceLog(5,
("SRXAFS_FetchData, Fid = %u.%u.%u, Host %s:%d, Id %d\n",
Fid->Volume, Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
Fid->Volume, Fid->Vnode, Fid->Unique, rxr_AddrStringOf(tcon),
ntohs(rxr_PortOf(tcon)), t_client->ViceId));
/*
* Get volume/vnode for the fetched file; caller's access rights to
@ -2274,7 +2272,6 @@ SRXAFS_FetchACL(struct rx_call * acall, struct AFSFid * Fid,
struct rx_connection *tcon = rx_ConnectionOf(acall);
struct host *thost;
struct client *t_client = NULL; /* tmp ptr to client data */
struct in_addr logHostAddr; /* host ip holder for inet_ntoa */
#if FS_STATS_DETAILED
struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
struct timeval opStartTime, opStopTime; /* Start/stop times for RPC op */
@ -2302,10 +2299,9 @@ SRXAFS_FetchACL(struct rx_call * acall, struct AFSFid * Fid,
/* Get ptr to client data for user Id for logging */
t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
logHostAddr.s_addr = rxr_HostOf(tcon);
ViceLog(5,
("SAFS_FetchACL, Fid = %u.%u.%u, Host %s:%d, Id %d\n", Fid->Volume,
Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
Fid->Vnode, Fid->Unique, rxr_AddrStringOf(tcon),
ntohs(rxr_PortOf(tcon)), t_client->ViceId));
AccessList->AFSOpaque_len = 0;
@ -2393,15 +2389,13 @@ SAFSS_FetchStatus(struct rx_call *acall, struct AFSFid *Fid,
struct client *client = 0; /* pointer to the client data */
afs_int32 rights, anyrights; /* rights for this and any user */
struct client *t_client = NULL; /* tmp ptr to client data */
struct in_addr logHostAddr; /* host ip holder for inet_ntoa */
struct rx_connection *tcon = rx_ConnectionOf(acall);
/* Get ptr to client data for user Id for logging */
t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
logHostAddr.s_addr = rxr_HostOf(tcon);
ViceLog(1,
("SAFS_FetchStatus, Fid = %u.%u.%u, Host %s:%d, Id %d\n",
Fid->Volume, Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
Fid->Volume, Fid->Vnode, Fid->Unique, rxr_AddrStringOf(tcon),
ntohs(rxr_PortOf(tcon)), t_client->ViceId));
FS_LOCK;
AFSCallStats.FetchStatus++, AFSCallStats.TotalCalls++;
@ -2847,7 +2841,6 @@ common_StoreData64(struct rx_call *acall, struct AFSFid *Fid,
struct client *client = 0; /* pointer to client structure */
afs_int32 rights, anyrights; /* rights for this and any user */
struct client *t_client = NULL; /* tmp ptr to client data */
struct in_addr logHostAddr; /* host ip holder for inet_ntoa */
struct rx_connection *tcon;
struct host *thost;
#if FS_STATS_DETAILED
@ -2883,10 +2876,9 @@ common_StoreData64(struct rx_call *acall, struct AFSFid *Fid,
/* Get ptr to client data for user Id for logging */
t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
logHostAddr.s_addr = rxr_HostOf(tcon);
ViceLog(5,
("StoreData: Fid = %u.%u.%u, Host %s:%d, Id %d\n", Fid->Volume,
Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
Fid->Vnode, Fid->Unique, rxr_AddrStringOf(tcon),
ntohs(rxr_PortOf(tcon)), t_client->ViceId));
/*
@ -3115,7 +3107,6 @@ SRXAFS_StoreACL(struct rx_call * acall, struct AFSFid * Fid,
struct rx_connection *tcon;
struct host *thost;
struct client *t_client = NULL; /* tmp ptr to client data */
struct in_addr logHostAddr; /* host ip holder for inet_ntoa */
#if FS_STATS_DETAILED
struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
struct timeval opStartTime, opStopTime; /* Start/stop times for RPC op */
@ -3136,11 +3127,10 @@ SRXAFS_StoreACL(struct rx_call * acall, struct AFSFid * Fid,
/* Get ptr to client data for user Id for logging */
t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
logHostAddr.s_addr = rxr_HostOf(tcon);
ViceLog(1,
("SAFS_StoreACL, Fid = %u.%u.%u, ACL=%s, Host %s:%d, Id %d\n",
Fid->Volume, Fid->Vnode, Fid->Unique, AccessList->AFSOpaque_val,
inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
rxr_AddrStringOf(tcon), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
FS_LOCK;
AFSCallStats.StoreACL++, AFSCallStats.TotalCalls++;
FS_UNLOCK;
@ -3233,15 +3223,13 @@ SAFSS_StoreStatus(struct rx_call *acall, struct AFSFid *Fid,
struct client *client = 0; /* pointer to client structure */
afs_int32 rights, anyrights; /* rights for this and any user */
struct client *t_client = NULL; /* tmp ptr to client data */
struct in_addr logHostAddr; /* host ip holder for inet_ntoa */
struct rx_connection *tcon = rx_ConnectionOf(acall);
/* Get ptr to client data for user Id for logging */
t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
logHostAddr.s_addr = rxr_HostOf(tcon);
ViceLog(1,
("SAFS_StoreStatus, Fid = %u.%u.%u, Host %s:%d, Id %d\n",
Fid->Volume, Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
Fid->Volume, Fid->Vnode, Fid->Unique, rxr_AddrStringOf(tcon),
ntohs(rxr_PortOf(tcon)), t_client->ViceId));
FS_LOCK;
AFSCallStats.StoreStatus++, AFSCallStats.TotalCalls++;
@ -3381,17 +3369,15 @@ SAFSS_RemoveFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
struct client *client = 0; /* pointer to client structure */
afs_int32 rights, anyrights; /* rights for this and any user */
struct client *t_client; /* tmp ptr to client data */
struct in_addr logHostAddr; /* host ip holder for inet_ntoa */
struct rx_connection *tcon = rx_ConnectionOf(acall);
FidZero(&dir);
/* Get ptr to client data for user Id for logging */
t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
logHostAddr.s_addr = rxr_HostOf(tcon);
ViceLog(1,
("SAFS_RemoveFile %s, Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
DirFid->Volume, DirFid->Vnode, DirFid->Unique,
inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
rxr_AddrStringOf(tcon), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
FS_LOCK;
AFSCallStats.RemoveFile++, AFSCallStats.TotalCalls++;
FS_UNLOCK;
@ -3546,18 +3532,16 @@ SAFSS_CreateFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
struct client *client = 0; /* pointer to client structure */
afs_int32 rights, anyrights; /* rights for this and any user */
struct client *t_client; /* tmp ptr to client data */
struct in_addr logHostAddr; /* host ip holder for inet_ntoa */
struct rx_connection *tcon = rx_ConnectionOf(acall);
FidZero(&dir);
/* Get ptr to client data for user Id for logging */
t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
logHostAddr.s_addr = rxr_HostOf(tcon);
ViceLog(1,
("SAFS_CreateFile %s, Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
DirFid->Volume, DirFid->Vnode, DirFid->Unique,
inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
rxr_AddrStringOf(tcon), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
FS_LOCK;
AFSCallStats.CreateFile++, AFSCallStats.TotalCalls++;
FS_UNLOCK;
@ -3730,7 +3714,6 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
int doDelete; /* deleted the rename target (ref count now 0) */
int code;
struct client *t_client; /* tmp ptr to client data */
struct in_addr logHostAddr; /* host ip holder for inet_ntoa */
struct rx_connection *tcon = rx_ConnectionOf(acall);
FidZero(&olddir);
@ -3740,12 +3723,11 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
/* Get ptr to client data for user Id for logging */
t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
logHostAddr.s_addr = rxr_HostOf(tcon);
ViceLog(1,
("SAFS_Rename %s to %s, Fid = %u.%u.%u to %u.%u.%u, Host %s:%d, Id %d\n",
OldName, NewName, OldDirFid->Volume, OldDirFid->Vnode,
OldDirFid->Unique, NewDirFid->Volume, NewDirFid->Vnode,
NewDirFid->Unique, inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
NewDirFid->Unique, rxr_AddrStringOf(tcon), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
FS_LOCK;
AFSCallStats.Rename++, AFSCallStats.TotalCalls++;
FS_UNLOCK;
@ -4206,7 +4188,6 @@ SAFSS_Symlink(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
struct client *client = 0; /* pointer to client structure */
afs_int32 rights, anyrights; /* rights for this and any user */
struct client *t_client; /* tmp ptr to client data */
struct in_addr logHostAddr; /* host ip holder for inet_ntoa */
FdHandle_t *fdP;
struct rx_connection *tcon = rx_ConnectionOf(acall);
@ -4214,11 +4195,10 @@ SAFSS_Symlink(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
/* Get ptr to client data for user Id for logging */
t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
logHostAddr.s_addr = rxr_HostOf(tcon);
ViceLog(1,
("SAFS_Symlink %s to %s, Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
LinkContents, DirFid->Volume, DirFid->Vnode, DirFid->Unique,
inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
rxr_AddrStringOf(tcon), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
FS_LOCK;
AFSCallStats.Symlink++, AFSCallStats.TotalCalls++;
FS_UNLOCK;
@ -4411,19 +4391,17 @@ SAFSS_Link(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
struct client *client = 0; /* pointer to client structure */
afs_int32 rights, anyrights; /* rights for this and any user */
struct client *t_client; /* tmp ptr to client data */
struct in_addr logHostAddr; /* host ip holder for inet_ntoa */
struct rx_connection *tcon = rx_ConnectionOf(acall);
FidZero(&dir);
/* Get ptr to client data for user Id for logging */
t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
logHostAddr.s_addr = rxr_HostOf(tcon);
ViceLog(1,
("SAFS_Link %s, Did = %u.%u.%u, Fid = %u.%u.%u, Host %s:%d, Id %d\n",
Name, DirFid->Volume, DirFid->Vnode, DirFid->Unique,
ExistingFid->Volume, ExistingFid->Vnode, ExistingFid->Unique,
inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
rxr_AddrStringOf(tcon), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
FS_LOCK;
AFSCallStats.Link++, AFSCallStats.TotalCalls++;
FS_UNLOCK;
@ -4617,7 +4595,6 @@ SAFSS_MakeDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
struct client *client = 0; /* pointer to client structure */
afs_int32 rights, anyrights; /* rights for this and any user */
struct client *t_client; /* tmp ptr to client data */
struct in_addr logHostAddr; /* host ip holder for inet_ntoa */
struct rx_connection *tcon = rx_ConnectionOf(acall);
FidZero(&dir);
@ -4625,11 +4602,10 @@ SAFSS_MakeDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
/* Get ptr to client data for user Id for logging */
t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
logHostAddr.s_addr = rxr_HostOf(tcon);
ViceLog(1,
("SAFS_MakeDir %s, Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
DirFid->Volume, DirFid->Vnode, DirFid->Unique,
inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
rxr_AddrStringOf(tcon), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
FS_LOCK;
AFSCallStats.MakeDir++, AFSCallStats.TotalCalls++;
FS_UNLOCK;
@ -4813,18 +4789,16 @@ SAFSS_RemoveDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
afs_int32 rights, anyrights; /* rights for this and any user */
Vnode debugvnode1, debugvnode2;
struct client *t_client; /* tmp ptr to client data */
struct in_addr logHostAddr; /* host ip holder for inet_ntoa */
struct rx_connection *tcon = rx_ConnectionOf(acall);
FidZero(&dir);
/* Get ptr to client data for user Id for logging */
t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
logHostAddr.s_addr = rxr_HostOf(tcon);
ViceLog(1,
("SAFS_RemoveDir %s, Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
DirFid->Volume, DirFid->Vnode, DirFid->Unique,
inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
rxr_AddrStringOf(tcon), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
FS_LOCK;
AFSCallStats.RemoveDir++, AFSCallStats.TotalCalls++;
FS_UNLOCK;
@ -4970,7 +4944,6 @@ SAFSS_SetLock(struct rx_call *acall, struct AFSFid *Fid, ViceLockType type,
struct client *client = 0; /* pointer to client structure */
afs_int32 rights, anyrights; /* rights for this and any user */
struct client *t_client; /* tmp ptr to client data */
struct in_addr logHostAddr; /* host ip holder for inet_ntoa */
static char *locktype[4] = { "LockRead", "LockWrite", "LockExtend", "LockRelease" };
struct rx_connection *tcon = rx_ConnectionOf(acall);
@ -4980,11 +4953,10 @@ SAFSS_SetLock(struct rx_call *acall, struct AFSFid *Fid, ViceLockType type,
}
/* Get ptr to client data for user Id for logging */
t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
logHostAddr.s_addr = rxr_HostOf(tcon);
ViceLog(1,
("SAFS_SetLock type = %s Fid = %u.%u.%u, Host %s:%d, Id %d\n",
locktype[(int)type], Fid->Volume, Fid->Vnode, Fid->Unique,
inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
rxr_AddrStringOf(tcon), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
FS_LOCK;
AFSCallStats.SetLock++, AFSCallStats.TotalCalls++;
FS_UNLOCK;
@ -5101,15 +5073,13 @@ SAFSS_ExtendLock(struct rx_call *acall, struct AFSFid *Fid,
struct client *client = 0; /* pointer to client structure */
afs_int32 rights, anyrights; /* rights for this and any user */
struct client *t_client; /* tmp ptr to client data */
struct in_addr logHostAddr; /* host ip holder for inet_ntoa */
struct rx_connection *tcon = rx_ConnectionOf(acall);
/* Get ptr to client data for user Id for logging */
t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
logHostAddr.s_addr = rxr_HostOf(tcon);
ViceLog(1,
("SAFS_ExtendLock Fid = %u.%u.%u, Host %s:%d, Id %d\n", Fid->Volume,
Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
Fid->Vnode, Fid->Unique, rxr_AddrStringOf(tcon),
ntohs(rxr_PortOf(tcon)), t_client->ViceId));
FS_LOCK;
AFSCallStats.ExtendLock++, AFSCallStats.TotalCalls++;
@ -5228,15 +5198,13 @@ SAFSS_ReleaseLock(struct rx_call *acall, struct AFSFid *Fid,
struct client *client = 0; /* pointer to client structure */
afs_int32 rights, anyrights; /* rights for this and any user */
struct client *t_client; /* tmp ptr to client data */
struct in_addr logHostAddr; /* host ip holder for inet_ntoa */
struct rx_connection *tcon = rx_ConnectionOf(acall);
/* Get ptr to client data for user Id for logging */
t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
logHostAddr.s_addr = rxr_HostOf(tcon);
ViceLog(1,
("SAFS_ReleaseLock Fid = %u.%u.%u, Host %s:%d, Id %d\n", Fid->Volume,
Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
Fid->Vnode, Fid->Unique, rxr_AddrStringOf(tcon),
ntohs(rxr_PortOf(tcon)), t_client->ViceId));
FS_LOCK;
AFSCallStats.ReleaseLock++, AFSCallStats.TotalCalls++;
@ -5936,8 +5904,8 @@ common_GiveUpCallBacks(struct rx_call *acall, struct AFSCBFids *FidArray,
if (!FidArray && !CallBackArray) {
ViceLog(1,
("SAFS_GiveUpAllCallBacks: host=%x\n",
(tcon->peer ? tcon->peer->host : 0)));
("SAFS_GiveUpAllCallBacks: host=%s\n",
(tcon->peer ? rx_AddrStringOf(tcon->peer) : "<unknown>")));
errorCode = GetClient(tcon, &client);
if (!errorCode) {
DeleteAllCallBacks_r(client->host, 1);
@ -5946,9 +5914,9 @@ common_GiveUpCallBacks(struct rx_call *acall, struct AFSCBFids *FidArray,
} else {
if (FidArray->AFSCBFids_len < CallBackArray->AFSCBs_len) {
ViceLog(0,
("GiveUpCallBacks: #Fids %d < #CallBacks %d, host=%x\n",
("GiveUpCallBacks: #Fids %d < #CallBacks %d, host=%s\n",
FidArray->AFSCBFids_len, CallBackArray->AFSCBs_len,
(tcon->peer ? tcon->peer->host : 0)));
(tcon->peer ? rx_AddrStringOf(tcon->peer) : "<unknown>")));
errorCode = EINVAL;
goto Bad_GiveUpCallBacks;
}
@ -6977,7 +6945,6 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
afs_sfsize_t adjustSize; /* bytes to call VAdjust... with */
int linkCount; /* link count on inode */
FdHandle_t *fdP;
struct in_addr logHostAddr; /* host ip holder for inet_ntoa */
#if FS_STATS_DETAILED
/*
@ -6995,12 +6962,12 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
if (Pos == -1 || VN_GET_INO(targetptr) == 0) {
/* the inode should have been created in Alloc_NewVnode */
logHostAddr.s_addr = rxr_HostOf(rx_ConnectionOf(Call));
ViceLog(0,
("StoreData_RXStyle : Inode non-existent Fid = %u.%u.%u, inode = %llu, Pos %llu Host %s:%d\n",
Fid->Volume, Fid->Vnode, Fid->Unique,
(afs_uintmax_t) VN_GET_INO(targetptr), (afs_uintmax_t) Pos,
inet_ntoa(logHostAddr), ntohs(rxr_PortOf(rx_ConnectionOf(Call)))));
rxr_AddrStringOf(rx_ConnectionOf(Call)),
ntohs(rxr_PortOf(rx_ConnectionOf(Call)))));
return ENOENT; /* is this proper error code? */
} else {
/*

View File

@ -1832,7 +1832,7 @@ h_FindClient_r(struct rx_connection *tcon)
if (created) {
ViceLog(0, ("FindClient: stillborn client %x(%x); conn %x (host %s:%d) had client %x(%x)\n",
client, client->sid, tcon,
afs_inet_ntoa_r(rxr_HostOf(tcon), hoststr),
rxr_AddrStringOf(tcon),
ntohs(rxr_PortOf(tcon)),
oldClient, oldClient->sid));
if ((client->ViceId != ANONYMOUSID) && client->CPS.prlist_val)
@ -1858,7 +1858,7 @@ h_FindClient_r(struct rx_connection *tcon)
oldClient->tcon = (struct rx_connection *)0;
ViceLog(0, ("FindClient: deleted client %x(%x) already had conn %x (host %s:%d), stolen by client %x(%x)\n",
oldClient, oldClient->sid, tcon,
afs_inet_ntoa_r(rxr_HostOf(tcon), hoststr),
rxr_AddrStringOf(tcon),
ntohs(rxr_PortOf(tcon)),
client, client->sid));
/* rx_SetSpecific will be done immediately below */
@ -1907,8 +1907,8 @@ GetClient(struct rx_connection *tcon, struct client **cp)
client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
if (client == NULL || client->tcon == NULL) {
ViceLog(0,
("GetClient: no client in conn %x (host %x:%d), VBUSYING\n",
tcon, rxr_HostOf(tcon),ntohs(rxr_PortOf(tcon))));
("GetClient: no client in conn %x (host %s:%d), VBUSYING\n",
tcon, rxr_AddrStringOf(tcon),ntohs(rxr_PortOf(tcon))));
H_UNLOCK;
return VBUSY;
}

View File

@ -279,6 +279,9 @@ struct host *(hosttableptrs[h_MAXHOSTTABLES]); /* Used by h_itoh */
#define rxr_HostOf(aconn) \
rx_HostOf(rx_PeerOf((struct rx_connection *)(aconn)))
#define rxr_AddrStringOf(aconn) \
rx_AddrStringOf(rx_PeerOf((struct rx_connection *)(aconn)))
#define HCPS_INPROGRESS 0x01 /*set when CPS is being updated */
#define HCPS_WAITING 0x02 /*waiting for CPS to get updated */
#define ALTADDR 0x04 /*InitCallBack is being done */