[BACK]Return to uipc_socket.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / kern

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/kern/uipc_socket.c between version 1.101 and 1.134.2.2

version 1.101, 2004/05/01 02:24:38 version 1.134.2.2, 2007/04/10 13:26:42
Line 1 
Line 1 
 /*      $NetBSD$        */  /*      $NetBSD$        */
   
 /*-  /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.   * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
  * All rights reserved.   * All rights reserved.
  *   *
  * This code is derived from software contributed to The NetBSD Foundation   * This code is derived from software contributed to The NetBSD Foundation
Line 91  __KERNEL_RCSID(0, "$NetBSD$");
Line 91  __KERNEL_RCSID(0, "$NetBSD$");
 #include <sys/pool.h>  #include <sys/pool.h>
 #include <sys/event.h>  #include <sys/event.h>
 #include <sys/poll.h>  #include <sys/poll.h>
   #include <sys/kauth.h>
   #include <sys/mutex.h>
   #include <sys/condvar.h>
   
 #include <uvm/uvm.h>  #include <uvm/uvm.h>
   
 POOL_INIT(socket_pool, sizeof(struct socket), 0, 0, 0, "sockpl", NULL);  POOL_INIT(socket_pool, sizeof(struct socket), 0, 0, 0, "sockpl", NULL,
       IPL_SOFTNET);
   
 MALLOC_DEFINE(M_SOOPTS, "soopts", "socket options");  MALLOC_DEFINE(M_SOOPTS, "soopts", "socket options");
 MALLOC_DEFINE(M_SONAME, "soname", "socket name");  MALLOC_DEFINE(M_SONAME, "soname", "socket name");
Line 105  int  somaxconn = SOMAXCONN;
Line 109  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++
Line 126  EVCNT_ATTACH_STATIC(sosend_kvalimit);
Line 130  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\n", 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
   
 struct simplelock so_pendfree_slock = SIMPLELOCK_INITIALIZER;  static kmutex_t so_pendfree_lock;
 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 kcondvar_t socurkva_cv;
   
 #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(void);
 static size_t sodopendfreel(struct socket *);  static size_t sodopendfreel(void);
 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 error;          int error;
   
         s = splvm();          mutex_enter(&so_pendfree_lock);
         simple_lock(&so_pendfree_slock);  
         while (socurkva + len > somaxkva) {          while (socurkva + len > somaxkva) {
                 size_t freed;                  size_t freed;
   
Line 175  sokvareserve(struct socket *so, vsize_t 
Line 166  sokvareserve(struct socket *so, vsize_t 
                  * try to do pendfree.                   * try to do pendfree.
                  */                   */
   
                 freed = sodopendfreel(so);                  freed = sodopendfreel();
   
                 /*                  /*
                  * if some kva was freed, try again.                   * if some kva was freed, try again.
Line 185  sokvareserve(struct socket *so, vsize_t 
Line 176  sokvareserve(struct socket *so, vsize_t 
                         continue;                          continue;
   
                 SOSEND_COUNTER_INCR(&sosend_kvalimit);                  SOSEND_COUNTER_INCR(&sosend_kvalimit);
                 sokvawaiters++;                  error = cv_wait_sig(&socurkva_cv, &so_pendfree_lock);
                 error = ltsleep(&socurkva, PVM | PCATCH, "sokva", 0,  
                     &so_pendfree_slock);  
                 sokvawaiters--;  
                 if (error) {                  if (error) {
                         len = 0;                          len = 0;
                         break;                          break;
                 }                  }
         }          }
         socurkva += len;          socurkva += len;
         simple_unlock(&so_pendfree_slock);          mutex_exit(&so_pendfree_lock);
         splx(s);  
         return len;          return len;
 }  }
   
 static __inline void  static void
 sokvaunreserve(vsize_t len)  sokvaunreserve(vsize_t len)
 {  {
         int s;  
   
         s = splvm();          mutex_enter(&so_pendfree_lock);
         simple_lock(&so_pendfree_slock);  
         socurkva -= len;          socurkva -= len;
         if (sokvawaiters)          cv_broadcast(&socurkva_cv);
                 wakeup(&socurkva);          mutex_exit(&so_pendfree_lock);
         simple_unlock(&so_pendfree_slock);  
         splx(s);  
 }  }
   
 /*  /*
Line 234  sokvaalloc(vsize_t len, struct socket *s
Line 217  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 238  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 265  sokvafree(vaddr_t sva, vsize_t len)
Line 248  sokvafree(vaddr_t sva, vsize_t len)
 }  }
   
 static void  static void
 sodoloanfree(struct vm_page **pgs, caddr_t buf, size_t size)  sodoloanfree(struct vm_page **pgs, void *buf, size_t size)
 {  {
         vaddr_t va, sva, eva;          vaddr_t va, sva, eva;
         vsize_t len;          vsize_t len;
Line 281  sodoloanfree(struct vm_page **pgs, caddr
Line 264  sodoloanfree(struct vm_page **pgs, caddr
                 pgs = alloca(npgs * sizeof(*pgs));                  pgs = alloca(npgs * sizeof(*pgs));
   
                 for (i = 0, va = sva; va < eva; i++, va += PAGE_SIZE) {                  for (i = 0, va = sva; va < eva; i++, va += PAGE_SIZE) {
                         if (pmap_extract(pmap_kernel(), va, &pa) == FALSE)                          if (pmap_extract(pmap_kernel(), va, &pa) == false)
                                 panic("sodoloanfree: va 0x%lx not mapped", va);                                  panic("sodoloanfree: va 0x%lx not mapped", va);
                         pgs[i] = PHYS_TO_VM_PAGE(pa);                          pgs[i] = PHYS_TO_VM_PAGE(pa);
                 }                  }
Line 294  sodoloanfree(struct vm_page **pgs, caddr
Line 277  sodoloanfree(struct vm_page **pgs, caddr
 }  }
   
 static size_t  static size_t
 sodopendfree(struct socket *so)  sodopendfree()
 {  {
         int s;  
         size_t rv;          size_t rv;
   
         s = splvm();          mutex_enter(&so_pendfree_lock);
         simple_lock(&so_pendfree_slock);          rv = sodopendfreel();
         rv = sodopendfreel(so);          mutex_exit(&so_pendfree_lock);
         simple_unlock(&so_pendfree_slock);  
         splx(s);  
   
         return rv;          return rv;
 }  }
   
 /*  /*
  * sodopendfreel: free mbufs on "pendfree" list.   * sodopendfreel: free mbufs on "pendfree" list.
  * unlock and relock so_pendfree_slock when freeing mbufs.   * unlock and relock so_pendfree_lock when freeing mbufs.
  *   *
  * => called with so_pendfree_slock held.   * => called with so_pendfree_lock held.
  * => called at splvm.  
  */   */
   
 static size_t  static size_t
 sodopendfreel(struct socket *so)  sodopendfreel()
 {  {
           struct mbuf *m, *next;
         size_t rv = 0;          size_t rv = 0;
           int s;
   
         LOCK_ASSERT(simple_lock_held(&so_pendfree_slock));          KASSERT(mutex_owned(&so_pendfree_lock));
   
         for (;;) {  
                 struct mbuf *m;  
                 struct mbuf *next;  
   
           while (so_pendfree != NULL) {
                 m = so_pendfree;                  m = so_pendfree;
                 if (m == NULL)  
                         break;  
                 so_pendfree = NULL;                  so_pendfree = NULL;
                 simple_unlock(&so_pendfree_slock);                  mutex_exit(&so_pendfree_lock);
                 /* XXX splx */  
   
                 for (; m != NULL; m = next) {                  for (; m != NULL; m = next) {
                         next = m->m_next;                          next = m->m_next;
Line 341  sodopendfreel(struct socket *so)
Line 316  sodopendfreel(struct socket *so)
                         sodoloanfree((m->m_flags & M_EXT_PAGES) ?                          sodoloanfree((m->m_flags & M_EXT_PAGES) ?
                             m->m_ext.ext_pgs : NULL, m->m_ext.ext_buf,                              m->m_ext.ext_pgs : NULL, m->m_ext.ext_buf,
                             m->m_ext.ext_size);                              m->m_ext.ext_size);
                           s = splvm();
                         pool_cache_put(&mbpool_cache, m);                          pool_cache_put(&mbpool_cache, m);
                           splx(s);
                 }                  }
   
                 /* XXX splvm */                  mutex_enter(&so_pendfree_lock);
                 simple_lock(&so_pendfree_slock);  
         }          }
   
         return (rv);          return (rv);
 }  }
   
 void  void
 soloanfree(struct mbuf *m, caddr_t buf, size_t size, void *arg)  soloanfree(struct mbuf *m, void *buf, size_t size, void *arg)
 {  {
         int s;  
   
         if (m == NULL) {          if (m == NULL) {
   
Line 373  soloanfree(struct mbuf *m, caddr_t buf, 
Line 348  soloanfree(struct mbuf *m, caddr_t buf, 
          * because we need to put kva back to kernel_map.           * because we need to put kva back to kernel_map.
          */           */
   
         s = splvm();          mutex_enter(&so_pendfree_lock);
         simple_lock(&so_pendfree_slock);  
         m->m_next = so_pendfree;          m->m_next = so_pendfree;
         so_pendfree = m;          so_pendfree = m;
         if (sokvawaiters)          cv_broadcast(&socurkva_cv);
                 wakeup(&socurkva);          mutex_exit(&so_pendfree_lock);
         simple_unlock(&so_pendfree_slock);  
         splx(s);  
 }  }
   
 static long  static long
Line 392  sosend_loan(struct socket *so, struct ui
Line 364  sosend_loan(struct socket *so, struct ui
         vaddr_t lva, va;          vaddr_t lva, va;
         int npgs, i, error;          int npgs, i, error;
   
         if (uio->uio_segflg != UIO_USERSPACE)          if (VMSPACE_IS_KERNEL_P(uio->uio_vmspace))
                 return (0);                  return (0);
   
         if (iov->iov_len < (size_t) space)          if (iov->iov_len < (size_t) space)
Line 412  sosend_loan(struct socket *so, struct ui
Line 384  sosend_loan(struct socket *so, struct ui
         if (lva == 0)          if (lva == 0)
                 return 0;                  return 0;
   
         error = uvm_loan(&uio->uio_procp->p_vmspace->vm_map, sva, len,          error = uvm_loan(&uio->uio_vmspace->vm_map, sva, len,
             m->m_ext.ext_pgs, UVM_LOAN_TOPAGE);              m->m_ext.ext_pgs, UVM_LOAN_TOPAGE);
         if (error) {          if (error) {
                 sokvafree(lva, len);                  sokvafree(lva, len);
Line 426  sosend_loan(struct socket *so, struct ui
Line 398  sosend_loan(struct socket *so, struct ui
   
         lva += (vaddr_t) iov->iov_base & PAGE_MASK;          lva += (vaddr_t) iov->iov_base & PAGE_MASK;
   
         MEXTADD(m, (caddr_t) lva, space, M_MBUF, soloanfree, so);          MEXTADD(m, (void *) lva, space, M_MBUF, soloanfree, so);
         m->m_flags |= M_EXT_PAGES | M_EXT_ROMAP;          m->m_flags |= M_EXT_PAGES | M_EXT_ROMAP;
   
         uio->uio_resid -= space;          uio->uio_resid -= space;
         /* uio_offset not updated, not set/used for write(2) */          /* uio_offset not updated, not set/used for write(2) */
         uio->uio_iov->iov_base = (caddr_t) uio->uio_iov->iov_base + space;          uio->uio_iov->iov_base = (char *)uio->uio_iov->iov_base + space;
         uio->uio_iov->iov_len -= space;          uio->uio_iov->iov_len -= space;
         if (uio->uio_iov->iov_len == 0) {          if (uio->uio_iov->iov_len == 0) {
                 uio->uio_iov++;                  uio->uio_iov++;
Line 441  sosend_loan(struct socket *so, struct ui
Line 413  sosend_loan(struct socket *so, struct ui
         return (space);          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)
   {
   
           mutex_init(&so_pendfree_lock, MUTEX_DRIVER, IPL_VM);
           cv_init(&socurkva_cv, "sokva");
   
           /* 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 450  sosend_loan(struct socket *so, struct ui
Line 451  sosend_loan(struct socket *so, struct ui
  */   */
 /*ARGSUSED*/  /*ARGSUSED*/
 int  int
 socreate(int dom, struct socket **aso, int type, int proto)  socreate(int dom, struct socket **aso, int type, int proto, struct lwp *l)
 {  {
         struct proc     *p;  
         const struct protosw    *prp;          const struct protosw    *prp;
         struct socket   *so;          struct socket   *so;
           uid_t           uid;
         int             error, s;          int             error, s;
   
         p = curproc;            /* XXX */          error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_SOCKET,
               KAUTH_REQ_NETWORK_SOCKET_OPEN, KAUTH_ARG(dom), KAUTH_ARG(type),
               KAUTH_ARG(proto));
           if (error)
                   return (error);
   
         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);
         s = splsoftnet();          s = splsoftnet();
         so = pool_get(&socket_pool, PR_WAITOK);          so = pool_get(&socket_pool, PR_WAITOK);
         memset((caddr_t)so, 0, sizeof(*so));          memset((void *)so, 0, sizeof(*so));
         TAILQ_INIT(&so->so_q0);          TAILQ_INIT(&so->so_q0);
         TAILQ_INIT(&so->so_q);          TAILQ_INIT(&so->so_q);
         so->so_type = type;          so->so_type = type;
Line 480  socreate(int dom, struct socket **aso, i
Line 495  socreate(int dom, struct socket **aso, i
         so->so_snd.sb_mowner = &prp->pr_domain->dom_mowner;          so->so_snd.sb_mowner = &prp->pr_domain->dom_mowner;
         so->so_mowner = &prp->pr_domain->dom_mowner;          so->so_mowner = &prp->pr_domain->dom_mowner;
 #endif  #endif
         if (p != 0)          uid = kauth_cred_geteuid(l->l_cred);
                 so->so_uid = p->p_ucred->cr_uid;          so->so_uidinfo = uid_find(uid);
         else  
                 so->so_uid = UID_MAX;  
         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, l);
         if (error) {          if (error) {
                 so->so_state |= SS_NOFDREF;                  so->so_state |= SS_NOFDREF;
                 sofree(so);                  sofree(so);
Line 498  socreate(int dom, struct socket **aso, i
Line 511  socreate(int dom, struct socket **aso, i
 }  }
   
 int  int
 sobind(struct socket *so, struct mbuf *nam, struct proc *p)  sobind(struct socket *so, struct mbuf *nam, struct lwp *l)
 {  {
         int     s, error;          int     s, error;
   
         s = splsoftnet();          s = splsoftnet();
         error = (*so->so_proto->pr_usrreq)(so, PRU_BIND, (struct mbuf *)0,          error = (*so->so_proto->pr_usrreq)(so, PRU_BIND, (struct mbuf *)0,
             nam, (struct mbuf *)0, p);              nam, (struct mbuf *)0, l);
         splx(s);          splx(s);
         return (error);          return (error);
 }  }
Line 516  solisten(struct socket *so, int backlog)
Line 529  solisten(struct socket *so, int backlog)
   
         s = splsoftnet();          s = splsoftnet();
         error = (*so->so_proto->pr_usrreq)(so, PRU_LISTEN, (struct mbuf *)0,          error = (*so->so_proto->pr_usrreq)(so, PRU_LISTEN, (struct mbuf *)0,
             (struct mbuf *)0, (struct mbuf *)0, (struct proc *)0);              (struct mbuf *)0, (struct mbuf *)0, (struct lwp *)0);
         if (error) {          if (error) {
                 splx(s);                  splx(s);
                 return (error);                  return (error);
Line 546  sofree(struct socket *so)
Line 559  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 592  soclose(struct socket *so)
Line 605  soclose(struct socket *so)
                             (so->so_state & SS_NBIO))                              (so->so_state & SS_NBIO))
                                 goto drop;                                  goto drop;
                         while (so->so_state & SS_ISCONNECTED) {                          while (so->so_state & SS_ISCONNECTED) {
                                 error = tsleep((caddr_t)&so->so_timeo,                                  error = tsleep((void *)&so->so_timeo,
                                                PSOCK | PCATCH, netcls,                                                 PSOCK | PCATCH, netcls,
                                                so->so_linger * hz);                                                 so->so_linger * hz);
                                 if (error)                                  if (error)
Line 604  soclose(struct socket *so)
Line 617  soclose(struct socket *so)
         if (so->so_pcb) {          if (so->so_pcb) {
                 int error2 = (*so->so_proto->pr_usrreq)(so, PRU_DETACH,                  int error2 = (*so->so_proto->pr_usrreq)(so, PRU_DETACH,
                     (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0,                      (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0,
                     (struct proc *)0);                      (struct lwp *)0);
                 if (error == 0)                  if (error == 0)
                         error = error2;                          error = error2;
         }          }
Line 625  soabort(struct socket *so)
Line 638  soabort(struct socket *so)
 {  {
   
         return (*so->so_proto->pr_usrreq)(so, PRU_ABORT, (struct mbuf *)0,          return (*so->so_proto->pr_usrreq)(so, PRU_ABORT, (struct mbuf *)0,
             (struct mbuf *)0, (struct mbuf *)0, (struct proc *)0);              (struct mbuf *)0, (struct mbuf *)0, (struct lwp *)0);
 }  }
   
 int  int
Line 641  soaccept(struct socket *so, struct mbuf 
Line 654  soaccept(struct socket *so, struct mbuf 
         if ((so->so_state & SS_ISDISCONNECTED) == 0 ||          if ((so->so_state & SS_ISDISCONNECTED) == 0 ||
             (so->so_proto->pr_flags & PR_ABRTACPTDIS) == 0)              (so->so_proto->pr_flags & PR_ABRTACPTDIS) == 0)
                 error = (*so->so_proto->pr_usrreq)(so, PRU_ACCEPT,                  error = (*so->so_proto->pr_usrreq)(so, PRU_ACCEPT,
                     (struct mbuf *)0, nam, (struct mbuf *)0, (struct proc *)0);                      (struct mbuf *)0, nam, (struct mbuf *)0, (struct lwp *)0);
         else          else
                 error = ECONNABORTED;                  error = ECONNABORTED;
   
Line 650  soaccept(struct socket *so, struct mbuf 
Line 663  soaccept(struct socket *so, struct mbuf 
 }  }
   
 int  int
 soconnect(struct socket *so, struct mbuf *nam)  soconnect(struct socket *so, struct mbuf *nam, struct lwp *l)
 {  {
         struct proc     *p;  
         int             s, error;          int             s, error;
   
         p = curproc;            /* XXX */  
         if (so->so_options & SO_ACCEPTCONN)          if (so->so_options & SO_ACCEPTCONN)
                 return (EOPNOTSUPP);                  return (EOPNOTSUPP);
         s = splsoftnet();          s = splsoftnet();
Line 671  soconnect(struct socket *so, struct mbuf
Line 682  soconnect(struct socket *so, struct mbuf
                 error = EISCONN;                  error = EISCONN;
         else          else
                 error = (*so->so_proto->pr_usrreq)(so, PRU_CONNECT,                  error = (*so->so_proto->pr_usrreq)(so, PRU_CONNECT,
                     (struct mbuf *)0, nam, (struct mbuf *)0, p);                      (struct mbuf *)0, nam, (struct mbuf *)0, l);
         splx(s);          splx(s);
         return (error);          return (error);
 }  }
Line 684  soconnect2(struct socket *so1, struct so
Line 695  soconnect2(struct socket *so1, struct so
         s = splsoftnet();          s = splsoftnet();
         error = (*so1->so_proto->pr_usrreq)(so1, PRU_CONNECT2,          error = (*so1->so_proto->pr_usrreq)(so1, PRU_CONNECT2,
             (struct mbuf *)0, (struct mbuf *)so2, (struct mbuf *)0,              (struct mbuf *)0, (struct mbuf *)so2, (struct mbuf *)0,
             (struct proc *)0);              (struct lwp *)0);
         splx(s);          splx(s);
         return (error);          return (error);
 }  }
Line 705  sodisconnect(struct socket *so)
Line 716  sodisconnect(struct socket *so)
         }          }
         error = (*so->so_proto->pr_usrreq)(so, PRU_DISCONNECT,          error = (*so->so_proto->pr_usrreq)(so, PRU_DISCONNECT,
             (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0,              (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0,
             (struct proc *)0);              (struct lwp *)0);
  bad:   bad:
         splx(s);          splx(s);
         sodopendfree(so);          sodopendfree();
         return (error);          return (error);
 }  }
   
Line 732  sodisconnect(struct socket *so)
Line 743  sodisconnect(struct socket *so)
  */   */
 int  int
 sosend(struct socket *so, struct mbuf *addr, struct uio *uio, struct mbuf *top,  sosend(struct socket *so, struct mbuf *addr, struct uio *uio, struct mbuf *top,
         struct mbuf *control, int flags)          struct mbuf *control, int flags, struct lwp *l)
 {  {
         struct proc     *p;  
         struct mbuf     **mp, *m;          struct mbuf     **mp, *m;
           struct proc     *p;
         long            space, len, resid, clen, mlen;          long            space, len, resid, clen, mlen;
         int             error, s, dontroute, atomic;          int             error, s, dontroute, atomic;
   
         sodopendfree(so);          p = l->l_proc;
           sodopendfree();
   
         p = curproc;            /* XXX */  
         clen = 0;          clen = 0;
         atomic = sosendallatonce(so) || top;          atomic = sosendallatonce(so) || top;
         if (uio)          if (uio)
Line 762  sosend(struct socket *so, struct mbuf *a
Line 773  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);
         p->p_stats->p_ru.ru_msgsnd++;          if (p)
                   p->p_stats->p_ru.ru_msgsnd++;
         if (control)          if (control)
                 clen = control->m_len;                  clen = control->m_len;
 #define snderr(errno)   { error = errno; splx(s); goto release; }  #define snderr(errno)   { error = errno; splx(s); goto release; }
Line 827  sosend(struct socket *so, struct mbuf *a
Line 839  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 861  sosend(struct socket *so, struct mbuf *a
Line 873  sosend(struct socket *so, struct mbuf *a
                                         if (atomic && top == 0 && len < mlen)                                          if (atomic && top == 0 && len < mlen)
                                                 MH_ALIGN(m, len);                                                  MH_ALIGN(m, len);
                                 }                                  }
                                 error = uiomove(mtod(m, caddr_t), (int)len,                                  error = uiomove(mtod(m, void *), (int)len,
                                     uio);                                      uio);
  have_data:   have_data:
                                 resid = uio->uio_resid;                                  resid = uio->uio_resid;
Line 877  sosend(struct socket *so, struct mbuf *a
Line 889  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 889  sosend(struct socket *so, struct mbuf *a
Line 901  sosend(struct socket *so, struct mbuf *a
                                 so->so_state |= SS_MORETOCOME;                                  so->so_state |= SS_MORETOCOME;
                         error = (*so->so_proto->pr_usrreq)(so,                          error = (*so->so_proto->pr_usrreq)(so,
                             (flags & MSG_OOB) ? PRU_SENDOOB : PRU_SEND,                              (flags & MSG_OOB) ? PRU_SENDOOB : PRU_SEND,
                             top, addr, control, p);                              top, addr, control, curlwp);        /* XXX */
                         if (dontroute)                          if (dontroute)
                                 so->so_options &= ~SO_DONTROUTE;                                  so->so_options &= ~SO_DONTROUTE;
                         if (resid > 0)                          if (resid > 0)
Line 935  int
Line 947  int
 soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio,  soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio,
         struct mbuf **mp0, struct mbuf **controlp, int *flagsp)          struct mbuf **mp0, struct mbuf **controlp, int *flagsp)
 {  {
           struct lwp *l = curlwp;
         struct mbuf     *m, **mp;          struct mbuf     *m, **mp;
         int             flags, len, error, s, offset, moff, type, orig_resid;          int             flags, len, error, s, offset, moff, type, orig_resid;
         const struct protosw    *pr;          const struct protosw    *pr;
Line 945  soreceive(struct socket *so, struct mbuf
Line 958  soreceive(struct socket *so, struct mbuf
         mp = mp0;          mp = mp0;
         type = 0;          type = 0;
         orig_resid = uio->uio_resid;          orig_resid = uio->uio_resid;
   
         if (paddr)          if (paddr)
                 *paddr = 0;                  *paddr = 0;
         if (controlp)          if (controlp)
Line 955  soreceive(struct socket *so, struct mbuf
Line 969  soreceive(struct socket *so, struct mbuf
                 flags = 0;                  flags = 0;
   
         if ((flags & MSG_DONTWAIT) == 0)          if ((flags & MSG_DONTWAIT) == 0)
                 sodopendfree(so);                  sodopendfree();
   
         if (flags & MSG_OOB) {          if (flags & MSG_OOB) {
                 m = m_get(M_WAIT, MT_DATA);                  m = m_get(M_WAIT, MT_DATA);
                 error = (*pr->pr_usrreq)(so, PRU_RCVOOB, m,                  error = (*pr->pr_usrreq)(so, PRU_RCVOOB, m,
                     (struct mbuf *)(long)(flags & MSG_PEEK), (struct mbuf *)0,                      (struct mbuf *)(long)(flags & MSG_PEEK),
                     (struct proc *)0);                      (struct mbuf *)0, l);
                 if (error)                  if (error)
                         goto bad;                          goto bad;
                 do {                  do {
                         error = uiomove(mtod(m, caddr_t),                          error = uiomove(mtod(m, void *),
                             (int) min(uio->uio_resid, m->m_len), uio);                              (int) min(uio->uio_resid, m->m_len), uio);
                         m = m_free(m);                          m = m_free(m);
                 } while (uio->uio_resid && error == 0 && m);                  } while (uio->uio_resid && error == 0 && m);
Line 978  soreceive(struct socket *so, struct mbuf
Line 992  soreceive(struct socket *so, struct mbuf
                 *mp = (struct mbuf *)0;                  *mp = (struct mbuf *)0;
         if (so->so_state & SS_ISCONFIRMING && uio->uio_resid)          if (so->so_state & SS_ISCONFIRMING && uio->uio_resid)
                 (*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0,                  (*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0,
                     (struct mbuf *)0, (struct mbuf *)0, (struct proc *)0);                      (struct mbuf *)0, (struct mbuf *)0, l);
   
  restart:   restart:
         if ((error = sblock(&so->so_rcv, SBLOCKWAIT(flags))) != 0)          if ((error = sblock(&so->so_rcv, SBLOCKWAIT(flags))) != 0)
Line 1051  soreceive(struct socket *so, struct mbuf
Line 1065  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 (l)
         if (uio->uio_procp)                  l->l_proc->p_stats->p_ru.ru_msgrcv++;
                 uio->uio_procp->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 1092  soreceive(struct socket *so, struct mbuf
Line 1104  soreceive(struct socket *so, struct mbuf
                         sbfree(&so->so_rcv, m);                          sbfree(&so->so_rcv, m);
                         mbuf_removed = 1;                          mbuf_removed = 1;
                         if (controlp) {                          if (controlp) {
                                 if (pr->pr_domain->dom_externalize &&                                  struct domain *dom = pr->pr_domain;
                                   if (dom->dom_externalize && l &&
                                     mtod(m, struct cmsghdr *)->cmsg_type ==                                      mtod(m, struct cmsghdr *)->cmsg_type ==
                                     SCM_RIGHTS)                                      SCM_RIGHTS)
                                         error = (*pr->pr_domain->dom_externalize)(m);                                          error = (*dom->dom_externalize)(m, l);
                                 *controlp = m;                                  *controlp = m;
                                 so->so_rcv.sb_mb = m->m_next;                                  so->so_rcv.sb_mb = m->m_next;
                                 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 1173  soreceive(struct socket *so, struct mbuf
Line 1193  soreceive(struct socket *so, struct mbuf
                         SBLASTRECORDCHK(&so->so_rcv, "soreceive uiomove");                          SBLASTRECORDCHK(&so->so_rcv, "soreceive uiomove");
                         SBLASTMBUFCHK(&so->so_rcv, "soreceive uiomove");                          SBLASTMBUFCHK(&so->so_rcv, "soreceive uiomove");
                         splx(s);                          splx(s);
                         error = uiomove(mtod(m, caddr_t) + moff, (int)len, uio);                          error = uiomove(mtod(m, char *) + moff, (int)len, uio);
                         s = splsoftnet();                          s = splsoftnet();
                         if (error) {                          if (error) {
                                 /*                                  /*
Line 1281  soreceive(struct socket *so, struct mbuf
Line 1301  soreceive(struct socket *so, struct mbuf
                                 (*pr->pr_usrreq)(so, PRU_RCVD,                                  (*pr->pr_usrreq)(so, PRU_RCVD,
                                     (struct mbuf *)0,                                      (struct mbuf *)0,
                                     (struct mbuf *)(long)flags,                                      (struct mbuf *)(long)flags,
                                     (struct mbuf *)0,                                      (struct mbuf *)0, l);
                                     (struct proc *)0);  
                         SBLASTRECORDCHK(&so->so_rcv, "soreceive sbwait 2");                          SBLASTRECORDCHK(&so->so_rcv, "soreceive sbwait 2");
                         SBLASTMBUFCHK(&so->so_rcv, "soreceive sbwait 2");                          SBLASTMBUFCHK(&so->so_rcv, "soreceive sbwait 2");
                         error = sbwait(&so->so_rcv);                          error = sbwait(&so->so_rcv);
Line 1319  soreceive(struct socket *so, struct mbuf
Line 1338  soreceive(struct socket *so, struct mbuf
                 SBLASTMBUFCHK(&so->so_rcv, "soreceive 4");                  SBLASTMBUFCHK(&so->so_rcv, "soreceive 4");
                 if (pr->pr_flags & PR_WANTRCVD && so->so_pcb)                  if (pr->pr_flags & PR_WANTRCVD && so->so_pcb)
                         (*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0,                          (*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0,
                             (struct mbuf *)(long)flags, (struct mbuf *)0,                              (struct mbuf *)(long)flags, (struct mbuf *)0, l);
                             (struct proc *)0);  
         }          }
         if (orig_resid == uio->uio_resid && orig_resid &&          if (orig_resid == uio->uio_resid && orig_resid &&
             (flags & MSG_EOR) == 0 && (so->so_state & SS_CANTRCVMORE) == 0) {              (flags & MSG_EOR) == 0 && (so->so_state & SS_CANTRCVMORE) == 0) {
Line 1328  soreceive(struct socket *so, struct mbuf
Line 1346  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 1350  soshutdown(struct socket *so, int how)
Line 1368  soshutdown(struct socket *so, int how)
                 sorflush(so);                  sorflush(so);
         if (how == SHUT_WR || how == SHUT_RDWR)          if (how == SHUT_WR || how == SHUT_RDWR)
                 return (*pr->pr_usrreq)(so, PRU_SHUTDOWN, (struct mbuf *)0,                  return (*pr->pr_usrreq)(so, PRU_SHUTDOWN, (struct mbuf *)0,
                     (struct mbuf *)0, (struct mbuf *)0, (struct proc *)0);                      (struct mbuf *)0, (struct mbuf *)0, (struct lwp *)0);
         return (0);          return (0);
 }  }
   
Line 1386  sosetopt(struct socket *so, int level, i
Line 1404  sosetopt(struct socket *so, int level, i
 {  {
         int             error;          int             error;
         struct mbuf     *m;          struct mbuf     *m;
           struct linger   *l;
   
         error = 0;          error = 0;
         m = m0;          m = m0;
Line 1402  sosetopt(struct socket *so, int level, i
Line 1421  sosetopt(struct socket *so, int level, i
                                 error = EINVAL;                                  error = EINVAL;
                                 goto bad;                                  goto bad;
                         }                          }
                         so->so_linger = mtod(m, struct linger *)->l_linger;                          l = mtod(m, struct linger *);
                         /* fall thru... */                          if (l->l_linger < 0 || l->l_linger > USHRT_MAX ||
                               l->l_linger > (INT_MAX / hz)) {
                                   error = EDOM;
                                   goto bad;
                           }
                           so->so_linger = l->l_linger;
                           if (l->l_onoff)
                                   so->so_options |= SO_LINGER;
                           else
                                   so->so_options &= ~SO_LINGER;
                           break;
   
                 case SO_DEBUG:                  case SO_DEBUG:
                 case SO_KEEPALIVE:                  case SO_KEEPALIVE:
Line 1480  sosetopt(struct socket *so, int level, i
Line 1509  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 1543  sogetopt(struct socket *so, int level, i
Line 1572  sogetopt(struct socket *so, int level, i
                 case SO_LINGER:                  case SO_LINGER:
                         m->m_len = sizeof(struct linger);                          m->m_len = sizeof(struct linger);
                         mtod(m, struct linger *)->l_onoff =                          mtod(m, struct linger *)->l_onoff =
                                 so->so_options & SO_LINGER;                              (so->so_options & SO_LINGER) ? 1 : 0;
                         mtod(m, struct linger *)->l_linger = so->so_linger;                          mtod(m, struct linger *)->l_linger = so->so_linger;
                         break;                          break;
   
Line 1556  sogetopt(struct socket *so, int level, i
Line 1585  sogetopt(struct socket *so, int level, i
                 case SO_BROADCAST:                  case SO_BROADCAST:
                 case SO_OOBINLINE:                  case SO_OOBINLINE:
                 case SO_TIMESTAMP:                  case SO_TIMESTAMP:
                         *mtod(m, int *) = so->so_options & optname;                          *mtod(m, int *) = (so->so_options & optname) ? 1 : 0;
                         break;                          break;
   
                 case SO_TYPE:                  case SO_TYPE:
Line 1597  sogetopt(struct socket *so, int level, i
Line 1626  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 1633  filt_soread(struct knote *kn, long hint)
Line 1666  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 1664  filt_sowrite(struct knote *kn, long hint
Line 1697  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 1689  filt_solisten(struct knote *kn, long hin
Line 1722  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 1742  sysctl_kern_somaxkva(SYSCTLFN_ARGS)
Line 1775  sysctl_kern_somaxkva(SYSCTLFN_ARGS)
 {  {
         int error, new_somaxkva;          int error, new_somaxkva;
         struct sysctlnode node;          struct sysctlnode node;
         int s;  
   
         new_somaxkva = somaxkva;          new_somaxkva = somaxkva;
         node = *rnode;          node = *rnode;
Line 1754  sysctl_kern_somaxkva(SYSCTLFN_ARGS)
Line 1786  sysctl_kern_somaxkva(SYSCTLFN_ARGS)
         if (new_somaxkva < (16 * 1024 * 1024)) /* sanity */          if (new_somaxkva < (16 * 1024 * 1024)) /* sanity */
                 return (EINVAL);                  return (EINVAL);
   
         s = splvm();          mutex_enter(&so_pendfree_lock);
         simple_lock(&so_pendfree_slock);  
         somaxkva = new_somaxkva;          somaxkva = new_somaxkva;
         wakeup(&socurkva);          cv_broadcast(&socurkva_cv);
         simple_unlock(&so_pendfree_slock);          mutex_exit(&so_pendfree_lock);
         splx(s);  
   
         return (error);          return (error);
 }  }
Line 1775  SYSCTL_SETUP(sysctl_kern_somaxkva_setup,
Line 1805  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);
 }  }

Legend:
Removed from v.1.101  
changed lines
  Added in v.1.134.2.2

CVSweb <webmaster@jp.NetBSD.org>