Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet Don't allocate resources for vtw until/unless it...



details:   https://anonhg.NetBSD.org/src/rev/8d93a43dda7c
branches:  trunk
changeset: 765813:8d93a43dda7c
user:      dyoung <dyoung%NetBSD.org@localhost>
date:      Mon Jun 06 19:15:43 2011 +0000

description:
Don't allocate resources for vtw until/unless it is enabled.  This will
further help those machines where memory is in short supply.

TBD: release resources after vtw is disabled and all entries have
expired.

diffstat:

 sys/netinet/tcp_usrreq.c |   6 +++---
 sys/netinet/tcp_vtw.c    |  38 ++++++++++++++++++++++++++++++++++++--
 sys/netinet/tcp_vtw.h    |   1 +
 3 files changed, 40 insertions(+), 5 deletions(-)

diffs (100 lines):

diff -r a3833f317e70 -r 8d93a43dda7c sys/netinet/tcp_usrreq.c
--- a/sys/netinet/tcp_usrreq.c  Mon Jun 06 18:27:12 2011 +0000
+++ b/sys/netinet/tcp_usrreq.c  Mon Jun 06 19:15:43 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_usrreq.c,v 1.159 2011/05/03 18:28:45 dyoung Exp $  */
+/*     $NetBSD: tcp_usrreq.c,v 1.160 2011/06/06 19:15:43 dyoung Exp $  */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -95,7 +95,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.159 2011/05/03 18:28:45 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.160 2011/06/06 19:15:43 dyoung Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -2093,7 +2093,7 @@
                       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
                       CTLTYPE_INT, "enable",
                       SYSCTL_DESCR("Enable Vestigial TIME_WAIT"),
-                      NULL, 0,
+                      sysctl_tcp_vtw_enable, 0,
                       (pf == AF_INET) ? &tcp4_vtw_enable : &tcp6_vtw_enable,
                       0, CTL_CREATE, CTL_EOL);
        sysctl_createv(clog, 0, &vtw_node, NULL,
diff -r a3833f317e70 -r 8d93a43dda7c sys/netinet/tcp_vtw.c
--- a/sys/netinet/tcp_vtw.c     Mon Jun 06 18:27:12 2011 +0000
+++ b/sys/netinet/tcp_vtw.c     Mon Jun 06 19:15:43 2011 +0000
@@ -77,7 +77,7 @@
 #include <machine/stdarg.h>
 #include <netinet/tcp_vtw.h>
 
-__KERNEL_RCSID(0, "$NetBSD: tcp_vtw.c,v 1.6 2011/06/03 20:01:00 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_vtw.c,v 1.7 2011/06/06 19:15:43 dyoung Exp $");
 
 #define db_trace(__a, __b)     do { } while (/*CONSTCOND*/0)
 
@@ -2138,6 +2138,36 @@
 }
 
 int
+sysctl_tcp_vtw_enable(SYSCTLFN_ARGS)
+{  
+       int en, rc;
+       struct sysctlnode node;
+
+       node = *rnode;
+       en = *(int *)rnode->sysctl_data;
+       node.sysctl_data = &en;
+
+       rc = sysctl_lookup(SYSCTLFN_CALL(&node));
+       if (rc != 0 || newp == NULL)
+               return rc;
+
+       if (rnode->sysctl_data != &tcp4_vtw_enable &&
+           rnode->sysctl_data != &tcp6_vtw_enable)
+               rc = ENOENT;
+       else if ((en & 1) == 0)
+               rc = 0;
+       else if (rnode->sysctl_data == &tcp4_vtw_enable)
+               rc = vtw_control_init(AF_INET);
+       else /* rnode->sysctl_data == &tcp6_vtw_enable */
+               rc = vtw_control_init(AF_INET6);
+
+       if (rc == 0)
+               *(int *)rnode->sysctl_data = en;
+
+       return rc;
+}
+
+int
 vtw_earlyinit(void)
 {
        int i, rc;
@@ -2150,7 +2180,11 @@
                vtw_tcpv6[i].is_v6 = 1;
        }
 
-       if ((rc = vtw_control_init(AF_INET)) != 0 || 
+       if ((tcp4_vtw_enable & 1) != 0 &&
+           (rc = vtw_control_init(AF_INET)) != 0)
+               return rc;
+
+       if ((tcp6_vtw_enable & 1) != 0 &&
            (rc = vtw_control_init(AF_INET6)) != 0)
                return rc;
 
diff -r a3833f317e70 -r 8d93a43dda7c sys/netinet/tcp_vtw.h
--- a/sys/netinet/tcp_vtw.h     Mon Jun 06 18:27:12 2011 +0000
+++ b/sys/netinet/tcp_vtw.h     Mon Jun 06 19:15:43 2011 +0000
@@ -389,6 +389,7 @@
 
 void vtw_restart(vestigial_inpcb_t*);
 int vtw_earlyinit(void);
+int sysctl_tcp_vtw_enable(SYSCTLFN_PROTO);
 
 #ifdef VTW_DEBUG
 typedef struct sin_either {



Home | Main Index | Thread Index | Old Index