Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/kern/uipc_socket.c,v retrieving revision 1.115.4.1 retrieving revision 1.116 diff -u -p -r1.115.4.1 -r1.116 --- src/sys/kern/uipc_socket.c 2006/09/09 02:57:17 1.115.4.1 +++ src/sys/kern/uipc_socket.c 2006/03/01 12:38:21 1.116 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.115.4.1 2006/09/09 02:57:17 rpaulo Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.116 2006/03/01 12:38:21 yamt Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.115.4.1 2006/09/09 02:57:17 rpaulo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.116 2006/03/01 12:38:21 yamt Exp $"); #include "opt_sock_counters.h" #include "opt_sosend_loan.h" @@ -91,7 +91,6 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_socket. #include #include #include -#include #include @@ -127,12 +126,20 @@ EVCNT_ATTACH_STATIC(sosend_kvalimit); #endif /* SOSEND_COUNTERS */ -static struct callback_entry sokva_reclaimerentry; +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); + +} #ifdef SOSEND_NO_LOAN -int sock_loan_thresh = -1; +int use_sosend_loan = 0; #else -int sock_loan_thresh = 4096; +int use_sosend_loan = 1; #endif static struct simplelock so_pendfree_slock = SIMPLELOCK_INITIALIZER; @@ -145,10 +152,11 @@ int somaxkva = SOMAXKVA; static int socurkva; static int sokvawaiters; +#define SOCK_LOAN_THRESH 4096 #define SOCK_LOAN_CHUNK 65536 -static size_t sodopendfree(void); -static size_t sodopendfreel(void); +static size_t sodopendfree(struct socket *); +static size_t sodopendfreel(struct socket *); static vsize_t sokvareserve(struct socket *so, vsize_t len) @@ -165,7 +173,7 @@ sokvareserve(struct socket *so, vsize_t * try to do pendfree. */ - freed = sodopendfreel(); + freed = sodopendfreel(so); /* * if some kva was freed, try again. @@ -284,14 +292,14 @@ sodoloanfree(struct vm_page **pgs, caddr } static size_t -sodopendfree() +sodopendfree(struct socket *so) { int s; size_t rv; s = splvm(); simple_lock(&so_pendfree_slock); - rv = sodopendfreel(); + rv = sodopendfreel(so); simple_unlock(&so_pendfree_slock); splx(s); @@ -307,7 +315,7 @@ sodopendfree() */ static size_t -sodopendfreel() +sodopendfreel(struct socket *so) { size_t rv = 0; @@ -431,32 +439,6 @@ sosend_loan(struct socket *so, struct ui return (space); } -static int -sokva_reclaim_callback(struct callback_entry *ce, void *obj, void *arg) -{ - - 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. * These routines are called by the routines in @@ -477,16 +459,7 @@ socreate(int dom, struct socket **aso, i prp = pffindproto(dom, proto, type); else prp = pffindtype(dom, type); - 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) + if (prp == 0 || prp->pr_usrreq == 0) return (EPROTONOSUPPORT); if (prp->pr_type != type) return (EPROTOTYPE); @@ -505,7 +478,7 @@ socreate(int dom, struct socket **aso, i so->so_mowner = &prp->pr_domain->dom_mowner; #endif if (l != NULL) { - uid = kauth_cred_geteuid(l->l_cred); + uid = l->l_proc->p_ucred->cr_uid; } else { uid = 0; } @@ -732,7 +705,7 @@ sodisconnect(struct socket *so) (struct lwp *)0); bad: splx(s); - sodopendfree(); + sodopendfree(so); return (error); } @@ -764,7 +737,7 @@ sosend(struct socket *so, struct mbuf *a int error, s, dontroute, atomic; p = l->l_proc; - sodopendfree(); + sodopendfree(so); clen = 0; atomic = sosendallatonce(so) || top; @@ -852,9 +825,9 @@ sosend(struct socket *so, struct mbuf *a mlen = MLEN; } MCLAIM(m, so->so_snd.sb_mowner); - if (sock_loan_thresh >= 0 && - uio->uio_iov->iov_len >= sock_loan_thresh && - space >= sock_loan_thresh && + if (use_sosend_loan && + uio->uio_iov->iov_len >= SOCK_LOAN_THRESH && + space >= SOCK_LOAN_THRESH && (len = sosend_loan(so, uio, m, space)) != 0) { SOSEND_COUNTER_INCR(&sosend_loan_big); @@ -982,7 +955,7 @@ soreceive(struct socket *so, struct mbuf flags = 0; if ((flags & MSG_DONTWAIT) == 0) - sodopendfree(); + sodopendfree(so); if (flags & MSG_OOB) { m = m_get(M_WAIT, MT_DATA);