version 1.209, 2012/02/01 02:27:23 |
version 1.215, 2013/04/08 21:12:33 |
Line 160 static void sopendfree_thread(void *); |
|
Line 160 static void sopendfree_thread(void *); |
|
static kcondvar_t pendfree_thread_cv; |
static kcondvar_t pendfree_thread_cv; |
static lwp_t *sopendfree_lwp; |
static lwp_t *sopendfree_lwp; |
|
|
static void sysctl_kern_somaxkva_setup(void); |
static void sysctl_kern_socket_setup(void); |
static struct sysctllog *socket_sysctllog; |
static struct sysctllog *socket_sysctllog; |
|
|
static vsize_t |
static vsize_t |
|
|
soinit(void) |
soinit(void) |
{ |
{ |
|
|
sysctl_kern_somaxkva_setup(); |
sysctl_kern_socket_setup(); |
|
|
mutex_init(&so_pendfree_lock, MUTEX_DEFAULT, IPL_VM); |
mutex_init(&so_pendfree_lock, MUTEX_DEFAULT, IPL_VM); |
softnet_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE); |
softnet_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE); |
Line 538 socreate(int dom, struct socket **aso, i |
|
Line 538 socreate(int dom, struct socket **aso, i |
|
lock = lockso->so_lock; |
lock = lockso->so_lock; |
so->so_lock = lock; |
so->so_lock = lock; |
mutex_obj_hold(lock); |
mutex_obj_hold(lock); |
|
/* XXX Why is this not solock, to match sounlock? */ |
mutex_enter(lock); |
mutex_enter(lock); |
} else { |
} else { |
/* Lock assigned and taken during PRU_ATTACH. */ |
/* Lock assigned and taken during PRU_ATTACH. */ |
Line 585 fsocreate(int domain, struct socket **so |
|
Line 586 fsocreate(int domain, struct socket **so |
|
fp->f_data = so; |
fp->f_data = so; |
fd_affix(curproc, fp, fd); |
fd_affix(curproc, fp, fd); |
*fdout = fd; |
*fdout = fd; |
|
if (flags & SOCK_NONBLOCK) |
|
so->so_state |= SS_NBIO; |
} |
} |
return error; |
return error; |
} |
} |
Line 622 solisten(struct socket *so, int backlog, |
|
Line 625 solisten(struct socket *so, int backlog, |
|
if ((so->so_state & (SS_ISCONNECTED | SS_ISCONNECTING | |
if ((so->so_state & (SS_ISCONNECTED | SS_ISCONNECTING | |
SS_ISDISCONNECTING)) != 0) { |
SS_ISDISCONNECTING)) != 0) { |
sounlock(so); |
sounlock(so); |
return (EOPNOTSUPP); |
return (EINVAL); |
} |
} |
error = (*so->so_proto->pr_usrreq)(so, PRU_LISTEN, NULL, |
error = (*so->so_proto->pr_usrreq)(so, PRU_LISTEN, NULL, |
NULL, NULL, l); |
NULL, NULL, l); |
Line 874 sosend(struct socket *so, struct mbuf *a |
|
Line 877 sosend(struct socket *so, struct mbuf *a |
|
struct mbuf *control, int flags, struct lwp *l) |
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; |
short wakeup_state = 0; |
short wakeup_state = 0; |
|
|
p = l->l_proc; |
|
clen = 0; |
clen = 0; |
|
|
/* |
/* |
Line 1132 soreceive(struct socket *so, struct mbuf |
|
Line 1133 soreceive(struct socket *so, struct mbuf |
|
{ |
{ |
struct lwp *l = curlwp; |
struct lwp *l = curlwp; |
struct mbuf *m, **mp, *mt; |
struct mbuf *m, **mp, *mt; |
int atomic, flags, len, error, s, offset, moff, type, orig_resid; |
size_t len, offset, moff, orig_resid; |
|
int atomic, flags, error, s, type; |
const struct protosw *pr; |
const struct protosw *pr; |
struct mbuf *nextrecord; |
struct mbuf *nextrecord; |
int mbuf_removed = 0; |
int mbuf_removed = 0; |
Line 1165 soreceive(struct socket *so, struct mbuf |
|
Line 1167 soreceive(struct socket *so, struct mbuf |
|
goto bad; |
goto bad; |
do { |
do { |
error = uiomove(mtod(m, void *), |
error = uiomove(mtod(m, void *), |
(int) min(uio->uio_resid, m->m_len), uio); |
MIN(uio->uio_resid, m->m_len), uio); |
m = m_free(m); |
m = m_free(m); |
} while (uio->uio_resid > 0 && error == 0 && m); |
} while (uio->uio_resid > 0 && error == 0 && m); |
bad: |
bad: |
Line 1419 soreceive(struct socket *so, struct mbuf |
|
Line 1421 soreceive(struct socket *so, struct mbuf |
|
SBLASTMBUFCHK(&so->so_rcv, "soreceive uiomove"); |
SBLASTMBUFCHK(&so->so_rcv, "soreceive uiomove"); |
sounlock(so); |
sounlock(so); |
splx(s); |
splx(s); |
error = uiomove(mtod(m, char *) + moff, (int)len, uio); |
error = uiomove(mtod(m, char *) + moff, len, uio); |
s = splsoftnet(); |
s = splsoftnet(); |
solock(so); |
solock(so); |
if (error != 0) { |
if (error != 0) { |
Line 2365 sopoll(struct socket *so, int events) |
|
Line 2367 sopoll(struct socket *so, int events) |
|
#include <sys/sysctl.h> |
#include <sys/sysctl.h> |
|
|
static int sysctl_kern_somaxkva(SYSCTLFN_PROTO); |
static int sysctl_kern_somaxkva(SYSCTLFN_PROTO); |
|
static int sysctl_kern_sbmax(SYSCTLFN_PROTO); |
|
|
/* |
/* |
* sysctl helper routine for kern.somaxkva. ensures that the given |
* sysctl helper routine for kern.somaxkva. ensures that the given |
Line 2395 sysctl_kern_somaxkva(SYSCTLFN_ARGS) |
|
Line 2398 sysctl_kern_somaxkva(SYSCTLFN_ARGS) |
|
return (error); |
return (error); |
} |
} |
|
|
|
/* |
|
* sysctl helper routine for kern.sbmax. Basically just ensures that |
|
* any new value is not too small. |
|
*/ |
|
static int |
|
sysctl_kern_sbmax(SYSCTLFN_ARGS) |
|
{ |
|
int error, new_sbmax; |
|
struct sysctlnode node; |
|
|
|
new_sbmax = sb_max; |
|
node = *rnode; |
|
node.sysctl_data = &new_sbmax; |
|
error = sysctl_lookup(SYSCTLFN_CALL(&node)); |
|
if (error || newp == NULL) |
|
return (error); |
|
|
|
KERNEL_LOCK(1, NULL); |
|
error = sb_max_set(new_sbmax); |
|
KERNEL_UNLOCK_ONE(NULL); |
|
|
|
return (error); |
|
} |
|
|
static void |
static void |
sysctl_kern_somaxkva_setup(void) |
sysctl_kern_socket_setup(void) |
{ |
{ |
|
|
KASSERT(socket_sysctllog == NULL); |
KASSERT(socket_sysctllog == NULL); |
Line 2413 sysctl_kern_somaxkva_setup(void) |
|
Line 2440 sysctl_kern_somaxkva_setup(void) |
|
"used for socket buffers"), |
"used for socket buffers"), |
sysctl_kern_somaxkva, 0, NULL, 0, |
sysctl_kern_somaxkva, 0, NULL, 0, |
CTL_KERN, KERN_SOMAXKVA, CTL_EOL); |
CTL_KERN, KERN_SOMAXKVA, CTL_EOL); |
|
|
|
sysctl_createv(&socket_sysctllog, 0, NULL, NULL, |
|
CTLFLAG_PERMANENT|CTLFLAG_READWRITE, |
|
CTLTYPE_INT, "sbmax", |
|
SYSCTL_DESCR("Maximum socket buffer size"), |
|
sysctl_kern_sbmax, 0, NULL, 0, |
|
CTL_KERN, KERN_SBMAX, CTL_EOL); |
} |
} |