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 rcsdiff: /ftp/cvs/cvsroot/src/sys/kern/uipc_socket.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.115.6.1 retrieving revision 1.122.6.1 diff -u -p -r1.115.6.1 -r1.122.6.1 --- src/sys/kern/uipc_socket.c 2006/04/22 11:39:59 1.115.6.1 +++ src/sys/kern/uipc_socket.c 2006/10/22 06:07:11 1.122.6.1 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.115.6.1 2006/04/22 11:39:59 simonb Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.122.6.1 2006/10/22 06:07:11 yamt Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.115.6.1 2006/04/22 11:39:59 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.122.6.1 2006/10/22 06:07:11 yamt Exp $"); #include "opt_sock_counters.h" #include "opt_sosend_loan.h" @@ -91,6 +91,7 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_socket. #include #include #include +#include #include @@ -126,20 +127,12 @@ EVCNT_ATTACH_STATIC(sosend_kvalimit); #endif /* SOSEND_COUNTERS */ -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); - -} +static struct callback_entry sokva_reclaimerentry; #ifdef SOSEND_NO_LOAN -int use_sosend_loan = 0; +int sock_loan_thresh = -1; #else -int use_sosend_loan = 1; +int sock_loan_thresh = 4096; #endif static struct simplelock so_pendfree_slock = SIMPLELOCK_INITIALIZER; @@ -152,14 +145,13 @@ 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 vsize_t -sokvareserve(struct socket *so, vsize_t len) +sokvareserve(struct socket *so __unused, vsize_t len) { int s; int error; @@ -350,7 +342,7 @@ sodopendfreel() } 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; @@ -439,6 +431,33 @@ sosend_loan(struct socket *so, struct ui 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. * These routines are called by the routines in @@ -459,7 +478,16 @@ socreate(int dom, struct socket **aso, i prp = pffindproto(dom, proto, type); else 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); if (prp->pr_type != type) return (EPROTOTYPE); @@ -478,7 +506,7 @@ socreate(int dom, struct socket **aso, i so->so_mowner = &prp->pr_domain->dom_mowner; #endif if (l != NULL) { - uid = l->l_proc->p_ucred->cr_uid; + uid = kauth_cred_geteuid(l->l_cred); } else { uid = 0; } @@ -825,9 +853,9 @@ sosend(struct socket *so, struct mbuf *a mlen = MLEN; } MCLAIM(m, so->so_snd.sb_mowner); - if (use_sosend_loan && - uio->uio_iov->iov_len >= SOCK_LOAN_THRESH && - space >= SOCK_LOAN_THRESH && + if (sock_loan_thresh >= 0 && + 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); @@ -1639,7 +1667,7 @@ filt_sordetach(struct knote *kn) /*ARGSUSED*/ static int -filt_soread(struct knote *kn, long hint) +filt_soread(struct knote *kn, long hint __unused) { struct socket *so; @@ -1670,7 +1698,7 @@ filt_sowdetach(struct knote *kn) /*ARGSUSED*/ static int -filt_sowrite(struct knote *kn, long hint) +filt_sowrite(struct knote *kn, long hint __unused) { struct socket *so; @@ -1693,7 +1721,7 @@ filt_sowrite(struct knote *kn, long hint /*ARGSUSED*/ static int -filt_solisten(struct knote *kn, long hint) +filt_solisten(struct knote *kn, long hint __unused) { struct socket *so; @@ -1715,7 +1743,7 @@ static const struct filterops sowrite_fi { 1, NULL, filt_sowdetach, filt_sowrite }; int -soo_kqfilter(struct file *fp, struct knote *kn) +soo_kqfilter(struct file *fp __unused, struct knote *kn) { struct socket *so; struct sockbuf *sb;