PERFORCE change 113248 for review
Marko Zec
zec at FreeBSD.org
Sun Jan 21 11:33:22 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=113248
Change 113248 by zec at zec_tca51 on 2007/01/21 11:33:03
Initial attempt to make the NFS client code aware of
stack virtualization.
So far NFS mounts work from the default vnet, but not
from the others. This problem is probably related to
the fact that nfs_connect() always provides &thread0, which
is bound to the default stack instance, as an argument to
socreate(). As a consequence the NFS socket gets open
in a wrong stack I guess... This needs more thought...
Affected files ...
.. //depot/projects/vimage/src/sys/kern/sys_socket.c#3 edit
.. //depot/projects/vimage/src/sys/kern/uipc_socket.c#6 edit
.. //depot/projects/vimage/src/sys/kern/uipc_syscalls.c#4 edit
.. //depot/projects/vimage/src/sys/nfsclient/nfs_vnops.c#2 edit
Differences ...
==== //depot/projects/vimage/src/sys/kern/sys_socket.c#3 (text+ko) ====
@@ -112,13 +112,11 @@
int error;
NET_LOCK_GIANT();
- CURVNETB_SET(so->so_vnetb);
#ifdef MAC
SOCK_LOCK(so);
error = mac_check_socket_send(active_cred, so);
SOCK_UNLOCK(so);
if (error) {
- CURVNETB_RESTORE();
NET_UNLOCK_GIANT();
return (error);
}
@@ -129,7 +127,6 @@
psignal(uio->uio_td->td_proc, SIGPIPE);
PROC_UNLOCK(uio->uio_td->td_proc);
}
- CURVNETB_RESTORE();
NET_UNLOCK_GIANT();
return (error);
}
@@ -323,9 +320,7 @@
fp->f_data = NULL;
if (so) {
- CURVNETB_SET(so->so_vnetb);
error = soclose(so);
- CURVNETB_RESTORE();
}
NET_UNLOCK_GIANT();
return (error);
==== //depot/projects/vimage/src/sys/kern/uipc_socket.c#6 (text+ko) ====
@@ -508,8 +508,12 @@
struct sockaddr *nam;
struct thread *td;
{
+ int error;
- return ((*so->so_proto->pr_usrreqs->pru_bind)(so, nam, td));
+ CURVNETB_SET(so->so_vnetb);
+ error = (*so->so_proto->pr_usrreqs->pru_bind)(so, nam, td);
+ CURVNETB_RESTORE();
+ return error;
}
/*
@@ -667,6 +671,7 @@
KASSERT(!(so->so_state & SS_NOFDREF), ("soclose: SS_NOFDREF on enter"));
+ CURVNETB_SET(so->so_vnetb);
funsetown(&so->so_sigio);
if (so->so_state & SS_ISCONNECTED) {
if ((so->so_state & SS_ISDISCONNECTING) == 0) {
@@ -718,6 +723,7 @@
KASSERT((so->so_state & SS_NOFDREF) == 0, ("soclose: NOFDREF"));
so->so_state |= SS_NOFDREF;
sorele(so);
+ CURVNETB_RESTORE();
return (error);
}
@@ -1344,8 +1350,10 @@
KASSERT(so->so_proto->pr_usrreqs->pru_sosend != sosend,
("sosend: protocol calls sosend"));
+ CURVNETB_SET(so->so_vnetb);
error = so->so_proto->pr_usrreqs->pru_sosend(so, addr, uio, top,
control, flags, td);
+ CURVNETB_RESTORE();
return (error);
}
==== //depot/projects/vimage/src/sys/kern/uipc_syscalls.c#4 (text+ko) ====
@@ -238,7 +238,6 @@
if (error)
goto done2;
so = fp->f_data;
- CURVNETB_SET(so->so_vnetb);
#ifdef MAC
SOCK_LOCK(so);
error = mac_check_socket_bind(td->td_ucred, so, sa);
@@ -251,7 +250,6 @@
done1:
#endif
fdrop(fp, td);
- CURVNETB_RESTORE();
done2:
NET_UNLOCK_GIANT();
return (error);
@@ -800,7 +798,6 @@
if (error)
goto bad2;
so = (struct socket *)fp->f_data;
- CURVNETB_SET(so->so_vnetb);
#ifdef MAC
SOCK_LOCK(so);
@@ -852,7 +849,6 @@
#endif
bad:
fdrop(fp, td);
- CURVNETB_RESTORE();
bad2:
NET_UNLOCK_GIANT();
return (error);
==== //depot/projects/vimage/src/sys/nfsclient/nfs_vnops.c#2 (text+ko) ====
@@ -40,6 +40,7 @@
*/
#include "opt_inet.h"
+#include "opt_vimage.h"
#include <sys/param.h>
#include <sys/kernel.h>
@@ -60,6 +61,7 @@
#include <sys/stat.h>
#include <sys/sysctl.h>
#include <sys/signalvar.h>
+#include <sys/vimage.h>
#include <vm/vm.h>
#include <vm/vm_object.h>
@@ -80,6 +82,8 @@
#include <nfsclient/nfsm_subs.h>
#include <net/if.h>
+
+#include <netinet/vinet.h>
#include <netinet/in.h>
#include <netinet/in_var.h>
@@ -1338,6 +1342,7 @@
static int
nfs_create(struct vop_create_args *ap)
{
+ INIT_VNET_INET(curvnetb);
struct vnode *dvp = ap->a_dvp;
struct vattr *vap = ap->a_vap;
struct componentname *cnp = ap->a_cnp;
@@ -1376,8 +1381,8 @@
*tl = txdr_unsigned(NFSV3CREATE_EXCLUSIVE);
tl = nfsm_build(u_int32_t *, NFSX_V3CREATEVERF);
#ifdef INET
- if (!TAILQ_EMPTY(&in_ifaddrhead))
- *tl++ = IA_SIN(TAILQ_FIRST(&in_ifaddrhead))->sin_addr.s_addr;
+ if (!TAILQ_EMPTY(&V_in_ifaddrhead))
+ *tl++ = IA_SIN(TAILQ_FIRST(&V_in_ifaddrhead))->sin_addr.s_addr;
else
#endif
*tl++ = create_verf;
More information about the p4-projects
mailing list