From e4700d005037e3f4546b85da39ea8640598c5d1a Mon Sep 17 00:00:00 2001 From: Jeffrey Hsu Date: Fri, 5 Mar 2004 16:57:16 +0000 Subject: [PATCH] Once we distribute socket protocol processing requests to different processors, we no longer have a process context to refer to, so eliminate the use of curproc in soreserve() by passing the sockbuf resource limit all the down from the system call code to sbreserve(). Eliminate the use of curproc in unp_attach() by passing down the fields it needs from the proc structure. Define a pru_attach_info structure to hold the information the attach usrreq function requires. The thread argument to in_pcballoc() is unused, so we don't need to pass a thread structure down to in_pcballoc(). --- sys/kern/kern_prot.c | 14 ++++++++++++-- sys/kern/uipc_socket.c | 11 ++++++++--- sys/kern/uipc_socket2.c | 32 ++++++++++++++------------------ sys/kern/uipc_usrreq.c | 19 ++++++++++--------- sys/net/raw_cb.c | 8 +++----- sys/net/raw_cb.h | 4 ++-- sys/net/raw_usrreq.c | 8 ++++---- sys/net/rtsock.c | 6 +++--- sys/netgraph/socket/ng_socket.c | 8 ++++---- sys/netinet/in_pcb.c | 4 ++-- sys/netinet/in_pcb.h | 4 ++-- sys/netinet/ip_divert.c | 10 +++++----- sys/netinet/raw_ip.c | 10 +++++----- sys/netinet/tcp_usrreq.c | 15 ++++++++------- sys/netinet/udp_usrreq.c | 8 ++++---- sys/netinet6/raw_ip6.c | 10 +++++----- sys/netinet6/udp6_usrreq.c | 9 +++++---- sys/netproto/atm/atm_usrreq.c | 10 ++++------ sys/netproto/ipx/ipx_usrreq.c | 26 +++++++++++++++----------- sys/netproto/ipx/spx_usrreq.c | 21 +++++++++++---------- sys/netproto/key/keysock.c | 6 +++--- sys/netproto/natm/natm.c | 12 +++++++----- sys/netproto/smb/smb_trantcp.c | 6 ++++-- sys/sys/proc.h | 5 +++-- sys/sys/protosw.h | 10 ++++++++-- sys/sys/socketops.h | 6 +++--- sys/sys/socketvar.h | 8 +++++--- sys/vfs/nfs/nfs_socket.c | 7 +++++-- sys/vfs/nfs/nfs_syscalls.c | 5 +++-- sys/vfs/portal/portal_vnops.c | 5 +++-- 30 files changed, 170 insertions(+), 137 deletions(-) diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 7778172ef5..88b6b2f86f 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -37,7 +37,7 @@ * * @(#)kern_prot.c 8.6 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/kern_prot.c,v 1.53.2.9 2002/03/09 05:20:26 dd Exp $ - * $DragonFly: src/sys/kern/kern_prot.c,v 1.14 2003/12/20 05:58:30 dillon Exp $ + * $DragonFly: src/sys/kern/kern_prot.c,v 1.15 2004/03/05 16:57:15 hsu Exp $ */ /* @@ -820,11 +820,21 @@ suser(struct thread *td) } } +/* + * A non-null credential is expected unless NULL_CRED_OKAY is set. + */ int suser_cred(struct ucred *cred, int flag) { - KASSERT(cred != NULL, ("suser_cred: NULL cred!")); + KASSERT(cred != NULL || flag & NULL_CRED_OKAY, + ("suser_cred: NULL cred!")); + if (cred == NULL) { + if (flag & NULL_CRED_OKAY) + return (0); + else + return (EPERM); + } if (cred->cr_uid != 0) return (EPERM); if (cred->cr_prison && !(flag & PRISON_ROOT)) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index b268ae8e53..2a4ead0f86 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -32,7 +32,7 @@ * * @(#)uipc_socket.c 8.3 (Berkeley) 4/15/94 * $FreeBSD: src/sys/kern/uipc_socket.c,v 1.68.2.24 2003/11/11 17:18:18 silby Exp $ - * $DragonFly: src/sys/kern/uipc_socket.c,v 1.14 2004/03/04 10:29:23 hsu Exp $ + * $DragonFly: src/sys/kern/uipc_socket.c,v 1.15 2004/03/05 16:57:15 hsu Exp $ */ #include "opt_inet.h" @@ -129,6 +129,7 @@ socreate(int dom, struct socket **aso, int type, struct proc *p = td->td_proc; struct protosw *prp; struct socket *so; + struct pru_attach_info ai; int error; if (proto) @@ -157,7 +158,10 @@ socreate(int dom, struct socket **aso, int type, so->so_type = type; so->so_cred = crhold(p->p_ucred); so->so_proto = prp; - error = so_pru_attach(so, proto, td); + ai.sb_rlimit = &p->p_rlimit[RLIMIT_SBSIZE]; + ai.p_ucred = p->p_ucred; + ai.fd_rdir = p->p_fd->fd_rdir; + error = so_pru_attach(so, proto, &ai); if (error) { so->so_state |= SS_NOFDREF; sofree(so); @@ -1174,7 +1178,8 @@ sosetopt(so, sopt) case SO_RCVBUF: if (sbreserve(sopt->sopt_name == SO_SNDBUF ? &so->so_snd : &so->so_rcv, (u_long)optval, - so, curproc) == 0) { + so, + &curproc->p_rlimit[RLIMIT_SBSIZE]) == 0) { error = ENOBUFS; goto bad; } diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c index e77388074f..47708f7c23 100644 --- a/sys/kern/uipc_socket2.c +++ b/sys/kern/uipc_socket2.c @@ -32,7 +32,7 @@ * * @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93 * $FreeBSD: src/sys/kern/uipc_socket2.c,v 1.55.2.17 2002/08/31 19:04:55 dwmalone Exp $ - * $DragonFly: src/sys/kern/uipc_socket2.c,v 1.6 2003/08/28 01:48:18 hmp Exp $ + * $DragonFly: src/sys/kern/uipc_socket2.c,v 1.7 2004/03/05 16:57:15 hsu Exp $ */ #include "opt_param.h" @@ -174,6 +174,7 @@ struct socket * sonewconn(struct socket *head, int connstatus) { struct socket *so; + struct pru_attach_info ai; if (head->so_qlen > 3 * head->so_qlimit / 2) return ((struct socket *)0); @@ -190,8 +191,11 @@ sonewconn(struct socket *head, int connstatus) so->so_proto = head->so_proto; so->so_timeo = head->so_timeo; so->so_cred = crhold(head->so_cred); - if (soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat) || - (*so->so_proto->pr_usrreqs->pru_attach)(so, 0, NULL)) { + ai.sb_rlimit = NULL; + ai.p_ucred = NULL; + ai.fd_rdir = NULL; /* jail code cruft XXX JH */ + if (soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat, NULL) || + (*so->so_proto->pr_usrreqs->pru_attach)(so, 0, &ai)) { sodealloc(so); return ((struct socket *)0); } @@ -341,15 +345,11 @@ sowakeup(so, sb) */ int -soreserve(so, sndcc, rcvcc) - struct socket *so; - u_long sndcc, rcvcc; +soreserve(struct socket *so, u_long sndcc, u_long rcvcc, struct rlimit *rl) { - struct proc *p = curproc; - - if (sbreserve(&so->so_snd, sndcc, so, p) == 0) + if (sbreserve(&so->so_snd, sndcc, so, rl) == 0) goto bad; - if (sbreserve(&so->so_rcv, rcvcc, so, p) == 0) + if (sbreserve(&so->so_rcv, rcvcc, so, rl) == 0) goto bad2; if (so->so_rcv.sb_lowat == 0) so->so_rcv.sb_lowat = 1; @@ -390,21 +390,17 @@ sysctl_handle_sb_max(SYSCTL_HANDLER_ARGS) * if buffering efficiency is near the normal case. */ int -sbreserve(sb, cc, so, p) - struct sockbuf *sb; - u_long cc; - struct socket *so; - struct proc *p; +sbreserve(struct sockbuf *sb, u_long cc, struct socket *so, struct rlimit *rl) { /* - * p will only be NULL when we're in an interrupt - * (e.g. in tcp_input()) + * rl will only be NULL when we're in an interrupt (eg, in tcp_input) + * or when called from netgraph (ie, ngd_attach) */ if (cc > sb_max_adj) return (0); if (!chgsbsize(so->so_cred->cr_uidinfo, &sb->sb_hiwat, cc, - p ? p->p_rlimit[RLIMIT_SBSIZE].rlim_cur : RLIM_INFINITY)) { + rl ? rl->rlim_cur : RLIM_INFINITY)) { return (0); } sb->sb_mbmax = min(cc * sb_efficiency, sb_max); diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 7679c41898..1ce167775e 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -32,7 +32,7 @@ * * From: @(#)uipc_usrreq.c 8.3 (Berkeley) 1/4/94 * $FreeBSD: src/sys/kern/uipc_usrreq.c,v 1.54.2.10 2003/03/04 17:28:09 nectar Exp $ - * $DragonFly: src/sys/kern/uipc_usrreq.c,v 1.11 2004/03/01 06:33:17 dillon Exp $ + * $DragonFly: src/sys/kern/uipc_usrreq.c,v 1.12 2004/03/05 16:57:15 hsu Exp $ */ #include @@ -77,7 +77,7 @@ static struct unp_head unp_shead, unp_dhead; static struct sockaddr sun_noname = { sizeof(sun_noname), AF_LOCAL }; static ino_t unp_ino; /* prototype for fake inode numbers */ -static int unp_attach (struct socket *); +static int unp_attach (struct socket *, struct pru_attach_info *); static void unp_detach (struct unpcb *); static int unp_bind (struct unpcb *,struct sockaddr *, struct thread *); static int unp_connect (struct socket *,struct sockaddr *, @@ -128,13 +128,13 @@ uipc_accept(struct socket *so, struct sockaddr **nam) } static int -uipc_attach(struct socket *so, int proto, struct thread *td) +uipc_attach(struct socket *so, int proto, struct pru_attach_info *ai) { struct unpcb *unp = sotounpcb(so); if (unp != 0) return EISCONN; - return unp_attach(so); + return unp_attach(so, ai); } static int @@ -509,8 +509,7 @@ SYSCTL_DECL(_net_local); SYSCTL_INT(_net_local, OID_AUTO, inflight, CTLFLAG_RD, &unp_rights, 0, ""); static int -unp_attach(so) - struct socket *so; +unp_attach(struct socket *so, struct pru_attach_info *ai) { struct unpcb *unp; int error; @@ -519,11 +518,13 @@ unp_attach(so) switch (so->so_type) { case SOCK_STREAM: - error = soreserve(so, unpst_sendspace, unpst_recvspace); + error = soreserve(so, unpst_sendspace, unpst_recvspace, + ai->sb_rlimit); break; case SOCK_DGRAM: - error = soreserve(so, unpdg_sendspace, unpdg_recvspace); + error = soreserve(so, unpdg_sendspace, unpdg_recvspace, + ai->sb_rlimit); break; default: @@ -540,7 +541,7 @@ unp_attach(so) unp_count++; LIST_INIT(&unp->unp_refs); unp->unp_socket = so; - unp->unp_rvnode = curproc->p_fd->fd_rdir; + unp->unp_rvnode = ai->fd_rdir; /* jail cruft XXX JH */ LIST_INSERT_HEAD(so->so_type == SOCK_DGRAM ? &unp_dhead : &unp_shead, unp, unp_link); so->so_pcb = (caddr_t)unp; diff --git a/sys/net/raw_cb.c b/sys/net/raw_cb.c index f01b1f8ad3..1793e39b87 100644 --- a/sys/net/raw_cb.c +++ b/sys/net/raw_cb.c @@ -32,7 +32,7 @@ * * @(#)raw_cb.c 8.1 (Berkeley) 6/10/93 * $FreeBSD: src/sys/net/raw_cb.c,v 1.16 1999/08/28 00:48:27 peter Exp $ - * $DragonFly: src/sys/net/raw_cb.c,v 1.4 2003/07/29 12:51:29 hmp Exp $ + * $DragonFly: src/sys/net/raw_cb.c,v 1.5 2004/03/05 16:57:15 hsu Exp $ */ #include @@ -63,9 +63,7 @@ static u_long raw_recvspace = RAWRCVQ; * of buffer space for the socket. */ int -raw_attach(so, proto) - struct socket *so; - int proto; +raw_attach(struct socket *so, int proto, struct rlimit *rl) { struct rawcb *rp = sotorawcb(so); int error; @@ -77,7 +75,7 @@ raw_attach(so, proto) */ if (rp == 0) return (ENOBUFS); - error = soreserve(so, raw_sendspace, raw_recvspace); + error = soreserve(so, raw_sendspace, raw_recvspace, rl); if (error) return (error); rp->rcb_socket = so; diff --git a/sys/net/raw_cb.h b/sys/net/raw_cb.h index 97cc0e1601..8d36c5b2e7 100644 --- a/sys/net/raw_cb.h +++ b/sys/net/raw_cb.h @@ -32,7 +32,7 @@ * * @(#)raw_cb.h 8.1 (Berkeley) 6/10/93 * $FreeBSD: src/sys/net/raw_cb.h,v 1.12 1999/12/29 04:38:37 peter Exp $ - * $DragonFly: src/sys/net/raw_cb.h,v 1.3 2003/08/26 20:49:47 rob Exp $ + * $DragonFly: src/sys/net/raw_cb.h,v 1.4 2004/03/05 16:57:15 hsu Exp $ */ #ifndef _NET_RAW_CB_H_ @@ -63,7 +63,7 @@ struct rawcb { #ifdef _KERNEL extern LIST_HEAD(rawcb_list_head, rawcb) rawcb_list; -int raw_attach (struct socket *, int); +int raw_attach (struct socket *, int, struct rlimit *); void raw_ctlinput (int, struct sockaddr *, void *); void raw_detach (struct rawcb *); void raw_disconnect (struct rawcb *); diff --git a/sys/net/raw_usrreq.c b/sys/net/raw_usrreq.c index 4c12348b7c..186eabcb6d 100644 --- a/sys/net/raw_usrreq.c +++ b/sys/net/raw_usrreq.c @@ -32,7 +32,7 @@ * * @(#)raw_usrreq.c 8.1 (Berkeley) 6/10/93 * $FreeBSD: src/sys/net/raw_usrreq.c,v 1.18 1999/08/28 00:48:28 peter Exp $ - * $DragonFly: src/sys/net/raw_usrreq.c,v 1.4 2003/06/25 03:56:02 dillon Exp $ + * $DragonFly: src/sys/net/raw_usrreq.c,v 1.5 2004/03/05 16:57:15 hsu Exp $ */ #include @@ -152,16 +152,16 @@ raw_uabort(struct socket *so) /* pru_accept is EOPNOTSUPP */ static int -raw_uattach(struct socket *so, int proto, struct thread *td) +raw_uattach(struct socket *so, int proto, struct pru_attach_info *ai) { struct rawcb *rp = sotorawcb(so); int error; if (rp == 0) return EINVAL; - if ((error = suser(td)) != 0) + if ((error = suser_cred(ai->p_ucred, NULL_CRED_OKAY)) != 0) return error; - return raw_attach(so, proto); + return raw_attach(so, proto, ai->sb_rlimit); } static int diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 89303229c4..0cbed1a992 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -32,7 +32,7 @@ * * @(#)rtsock.c 8.7 (Berkeley) 10/12/95 * $FreeBSD: src/sys/net/rtsock.c,v 1.44.2.11 2002/12/04 14:05:41 ru Exp $ - * $DragonFly: src/sys/net/rtsock.c,v 1.8 2004/01/06 03:17:25 dillon Exp $ + * $DragonFly: src/sys/net/rtsock.c,v 1.9 2004/03/05 16:57:15 hsu Exp $ */ @@ -102,7 +102,7 @@ rts_abort(struct socket *so) /* pru_accept is EOPNOTSUPP */ static int -rts_attach(struct socket *so, int proto, struct thread *td) +rts_attach(struct socket *so, int proto, struct pru_attach_info *ai) { struct rawcb *rp; int s, error; @@ -122,7 +122,7 @@ rts_attach(struct socket *so, int proto, struct thread *td) */ s = splnet(); so->so_pcb = (caddr_t)rp; - error = raw_attach(so, proto); + error = raw_attach(so, proto, ai->sb_rlimit); rp = sotorawcb(so); if (error) { splx(s); diff --git a/sys/netgraph/socket/ng_socket.c b/sys/netgraph/socket/ng_socket.c index f6d4fec9f6..786e5ffcec 100644 --- a/sys/netgraph/socket/ng_socket.c +++ b/sys/netgraph/socket/ng_socket.c @@ -37,7 +37,7 @@ * Author: Julian Elischer * * $FreeBSD: src/sys/netgraph/ng_socket.c,v 1.11.2.6 2002/07/02 22:17:18 archie Exp $ - * $DragonFly: src/sys/netgraph/socket/ng_socket.c,v 1.5 2003/08/07 21:17:32 dillon Exp $ + * $DragonFly: src/sys/netgraph/socket/ng_socket.c,v 1.6 2004/03/05 16:57:15 hsu Exp $ * $Whistle: ng_socket.c,v 1.28 1999/11/01 09:24:52 julian Exp $ */ @@ -157,11 +157,11 @@ LIST_HEAD(, ngpcb) ngsocklist; ***************************************************************/ static int -ngc_attach(struct socket *so, int proto, struct thread *td) +ngc_attach(struct socket *so, int proto, struct pru_attach_info *ai) { struct ngpcb *const pcbp = sotongpcb(so); - if (suser(td)) + if (suser_cred(ai->p_ucred, NULL_CRED_OKAY) != 0) return (EPERM); if (pcbp != NULL) return (EISCONN); @@ -479,7 +479,7 @@ ng_attach_common(struct socket *so, int type) int error; /* Standard socket setup stuff */ - error = soreserve(so, ngpdg_sendspace, ngpdg_recvspace); + error = soreserve(so, ngpdg_sendspace, ngpdg_recvspace, NULL); if (error) return (error); diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 5c2b258b0e..110b015c02 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -32,7 +32,7 @@ * * @(#)in_pcb.c 8.4 (Berkeley) 5/24/95 * $FreeBSD: src/sys/netinet/in_pcb.c,v 1.59.2.27 2004/01/02 04:06:42 ambrisko Exp $ - * $DragonFly: src/sys/netinet/in_pcb.c,v 1.11 2004/03/04 01:02:05 hsu Exp $ + * $DragonFly: src/sys/netinet/in_pcb.c,v 1.12 2004/03/05 16:57:15 hsu Exp $ */ #include "opt_ipsec.h" @@ -153,7 +153,7 @@ SYSCTL_PROC(_net_inet_ip_portrange, OID_AUTO, hilast, CTLTYPE_INT|CTLFLAG_RW, * Allocate a PCB and associate it with the socket. */ int -in_pcballoc(struct socket *so, struct inpcbinfo *pcbinfo, struct thread *td) +in_pcballoc(struct socket *so, struct inpcbinfo *pcbinfo) { struct inpcb *inp; #ifdef IPSEC diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 5fa127ad01..9551b652a0 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -32,7 +32,7 @@ * * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93 * $FreeBSD: src/sys/netinet/in_pcb.h,v 1.32.2.7 2003/01/24 05:11:34 sam Exp $ - * $DragonFly: src/sys/netinet/in_pcb.h,v 1.6 2004/03/04 01:02:05 hsu Exp $ + * $DragonFly: src/sys/netinet/in_pcb.h,v 1.7 2004/03/05 16:57:15 hsu Exp $ */ #ifndef _NETINET_IN_PCB_H_ @@ -321,7 +321,7 @@ extern int ipport_hilastauto; void in_pcbpurgeif0 (struct inpcb *, struct ifnet *); void in_losing (struct inpcb *); void in_rtchange (struct inpcb *, int); -int in_pcballoc (struct socket *, struct inpcbinfo *, struct thread *); +int in_pcballoc (struct socket *, struct inpcbinfo *); int in_pcbbind (struct inpcb *, struct sockaddr *, struct thread *); int in_pcbconnect (struct inpcb *, struct sockaddr *, struct thread *); void in_pcbdetach (struct inpcb *); diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 5fb258d110..b5b53e2dcd 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netinet/ip_divert.c,v 1.42.2.6 2003/01/23 21:06:45 sam Exp $ - * $DragonFly: src/sys/netinet/ip_divert.c,v 1.7 2004/03/04 01:02:05 hsu Exp $ + * $DragonFly: src/sys/netinet/ip_divert.c,v 1.8 2004/03/05 16:57:15 hsu Exp $ */ #include "opt_inet.h" @@ -336,7 +336,7 @@ cantsend: } static int -div_attach(struct socket *so, int proto, struct thread *td) +div_attach(struct socket *so, int proto, struct pru_attach_info *ai) { struct inpcb *inp; int error, s; @@ -344,14 +344,14 @@ div_attach(struct socket *so, int proto, struct thread *td) inp = sotoinpcb(so); if (inp) panic("div_attach"); - if ((error = suser(td)) != 0) + if ((error = suser_cred(ai->p_ucred, NULL_CRED_OKAY)) != 0) return error; - error = soreserve(so, div_sendspace, div_recvspace); + error = soreserve(so, div_sendspace, div_recvspace, ai->sb_rlimit); if (error) return error; s = splnet(); - error = in_pcballoc(so, &divcbinfo, td); + error = in_pcballoc(so, &divcbinfo); splx(s); if (error) return error; diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index d684fe19fa..bf62c11994 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -32,7 +32,7 @@ * * @(#)raw_ip.c 8.7 (Berkeley) 5/15/95 * $FreeBSD: src/sys/netinet/raw_ip.c,v 1.64.2.16 2003/08/24 08:24:38 hsu Exp $ - * $DragonFly: src/sys/netinet/raw_ip.c,v 1.9 2004/03/04 01:02:05 hsu Exp $ + * $DragonFly: src/sys/netinet/raw_ip.c,v 1.10 2004/03/05 16:57:15 hsu Exp $ */ #include "opt_inet6.h" @@ -497,7 +497,7 @@ SYSCTL_INT(_net_inet_raw, OID_AUTO, recvspace, CTLFLAG_RW, &rip_recvspace, 0, "Maximum incoming raw IP datagram size"); static int -rip_attach(struct socket *so, int proto, struct thread *td) +rip_attach(struct socket *so, int proto, struct pru_attach_info *ai) { struct inpcb *inp; int error, s; @@ -505,14 +505,14 @@ rip_attach(struct socket *so, int proto, struct thread *td) inp = sotoinpcb(so); if (inp) panic("rip_attach"); - if ((error = suser(td)) != 0) + if ((error = suser_cred(ai->p_ucred, NULL_CRED_OKAY)) != 0) return error; - error = soreserve(so, rip_sendspace, rip_recvspace); + error = soreserve(so, rip_sendspace, rip_recvspace, ai->sb_rlimit); if (error) return error; s = splnet(); - error = in_pcballoc(so, &ripcbinfo, td); + error = in_pcballoc(so, &ripcbinfo); splx(s); if (error) return error; diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 6f00e72d98..5a2edad8c3 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -32,7 +32,7 @@ * * From: @(#)tcp_usrreq.c 8.2 (Berkeley) 1/3/94 * $FreeBSD: src/sys/netinet/tcp_usrreq.c,v 1.51.2.17 2002/10/11 11:46:44 ume Exp $ - * $DragonFly: src/sys/netinet/tcp_usrreq.c,v 1.6 2004/03/04 01:02:05 hsu Exp $ + * $DragonFly: src/sys/netinet/tcp_usrreq.c,v 1.7 2004/03/05 16:57:15 hsu Exp $ */ #include "opt_ipsec.h" @@ -87,7 +87,7 @@ */ extern char *tcpstates[]; /* XXX ??? */ -static int tcp_attach (struct socket *, struct thread *); +static int tcp_attach (struct socket *, struct pru_attach_info *); static int tcp_connect (struct tcpcb *, struct sockaddr *, struct thread *); #ifdef INET6 @@ -115,7 +115,7 @@ static struct tcpcb * * and an internet control block. */ static int -tcp_usr_attach(struct socket *so, int proto, struct thread *td) +tcp_usr_attach(struct socket *so, int proto, struct pru_attach_info *ai) { int s = splnet(); int error; @@ -129,7 +129,7 @@ tcp_usr_attach(struct socket *so, int proto, struct thread *td) goto out; } - error = tcp_attach(so, td); + error = tcp_attach(so, ai); if (error) goto out; @@ -1004,7 +1004,7 @@ SYSCTL_INT(_net_inet_tcp, TCPCTL_RECVSPACE, recvspace, CTLFLAG_RW, * bufer space, and entering LISTEN state if to accept connections. */ static int -tcp_attach(struct socket *so, struct thread *td) +tcp_attach(struct socket *so, struct pru_attach_info *ai) { struct tcpcb *tp; struct inpcb *inp; @@ -1014,11 +1014,12 @@ tcp_attach(struct socket *so, struct thread *td) #endif if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) { - error = soreserve(so, tcp_sendspace, tcp_recvspace); + error = soreserve(so, tcp_sendspace, tcp_recvspace, + ai->sb_rlimit); if (error) return (error); } - error = in_pcballoc(so, &tcbinfo, td); + error = in_pcballoc(so, &tcbinfo); if (error) return (error); inp = sotoinpcb(so); diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index c6b7361b92..ee7d3d3b10 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -32,7 +32,7 @@ * * @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95 * $FreeBSD: src/sys/netinet/udp_usrreq.c,v 1.64.2.18 2003/01/24 05:11:34 sam Exp $ - * $DragonFly: src/sys/netinet/udp_usrreq.c,v 1.11 2004/03/04 06:13:05 hsu Exp $ + * $DragonFly: src/sys/netinet/udp_usrreq.c,v 1.12 2004/03/05 16:57:15 hsu Exp $ */ #include "opt_ipsec.h" @@ -847,7 +847,7 @@ udp_abort(struct socket *so) } static int -udp_attach(struct socket *so, int proto, struct thread *td) +udp_attach(struct socket *so, int proto, struct pru_attach_info *ai) { struct inpcb *inp; int s, error; @@ -856,11 +856,11 @@ udp_attach(struct socket *so, int proto, struct thread *td) if (inp != 0) return EINVAL; - error = soreserve(so, udp_sendspace, udp_recvspace); + error = soreserve(so, udp_sendspace, udp_recvspace, ai->sb_rlimit); if (error) return error; s = splnet(); - error = in_pcballoc(so, &udbinfo, td); + error = in_pcballoc(so, &udbinfo); splx(s); if (error) return error; diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index a1daa0ef92..9570e7a341 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netinet6/raw_ip6.c,v 1.7.2.7 2003/01/24 05:11:35 sam Exp $ - * $DragonFly: src/sys/netinet6/raw_ip6.c,v 1.9 2003/11/09 02:22:36 dillon Exp $ + * $DragonFly: src/sys/netinet6/raw_ip6.c,v 1.10 2004/03/05 16:57:15 hsu Exp $ */ /* @@ -548,7 +548,7 @@ rip6_ctloutput(so, sopt) } static int -rip6_attach(struct socket *so, int proto, struct thread *td) +rip6_attach(struct socket *so, int proto, struct pru_attach_info *ai) { struct inpcb *inp; int error, s; @@ -556,14 +556,14 @@ rip6_attach(struct socket *so, int proto, struct thread *td) inp = sotoinpcb(so); if (inp) panic("rip6_attach"); - if ((error = suser(td)) != 0) + if ((error = suser_cred(ai->p_ucred, NULL_CRED_OKAY)) != 0) return error; - error = soreserve(so, rip_sendspace, rip_recvspace); + error = soreserve(so, rip_sendspace, rip_recvspace, ai->sb_rlimit); if (error) return error; s = splnet(); - error = in_pcballoc(so, &ripcbinfo, td); + error = in_pcballoc(so, &ripcbinfo); splx(s); if (error) return error; diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index fb5b1d544b..64eb1aa4cc 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/netinet6/udp6_usrreq.c,v 1.6.2.13 2003/01/24 05:11:35 sam Exp $ */ -/* $DragonFly: src/sys/netinet6/udp6_usrreq.c,v 1.9 2003/08/23 11:02:46 rob Exp $ */ +/* $DragonFly: src/sys/netinet6/udp6_usrreq.c,v 1.10 2004/03/05 16:57:15 hsu Exp $ */ /* $KAME: udp6_usrreq.c,v 1.27 2001/05/21 05:45:10 jinmei Exp $ */ /* @@ -541,7 +541,7 @@ udp6_abort(struct socket *so) } static int -udp6_attach(struct socket *so, int proto, struct thread *td) +udp6_attach(struct socket *so, int proto, struct pru_attach_info *ai) { struct inpcb *inp; int s, error; @@ -551,12 +551,13 @@ udp6_attach(struct socket *so, int proto, struct thread *td) return EINVAL; if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) { - error = soreserve(so, udp_sendspace, udp_recvspace); + error = soreserve(so, udp_sendspace, udp_recvspace, + ai->sb_rlimit); if (error) return error; } s = splnet(); - error = in_pcballoc(so, &udbinfo, td); + error = in_pcballoc(so, &udbinfo); splx(s); if (error) return error; diff --git a/sys/netproto/atm/atm_usrreq.c b/sys/netproto/atm/atm_usrreq.c index 9cf67f064b..a933995594 100644 --- a/sys/netproto/atm/atm_usrreq.c +++ b/sys/netproto/atm/atm_usrreq.c @@ -24,7 +24,7 @@ * notice must be reproduced on all copies. * * @(#) $FreeBSD: src/sys/netatm/atm_usrreq.c,v 1.6 1999/08/28 00:48:39 peter Exp $ - * @(#) $DragonFly: src/sys/netproto/atm/atm_usrreq.c,v 1.7 2004/02/06 09:17:40 rob Exp $ + * @(#) $DragonFly: src/sys/netproto/atm/atm_usrreq.c,v 1.8 2004/03/05 16:57:16 hsu Exp $ */ /* @@ -40,7 +40,8 @@ /* * Local functions */ -static int atm_dgram_attach (struct socket *, int, struct thread *); +static int atm_dgram_attach (struct socket *, int, + struct pru_attach_info *); static int atm_dgram_control (struct socket *, u_long, caddr_t, struct ifnet *, struct thread *); static int atm_dgram_info (caddr_t); @@ -121,10 +122,7 @@ struct pr_usrreqs atm_dgram_usrreqs = { * */ static int -atm_dgram_attach(so, proto, td) - struct socket *so; - int proto; - struct thread *td; +atm_dgram_attach(struct socket *so, int proto, struct pru_attach_info *ai) { ATM_INTRO(); diff --git a/sys/netproto/ipx/ipx_usrreq.c b/sys/netproto/ipx/ipx_usrreq.c index e319aedd3b..6410dbffb7 100644 --- a/sys/netproto/ipx/ipx_usrreq.c +++ b/sys/netproto/ipx/ipx_usrreq.c @@ -34,7 +34,7 @@ * @(#)ipx_usrreq.c * * $FreeBSD: src/sys/netipx/ipx_usrreq.c,v 1.26.2.1 2001/02/22 09:44:18 bp Exp $ - * $DragonFly: src/sys/netproto/ipx/ipx_usrreq.c,v 1.5 2003/08/07 21:17:37 dillon Exp $ + * $DragonFly: src/sys/netproto/ipx/ipx_usrreq.c,v 1.6 2004/03/05 16:57:16 hsu Exp $ */ #include "opt_ipx.h" @@ -72,8 +72,10 @@ SYSCTL_INT(_net_ipx_ipx, OID_AUTO, ipxrecvspace, CTLFLAG_RW, &ipxrecvspace, 0, ""); static int ipx_usr_abort(struct socket *so); -static int ipx_attach(struct socket *so, int proto, struct thread *td); -static int ipx_bind(struct socket *so, struct sockaddr *nam, struct thread *td); +static int ipx_attach(struct socket *so, int proto, + struct pru_attach_info *ai); +static int ipx_bind(struct socket *so, struct sockaddr *nam, + struct thread *td); static int ipx_connect(struct socket *so, struct sockaddr *nam, struct thread *td); static int ipx_detach(struct socket *so); @@ -82,7 +84,8 @@ static int ipx_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct thread *td); static int ipx_shutdown(struct socket *so); -static int ripx_attach(struct socket *so, int proto, struct thread *td); +static int ripx_attach(struct socket *so, int proto, + struct pru_attach_info *ai); static int ipx_output(struct ipxpcb *ipxp, struct mbuf *m0); struct pr_usrreqs ipx_usrreqs = { @@ -434,7 +437,7 @@ ipx_usr_abort(so) } static int -ipx_attach(struct socket *so, int proto, struct thread *td) +ipx_attach(struct socket *so, int proto, struct pru_attach_info *ai) { int error; int s; @@ -443,10 +446,11 @@ ipx_attach(struct socket *so, int proto, struct thread *td) if (ipxp != NULL) return (EINVAL); s = splnet(); - error = ipx_pcballoc(so, &ipxpcb, td); + error = ipx_pcballoc(so, &ipxpcb); splx(s); if (error == 0) - error = soreserve(so, ipxsendspace, ipxrecvspace); + error = soreserve(so, ipxsendspace, ipxrecvspace, + ai->sb_rlimit); return (error); } @@ -581,20 +585,20 @@ ipx_sockaddr(so, nam) } static int -ripx_attach(struct socket *so, int proto, struct thread *td) +ripx_attach(struct socket *so, int proto, struct pru_attach_info *ai) { int error = 0; int s; struct ipxpcb *ipxp = sotoipxpcb(so); - if ((error = suser(td)) != 0) + if ((error = suser_cred(ai->p_ucred, NULL_CRED_OKAY)) != 0) return (error); s = splnet(); - error = ipx_pcballoc(so, &ipxrawpcb, td); + error = ipx_pcballoc(so, &ipxrawpcb); splx(s); if (error) return (error); - error = soreserve(so, ipxsendspace, ipxrecvspace); + error = soreserve(so, ipxsendspace, ipxrecvspace, ai->sb_rlimit); if (error) return (error); ipxp = sotoipxpcb(so); diff --git a/sys/netproto/ipx/spx_usrreq.c b/sys/netproto/ipx/spx_usrreq.c index 8b1cf6ac0c..ae66c40ccf 100644 --- a/sys/netproto/ipx/spx_usrreq.c +++ b/sys/netproto/ipx/spx_usrreq.c @@ -34,7 +34,7 @@ * @(#)spx_usrreq.h * * $FreeBSD: src/sys/netipx/spx_usrreq.c,v 1.27.2.1 2001/02/22 09:44:18 bp Exp $ - * $DragonFly: src/sys/netproto/ipx/spx_usrreq.c,v 1.5 2003/08/07 21:17:37 dillon Exp $ + * $DragonFly: src/sys/netproto/ipx/spx_usrreq.c,v 1.6 2004/03/05 16:57:16 hsu Exp $ */ #include @@ -88,8 +88,10 @@ static struct spxpcb *spx_usrclosed(struct spxpcb *cb); static int spx_usr_abort(struct socket *so); static int spx_accept(struct socket *so, struct sockaddr **nam); -static int spx_attach(struct socket *so, int proto, struct thread *td); -static int spx_bind(struct socket *so, struct sockaddr *nam, struct thread *td); +static int spx_attach(struct socket *so, int proto, + struct pru_attach_info *ai); +static int spx_bind(struct socket *so, struct sockaddr *nam, + struct thread *td); static int spx_connect(struct socket *so, struct sockaddr *nam, struct thread *td); static int spx_detach(struct socket *so); @@ -101,7 +103,8 @@ static int spx_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct thread *td); static int spx_shutdown(struct socket *so); -static int spx_sp_attach(struct socket *so, int proto, struct thread *td); +static int spx_sp_attach(struct socket *so, int proto, + struct pru_attach_info *ai); struct pr_usrreqs spx_usrreqs = { spx_usr_abort, spx_accept, spx_attach, spx_bind, @@ -1303,10 +1306,7 @@ spx_accept(so, nam) } static int -spx_attach(so, proto, td) - struct socket *so; - int proto; - struct thread *td; +spx_attach(struct socket *so, int proto, struct pru_attach_info *ai) { int error; int s; @@ -1321,11 +1321,12 @@ spx_attach(so, proto, td) if (ipxp != NULL) return (EISCONN); s = splnet(); - error = ipx_pcballoc(so, &ipxpcb, td); + error = ipx_pcballoc(so, &ipxpcb); if (error) goto spx_attach_end; if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) { - error = soreserve(so, (u_long) 3072, (u_long) 3072); + error = soreserve(so, (u_long) 3072, (u_long) 3072, + ai->sb_rlimit); if (error) goto spx_attach_end; } diff --git a/sys/netproto/key/keysock.c b/sys/netproto/key/keysock.c index 3edfcd1378..85a73a7e10 100644 --- a/sys/netproto/key/keysock.c +++ b/sys/netproto/key/keysock.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/netkey/keysock.c,v 1.1.2.4 2003/01/11 19:10:59 ume Exp $ */ -/* $DragonFly: src/sys/netproto/key/keysock.c,v 1.7 2003/11/09 02:22:37 dillon Exp $ */ +/* $DragonFly: src/sys/netproto/key/keysock.c,v 1.8 2004/03/05 16:57:16 hsu Exp $ */ /* $KAME: keysock.c,v 1.25 2001/08/13 20:07:41 itojun Exp $ */ /* @@ -387,7 +387,7 @@ key_abort(struct socket *so) * derived from net/rtsock.c:rts_attach() */ static int -key_attach(struct socket *so, int proto, struct thread *td) +key_attach(struct socket *so, int proto, struct pru_attach_info *ai) { struct keycb *kp; int s, error; @@ -408,7 +408,7 @@ key_attach(struct socket *so, int proto, struct thread *td) */ s = splnet(); so->so_pcb = (caddr_t)kp; - error = raw_usrreqs.pru_attach(so, proto, td); + error = raw_usrreqs.pru_attach(so, proto, ai); kp = (struct keycb *)sotorawcb(so); if (error) { free(kp, M_PCB); diff --git a/sys/netproto/natm/natm.c b/sys/netproto/natm/natm.c index 038596ee64..8c5fb4e1c7 100644 --- a/sys/netproto/natm/natm.c +++ b/sys/netproto/natm/natm.c @@ -1,6 +1,6 @@ /* $NetBSD: natm.c,v 1.5 1996/11/09 03:26:26 chuck Exp $ */ /* $FreeBSD: src/sys/netnatm/natm.c,v 1.12 2000/02/13 03:32:03 peter Exp $ */ -/* $DragonFly: src/sys/netproto/natm/natm.c,v 1.9 2004/02/06 09:17:41 rob Exp $ */ +/* $DragonFly: src/sys/netproto/natm/natm.c,v 1.10 2004/03/05 16:57:16 hsu Exp $ */ /* * @@ -69,7 +69,7 @@ static u_long natm0_recvspace = 16*1024; /* * FreeBSD new usrreqs supersedes pr_usrreq. */ -static int natm_usr_attach (struct socket *, int, struct thread *); +static int natm_usr_attach (struct socket *, int, struct pru_attach_info *ai); static int natm_usr_detach (struct socket *); static int natm_usr_connect (struct socket *, struct sockaddr *, struct thread *); @@ -87,7 +87,7 @@ static int natm_usr_bind (struct socket *, struct sockaddr *, static int natm_usr_sockaddr (struct socket *, struct sockaddr **); static int -natm_usr_attach(struct socket *so, int proto, struct thread *td) +natm_usr_attach(struct socket *so, int proto, struct pru_attach_info *ai) { struct natmpcb *npcb; int error = 0; @@ -102,9 +102,11 @@ natm_usr_attach(struct socket *so, int proto, struct thread *td) if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) { if (proto == PROTO_NATMAAL5) - error = soreserve(so, natm5_sendspace, natm5_recvspace); + error = soreserve(so, natm5_sendspace, natm5_recvspace, + ai->sb_rlimit); else - error = soreserve(so, natm0_sendspace, natm0_recvspace); + error = soreserve(so, natm0_sendspace, natm0_recvspace, + ai->sb_rlimit); if (error) goto out; } diff --git a/sys/netproto/smb/smb_trantcp.c b/sys/netproto/smb/smb_trantcp.c index 963301a69e..cd2f15288a 100644 --- a/sys/netproto/smb/smb_trantcp.c +++ b/sys/netproto/smb/smb_trantcp.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_trantcp.c,v 1.3.2.1 2001/05/22 08:32:34 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_trantcp.c,v 1.8 2004/03/04 10:29:24 hsu Exp $ + * $DragonFly: src/sys/netproto/smb/smb_trantcp.c,v 1.9 2004/03/05 16:57:16 hsu Exp $ */ #include #include @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -207,7 +208,8 @@ nb_connect_in(struct nbpcb *nbp, struct sockaddr_in *to, struct thread *td) so->so_rcv.sb_flags |= SB_UPCALL; so->so_rcv.sb_timeo = (5 * hz); so->so_snd.sb_timeo = (5 * hz); - error = soreserve(so, nbp->nbp_sndbuf, nbp->nbp_rcvbuf); + error = soreserve(so, nbp->nbp_sndbuf, nbp->nbp_rcvbuf, + &td->td_proc->p_rlimit[RLIMIT_SBSIZE]); if (error) goto bad; nb_setsockopt_int(so, SOL_SOCKET, SO_KEEPALIVE, 1); diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 09f3f50483..5d0fd2364b 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -37,7 +37,7 @@ * * @(#)proc.h 8.15 (Berkeley) 5/19/95 * $FreeBSD: src/sys/sys/proc.h,v 1.99.2.9 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/sys/proc.h,v 1.43 2004/03/01 06:33:19 dillon Exp $ + * $DragonFly: src/sys/sys/proc.h,v 1.44 2004/03/05 16:57:16 hsu Exp $ */ #ifndef _SYS_PROC_H_ @@ -301,7 +301,8 @@ MALLOC_DECLARE(M_PARGS); #endif /* flags for suser_xxx() */ -#define PRISON_ROOT 1 +#define PRISON_ROOT 0x1 +#define NULL_CRED_OKAY 0x2 /* Handy macro to determine if p1 can mangle p2 */ diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h index 5e2b322fcd..02eeda6103 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -32,7 +32,7 @@ * * @(#)protosw.h 8.1 (Berkeley) 6/2/93 * $FreeBSD: src/sys/sys/protosw.h,v 1.28.2.2 2001/07/03 11:02:01 ume Exp $ - * $DragonFly: src/sys/sys/protosw.h,v 1.5 2004/02/25 17:38:51 joerg Exp $ + * $DragonFly: src/sys/sys/protosw.h,v 1.6 2004/03/05 16:57:16 hsu Exp $ */ #ifndef _SYS_PROTOSW_H_ @@ -174,6 +174,12 @@ struct stat; struct ucred; struct uio; +struct pru_attach_info { + struct rlimit *sb_rlimit; + struct ucred *p_ucred; + struct vnode *fd_rdir; +}; + /* * If the ordering here looks odd, that's because it's alphabetical. * Having this structure separated out from the main protoswitch is allegedly @@ -184,7 +190,7 @@ struct pr_usrreqs { int (*pru_abort) (struct socket *so); int (*pru_accept) (struct socket *so, struct sockaddr **nam); int (*pru_attach) (struct socket *so, int proto, - struct thread *td); + struct pru_attach_info *ai); int (*pru_bind) (struct socket *so, struct sockaddr *nam, struct thread *td); int (*pru_connect) (struct socket *so, struct sockaddr *nam, diff --git a/sys/sys/socketops.h b/sys/sys/socketops.h index 3d31ad290c..a6024248ec 100644 --- a/sys/sys/socketops.h +++ b/sys/sys/socketops.h @@ -27,7 +27,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $DragonFly: src/sys/sys/socketops.h,v 1.1 2004/03/04 10:29:24 hsu Exp $ + * $DragonFly: src/sys/sys/socketops.h,v 1.2 2004/03/05 16:57:16 hsu Exp $ */ #ifndef _SOCKETOPS_H_ @@ -67,9 +67,9 @@ so_pru_accept(struct socket *so, } static __inline int -so_pru_attach(struct socket *so, int proto, struct thread *td) +so_pru_attach(struct socket *so, int proto, struct pru_attach_info *ai) { - return ((*so->so_proto->pr_usrreqs->pru_attach)(so, proto, td)); + return ((*so->so_proto->pr_usrreqs->pru_attach)(so, proto, ai)); } static __inline int diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h index 5051c4559e..3dbf21a964 100644 --- a/sys/sys/socketvar.h +++ b/sys/sys/socketvar.h @@ -32,7 +32,7 @@ * * @(#)socketvar.h 8.3 (Berkeley) 2/19/95 * $FreeBSD: src/sys/sys/socketvar.h,v 1.46.2.10 2003/08/24 08:24:39 hsu Exp $ - * $DragonFly: src/sys/sys/socketvar.h,v 1.8 2003/12/10 23:48:07 hsu Exp $ + * $DragonFly: src/sys/sys/socketvar.h,v 1.9 2004/03/05 16:57:16 hsu Exp $ */ #ifndef _SYS_SOCKETVAR_H_ @@ -295,6 +295,7 @@ extern so_gen_t so_gencnt; struct file; struct filedesc; struct mbuf; +struct rlimit; struct sockaddr; struct stat; struct ucred; @@ -338,7 +339,7 @@ void sbflush (struct sockbuf *sb); void sbinsertoob (struct sockbuf *sb, struct mbuf *m0); void sbrelease (struct sockbuf *sb, struct socket *so); int sbreserve (struct sockbuf *sb, u_long cc, struct socket *so, - struct proc *p); + struct rlimit *rl); void sbtoxsockbuf (struct sockbuf *sb, struct xsockbuf *xsb); int sbwait (struct sockbuf *sb); int sb_lock (struct sockbuf *sb); @@ -378,7 +379,8 @@ int sopoll (struct socket *so, int events, struct ucred *cred, int soreceive (struct socket *so, struct sockaddr **paddr, struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, int *flagsp); -int soreserve (struct socket *so, u_long sndcc, u_long rcvcc); +int soreserve (struct socket *so, u_long sndcc, u_long rcvcc, + struct rlimit *rl); void sorflush (struct socket *so); int sosend (struct socket *so, struct sockaddr *addr, struct uio *uio, struct mbuf *top, struct mbuf *control, int flags, diff --git a/sys/vfs/nfs/nfs_socket.c b/sys/vfs/nfs/nfs_socket.c index 39e70dc059..203048d582 100644 --- a/sys/vfs/nfs/nfs_socket.c +++ b/sys/vfs/nfs/nfs_socket.c @@ -35,7 +35,7 @@ * * @(#)nfs_socket.c 8.5 (Berkeley) 3/30/95 * $FreeBSD: src/sys/nfs/nfs_socket.c,v 1.60.2.6 2003/03/26 01:44:46 alfred Exp $ - * $DragonFly: src/sys/vfs/nfs/nfs_socket.c,v 1.12 2004/03/04 10:29:24 hsu Exp $ + * $DragonFly: src/sys/vfs/nfs/nfs_socket.c,v 1.13 2004/03/05 16:57:16 hsu Exp $ */ /* @@ -51,10 +51,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -350,7 +352,8 @@ nfs_connect(struct nfsmount *nmp, struct nfsreq *rep) rcvreserve = (nmp->nm_rsize + NFS_MAXPKTHDR + sizeof (u_int32_t)) * pktscale; } - error = soreserve(so, sndreserve, rcvreserve); + error = soreserve(so, sndreserve, rcvreserve, + &td->td_proc->p_rlimit[RLIMIT_SBSIZE]); if (error) goto bad; so->so_rcv.sb_flags |= SB_NOINTR; diff --git a/sys/vfs/nfs/nfs_syscalls.c b/sys/vfs/nfs/nfs_syscalls.c index f360a16419..b9efffa243 100644 --- a/sys/vfs/nfs/nfs_syscalls.c +++ b/sys/vfs/nfs/nfs_syscalls.c @@ -35,7 +35,7 @@ * * @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95 * $FreeBSD: src/sys/nfs/nfs_syscalls.c,v 1.58.2.1 2000/11/26 02:30:06 dillon Exp $ - * $DragonFly: src/sys/vfs/nfs/nfs_syscalls.c,v 1.11 2003/09/23 05:03:53 dillon Exp $ + * $DragonFly: src/sys/vfs/nfs/nfs_syscalls.c,v 1.12 2004/03/05 16:57:16 hsu Exp $ */ #include @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -339,7 +340,7 @@ nfssvc_addsock(struct file *fp, struct sockaddr *mynam, struct thread *td) siz = NFS_MAXPACKET + sizeof (u_long); else siz = NFS_MAXPACKET; - error = soreserve(so, siz, siz); + error = soreserve(so, siz, siz, &td->td_proc->p_rlimit[RLIMIT_SBSIZE]); if (error) { if (mynam != NULL) FREE(mynam, M_SONAME); diff --git a/sys/vfs/portal/portal_vnops.c b/sys/vfs/portal/portal_vnops.c index ab5e24bc3c..683a38281a 100644 --- a/sys/vfs/portal/portal_vnops.c +++ b/sys/vfs/portal/portal_vnops.c @@ -36,7 +36,7 @@ * @(#)portal_vnops.c 8.14 (Berkeley) 5/21/95 * * $FreeBSD: src/sys/miscfs/portal/portal_vnops.c,v 1.38 1999/12/21 06:29:00 chris Exp $ - * $DragonFly: src/sys/vfs/portal/portal_vnops.c,v 1.9 2004/03/01 06:33:22 dillon Exp $ + * $DragonFly: src/sys/vfs/portal/portal_vnops.c,v 1.10 2004/03/05 16:57:16 hsu Exp $ */ /* @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include @@ -258,7 +259,7 @@ portal_open(ap) * Reserve some buffer space */ res = pt->pt_size + sizeof(pcred) + 512; /* XXX */ - error = soreserve(so, res, res); + error = soreserve(so, res, res, &td->td_proc->p_rlimit[RLIMIT_SBSIZE]); if (error) goto bad; -- 2.41.0