Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Eliminate several uses of `curproc' from the socket-laye...
details: https://anonhg.NetBSD.org/src/rev/439088f010fe
branches: trunk
changeset: 566869:439088f010fe
user: jonathan <jonathan%NetBSD.org@localhost>
date: Sat May 22 22:52:13 2004 +0000
description:
Eliminate several uses of `curproc' from the socket-layer code and from NFS.
Add a new explicit `struct proc *p' argument to socreate(), sosend().
Use that argument instead of curproc. Follow-on changes to pass that
argument to socreate(), sosend(), and (*so->so_send)() calls.
These changes reviewed and independently recoded by Matt Thomas.
Changes to soreceive() and (*dom->dom_exernalize() from Matt Thomas:
pass soreceive()'s struct uio* uio->uio_procp to unp_externalize().
Eliminate curproc from unp_externalize. Also, now soreceive() uses
its uio->uio_procp value, pass that same value downward to
((pr->pru_usrreq)() calls for consistency, instead of (struct proc * )0.
Similar changes in sys/nfs to eliminate (most) uses of curproc,
either via the req-> r_procp field of a struct nfsreq *req argument,
or by passing down new explicit struct proc * arguments.
Reviewed by: Matt Thomas, posted to tech-kern.
NB: The (*pr->pru_usrreq)() change should be tested on more (all!) protocols.
diffstat:
sys/compat/svr4/svr4_net.c | 6 ++--
sys/kern/sys_socket.c | 6 ++--
sys/kern/uipc_socket.c | 44 +++++++++++++++----------------
sys/kern/uipc_syscalls.c | 18 ++++++------
sys/kern/uipc_usrreq.c | 7 ++--
sys/miscfs/fifofs/fifo_vnops.c | 12 +++++---
sys/miscfs/portal/portal_vnops.c | 8 ++--
sys/netsmb/smb_trantcp.c | 10 +++---
sys/nfs/krpc.h | 7 ++--
sys/nfs/krpc_subr.c | 19 +++++++-----
sys/nfs/nfs_boot.c | 41 ++++++++++++++++------------
sys/nfs/nfs_bootdhcp.c | 12 ++++----
sys/nfs/nfs_bootparam.c | 24 +++++++++-------
sys/nfs/nfs_nqlease.c | 20 +++++++------
sys/nfs/nfs_socket.c | 56 +++++++++++++++++++++++++---------------
sys/nfs/nfs_syscalls.c | 6 ++--
sys/nfs/nfs_var.h | 17 ++++++-----
sys/nfs/nfs_vfsops.c | 15 +++++-----
sys/nfs/nfsdiskless.h | 6 ++--
sys/nfs/nfsmount.h | 5 ++-
sys/sys/domain.h | 5 ++-
sys/sys/socketvar.h | 10 +++---
sys/sys/un.h | 4 +-
23 files changed, 194 insertions(+), 164 deletions(-)
diffs (truncated from 1448 to 300 lines):
diff -r bcc7b25ad072 -r 439088f010fe sys/compat/svr4/svr4_net.c
--- a/sys/compat/svr4/svr4_net.c Sat May 22 22:13:50 2004 +0000
+++ b/sys/compat/svr4/svr4_net.c Sat May 22 22:52:13 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: svr4_net.c,v 1.35 2003/09/13 08:32:10 jdolecek Exp $ */
+/* $NetBSD: svr4_net.c,v 1.36 2004/05/22 22:52:13 jonathan Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svr4_net.c,v 1.35 2003/09/13 08:32:10 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_net.c,v 1.36 2004/05/22 22:52:13 jonathan Exp $");
#define COMPAT_SVR4 1
@@ -203,7 +203,7 @@
if ((error = falloc(p, &fp, &fd)) != 0)
return error;
- if ((error = socreate(family, &so, type, protocol)) != 0) {
+ if ((error = socreate(family, &so, type, protocol, p)) != 0) {
DPRINTF(("socreate error %d\n", error));
fdremove(p->p_fd, fd);
FILE_UNUSE(fp, NULL);
diff -r bcc7b25ad072 -r 439088f010fe sys/kern/sys_socket.c
--- a/sys/kern/sys_socket.c Sat May 22 22:13:50 2004 +0000
+++ b/sys/kern/sys_socket.c Sat May 22 22:52:13 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_socket.c,v 1.39 2003/09/21 19:17:08 jdolecek Exp $ */
+/* $NetBSD: sys_socket.c,v 1.40 2004/05/22 22:52:13 jonathan Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.39 2003/09/21 19:17:08 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.40 2004/05/22 22:52:13 jonathan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -79,7 +79,7 @@
{
struct socket *so = (struct socket *) fp->f_data;
return ((*so->so_send)(so, (struct mbuf *)0,
- uio, (struct mbuf *)0, (struct mbuf *)0, 0));
+ uio, (struct mbuf *)0, (struct mbuf *)0, 0, uio->uio_procp));
}
int
diff -r bcc7b25ad072 -r 439088f010fe sys/kern/uipc_socket.c
--- a/sys/kern/uipc_socket.c Sat May 22 22:13:50 2004 +0000
+++ b/sys/kern/uipc_socket.c Sat May 22 22:52:13 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_socket.c,v 1.101 2004/05/01 02:24:38 matt Exp $ */
+/* $NetBSD: uipc_socket.c,v 1.102 2004/05/22 22:52:13 jonathan Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.101 2004/05/01 02:24:38 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.102 2004/05/22 22:52:13 jonathan Exp $");
#include "opt_sock_counters.h"
#include "opt_sosend_loan.h"
@@ -407,6 +407,7 @@
/* XXX KDASSERT */
KASSERT(npgs <= M_EXT_MAXPAGES);
+ KASSERT(uio->uio_procp != NULL);
lva = sokvaalloc(len, so);
if (lva == 0)
@@ -450,14 +451,12 @@
*/
/*ARGSUSED*/
int
-socreate(int dom, struct socket **aso, int type, int proto)
+socreate(int dom, struct socket **aso, int type, int proto, struct proc *p)
{
- struct proc *p;
const struct protosw *prp;
struct socket *so;
int error, s;
- p = curproc; /* XXX */
if (proto)
prp = pffindproto(dom, proto, type);
else
@@ -650,12 +649,10 @@
}
int
-soconnect(struct socket *so, struct mbuf *nam)
+soconnect(struct socket *so, struct mbuf *nam, struct proc *p)
{
- struct proc *p;
int s, error;
- p = curproc; /* XXX */
if (so->so_options & SO_ACCEPTCONN)
return (EOPNOTSUPP);
s = splsoftnet();
@@ -732,16 +729,14 @@
*/
int
sosend(struct socket *so, struct mbuf *addr, struct uio *uio, struct mbuf *top,
- struct mbuf *control, int flags)
+ struct mbuf *control, int flags, struct proc *p)
{
- struct proc *p;
struct mbuf **mp, *m;
long space, len, resid, clen, mlen;
int error, s, dontroute, atomic;
sodopendfree(so);
- p = curproc; /* XXX */
clen = 0;
atomic = sosendallatonce(so) || top;
if (uio)
@@ -762,7 +757,8 @@
dontroute =
(flags & MSG_DONTROUTE) && (so->so_options & SO_DONTROUTE) == 0 &&
(so->so_proto->pr_flags & PR_ATOMIC);
- p->p_stats->p_ru.ru_msgsnd++;
+ if (p)
+ p->p_stats->p_ru.ru_msgsnd++;
if (control)
clen = control->m_len;
#define snderr(errno) { error = errno; splx(s); goto release; }
@@ -935,6 +931,7 @@
soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio,
struct mbuf **mp0, struct mbuf **controlp, int *flagsp)
{
+ struct proc * p;
struct mbuf *m, **mp;
int flags, len, error, s, offset, moff, type, orig_resid;
const struct protosw *pr;
@@ -945,6 +942,8 @@
mp = mp0;
type = 0;
orig_resid = uio->uio_resid;
+ p = uio->uio_procp;
+
if (paddr)
*paddr = 0;
if (controlp)
@@ -960,8 +959,8 @@
if (flags & MSG_OOB) {
m = m_get(M_WAIT, MT_DATA);
error = (*pr->pr_usrreq)(so, PRU_RCVOOB, m,
- (struct mbuf *)(long)(flags & MSG_PEEK), (struct mbuf *)0,
- (struct proc *)0);
+ (struct mbuf *)(long)(flags & MSG_PEEK),
+ (struct mbuf *)0, p);
if (error)
goto bad;
do {
@@ -978,7 +977,7 @@
*mp = (struct mbuf *)0;
if (so->so_state & SS_ISCONFIRMING && uio->uio_resid)
(*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0,
- (struct mbuf *)0, (struct mbuf *)0, (struct proc *)0);
+ (struct mbuf *)0, (struct mbuf *)0, p);
restart:
if ((error = sblock(&so->so_rcv, SBLOCKWAIT(flags))) != 0)
@@ -1052,8 +1051,8 @@
* info, we save a copy of m->m_nextpkt into nextrecord.
*/
#ifdef notyet /* XXXX */
- if (uio->uio_procp)
- uio->uio_procp->p_stats->p_ru.ru_msgrcv++;
+ if (p)
+ p->p_stats->p_ru.ru_msgrcv++;
#endif
KASSERT(m == so->so_rcv.sb_mb);
SBLASTRECORDCHK(&so->so_rcv, "soreceive 1");
@@ -1092,10 +1091,11 @@
sbfree(&so->so_rcv, m);
mbuf_removed = 1;
if (controlp) {
- if (pr->pr_domain->dom_externalize &&
+ struct domain *dom = pr->pr_domain;
+ if (dom->dom_externalize && p &&
mtod(m, struct cmsghdr *)->cmsg_type ==
SCM_RIGHTS)
- error = (*pr->pr_domain->dom_externalize)(m);
+ error = (*dom->dom_externalize)(m, p);
*controlp = m;
so->so_rcv.sb_mb = m->m_next;
m->m_next = 0;
@@ -1281,8 +1281,7 @@
(*pr->pr_usrreq)(so, PRU_RCVD,
(struct mbuf *)0,
(struct mbuf *)(long)flags,
- (struct mbuf *)0,
- (struct proc *)0);
+ (struct mbuf *)0, p);
SBLASTRECORDCHK(&so->so_rcv, "soreceive sbwait 2");
SBLASTMBUFCHK(&so->so_rcv, "soreceive sbwait 2");
error = sbwait(&so->so_rcv);
@@ -1319,8 +1318,7 @@
SBLASTMBUFCHK(&so->so_rcv, "soreceive 4");
if (pr->pr_flags & PR_WANTRCVD && so->so_pcb)
(*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0,
- (struct mbuf *)(long)flags, (struct mbuf *)0,
- (struct proc *)0);
+ (struct mbuf *)(long)flags, (struct mbuf *)0, p);
}
if (orig_resid == uio->uio_resid && orig_resid &&
(flags & MSG_EOR) == 0 && (so->so_state & SS_CANTRCVMORE) == 0) {
diff -r bcc7b25ad072 -r 439088f010fe sys/kern/uipc_syscalls.c
--- a/sys/kern/uipc_syscalls.c Sat May 22 22:13:50 2004 +0000
+++ b/sys/kern/uipc_syscalls.c Sat May 22 22:52:13 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_syscalls.c,v 1.87 2004/05/18 11:31:49 ragge Exp $ */
+/* $NetBSD: uipc_syscalls.c,v 1.88 2004/05/22 22:52:13 jonathan Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1990, 1993
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.87 2004/05/18 11:31:49 ragge Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.88 2004/05/22 22:52:13 jonathan Exp $");
#include "opt_ktrace.h"
#include "opt_pipe.h"
@@ -90,7 +90,7 @@
fp->f_type = DTYPE_SOCKET;
fp->f_ops = &socketops;
error = socreate(SCARG(uap, domain), &so, SCARG(uap, type),
- SCARG(uap, protocol));
+ SCARG(uap, protocol), p);
if (error) {
FILE_UNUSE(fp, p);
fdremove(fdp, fd);
@@ -288,7 +288,7 @@
if (error)
goto out;
MCLAIM(nam, so->so_mowner);
- error = soconnect(so, nam);
+ error = soconnect(so, nam, p);
if (error)
goto bad;
if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING)) {
@@ -340,11 +340,11 @@
p = l->l_proc;
fdp = p->p_fd;
error = socreate(SCARG(uap, domain), &so1, SCARG(uap, type),
- SCARG(uap, protocol));
+ SCARG(uap, protocol), p);
if (error)
return (error);
error = socreate(SCARG(uap, domain), &so2, SCARG(uap, type),
- SCARG(uap, protocol));
+ SCARG(uap, protocol), p);
if (error)
goto free1;
/* falloc() will use the descriptor for us */
@@ -535,7 +535,7 @@
}
#endif
len = auio.uio_resid;
- error = (*so->so_send)(so, to, &auio, NULL, control, flags);
+ error = (*so->so_send)(so, to, &auio, NULL, control, flags, p);
if (error) {
if (auio.uio_resid != len && (error == ERESTART ||
error == EINTR || error == EWOULDBLOCK))
@@ -907,9 +907,9 @@
p = l->l_proc;
fdp = p->p_fd;
- if ((error = socreate(AF_LOCAL, &rso, SOCK_STREAM, 0)) != 0)
+ if ((error = socreate(AF_LOCAL, &rso, SOCK_STREAM, 0, p)) != 0)
return (error);
- if ((error = socreate(AF_LOCAL, &wso, SOCK_STREAM, 0)) != 0)
+ if ((error = socreate(AF_LOCAL, &wso, SOCK_STREAM, 0, p)) != 0)
goto free1;
/* remember this socket pair implements a pipe */
wso->so_state |= SS_ISAPIPE;
diff -r bcc7b25ad072 -r 439088f010fe sys/kern/uipc_usrreq.c
--- a/sys/kern/uipc_usrreq.c Sat May 22 22:13:50 2004 +0000
+++ b/sys/kern/uipc_usrreq.c Sat May 22 22:52:13 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_usrreq.c,v 1.77 2004/04/18 22:20:32 matt Exp $ */
+/* $NetBSD: uipc_usrreq.c,v 1.78 2004/05/22 22:52:13 jonathan Exp $ */
/*-
* Copyright (c) 1998, 2000, 2004 The NetBSD Foundation, Inc.
Home |
Main Index |
Thread Index |
Old Index