version 1.102, 2004/05/22 22:52:13 |
version 1.113, 2005/12/08 03:13:18 |
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++ |
|
|
|
|
/* Set the initial adjusted socket buffer size. */ |
/* Set the initial adjusted socket buffer size. */ |
if (sb_max_set(sb_max)) |
if (sb_max_set(sb_max)) |
panic("bad initial sb_max value: %lu\n", sb_max); |
panic("bad initial sb_max value: %lu", sb_max); |
|
|
} |
} |
|
|
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(struct socket *); |
static size_t sodopendfreel(struct socket *); |
static size_t sodopendfreel(struct socket *); |
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 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 234 sokvaalloc(vsize_t len, struct socket *s |
|
Line 232 sokvaalloc(vsize_t len, struct socket *s |
|
* allocate kva. |
* allocate kva. |
*/ |
*/ |
|
|
lva = uvm_km_valloc_wait(kernel_map, len); |
lva = uvm_km_alloc(kernel_map, len, 0, UVM_KMF_VAONLY | UVM_KMF_WAITVA); |
if (lva == 0) { |
if (lva == 0) { |
sokvaunreserve(len); |
sokvaunreserve(len); |
return (0); |
return (0); |
Line 255 sokvafree(vaddr_t sva, vsize_t len) |
|
Line 253 sokvafree(vaddr_t sva, vsize_t len) |
|
* free kva. |
* free kva. |
*/ |
*/ |
|
|
uvm_km_free(kernel_map, sva, len); |
uvm_km_free(kernel_map, sva, len, UVM_KMF_VAONLY); |
|
|
/* |
/* |
* unreserve kva. |
* unreserve kva. |
Line 480 socreate(int dom, struct socket **aso, i |
|
Line 478 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 (p != 0) |
if (p != 0) |
so->so_uid = p->p_ucred->cr_uid; |
so->so_uidinfo = uid_find(p->p_ucred->cr_uid); |
else |
else |
so->so_uid = UID_MAX; |
so->so_uidinfo = uid_find(0); |
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, p); |
if (error) { |
if (error) { |
Line 545 sofree(struct socket *so) |
|
Line 543 sofree(struct socket *so) |
|
return; |
return; |
} |
} |
if (so->so_rcv.sb_hiwat) |
if (so->so_rcv.sb_hiwat) |
(void)chgsbsize(so->so_uid, &so->so_rcv.sb_hiwat, 0, |
(void)chgsbsize(so->so_uidinfo, &so->so_rcv.sb_hiwat, 0, |
RLIM_INFINITY); |
RLIM_INFINITY); |
if (so->so_snd.sb_hiwat) |
if (so->so_snd.sb_hiwat) |
(void)chgsbsize(so->so_uid, &so->so_snd.sb_hiwat, 0, |
(void)chgsbsize(so->so_uidinfo, &so->so_snd.sb_hiwat, 0, |
RLIM_INFINITY); |
RLIM_INFINITY); |
sbrelease(&so->so_snd, so); |
sbrelease(&so->so_snd, so); |
sorflush(so); |
sorflush(so); |
Line 873 sosend(struct socket *so, struct mbuf *a |
|
Line 871 sosend(struct socket *so, struct mbuf *a |
|
break; |
break; |
} |
} |
} while (space > 0 && atomic); |
} while (space > 0 && atomic); |
|
|
s = splsoftnet(); |
s = splsoftnet(); |
|
|
if (so->so_state & SS_CANTSENDMORE) |
if (so->so_state & SS_CANTSENDMORE) |
Line 1050 soreceive(struct socket *so, struct mbuf |
|
Line 1048 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. |
*/ |
*/ |
#ifdef notyet /* XXXX */ |
|
if (p) |
if (p) |
p->p_stats->p_ru.ru_msgrcv++; |
p->p_stats->p_ru.ru_msgrcv++; |
#endif |
|
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 1101 soreceive(struct socket *so, struct mbuf |
|
Line 1097 soreceive(struct socket *so, struct mbuf |
|
m->m_next = 0; |
m->m_next = 0; |
m = so->so_rcv.sb_mb; |
m = so->so_rcv.sb_mb; |
} else { |
} 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); |
MFREE(m, so->so_rcv.sb_mb); |
m = so->so_rcv.sb_mb; |
m = so->so_rcv.sb_mb; |
} |
} |
Line 1326 soreceive(struct socket *so, struct mbuf |
|
Line 1329 soreceive(struct socket *so, struct mbuf |
|
splx(s); |
splx(s); |
goto restart; |
goto restart; |
} |
} |
|
|
if (flagsp) |
if (flagsp) |
*flagsp |= flags; |
*flagsp |= flags; |
release: |
release: |
Line 1400 sosetopt(struct socket *so, int level, i |
|
Line 1403 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... */ |
|
|
Line 1478 sosetopt(struct socket *so, int level, i |
|
Line 1486 sosetopt(struct socket *so, int level, i |
|
case SO_RCVTIMEO: |
case SO_RCVTIMEO: |
{ |
{ |
struct timeval *tv; |
struct timeval *tv; |
short val; |
int val; |
|
|
if (m == NULL || m->m_len < sizeof(*tv)) { |
if (m == NULL || m->m_len < sizeof(*tv)) { |
error = EINVAL; |
error = EINVAL; |
goto bad; |
goto bad; |
} |
} |
tv = mtod(m, struct timeval *); |
tv = mtod(m, struct timeval *); |
if (tv->tv_sec > (SHRT_MAX - tv->tv_usec / tick) / hz) { |
if (tv->tv_sec > (INT_MAX - tv->tv_usec / tick) / hz) { |
error = EDOM; |
error = EDOM; |
goto bad; |
goto bad; |
} |
} |
Line 1595 sogetopt(struct socket *so, int level, i |
|
Line 1603 sogetopt(struct socket *so, int level, i |
|
break; |
break; |
} |
} |
|
|
|
case SO_OVERFLOWED: |
|
*mtod(m, int *) = so->so_rcv.sb_overflowed; |
|
break; |
|
|
default: |
default: |
(void)m_free(m); |
(void)m_free(m); |
return (ENOPROTOOPT); |
return (ENOPROTOOPT); |
Line 1631 filt_soread(struct knote *kn, long hint) |
|
Line 1643 filt_soread(struct knote *kn, long hint) |
|
so = (struct socket *)kn->kn_fp->f_data; |
so = (struct socket *)kn->kn_fp->f_data; |
kn->kn_data = so->so_rcv.sb_cc; |
kn->kn_data = so->so_rcv.sb_cc; |
if (so->so_state & SS_CANTRCVMORE) { |
if (so->so_state & SS_CANTRCVMORE) { |
kn->kn_flags |= EV_EOF; |
kn->kn_flags |= EV_EOF; |
kn->kn_fflags = so->so_error; |
kn->kn_fflags = so->so_error; |
return (1); |
return (1); |
} |
} |
Line 1662 filt_sowrite(struct knote *kn, long hint |
|
Line 1674 filt_sowrite(struct knote *kn, long hint |
|
so = (struct socket *)kn->kn_fp->f_data; |
so = (struct socket *)kn->kn_fp->f_data; |
kn->kn_data = sbspace(&so->so_snd); |
kn->kn_data = sbspace(&so->so_snd); |
if (so->so_state & SS_CANTSENDMORE) { |
if (so->so_state & SS_CANTSENDMORE) { |
kn->kn_flags |= EV_EOF; |
kn->kn_flags |= EV_EOF; |
kn->kn_fflags = so->so_error; |
kn->kn_fflags = so->so_error; |
return (1); |
return (1); |
} |
} |
Line 1687 filt_solisten(struct knote *kn, long hin |
|
Line 1699 filt_solisten(struct knote *kn, long hin |
|
/* |
/* |
* Set kn_data to number of incoming connections, not |
* Set kn_data to number of incoming connections, not |
* counting partial (incomplete) connections. |
* counting partial (incomplete) connections. |
*/ |
*/ |
kn->kn_data = so->so_qlen; |
kn->kn_data = so->so_qlen; |
return (kn->kn_data > 0); |
return (kn->kn_data > 0); |
} |
} |
Line 1773 SYSCTL_SETUP(sysctl_kern_somaxkva_setup, |
|
Line 1785 SYSCTL_SETUP(sysctl_kern_somaxkva_setup, |
|
|
|
sysctl_createv(clog, 0, NULL, NULL, |
sysctl_createv(clog, 0, NULL, NULL, |
CTLFLAG_PERMANENT|CTLFLAG_READWRITE, |
CTLFLAG_PERMANENT|CTLFLAG_READWRITE, |
CTLTYPE_INT, "somaxkva", NULL, |
CTLTYPE_INT, "somaxkva", |
|
SYSCTL_DESCR("Maximum amount of kernel memory to be " |
|
"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); |
} |
} |