version 1.111.2.2, 2005/07/07 12:42:25 |
version 1.115.6.1, 2006/04/22 11:39:59 |
Line 105 int somaxconn = SOMAXCONN; |
|
Line 105 int somaxconn = SOMAXCONN; |
|
#ifdef SOSEND_COUNTERS |
#ifdef SOSEND_COUNTERS |
#include <sys/device.h> |
#include <sys/device.h> |
|
|
struct evcnt sosend_loan_big = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, |
static struct evcnt sosend_loan_big = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, |
NULL, "sosend", "loan big"); |
NULL, "sosend", "loan big"); |
struct evcnt sosend_copy_big = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, |
static struct evcnt sosend_copy_big = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, |
NULL, "sosend", "copy big"); |
NULL, "sosend", "copy big"); |
struct evcnt sosend_copy_small = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, |
static struct evcnt sosend_copy_small = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, |
NULL, "sosend", "copy small"); |
NULL, "sosend", "copy small"); |
struct evcnt sosend_kvalimit = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, |
static struct evcnt sosend_kvalimit = EVCNT_INITIALIZER(EVCNT_TYPE_MISC, |
NULL, "sosend", "kva limit"); |
NULL, "sosend", "kva limit"); |
|
|
#define SOSEND_COUNTER_INCR(ev) (ev)->ev_count++ |
#define SOSEND_COUNTER_INCR(ev) (ev)->ev_count++ |
Line 142 int use_sosend_loan = 0; |
|
Line 142 int use_sosend_loan = 0; |
|
int use_sosend_loan = 1; |
int use_sosend_loan = 1; |
#endif |
#endif |
|
|
struct simplelock so_pendfree_slock = SIMPLELOCK_INITIALIZER; |
static struct simplelock so_pendfree_slock = SIMPLELOCK_INITIALIZER; |
struct mbuf *so_pendfree; |
static struct mbuf *so_pendfree; |
|
|
#ifndef SOMAXKVA |
#ifndef SOMAXKVA |
#define SOMAXKVA (16 * 1024 * 1024) |
#define SOMAXKVA (16 * 1024 * 1024) |
#endif |
#endif |
int somaxkva = SOMAXKVA; |
int somaxkva = SOMAXKVA; |
int socurkva; |
static int socurkva; |
int sokvawaiters; |
static int sokvawaiters; |
|
|
#define SOCK_LOAN_THRESH 4096 |
#define SOCK_LOAN_THRESH 4096 |
#define SOCK_LOAN_CHUNK 65536 |
#define SOCK_LOAN_CHUNK 65536 |
|
|
static size_t sodopendfree(struct socket *); |
static size_t sodopendfree(void); |
static size_t sodopendfreel(struct socket *); |
static size_t sodopendfreel(void); |
static __inline vsize_t sokvareserve(struct socket *, vsize_t); |
|
static __inline void sokvaunreserve(vsize_t); |
|
|
|
static __inline vsize_t |
static vsize_t |
sokvareserve(struct socket *so, vsize_t len) |
sokvareserve(struct socket *so, vsize_t len) |
{ |
{ |
int s; |
int s; |
Line 175 sokvareserve(struct socket *so, vsize_t |
|
Line 173 sokvareserve(struct socket *so, vsize_t |
|
* try to do pendfree. |
* try to do pendfree. |
*/ |
*/ |
|
|
freed = sodopendfreel(so); |
freed = sodopendfreel(); |
|
|
/* |
/* |
* if some kva was freed, try again. |
* if some kva was freed, try again. |
Line 200 sokvareserve(struct socket *so, vsize_t |
|
Line 198 sokvareserve(struct socket *so, vsize_t |
|
return len; |
return len; |
} |
} |
|
|
static __inline void |
static void |
sokvaunreserve(vsize_t len) |
sokvaunreserve(vsize_t len) |
{ |
{ |
int s; |
int s; |
Line 265 sokvafree(vaddr_t sva, vsize_t len) |
|
Line 263 sokvafree(vaddr_t sva, vsize_t len) |
|
} |
} |
|
|
static void |
static void |
sodoloanfree(struct vm_page **pgs, caddr_t buf, size_t size, boolean_t mapped) |
sodoloanfree(struct vm_page **pgs, caddr_t buf, size_t size) |
{ |
{ |
vaddr_t sva, eva; |
vaddr_t va, sva, eva; |
vsize_t len; |
vsize_t len; |
int npgs; |
paddr_t pa; |
|
int i, npgs; |
KASSERT(pgs != NULL); |
|
|
|
eva = round_page((vaddr_t) buf + size); |
eva = round_page((vaddr_t) buf + size); |
sva = trunc_page((vaddr_t) buf); |
sva = trunc_page((vaddr_t) buf); |
len = eva - sva; |
len = eva - sva; |
npgs = len >> PAGE_SHIFT; |
npgs = len >> PAGE_SHIFT; |
|
|
if (mapped) { |
if (__predict_false(pgs == NULL)) { |
pmap_kremove(sva, len); |
pgs = alloca(npgs * sizeof(*pgs)); |
pmap_update(pmap_kernel()); |
|
|
for (i = 0, va = sva; va < eva; i++, va += PAGE_SIZE) { |
|
if (pmap_extract(pmap_kernel(), va, &pa) == FALSE) |
|
panic("sodoloanfree: va 0x%lx not mapped", va); |
|
pgs[i] = PHYS_TO_VM_PAGE(pa); |
|
} |
} |
} |
|
|
|
pmap_kremove(sva, len); |
|
pmap_update(pmap_kernel()); |
uvm_unloan(pgs, npgs, UVM_LOAN_TOPAGE); |
uvm_unloan(pgs, npgs, UVM_LOAN_TOPAGE); |
sokvafree(sva, len); |
sokvafree(sva, len); |
} |
} |
|
|
static size_t |
static size_t |
sodopendfree(struct socket *so) |
sodopendfree() |
{ |
{ |
int s; |
int s; |
size_t rv; |
size_t rv; |
|
|
s = splvm(); |
s = splvm(); |
simple_lock(&so_pendfree_slock); |
simple_lock(&so_pendfree_slock); |
rv = sodopendfreel(so); |
rv = sodopendfreel(); |
simple_unlock(&so_pendfree_slock); |
simple_unlock(&so_pendfree_slock); |
splx(s); |
splx(s); |
|
|
Line 310 sodopendfree(struct socket *so) |
|
Line 315 sodopendfree(struct socket *so) |
|
*/ |
*/ |
|
|
static size_t |
static size_t |
sodopendfreel(struct socket *so) |
sodopendfreel() |
{ |
{ |
size_t rv = 0; |
size_t rv = 0; |
|
|
Line 329 sodopendfreel(struct socket *so) |
|
Line 334 sodopendfreel(struct socket *so) |
|
|
|
for (; m != NULL; m = next) { |
for (; m != NULL; m = next) { |
next = m->m_next; |
next = m->m_next; |
KASSERT((~m->m_flags & (M_EXT|M_EXT_PAGES)) == 0); |
|
KASSERT(!MCLISREFERENCED(m)); |
|
|
|
rv += m->m_ext.ext_size; |
rv += m->m_ext.ext_size; |
sodoloanfree(m->m_ext.ext_pgs, m->m_ext.ext_buf, |
sodoloanfree((m->m_flags & M_EXT_PAGES) ? |
m->m_ext.ext_size, |
m->m_ext.ext_pgs : NULL, m->m_ext.ext_buf, |
(m->m_ext.ext_flags & M_EXT_LAZY) == 0); |
m->m_ext.ext_size); |
pool_cache_put(&mbpool_cache, m); |
pool_cache_put(&mbpool_cache, m); |
} |
} |
|
|
Line 351 soloanfree(struct mbuf *m, caddr_t buf, |
|
Line 354 soloanfree(struct mbuf *m, caddr_t buf, |
|
{ |
{ |
int s; |
int s; |
|
|
KASSERT(m != NULL); |
if (m == NULL) { |
|
|
|
/* |
|
* called from MEXTREMOVE. |
|
*/ |
|
|
|
sodoloanfree(NULL, buf, size); |
|
return; |
|
} |
|
|
/* |
/* |
* postpone freeing mbuf. |
* postpone freeing mbuf. |
Line 376 sosend_loan(struct socket *so, struct ui |
|
Line 387 sosend_loan(struct socket *so, struct ui |
|
struct iovec *iov = uio->uio_iov; |
struct iovec *iov = uio->uio_iov; |
vaddr_t sva, eva; |
vaddr_t sva, eva; |
vsize_t len; |
vsize_t len; |
vaddr_t lva; |
vaddr_t lva, va; |
int npgs, error; |
int npgs, i, error; |
#if !defined(__HAVE_LAZY_MBUF) |
|
vaddr_t va; |
|
int i; |
|
#endif /* !defined(__HAVE_LAZY_MBUF) */ |
|
|
|
if (uio->uio_segflg != UIO_USERSPACE) |
if (VMSPACE_IS_KERNEL_P(uio->uio_vmspace)) |
return (0); |
return (0); |
|
|
if (iov->iov_len < (size_t) space) |
if (iov->iov_len < (size_t) space) |
Line 398 sosend_loan(struct socket *so, struct ui |
|
Line 405 sosend_loan(struct socket *so, struct ui |
|
|
|
/* XXX KDASSERT */ |
/* XXX KDASSERT */ |
KASSERT(npgs <= M_EXT_MAXPAGES); |
KASSERT(npgs <= M_EXT_MAXPAGES); |
KASSERT(uio->uio_procp != NULL); |
|
|
|
lva = sokvaalloc(len, so); |
lva = sokvaalloc(len, so); |
if (lva == 0) |
if (lva == 0) |
return 0; |
return 0; |
|
|
error = uvm_loan(&uio->uio_procp->p_vmspace->vm_map, sva, len, |
error = uvm_loan(&uio->uio_vmspace->vm_map, sva, len, |
m->m_ext.ext_pgs, UVM_LOAN_TOPAGE); |
m->m_ext.ext_pgs, UVM_LOAN_TOPAGE); |
if (error) { |
if (error) { |
sokvafree(lva, len); |
sokvafree(lva, len); |
return (0); |
return (0); |
} |
} |
|
|
#if !defined(__HAVE_LAZY_MBUF) |
|
for (i = 0, va = lva; i < npgs; i++, va += PAGE_SIZE) |
for (i = 0, va = lva; i < npgs; i++, va += PAGE_SIZE) |
pmap_kenter_pa(va, VM_PAGE_TO_PHYS(m->m_ext.ext_pgs[i]), |
pmap_kenter_pa(va, VM_PAGE_TO_PHYS(m->m_ext.ext_pgs[i]), |
VM_PROT_READ); |
VM_PROT_READ); |
pmap_update(pmap_kernel()); |
pmap_update(pmap_kernel()); |
#endif /* !defined(__HAVE_LAZY_MBUF) */ |
|
|
|
lva += (vaddr_t) iov->iov_base & PAGE_MASK; |
lva += (vaddr_t) iov->iov_base & PAGE_MASK; |
|
|
MEXTADD(m, (caddr_t) lva, space, M_MBUF, soloanfree, so); |
MEXTADD(m, (caddr_t) lva, space, M_MBUF, soloanfree, so); |
m->m_flags |= M_EXT_PAGES | M_EXT_ROMAP; |
m->m_flags |= M_EXT_PAGES | M_EXT_ROMAP; |
|
|
#if defined(__HAVE_LAZY_MBUF) |
|
m->m_flags |= M_EXT_LAZY; |
|
m->m_ext.ext_flags |= M_EXT_LAZY; |
|
#endif /* defined(__HAVE_LAZY_MBUF) */ |
|
|
|
uio->uio_resid -= space; |
uio->uio_resid -= space; |
/* uio_offset not updated, not set/used for write(2) */ |
/* uio_offset not updated, not set/used for write(2) */ |
uio->uio_iov->iov_base = (caddr_t) uio->uio_iov->iov_base + space; |
uio->uio_iov->iov_base = (caddr_t) uio->uio_iov->iov_base + space; |
Line 449 sosend_loan(struct socket *so, struct ui |
|
Line 448 sosend_loan(struct socket *so, struct ui |
|
*/ |
*/ |
/*ARGSUSED*/ |
/*ARGSUSED*/ |
int |
int |
socreate(int dom, struct socket **aso, int type, int proto, struct proc *p) |
socreate(int dom, struct socket **aso, int type, int proto, struct lwp *l) |
{ |
{ |
const struct protosw *prp; |
const struct protosw *prp; |
struct socket *so; |
struct socket *so; |
|
uid_t uid; |
int error, s; |
int error, s; |
|
|
if (proto) |
if (proto) |
Line 477 socreate(int dom, struct socket **aso, i |
|
Line 477 socreate(int dom, struct socket **aso, i |
|
so->so_snd.sb_mowner = &prp->pr_domain->dom_mowner; |
so->so_snd.sb_mowner = &prp->pr_domain->dom_mowner; |
so->so_mowner = &prp->pr_domain->dom_mowner; |
so->so_mowner = &prp->pr_domain->dom_mowner; |
#endif |
#endif |
if (p != 0) |
if (l != NULL) { |
so->so_uidinfo = uid_find(p->p_ucred->cr_uid); |
uid = l->l_proc->p_ucred->cr_uid; |
else |
} else { |
so->so_uidinfo = uid_find(0); |
uid = 0; |
|
} |
|
so->so_uidinfo = uid_find(uid); |
error = (*prp->pr_usrreq)(so, PRU_ATTACH, (struct mbuf *)0, |
error = (*prp->pr_usrreq)(so, PRU_ATTACH, (struct mbuf *)0, |
(struct mbuf *)(long)proto, (struct mbuf *)0, p); |
(struct mbuf *)(long)proto, (struct mbuf *)0, l); |
if (error) { |
if (error) { |
so->so_state |= SS_NOFDREF; |
so->so_state |= SS_NOFDREF; |
sofree(so); |
sofree(so); |
Line 495 socreate(int dom, struct socket **aso, i |
|
Line 497 socreate(int dom, struct socket **aso, i |
|
} |
} |
|
|
int |
int |
sobind(struct socket *so, struct mbuf *nam, struct proc *p) |
sobind(struct socket *so, struct mbuf *nam, struct lwp *l) |
{ |
{ |
int s, error; |
int s, error; |
|
|
s = splsoftnet(); |
s = splsoftnet(); |
error = (*so->so_proto->pr_usrreq)(so, PRU_BIND, (struct mbuf *)0, |
error = (*so->so_proto->pr_usrreq)(so, PRU_BIND, (struct mbuf *)0, |
nam, (struct mbuf *)0, p); |
nam, (struct mbuf *)0, l); |
splx(s); |
splx(s); |
return (error); |
return (error); |
} |
} |
Line 513 solisten(struct socket *so, int backlog) |
|
Line 515 solisten(struct socket *so, int backlog) |
|
|
|
s = splsoftnet(); |
s = splsoftnet(); |
error = (*so->so_proto->pr_usrreq)(so, PRU_LISTEN, (struct mbuf *)0, |
error = (*so->so_proto->pr_usrreq)(so, PRU_LISTEN, (struct mbuf *)0, |
(struct mbuf *)0, (struct mbuf *)0, (struct proc *)0); |
(struct mbuf *)0, (struct mbuf *)0, (struct lwp *)0); |
if (error) { |
if (error) { |
splx(s); |
splx(s); |
return (error); |
return (error); |
Line 601 soclose(struct socket *so) |
|
Line 603 soclose(struct socket *so) |
|
if (so->so_pcb) { |
if (so->so_pcb) { |
int error2 = (*so->so_proto->pr_usrreq)(so, PRU_DETACH, |
int error2 = (*so->so_proto->pr_usrreq)(so, PRU_DETACH, |
(struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0, |
(struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0, |
(struct proc *)0); |
(struct lwp *)0); |
if (error == 0) |
if (error == 0) |
error = error2; |
error = error2; |
} |
} |
Line 622 soabort(struct socket *so) |
|
Line 624 soabort(struct socket *so) |
|
{ |
{ |
|
|
return (*so->so_proto->pr_usrreq)(so, PRU_ABORT, (struct mbuf *)0, |
return (*so->so_proto->pr_usrreq)(so, PRU_ABORT, (struct mbuf *)0, |
(struct mbuf *)0, (struct mbuf *)0, (struct proc *)0); |
(struct mbuf *)0, (struct mbuf *)0, (struct lwp *)0); |
} |
} |
|
|
int |
int |
Line 638 soaccept(struct socket *so, struct mbuf |
|
Line 640 soaccept(struct socket *so, struct mbuf |
|
if ((so->so_state & SS_ISDISCONNECTED) == 0 || |
if ((so->so_state & SS_ISDISCONNECTED) == 0 || |
(so->so_proto->pr_flags & PR_ABRTACPTDIS) == 0) |
(so->so_proto->pr_flags & PR_ABRTACPTDIS) == 0) |
error = (*so->so_proto->pr_usrreq)(so, PRU_ACCEPT, |
error = (*so->so_proto->pr_usrreq)(so, PRU_ACCEPT, |
(struct mbuf *)0, nam, (struct mbuf *)0, (struct proc *)0); |
(struct mbuf *)0, nam, (struct mbuf *)0, (struct lwp *)0); |
else |
else |
error = ECONNABORTED; |
error = ECONNABORTED; |
|
|
Line 647 soaccept(struct socket *so, struct mbuf |
|
Line 649 soaccept(struct socket *so, struct mbuf |
|
} |
} |
|
|
int |
int |
soconnect(struct socket *so, struct mbuf *nam, struct proc *p) |
soconnect(struct socket *so, struct mbuf *nam, struct lwp *l) |
{ |
{ |
int s, error; |
int s, error; |
|
|
Line 666 soconnect(struct socket *so, struct mbuf |
|
Line 668 soconnect(struct socket *so, struct mbuf |
|
error = EISCONN; |
error = EISCONN; |
else |
else |
error = (*so->so_proto->pr_usrreq)(so, PRU_CONNECT, |
error = (*so->so_proto->pr_usrreq)(so, PRU_CONNECT, |
(struct mbuf *)0, nam, (struct mbuf *)0, p); |
(struct mbuf *)0, nam, (struct mbuf *)0, l); |
splx(s); |
splx(s); |
return (error); |
return (error); |
} |
} |
Line 679 soconnect2(struct socket *so1, struct so |
|
Line 681 soconnect2(struct socket *so1, struct so |
|
s = splsoftnet(); |
s = splsoftnet(); |
error = (*so1->so_proto->pr_usrreq)(so1, PRU_CONNECT2, |
error = (*so1->so_proto->pr_usrreq)(so1, PRU_CONNECT2, |
(struct mbuf *)0, (struct mbuf *)so2, (struct mbuf *)0, |
(struct mbuf *)0, (struct mbuf *)so2, (struct mbuf *)0, |
(struct proc *)0); |
(struct lwp *)0); |
splx(s); |
splx(s); |
return (error); |
return (error); |
} |
} |
Line 700 sodisconnect(struct socket *so) |
|
Line 702 sodisconnect(struct socket *so) |
|
} |
} |
error = (*so->so_proto->pr_usrreq)(so, PRU_DISCONNECT, |
error = (*so->so_proto->pr_usrreq)(so, PRU_DISCONNECT, |
(struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0, |
(struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0, |
(struct proc *)0); |
(struct lwp *)0); |
bad: |
bad: |
splx(s); |
splx(s); |
sodopendfree(so); |
sodopendfree(); |
return (error); |
return (error); |
} |
} |
|
|
Line 727 sodisconnect(struct socket *so) |
|
Line 729 sodisconnect(struct socket *so) |
|
*/ |
*/ |
int |
int |
sosend(struct socket *so, struct mbuf *addr, struct uio *uio, struct mbuf *top, |
sosend(struct socket *so, struct mbuf *addr, struct uio *uio, struct mbuf *top, |
struct mbuf *control, int flags, struct proc *p) |
struct mbuf *control, int flags, struct lwp *l) |
{ |
{ |
struct mbuf **mp, *m; |
struct mbuf **mp, *m; |
|
struct proc *p; |
long space, len, resid, clen, mlen; |
long space, len, resid, clen, mlen; |
int error, s, dontroute, atomic; |
int error, s, dontroute, atomic; |
|
|
sodopendfree(so); |
p = l->l_proc; |
|
sodopendfree(); |
|
|
clen = 0; |
clen = 0; |
atomic = sosendallatonce(so) || top; |
atomic = sosendallatonce(so) || top; |
Line 883 sosend(struct socket *so, struct mbuf *a |
|
Line 887 sosend(struct socket *so, struct mbuf *a |
|
so->so_state |= SS_MORETOCOME; |
so->so_state |= SS_MORETOCOME; |
error = (*so->so_proto->pr_usrreq)(so, |
error = (*so->so_proto->pr_usrreq)(so, |
(flags & MSG_OOB) ? PRU_SENDOOB : PRU_SEND, |
(flags & MSG_OOB) ? PRU_SENDOOB : PRU_SEND, |
top, addr, control, p); |
top, addr, control, curlwp); /* XXX */ |
if (dontroute) |
if (dontroute) |
so->so_options &= ~SO_DONTROUTE; |
so->so_options &= ~SO_DONTROUTE; |
if (resid > 0) |
if (resid > 0) |
|
|
soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio, |
soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio, |
struct mbuf **mp0, struct mbuf **controlp, int *flagsp) |
struct mbuf **mp0, struct mbuf **controlp, int *flagsp) |
{ |
{ |
struct proc * p; |
struct lwp *l = curlwp; |
struct mbuf *m, **mp; |
struct mbuf *m, **mp; |
int flags, len, error, s, offset, moff, type, orig_resid; |
int flags, len, error, s, offset, moff, type, orig_resid; |
const struct protosw *pr; |
const struct protosw *pr; |
Line 940 soreceive(struct socket *so, struct mbuf |
|
Line 944 soreceive(struct socket *so, struct mbuf |
|
mp = mp0; |
mp = mp0; |
type = 0; |
type = 0; |
orig_resid = uio->uio_resid; |
orig_resid = uio->uio_resid; |
p = uio->uio_procp; |
|
|
|
if (paddr) |
if (paddr) |
*paddr = 0; |
*paddr = 0; |
Line 952 soreceive(struct socket *so, struct mbuf |
|
Line 955 soreceive(struct socket *so, struct mbuf |
|
flags = 0; |
flags = 0; |
|
|
if ((flags & MSG_DONTWAIT) == 0) |
if ((flags & MSG_DONTWAIT) == 0) |
sodopendfree(so); |
sodopendfree(); |
|
|
if (flags & MSG_OOB) { |
if (flags & MSG_OOB) { |
m = m_get(M_WAIT, MT_DATA); |
m = m_get(M_WAIT, MT_DATA); |
error = (*pr->pr_usrreq)(so, PRU_RCVOOB, m, |
error = (*pr->pr_usrreq)(so, PRU_RCVOOB, m, |
(struct mbuf *)(long)(flags & MSG_PEEK), |
(struct mbuf *)(long)(flags & MSG_PEEK), |
(struct mbuf *)0, p); |
(struct mbuf *)0, l); |
if (error) |
if (error) |
goto bad; |
goto bad; |
do { |
do { |
Line 975 soreceive(struct socket *so, struct mbuf |
|
Line 978 soreceive(struct socket *so, struct mbuf |
|
*mp = (struct mbuf *)0; |
*mp = (struct mbuf *)0; |
if (so->so_state & SS_ISCONFIRMING && uio->uio_resid) |
if (so->so_state & SS_ISCONFIRMING && uio->uio_resid) |
(*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0, |
(*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0, |
(struct mbuf *)0, (struct mbuf *)0, p); |
(struct mbuf *)0, (struct mbuf *)0, l); |
|
|
restart: |
restart: |
if ((error = sblock(&so->so_rcv, SBLOCKWAIT(flags))) != 0) |
if ((error = sblock(&so->so_rcv, SBLOCKWAIT(flags))) != 0) |
Line 1048 soreceive(struct socket *so, struct mbuf |
|
Line 1051 soreceive(struct socket *so, struct mbuf |
|
* While we process the initial mbufs containing address and control |
* While we process the initial mbufs containing address and control |
* info, we save a copy of m->m_nextpkt into nextrecord. |
* info, we save a copy of m->m_nextpkt into nextrecord. |
*/ |
*/ |
if (p) |
if (l) |
p->p_stats->p_ru.ru_msgrcv++; |
l->l_proc->p_stats->p_ru.ru_msgrcv++; |
KASSERT(m == so->so_rcv.sb_mb); |
KASSERT(m == so->so_rcv.sb_mb); |
SBLASTRECORDCHK(&so->so_rcv, "soreceive 1"); |
SBLASTRECORDCHK(&so->so_rcv, "soreceive 1"); |
SBLASTMBUFCHK(&so->so_rcv, "soreceive 1"); |
SBLASTMBUFCHK(&so->so_rcv, "soreceive 1"); |
Line 1088 soreceive(struct socket *so, struct mbuf |
|
Line 1091 soreceive(struct socket *so, struct mbuf |
|
mbuf_removed = 1; |
mbuf_removed = 1; |
if (controlp) { |
if (controlp) { |
struct domain *dom = pr->pr_domain; |
struct domain *dom = pr->pr_domain; |
if (dom->dom_externalize && p && |
if (dom->dom_externalize && l && |
mtod(m, struct cmsghdr *)->cmsg_type == |
mtod(m, struct cmsghdr *)->cmsg_type == |
SCM_RIGHTS) |
SCM_RIGHTS) |
error = (*dom->dom_externalize)(m, p); |
error = (*dom->dom_externalize)(m, l); |
*controlp = m; |
*controlp = m; |
so->so_rcv.sb_mb = m->m_next; |
so->so_rcv.sb_mb = m->m_next; |
m->m_next = 0; |
m->m_next = 0; |
Line 1284 soreceive(struct socket *so, struct mbuf |
|
Line 1287 soreceive(struct socket *so, struct mbuf |
|
(*pr->pr_usrreq)(so, PRU_RCVD, |
(*pr->pr_usrreq)(so, PRU_RCVD, |
(struct mbuf *)0, |
(struct mbuf *)0, |
(struct mbuf *)(long)flags, |
(struct mbuf *)(long)flags, |
(struct mbuf *)0, p); |
(struct mbuf *)0, l); |
SBLASTRECORDCHK(&so->so_rcv, "soreceive sbwait 2"); |
SBLASTRECORDCHK(&so->so_rcv, "soreceive sbwait 2"); |
SBLASTMBUFCHK(&so->so_rcv, "soreceive sbwait 2"); |
SBLASTMBUFCHK(&so->so_rcv, "soreceive sbwait 2"); |
error = sbwait(&so->so_rcv); |
error = sbwait(&so->so_rcv); |
Line 1321 soreceive(struct socket *so, struct mbuf |
|
Line 1324 soreceive(struct socket *so, struct mbuf |
|
SBLASTMBUFCHK(&so->so_rcv, "soreceive 4"); |
SBLASTMBUFCHK(&so->so_rcv, "soreceive 4"); |
if (pr->pr_flags & PR_WANTRCVD && so->so_pcb) |
if (pr->pr_flags & PR_WANTRCVD && so->so_pcb) |
(*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0, |
(*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0, |
(struct mbuf *)(long)flags, (struct mbuf *)0, p); |
(struct mbuf *)(long)flags, (struct mbuf *)0, l); |
} |
} |
if (orig_resid == uio->uio_resid && orig_resid && |
if (orig_resid == uio->uio_resid && orig_resid && |
(flags & MSG_EOR) == 0 && (so->so_state & SS_CANTRCVMORE) == 0) { |
(flags & MSG_EOR) == 0 && (so->so_state & SS_CANTRCVMORE) == 0) { |
Line 1351 soshutdown(struct socket *so, int how) |
|
Line 1354 soshutdown(struct socket *so, int how) |
|
sorflush(so); |
sorflush(so); |
if (how == SHUT_WR || how == SHUT_RDWR) |
if (how == SHUT_WR || how == SHUT_RDWR) |
return (*pr->pr_usrreq)(so, PRU_SHUTDOWN, (struct mbuf *)0, |
return (*pr->pr_usrreq)(so, PRU_SHUTDOWN, (struct mbuf *)0, |
(struct mbuf *)0, (struct mbuf *)0, (struct proc *)0); |
(struct mbuf *)0, (struct mbuf *)0, (struct lwp *)0); |
return (0); |
return (0); |
} |
} |
|
|
Line 1403 sosetopt(struct socket *so, int level, i |
|
Line 1406 sosetopt(struct socket *so, int level, i |
|
error = EINVAL; |
error = EINVAL; |
goto bad; |
goto bad; |
} |
} |
|
if (mtod(m, struct linger *)->l_linger < 0 || |
|
mtod(m, struct linger *)->l_linger > (INT_MAX / hz)) { |
|
error = EDOM; |
|
goto bad; |
|
} |
so->so_linger = mtod(m, struct linger *)->l_linger; |
so->so_linger = mtod(m, struct linger *)->l_linger; |
/* fall thru... */ |
/* fall thru... */ |
|
|