Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/kern/uipc_socket.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/kern/uipc_socket.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.83.2.2 retrieving revision 1.83.2.5 diff -u -p -r1.83.2.2 -r1.83.2.5 --- src/sys/kern/uipc_socket.c 2004/08/03 10:52:57 1.83.2.2 +++ src/sys/kern/uipc_socket.c 2004/09/18 14:53:04 1.83.2.5 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.83.2.2 2004/08/03 10:52:57 skrll Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.83.2.5 2004/09/18 14:53:04 skrll Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.83.2.2 2004/08/03 10:52:57 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.83.2.5 2004/09/18 14:53:04 skrll Exp $"); #include "opt_sock_counters.h" #include "opt_sosend_loan.h" @@ -407,13 +407,13 @@ sosend_loan(struct socket *so, struct ui /* XXX KDASSERT */ KASSERT(npgs <= M_EXT_MAXPAGES); - KASSERT(uio->uio_lwp != NULL); + KASSERT(uio->uio_procp != NULL); lva = sokvaalloc(len, so); if (lva == 0) return 0; - error = uvm_loan(&uio->uio_lwp->l_proc->p_vmspace->vm_map, sva, len, + error = uvm_loan(&uio->uio_procp->p_vmspace->vm_map, sva, len, m->m_ext.ext_pgs, UVM_LOAN_TOPAGE); if (error) { sokvafree(lva, len); @@ -451,14 +451,12 @@ sosend_loan(struct socket *so, struct ui */ /*ARGSUSED*/ int -socreate(int dom, struct socket **aso, int type, int proto, struct lwp *l) +socreate(int dom, struct socket **aso, int type, int proto, struct proc *p) { const struct protosw *prp; struct socket *so; - struct proc *p; int error, s; - p = l->l_proc; if (proto) prp = pffindproto(dom, proto, type); else @@ -486,7 +484,7 @@ socreate(int dom, struct socket **aso, i else so->so_uid = UID_MAX; error = (*prp->pr_usrreq)(so, PRU_ATTACH, (struct mbuf *)0, - (struct mbuf *)(long)proto, (struct mbuf *)0, l); + (struct mbuf *)(long)proto, (struct mbuf *)0, p); if (error) { so->so_state |= SS_NOFDREF; sofree(so); @@ -499,13 +497,13 @@ socreate(int dom, struct socket **aso, i } int -sobind(struct socket *so, struct mbuf *nam, struct lwp *l) +sobind(struct socket *so, struct mbuf *nam, struct proc *p) { int s, error; s = splsoftnet(); error = (*so->so_proto->pr_usrreq)(so, PRU_BIND, (struct mbuf *)0, - nam, (struct mbuf *)0, l); + nam, (struct mbuf *)0, p); splx(s); return (error); } @@ -517,7 +515,7 @@ solisten(struct socket *so, int backlog) s = splsoftnet(); error = (*so->so_proto->pr_usrreq)(so, PRU_LISTEN, (struct mbuf *)0, - (struct mbuf *)0, (struct mbuf *)0, (struct lwp *)0); + (struct mbuf *)0, (struct mbuf *)0, (struct proc *)0); if (error) { splx(s); return (error); @@ -605,7 +603,7 @@ soclose(struct socket *so) if (so->so_pcb) { int error2 = (*so->so_proto->pr_usrreq)(so, PRU_DETACH, (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0, - (struct lwp *)0); + (struct proc *)0); if (error == 0) error = error2; } @@ -626,7 +624,7 @@ soabort(struct socket *so) { return (*so->so_proto->pr_usrreq)(so, PRU_ABORT, (struct mbuf *)0, - (struct mbuf *)0, (struct mbuf *)0, (struct lwp *)0); + (struct mbuf *)0, (struct mbuf *)0, (struct proc *)0); } int @@ -642,7 +640,7 @@ soaccept(struct socket *so, struct mbuf if ((so->so_state & SS_ISDISCONNECTED) == 0 || (so->so_proto->pr_flags & PR_ABRTACPTDIS) == 0) error = (*so->so_proto->pr_usrreq)(so, PRU_ACCEPT, - (struct mbuf *)0, nam, (struct mbuf *)0, (struct lwp *)0); + (struct mbuf *)0, nam, (struct mbuf *)0, (struct proc *)0); else error = ECONNABORTED; @@ -651,7 +649,7 @@ soaccept(struct socket *so, struct mbuf } int -soconnect(struct socket *so, struct mbuf *nam, struct lwp *l) +soconnect(struct socket *so, struct mbuf *nam, struct proc *p) { int s, error; @@ -670,7 +668,7 @@ soconnect(struct socket *so, struct mbuf error = EISCONN; else error = (*so->so_proto->pr_usrreq)(so, PRU_CONNECT, - (struct mbuf *)0, nam, (struct mbuf *)0, l); + (struct mbuf *)0, nam, (struct mbuf *)0, p); splx(s); return (error); } @@ -683,7 +681,7 @@ soconnect2(struct socket *so1, struct so s = splsoftnet(); error = (*so1->so_proto->pr_usrreq)(so1, PRU_CONNECT2, (struct mbuf *)0, (struct mbuf *)so2, (struct mbuf *)0, - (struct lwp *)0); + (struct proc *)0); splx(s); return (error); } @@ -704,7 +702,7 @@ sodisconnect(struct socket *so) } error = (*so->so_proto->pr_usrreq)(so, PRU_DISCONNECT, (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0, - (struct lwp *)0); + (struct proc *)0); bad: splx(s); sodopendfree(so); @@ -731,14 +729,12 @@ sodisconnect(struct socket *so) */ int sosend(struct socket *so, struct mbuf *addr, struct uio *uio, struct mbuf *top, - struct mbuf *control, int flags, struct lwp *l) + struct mbuf *control, int flags, struct proc *p) { struct mbuf **mp, *m; - struct proc *p; long space, len, resid, clen, mlen; int error, s, dontroute, atomic; - p = l->l_proc; sodopendfree(so); clen = 0; @@ -889,7 +885,7 @@ sosend(struct socket *so, struct mbuf *a so->so_state |= SS_MORETOCOME; error = (*so->so_proto->pr_usrreq)(so, (flags & MSG_OOB) ? PRU_SENDOOB : PRU_SEND, - top, addr, control, curlwp); /* XXX */ + top, addr, control, p); if (dontroute) so->so_options &= ~SO_DONTROUTE; if (resid > 0) @@ -935,8 +931,7 @@ int soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, int *flagsp) { - struct lwp *l; - struct proc *p; + struct proc * p; struct mbuf *m, **mp; int flags, len, error, s, offset, moff, type, orig_resid; const struct protosw *pr; @@ -947,8 +942,7 @@ soreceive(struct socket *so, struct mbuf mp = mp0; type = 0; orig_resid = uio->uio_resid; - l = uio->uio_lwp; - p = l->l_proc; + p = uio->uio_procp; if (paddr) *paddr = 0; @@ -966,7 +960,7 @@ soreceive(struct socket *so, struct mbuf m = m_get(M_WAIT, MT_DATA); error = (*pr->pr_usrreq)(so, PRU_RCVOOB, m, (struct mbuf *)(long)(flags & MSG_PEEK), - (struct mbuf *)0, l); + (struct mbuf *)0, p); if (error) goto bad; do { @@ -983,7 +977,7 @@ soreceive(struct socket *so, struct mbuf *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, l); + (struct mbuf *)0, (struct mbuf *)0, p); restart: if ((error = sblock(&so->so_rcv, SBLOCKWAIT(flags))) != 0) @@ -1056,10 +1050,8 @@ soreceive(struct socket *so, struct mbuf * While we process the initial mbufs containing address and control * info, we save a copy of m->m_nextpkt into nextrecord. */ -#ifdef notyet /* XXXX */ if (p) p->p_stats->p_ru.ru_msgrcv++; -#endif KASSERT(m == so->so_rcv.sb_mb); SBLASTRECORDCHK(&so->so_rcv, "soreceive 1"); SBLASTMBUFCHK(&so->so_rcv, "soreceive 1"); @@ -1101,12 +1093,19 @@ soreceive(struct socket *so, struct mbuf if (dom->dom_externalize && p && mtod(m, struct cmsghdr *)->cmsg_type == SCM_RIGHTS) - error = (*dom->dom_externalize)(m, l); + error = (*dom->dom_externalize)(m, p); *controlp = m; so->so_rcv.sb_mb = m->m_next; m->m_next = 0; m = so->so_rcv.sb_mb; } else { + /* + * Dispose of any SCM_RIGHTS message that went + * through the read path rather than recv. + */ + if (pr->pr_domain->dom_dispose && + mtod(m, struct cmsghdr *)->cmsg_type == SCM_RIGHTS) + (*pr->pr_domain->dom_dispose)(m); MFREE(m, so->so_rcv.sb_mb); m = so->so_rcv.sb_mb; } @@ -1287,7 +1286,7 @@ soreceive(struct socket *so, struct mbuf (*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0, (struct mbuf *)(long)flags, - (struct mbuf *)0, l); + (struct mbuf *)0, p); SBLASTRECORDCHK(&so->so_rcv, "soreceive sbwait 2"); SBLASTMBUFCHK(&so->so_rcv, "soreceive sbwait 2"); error = sbwait(&so->so_rcv); @@ -1324,7 +1323,7 @@ soreceive(struct socket *so, struct mbuf 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, l); + (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) { @@ -1354,7 +1353,7 @@ soshutdown(struct socket *so, int how) sorflush(so); if (how == SHUT_WR || how == SHUT_RDWR) return (*pr->pr_usrreq)(so, PRU_SHUTDOWN, (struct mbuf *)0, - (struct mbuf *)0, (struct mbuf *)0, (struct lwp *)0); + (struct mbuf *)0, (struct mbuf *)0, (struct proc *)0); return (0); } @@ -1601,6 +1600,10 @@ sogetopt(struct socket *so, int level, i break; } + case SO_OVERFLOWED: + *mtod(m, int *) = so->so_rcv.sb_overflowed; + break; + default: (void)m_free(m); return (ENOPROTOOPT);