/*
- * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2010 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* If there is any doubt, return FALSE.
* The AF_INET family is handled as a special case so that address mbufs
* don't need to be saved to store "struct in_addr", which is only 4 bytes.
+ * Ditto for AF_INET6 which is only 16 bytes.
*/
static int
netaddr_match(
mbuf_t nam)
{
struct sockaddr_in *inetaddr;
+ struct sockaddr_in6 *inet6addr;
switch (family) {
case AF_INET:
inetaddr = mbuf_data(nam);
- if (inetaddr->sin_family == AF_INET &&
- inetaddr->sin_addr.s_addr == haddr->had_inetaddr)
+ if ((inetaddr->sin_family == AF_INET) &&
+ (inetaddr->sin_addr.s_addr == haddr->had_inetaddr))
return (1);
break;
- default:
+ case AF_INET6:
+ inet6addr = mbuf_data(nam);
+ if ((inet6addr->sin6_family == AF_INET6) &&
+ !bcmp(&inet6addr->sin6_addr, &haddr->had_inet6addr, sizeof(inet6addr->sin6_addr)))
+ return (1);
break;
- };
+ }
return (0);
}
{
struct nfsrvcache *rp;
struct nfsm_chain nmrep;
- struct sockaddr_in *saddr;
+ struct sockaddr *saddr;
int ret, error;
/*
for (rp = NFSRCHASH(nd->nd_retxid)->lh_first; rp != 0;
rp = rp->rc_hash.le_next) {
if (nd->nd_retxid == rp->rc_xid && nd->nd_procnum == rp->rc_proc &&
- netaddr_match(AF_INET, &rp->rc_haddr, nd->nd_nam)) {
+ netaddr_match(rp->rc_family, &rp->rc_haddr, nd->nd_nam)) {
if ((rp->rc_flag & RC_LOCKED) != 0) {
rp->rc_flag |= RC_WANTED;
msleep(rp, nfsrv_reqcache_mutex, PZERO-1, "nfsrc", NULL);
if (rp->rc_state == RC_UNUSED)
panic("nfsrv cache");
if (rp->rc_state == RC_INPROG) {
- OSAddAtomic(1, (SInt32*)&nfsstats.srvcache_inproghits);
+ OSAddAtomic64(1, &nfsstats.srvcache_inproghits);
ret = RC_DROPIT;
} else if (rp->rc_flag & RC_REPSTATUS) {
- OSAddAtomic(1, (SInt32*)&nfsstats.srvcache_nonidemdonehits);
+ OSAddAtomic64(1, &nfsstats.srvcache_nonidemdonehits);
nd->nd_repstat = rp->rc_status;
error = nfsrv_rephead(nd, slp, &nmrep, 0);
if (error) {
*mrepp = nmrep.nmc_mhead;
}
} else if (rp->rc_flag & RC_REPMBUF) {
- OSAddAtomic(1, (SInt32*)&nfsstats.srvcache_nonidemdonehits);
+ OSAddAtomic64(1, &nfsstats.srvcache_nonidemdonehits);
error = mbuf_copym(rp->rc_reply, 0, MBUF_COPYALL, MBUF_WAITOK, mrepp);
if (error) {
printf("nfsrv cache: reply copym failed for nonidem request hit\n");
ret = RC_REPLY;
}
} else {
- OSAddAtomic(1, (SInt32*)&nfsstats.srvcache_idemdonehits);
+ OSAddAtomic64(1, &nfsstats.srvcache_idemdonehits);
rp->rc_state = RC_INPROG;
ret = RC_DOIT;
}
return (ret);
}
}
- OSAddAtomic(1, (SInt32*)&nfsstats.srvcache_misses);
+ OSAddAtomic64(1, &nfsstats.srvcache_misses);
if (nfsrv_reqcache_count < nfsrv_reqcache_size) {
/* try to allocate a new entry */
MALLOC(rp, struct nfsrvcache *, sizeof *rp, M_NFSD, M_WAITOK);
rp->rc_state = RC_INPROG;
rp->rc_xid = nd->nd_retxid;
saddr = mbuf_data(nd->nd_nam);
- switch (saddr->sin_family) {
+ rp->rc_family = saddr->sa_family;
+ switch (saddr->sa_family) {
case AF_INET:
rp->rc_flag |= RC_INETADDR;
- rp->rc_inetaddr = saddr->sin_addr.s_addr;
+ rp->rc_inetaddr = ((struct sockaddr_in*)saddr)->sin_addr.s_addr;
+ break;
+ case AF_INET6:
+ rp->rc_flag |= RC_INETADDR;
+ rp->rc_inet6addr = ((struct sockaddr_in6*)saddr)->sin6_addr;
break;
default:
error = mbuf_copym(nd->nd_nam, 0, MBUF_COPYALL, MBUF_WAITOK, &rp->rc_nam);
for (rp = NFSRCHASH(nd->nd_retxid)->lh_first; rp != 0;
rp = rp->rc_hash.le_next) {
if (nd->nd_retxid == rp->rc_xid && nd->nd_procnum == rp->rc_proc &&
- netaddr_match(AF_INET, &rp->rc_haddr, nd->nd_nam)) {
+ netaddr_match(rp->rc_family, &rp->rc_haddr, nd->nd_nam)) {
if ((rp->rc_flag & RC_LOCKED) != 0) {
rp->rc_flag |= RC_WANTED;
msleep(rp, nfsrv_reqcache_mutex, PZERO-1, "nfsrc", NULL);