summaryrefslogtreecommitdiffstats
path: root/sys/nfsclient
diff options
context:
space:
mode:
authorbz <bz@FreeBSD.org>2011-02-16 21:29:13 +0000
committerbz <bz@FreeBSD.org>2011-02-16 21:29:13 +0000
commitb9b7d3e93a251adacd363eaf9d23963ec7467075 (patch)
treee312f60d853b2306ae67fe2988280d1dbc41c9cf /sys/nfsclient
parentea2186a5ebf08dfc9eddc393caec2d574ac8ce0b (diff)
downloadFreeBSD-src-b9b7d3e93a251adacd363eaf9d23963ec7467075.zip
FreeBSD-src-b9b7d3e93a251adacd363eaf9d23963ec7467075.tar.gz
Mfp4 CH=177274,177280,177284-177285,177297,177324-177325
VNET socket push back: try to minimize the number of places where we have to switch vnets and narrow down the time we stay switched. Add assertions to the socket code to catch possibly unset vnets as seen in r204147. While this reduces the number of vnet recursion in some places like NFS, POSIX local sockets and some netgraph, .. recursions are impossible to fix. The current expectations are documented at the beginning of uipc_socket.c along with the other information there. Sponsored by: The FreeBSD Foundation Sponsored by: CK Software GmbH Reviewed by: jhb Tested by: zec Tested by: Mikolaj Golub (to.my.trociny gmail.com) MFC after: 2 weeks
Diffstat (limited to 'sys/nfsclient')
-rw-r--r--sys/nfsclient/bootp_subr.c9
-rw-r--r--sys/nfsclient/krpc_subr.c3
-rw-r--r--sys/nfsclient/nfs_diskless.c4
-rw-r--r--sys/nfsclient/nfs_vfsops.c6
4 files changed, 8 insertions, 14 deletions
diff --git a/sys/nfsclient/bootp_subr.c b/sys/nfsclient/bootp_subr.c
index cff72c7..9fcd03f 100644
--- a/sys/nfsclient/bootp_subr.c
+++ b/sys/nfsclient/bootp_subr.c
@@ -584,8 +584,6 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td)
int retry;
const char *s;
- CURVNET_SET(TD_TO_VNET(td));
-
/*
* Create socket and set its recieve timeout.
*/
@@ -962,7 +960,6 @@ gotreply:
out:
soclose(so);
out0:
- CURVNET_RESTORE();
return error;
}
@@ -977,8 +974,6 @@ bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx,
struct ifaddr *ifa;
struct sockaddr_dl *sdl;
- CURVNET_SET(TD_TO_VNET(td));
-
error = socreate(AF_INET, &ifctx->so, SOCK_DGRAM, 0, td->td_ucred, td);
if (error != 0)
panic("nfs_boot: socreate, error=%d", error);
@@ -1053,8 +1048,6 @@ bootpc_fakeup_interface(struct bootpc_ifcontext *ifctx,
ifctx->ireq.ifr_name);
ifctx->sdl = sdl;
- CURVNET_RESTORE();
-
return error;
}
@@ -1630,6 +1623,7 @@ bootpc_init(void)
/*
* Find a network interface.
*/
+ CURVNET_SET(TD_TO_VNET(td));
#ifdef BOOTP_WIRED_TO
printf("bootpc_init: wired to interface '%s'\n",
__XSTRING(BOOTP_WIRED_TO));
@@ -1676,6 +1670,7 @@ bootpc_init(void)
ifctx = ifctx->next;
}
IFNET_RUNLOCK();
+ CURVNET_RESTORE();
if (gctx->interfaces == NULL || gctx->interfaces->ifp == NULL) {
#ifdef BOOTP_WIRED_TO
diff --git a/sys/nfsclient/krpc_subr.c b/sys/nfsclient/krpc_subr.c
index c2a8450..0639b6c 100644
--- a/sys/nfsclient/krpc_subr.c
+++ b/sys/nfsclient/krpc_subr.c
@@ -216,8 +216,6 @@ krpc_call(struct sockaddr_in *sa, u_int prog, u_int vers, u_int func,
nam = mhead = NULL;
from = NULL;
- CURVNET_SET(TD_TO_VNET(td));
-
/*
* Create socket and set its recieve timeout.
*/
@@ -430,7 +428,6 @@ krpc_call(struct sockaddr_in *sa, u_int prog, u_int vers, u_int func,
if (mhead) m_freem(mhead);
if (from) free(from, M_SONAME);
soclose(so);
- CURVNET_RESTORE();
return error;
}
diff --git a/sys/nfsclient/nfs_diskless.c b/sys/nfsclient/nfs_diskless.c
index aacecff..b574945 100644
--- a/sys/nfsclient/nfs_diskless.c
+++ b/sys/nfsclient/nfs_diskless.c
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/jail.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mount.h>
@@ -202,6 +203,7 @@ nfs_setup_diskless(void)
return;
}
ifa = NULL;
+ CURVNET_SET(TD_TO_VNET(curthread));
IFNET_RLOCK();
TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
@@ -213,12 +215,14 @@ nfs_setup_diskless(void)
LLADDR(&ourdl),
sdl->sdl_alen)) {
IFNET_RUNLOCK();
+ CURVNET_RESTORE();
goto match_done;
}
}
}
}
IFNET_RUNLOCK();
+ CURVNET_RESTORE();
printf("nfs_diskless: no interface\n");
return; /* no matching interface */
match_done:
diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c
index fc54ff6..3700708 100644
--- a/sys/nfsclient/nfs_vfsops.c
+++ b/sys/nfsclient/nfs_vfsops.c
@@ -428,7 +428,6 @@ nfs_mountroot(struct mount *mp)
char buf[128];
char *cp;
- CURVNET_SET(TD_TO_VNET(td));
#if defined(BOOTP_NFSROOT) && defined(BOOTP)
bootpc_init(); /* use bootp to get nfs_diskless filled in */
@@ -437,7 +436,6 @@ nfs_mountroot(struct mount *mp)
#endif
if (nfs_diskless_valid == 0) {
- CURVNET_RESTORE();
return (-1);
}
if (nfs_diskless_valid == 1)
@@ -504,10 +502,12 @@ nfs_mountroot(struct mount *mp)
sin.sin_family = AF_INET;
sin.sin_len = sizeof(sin);
/* XXX MRT use table 0 for this sort of thing */
+ CURVNET_SET(TD_TO_VNET(td));
error = rtrequest(RTM_ADD, (struct sockaddr *)&sin,
(struct sockaddr *)&nd->mygateway,
(struct sockaddr *)&mask,
RTF_UP | RTF_GATEWAY, NULL);
+ CURVNET_RESTORE();
if (error)
panic("nfs_mountroot: RTM_ADD: %d", error);
}
@@ -525,7 +525,6 @@ nfs_mountroot(struct mount *mp)
nd->root_args.hostname = buf;
if ((error = nfs_mountdiskless(buf,
&nd->root_saddr, &nd->root_args, td, &vp, mp)) != 0) {
- CURVNET_RESTORE();
return (error);
}
@@ -539,7 +538,6 @@ nfs_mountroot(struct mount *mp)
sizeof (prison0.pr_hostname));
mtx_unlock(&prison0.pr_mtx);
inittodr(ntohl(nd->root_time));
- CURVNET_RESTORE();
return (0);
}
OpenPOWER on IntegriCloud