| version 1.159.2.3, 2008/06/06 20:18:19 |
version 1.160, 2008/04/24 11:38:36 |
|
|
| * 2. Redistributions in binary form must reproduce the above copyright |
* 2. Redistributions in binary form must reproduce the above copyright |
| * notice, this list of conditions and the following disclaimer in the |
* notice, this list of conditions and the following disclaimer in the |
| * documentation and/or other materials provided with the distribution. |
* documentation and/or other materials provided with the distribution. |
| |
* 3. All advertising materials mentioning features or use of this software |
| |
* must display the following acknowledgement: |
| |
* This product includes software developed by the NetBSD |
| |
* Foundation, Inc. and its contributors. |
| |
* 4. Neither the name of The NetBSD Foundation nor the names of its |
| |
* contributors may be used to endorse or promote products derived |
| |
* from this software without specific prior written permission. |
| * |
* |
| * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
| * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| Line 69 __KERNEL_RCSID(0, "$NetBSD$"); |
|
| Line 76 __KERNEL_RCSID(0, "$NetBSD$"); |
|
| #include "opt_sosend_loan.h" |
#include "opt_sosend_loan.h" |
| #include "opt_mbuftrace.h" |
#include "opt_mbuftrace.h" |
| #include "opt_somaxkva.h" |
#include "opt_somaxkva.h" |
| #include "opt_multiprocessor.h" /* XXX */ |
|
| |
|
| #include <sys/param.h> |
#include <sys/param.h> |
| #include <sys/systm.h> |
#include <sys/systm.h> |
| Line 128 EVCNT_ATTACH_STATIC(sosend_kvalimit); |
|
| Line 134 EVCNT_ATTACH_STATIC(sosend_kvalimit); |
|
| |
|
| static struct callback_entry sokva_reclaimerentry; |
static struct callback_entry sokva_reclaimerentry; |
| |
|
| #if defined(SOSEND_NO_LOAN) || defined(MULTIPROCESSOR) |
#ifdef SOSEND_NO_LOAN |
| int sock_loan_thresh = -1; |
int sock_loan_thresh = -1; |
| #else |
#else |
| int sock_loan_thresh = 4096; |
int sock_loan_thresh = 4096; |
|
|
| 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); |
| cv_init(&socurkva_cv, "sokva"); |
cv_init(&socurkva_cv, "sokva"); |
| soinit2(); |
|
| |
|
| /* 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)) |
| Line 500 socreate(int dom, struct socket **aso, i |
|
| Line 505 socreate(int dom, struct socket **aso, i |
|
| #endif |
#endif |
| uid = kauth_cred_geteuid(l->l_cred); |
uid = kauth_cred_geteuid(l->l_cred); |
| so->so_uidinfo = uid_find(uid); |
so->so_uidinfo = uid_find(uid); |
| so->so_egid = kauth_cred_getegid(l->l_cred); |
|
| so->so_cpid = l->l_proc->p_pid; |
|
| if (lockso != NULL) { |
if (lockso != NULL) { |
| /* Caller wants us to share a lock. */ |
/* Caller wants us to share a lock. */ |
| lock = lockso->so_lock; |
lock = lockso->so_lock; |
| Line 571 solisten(struct socket *so, int backlog, |
|
| Line 574 solisten(struct socket *so, int backlog, |
|
| |
|
| solock(so); |
solock(so); |
| if ((so->so_state & (SS_ISCONNECTED | SS_ISCONNECTING | |
if ((so->so_state & (SS_ISCONNECTED | SS_ISCONNECTING | |
| SS_ISDISCONNECTING)) != 0) { |
SS_ISDISCONNECTING)) != 0) |
| sounlock(so); |
|
| return (EOPNOTSUPP); |
return (EOPNOTSUPP); |
| } |
|
| 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); |
| if (error != 0) { |
if (error != 0) { |
| Line 593 solisten(struct socket *so, int backlog, |
|
| Line 594 solisten(struct socket *so, int backlog, |
|
| void |
void |
| sofree(struct socket *so) |
sofree(struct socket *so) |
| { |
{ |
| u_int refs; |
|
| |
|
| KASSERT(solocked(so)); |
KASSERT(solocked(so)); |
| |
|
| Line 623 sofree(struct socket *so) |
|
| Line 623 sofree(struct socket *so) |
|
| KASSERT(!cv_has_waiters(&so->so_rcv.sb_cv)); |
KASSERT(!cv_has_waiters(&so->so_rcv.sb_cv)); |
| KASSERT(!cv_has_waiters(&so->so_snd.sb_cv)); |
KASSERT(!cv_has_waiters(&so->so_snd.sb_cv)); |
| sorflush(so); |
sorflush(so); |
| refs = so->so_aborting; /* XXX */ |
|
| sounlock(so); |
sounlock(so); |
| if (refs == 0) /* XXX */ |
soput(so); |
| soput(so); |
|
| } |
} |
| |
|
| /* |
/* |
| Line 702 soclose(struct socket *so) |
|
| Line 700 soclose(struct socket *so) |
|
| int |
int |
| soabort(struct socket *so) |
soabort(struct socket *so) |
| { |
{ |
| u_int refs; |
|
| int error; |
int error; |
| |
|
| KASSERT(solocked(so)); |
KASSERT(solocked(so)); |
| KASSERT(so->so_head == NULL); |
KASSERT(so->so_head == NULL); |
| |
|
| so->so_aborting++; /* XXX */ |
|
| error = (*so->so_proto->pr_usrreq)(so, PRU_ABORT, NULL, |
error = (*so->so_proto->pr_usrreq)(so, PRU_ABORT, NULL, |
| NULL, NULL, NULL); |
NULL, NULL, NULL); |
| refs = --so->so_aborting; /* XXX */ |
if (error) { |
| if (error || (refs == 0)) { |
|
| sofree(so); |
sofree(so); |
| } else { |
} else { |
| sounlock(so); |
sounlock(so); |
| Line 854 sosend(struct socket *so, struct mbuf *a |
|
| Line 849 sosend(struct socket *so, struct mbuf *a |
|
| dontroute = |
dontroute = |
| (flags & MSG_DONTROUTE) && (so->so_options & SO_DONTROUTE) == 0 && |
(flags & MSG_DONTROUTE) && (so->so_options & SO_DONTROUTE) == 0 && |
| (so->so_proto->pr_flags & PR_ATOMIC); |
(so->so_proto->pr_flags & PR_ATOMIC); |
| l->l_ru.ru_msgsnd++; |
if (l) |
| |
l->l_ru.ru_msgsnd++; |
| if (control) |
if (control) |
| clen = control->m_len; |
clen = control->m_len; |
| restart: |
restart: |