diff options
author | wollman <wollman@FreeBSD.org> | 1997-04-27 20:01:29 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 1997-04-27 20:01:29 +0000 |
commit | 6afbf203bd570424ecf3f9d9d9ced17f82c81adc (patch) | |
tree | 41103dcf8addc8e73880fc79975713ce1e6ba14c /sys/nfs | |
parent | ced78602fea5284de7f4cb1673405ad3f3ad57ce (diff) | |
download | FreeBSD-src-6afbf203bd570424ecf3f9d9d9ced17f82c81adc.zip FreeBSD-src-6afbf203bd570424ecf3f9d9d9ced17f82c81adc.tar.gz |
The long-awaited mega-massive-network-code- cleanup. Part I.
This commit includes the following changes:
1) Old-style (pr_usrreq()) protocols are no longer supported, the compatibility
glue for them is deleted, and the kernel will panic on boot if any are compiled
in.
2) Certain protocol entry points are modified to take a process structure,
so they they can easily tell whether or not it is possible to sleep, and
also to access credentials.
3) SS_PRIV is no more, and with it goes the SO_PRIVSTATE setsockopt()
call. Protocols should use the process pointer they are now passed.
4) The PF_LOCAL and PF_ROUTE families have been updated to use the new
style, as has the `raw' skeleton family.
5) PF_LOCAL sockets now obey the process's umask when creating a socket
in the filesystem.
As a result, LINT is now broken. I'm hoping that some enterprising hacker
with a bit more time will either make the broken bits work (should be
easy for netipx) or dike them out.
Diffstat (limited to 'sys/nfs')
-rw-r--r-- | sys/nfs/nfs_socket.c | 46 | ||||
-rw-r--r-- | sys/nfs/nfs_syscalls.c | 14 |
2 files changed, 35 insertions, 25 deletions
diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c index 86ac106..78a5773 100644 --- a/sys/nfs/nfs_socket.c +++ b/sys/nfs/nfs_socket.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_socket.c 8.5 (Berkeley) 3/30/95 - * $Id: nfs_socket.c,v 1.22 1997/03/22 06:53:08 bde Exp $ + * $Id: nfs_socket.c,v 1.23 1997/04/22 17:38:01 dfr Exp $ */ /* @@ -192,7 +192,7 @@ nfs_connect(nmp, rep) struct sockaddr_in *sin; struct mbuf *m; u_short tport; - struct proc *p = &proc0; /* only used for socreate */ + struct proc *p = &proc0; /* only used for socreate and sobind */ nmp->nm_so = (struct socket *)0; saddr = mtod(nmp->nm_nam, struct sockaddr *); @@ -201,7 +201,6 @@ nfs_connect(nmp, rep) if (error) goto bad; so = nmp->nm_so; - so->so_state &= ~SS_PRIV; /* don't need it */ nmp->nm_soflags = so->so_proto->pr_flags; /* @@ -215,7 +214,7 @@ nfs_connect(nmp, rep) sin->sin_addr.s_addr = INADDR_ANY; tport = IPPORT_RESERVED - 1; sin->sin_port = htons(tport); - while ((error = sobind(so, m)) == EADDRINUSE && + while ((error = sobind(so, m, p)) == EADDRINUSE && --tport > IPPORT_RESERVED / 2) sin->sin_port = htons(tport); m_freem(m); @@ -233,7 +232,7 @@ nfs_connect(nmp, rep) goto bad; } } else { - error = soconnect(so, nmp->nm_nam); + error = soconnect(so, nmp->nm_nam, p); if (error) goto bad; @@ -282,13 +281,13 @@ nfs_connect(nmp, rep) MGET(m, M_WAIT, MT_SOOPTS); *mtod(m, int *) = 1; m->m_len = sizeof(int); - sosetopt(so, SOL_SOCKET, SO_KEEPALIVE, m); + sosetopt(so, SOL_SOCKET, SO_KEEPALIVE, m, p); } if (so->so_proto->pr_protocol == IPPROTO_TCP) { MGET(m, M_WAIT, MT_SOOPTS); *mtod(m, int *) = 1; m->m_len = sizeof(int); - sosetopt(so, IPPROTO_TCP, TCP_NODELAY, m); + sosetopt(so, IPPROTO_TCP, TCP_NODELAY, m, p); } sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR + sizeof (u_long)) * 2; @@ -414,8 +413,8 @@ nfs_send(so, nam, top, rep) else flags = 0; - error = sosend(so, sendnam, (struct uio *)0, top, - (struct mbuf *)0, flags); + error = so->so_proto->pr_usrreqs->pru_sosend(so, sendnam, 0, top, 0, + flags); if (error) { if (rep) { log(LOG_INFO, "nfs send error %d for server %s\n",error, @@ -533,8 +532,10 @@ tryagain: auio.uio_procp = p; do { rcvflg = MSG_WAITALL; - error = soreceive(so, (struct mbuf **)0, &auio, - (struct mbuf **)0, (struct mbuf **)0, &rcvflg); + error = so->so_proto->pr_usrreqs->pru_soreceive + (so, (struct mbuf **)0, &auio, + (struct mbuf **)0, (struct mbuf **)0, + &rcvflg); if (error == EWOULDBLOCK && rep) { if (rep->r_flags & R_SOFTTERM) return (EINTR); @@ -566,8 +567,9 @@ tryagain: auio.uio_resid = len; do { rcvflg = MSG_WAITALL; - error = soreceive(so, (struct mbuf **)0, - &auio, mp, (struct mbuf **)0, &rcvflg); + error = so->so_proto->pr_usrreqs->pru_soreceive + (so, (struct mbuf **)0, + &auio, mp, (struct mbuf **)0, &rcvflg); } while (error == EWOULDBLOCK || error == EINTR || error == ERESTART); if (!error && auio.uio_resid > 0) { @@ -590,7 +592,8 @@ tryagain: auio.uio_procp = p; do { rcvflg = 0; - error = soreceive(so, (struct mbuf **)0, + error = so->so_proto->pr_usrreqs->pru_soreceive + (so, (struct mbuf **)0, &auio, mp, &control, &rcvflg); if (control) m_freem(control); @@ -632,7 +635,8 @@ errout: auio.uio_procp = p; do { rcvflg = 0; - error = soreceive(so, getnam, &auio, mp, + error = so->so_proto->pr_usrreqs->pru_soreceive + (so, getnam, &auio, mp, (struct mbuf **)0, &rcvflg); if (error == EWOULDBLOCK && (rep->r_flags & R_SOFTTERM)) @@ -1291,6 +1295,7 @@ nfs_timer(arg) register struct nfssvc_sock *slp; u_quad_t cur_usec; #endif /* NFS_NOSERVER */ + struct proc *p = &proc0; /* XXX for credentials, will break if sleep */ s = splnet(); for (rep = nfs_reqq.tqh_first; rep != 0; rep = rep->r_chain.tqe_next) { @@ -1351,10 +1356,11 @@ nfs_timer(arg) if ((nmp->nm_flag & NFSMNT_NOCONN) == 0) error = (*so->so_proto->pr_usrreqs->pru_send) (so, 0, m, (struct mbuf *)0, - (struct mbuf *)0); + (struct mbuf *)0, p); else error = (*so->so_proto->pr_usrreqs->pru_send) - (so, 0, m, nmp->nm_nam, (struct mbuf *)0); + (so, 0, m, nmp->nm_nam, (struct mbuf *)0, + p); if (error) { if (NFSIGNORE_SOERROR(nmp->nm_soflags, error)) so->so_error = 0; @@ -1666,7 +1672,8 @@ nfsrv_rcv(so, arg, waitflag) */ auio.uio_resid = 1000000000; flags = MSG_DONTWAIT; - error = soreceive(so, &nam, &auio, &mp, (struct mbuf **)0, &flags); + error = so->so_proto->pr_usrreqs->pru_soreceive + (so, &nam, &auio, &mp, (struct mbuf **)0, &flags); if (error || mp == (struct mbuf *)0) { if (error == EWOULDBLOCK) slp->ns_flag |= SLP_NEEDQ; @@ -1700,7 +1707,8 @@ nfsrv_rcv(so, arg, waitflag) do { auio.uio_resid = 1000000000; flags = MSG_DONTWAIT; - error = soreceive(so, &nam, &auio, &mp, + error = so->so_proto->pr_usrreqs->pru_soreceive + (so, &nam, &auio, &mp, (struct mbuf **)0, &flags); if (mp) { nfs_realign(mp, 10 * NFSX_UNSIGNED); diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c index 396dff8..75d43c2 100644 --- a/sys/nfs/nfs_syscalls.c +++ b/sys/nfs/nfs_syscalls.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95 - * $Id: nfs_syscalls.c,v 1.19 1997/03/22 06:53:11 bde Exp $ + * $Id: nfs_syscalls.c,v 1.20 1997/03/27 20:01:07 guido Exp $ */ #include <sys/param.h> @@ -105,7 +105,8 @@ static int notstarted = 1; static int modify_flag = 0; static void nfsd_rt __P((int sotype, struct nfsrv_descript *nd, int cacherep)); -static int nfssvc_addsock __P((struct file *,struct mbuf *)); +static int nfssvc_addsock __P((struct file *, struct mbuf *, + struct proc *)); static int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t,struct proc *)); static int nfs_privport = 0; @@ -246,7 +247,7 @@ nfssvc(p, uap, retval) if (error) return (error); } - error = nfssvc_addsock(fp, nam); + error = nfssvc_addsock(fp, nam, p); } else { error = copyin(uap->argp, (caddr_t)nsd, sizeof (*nsd)); if (error) @@ -350,9 +351,10 @@ nfssvc(p, uap, retval) * Adds a socket to the list for servicing by nfsds. */ static int -nfssvc_addsock(fp, mynam) +nfssvc_addsock(fp, mynam, p) struct file *fp; struct mbuf *mynam; + struct proc *p; { register struct mbuf *m; register int siz; @@ -400,14 +402,14 @@ nfssvc_addsock(fp, mynam) MGET(m, M_WAIT, MT_SOOPTS); *mtod(m, int *) = 1; m->m_len = sizeof(int); - sosetopt(so, SOL_SOCKET, SO_KEEPALIVE, m); + sosetopt(so, SOL_SOCKET, SO_KEEPALIVE, m, p); } if (so->so_proto->pr_domain->dom_family == AF_INET && so->so_proto->pr_protocol == IPPROTO_TCP) { MGET(m, M_WAIT, MT_SOOPTS); *mtod(m, int *) = 1; m->m_len = sizeof(int); - sosetopt(so, IPPROTO_TCP, TCP_NODELAY, m); + sosetopt(so, IPPROTO_TCP, TCP_NODELAY, m, p); } so->so_rcv.sb_flags &= ~SB_NOINTR; so->so_rcv.sb_timeo = 0; |