version 1.118, 2006/05/14 21:15:12 |
version 1.127, 2006/10/25 22:49:23 |
Line 127 EVCNT_ATTACH_STATIC(sosend_kvalimit); |
|
Line 127 EVCNT_ATTACH_STATIC(sosend_kvalimit); |
|
|
|
#endif /* SOSEND_COUNTERS */ |
#endif /* SOSEND_COUNTERS */ |
|
|
void |
static struct callback_entry sokva_reclaimerentry; |
soinit(void) |
|
{ |
|
|
|
/* Set the initial adjusted socket buffer size. */ |
|
if (sb_max_set(sb_max)) |
|
panic("bad initial sb_max value: %lu", sb_max); |
|
|
|
} |
|
|
|
#ifdef SOSEND_NO_LOAN |
#ifdef SOSEND_NO_LOAN |
int use_sosend_loan = 0; |
int sock_loan_thresh = -1; |
#else |
#else |
int use_sosend_loan = 1; |
int sock_loan_thresh = 4096; |
#endif |
#endif |
|
|
static struct simplelock so_pendfree_slock = SIMPLELOCK_INITIALIZER; |
static struct simplelock so_pendfree_slock = SIMPLELOCK_INITIALIZER; |
Line 153 int somaxkva = SOMAXKVA; |
|
Line 145 int somaxkva = SOMAXKVA; |
|
static int socurkva; |
static int socurkva; |
static int sokvawaiters; |
static int sokvawaiters; |
|
|
#define SOCK_LOAN_THRESH 4096 |
|
#define SOCK_LOAN_CHUNK 65536 |
#define SOCK_LOAN_CHUNK 65536 |
|
|
static size_t sodopendfree(void); |
static size_t sodopendfree(void); |
static size_t sodopendfreel(void); |
static size_t sodopendfreel(void); |
|
|
static vsize_t |
static vsize_t |
sokvareserve(struct socket *so, vsize_t len) |
sokvareserve(struct socket *so __unused, vsize_t len) |
{ |
{ |
int s; |
int s; |
int error; |
int error; |
|
|
} |
} |
|
|
void |
void |
soloanfree(struct mbuf *m, caddr_t buf, size_t size, void *arg) |
soloanfree(struct mbuf *m, caddr_t buf, size_t size, void *arg __unused) |
{ |
{ |
int s; |
int s; |
|
|
Line 440 sosend_loan(struct socket *so, struct ui |
|
Line 431 sosend_loan(struct socket *so, struct ui |
|
return (space); |
return (space); |
} |
} |
|
|
|
static int |
|
sokva_reclaim_callback(struct callback_entry *ce __unused, void *obj __unused, |
|
void *arg __unused) |
|
{ |
|
|
|
KASSERT(ce == &sokva_reclaimerentry); |
|
KASSERT(obj == NULL); |
|
|
|
sodopendfree(); |
|
if (!vm_map_starved_p(kernel_map)) { |
|
return CALLBACK_CHAIN_ABORT; |
|
} |
|
return CALLBACK_CHAIN_CONTINUE; |
|
} |
|
|
|
void |
|
soinit(void) |
|
{ |
|
|
|
/* Set the initial adjusted socket buffer size. */ |
|
if (sb_max_set(sb_max)) |
|
panic("bad initial sb_max value: %lu", sb_max); |
|
|
|
callback_register(&vm_map_to_kernel(kernel_map)->vmk_reclaim_callback, |
|
&sokva_reclaimerentry, NULL, sokva_reclaim_callback); |
|
} |
|
|
/* |
/* |
* Socket operation routines. |
* Socket operation routines. |
* These routines are called by the routines in |
* These routines are called by the routines in |
Line 456 socreate(int dom, struct socket **aso, i |
|
Line 474 socreate(int dom, struct socket **aso, i |
|
uid_t uid; |
uid_t uid; |
int error, s; |
int error, s; |
|
|
|
if (kauth_authorize_network(l->l_cred, KAUTH_NETWORK_SOCKET, |
|
KAUTH_REQ_NETWORK_SOCKET_OPEN, &dom, &type, &proto) != 0) |
|
return (EPERM); |
|
|
if (proto) |
if (proto) |
prp = pffindproto(dom, proto, type); |
prp = pffindproto(dom, proto, type); |
else |
else |
prp = pffindtype(dom, type); |
prp = pffindtype(dom, type); |
if (prp == 0 || prp->pr_usrreq == 0) |
if (prp == 0) { |
|
/* no support for domain */ |
|
if (pffinddomain(dom) == 0) |
|
return (EAFNOSUPPORT); |
|
/* no support for socket type */ |
|
if (proto == 0 && type != 0) |
|
return (EPROTOTYPE); |
|
return (EPROTONOSUPPORT); |
|
} |
|
if (prp->pr_usrreq == 0) |
return (EPROTONOSUPPORT); |
return (EPROTONOSUPPORT); |
if (prp->pr_type != type) |
if (prp->pr_type != type) |
return (EPROTOTYPE); |
return (EPROTOTYPE); |
Line 479 socreate(int dom, struct socket **aso, i |
|
Line 510 socreate(int dom, struct socket **aso, i |
|
so->so_mowner = &prp->pr_domain->dom_mowner; |
so->so_mowner = &prp->pr_domain->dom_mowner; |
#endif |
#endif |
if (l != NULL) { |
if (l != NULL) { |
uid = kauth_cred_geteuid(l->l_proc->p_cred); |
uid = kauth_cred_geteuid(l->l_cred); |
} else { |
} else { |
uid = 0; |
uid = 0; |
} |
} |
Line 826 sosend(struct socket *so, struct mbuf *a |
|
Line 857 sosend(struct socket *so, struct mbuf *a |
|
mlen = MLEN; |
mlen = MLEN; |
} |
} |
MCLAIM(m, so->so_snd.sb_mowner); |
MCLAIM(m, so->so_snd.sb_mowner); |
if (use_sosend_loan && |
if (sock_loan_thresh >= 0 && |
uio->uio_iov->iov_len >= SOCK_LOAN_THRESH && |
uio->uio_iov->iov_len >= sock_loan_thresh && |
space >= SOCK_LOAN_THRESH && |
space >= sock_loan_thresh && |
(len = sosend_loan(so, uio, m, |
(len = sosend_loan(so, uio, m, |
space)) != 0) { |
space)) != 0) { |
SOSEND_COUNTER_INCR(&sosend_loan_big); |
SOSEND_COUNTER_INCR(&sosend_loan_big); |
Line 1640 filt_sordetach(struct knote *kn) |
|
Line 1671 filt_sordetach(struct knote *kn) |
|
|
|
/*ARGSUSED*/ |
/*ARGSUSED*/ |
static int |
static int |
filt_soread(struct knote *kn, long hint) |
filt_soread(struct knote *kn, long hint __unused) |
{ |
{ |
struct socket *so; |
struct socket *so; |
|
|
Line 1671 filt_sowdetach(struct knote *kn) |
|
Line 1702 filt_sowdetach(struct knote *kn) |
|
|
|
/*ARGSUSED*/ |
/*ARGSUSED*/ |
static int |
static int |
filt_sowrite(struct knote *kn, long hint) |
filt_sowrite(struct knote *kn, long hint __unused) |
{ |
{ |
struct socket *so; |
struct socket *so; |
|
|
Line 1694 filt_sowrite(struct knote *kn, long hint |
|
Line 1725 filt_sowrite(struct knote *kn, long hint |
|
|
|
/*ARGSUSED*/ |
/*ARGSUSED*/ |
static int |
static int |
filt_solisten(struct knote *kn, long hint) |
filt_solisten(struct knote *kn, long hint __unused) |
{ |
{ |
struct socket *so; |
struct socket *so; |
|
|
Line 1716 static const struct filterops sowrite_fi |
|
Line 1747 static const struct filterops sowrite_fi |
|
{ 1, NULL, filt_sowdetach, filt_sowrite }; |
{ 1, NULL, filt_sowdetach, filt_sowrite }; |
|
|
int |
int |
soo_kqfilter(struct file *fp, struct knote *kn) |
soo_kqfilter(struct file *fp __unused, struct knote *kn) |
{ |
{ |
struct socket *so; |
struct socket *so; |
struct sockbuf *sb; |
struct sockbuf *sb; |