2005-01-07 01:45:51 +00:00
|
|
|
/*-
|
2003-11-20 20:07:39 +00:00
|
|
|
* Copyright (c) 2002 Andre Oppermann, Internet Business Solutions AG
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote
|
|
|
|
* products derived from this software without specific prior written
|
|
|
|
* permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* The tcp_hostcache moves the tcp-specific cached metrics from the routing
|
|
|
|
* table to a dedicated structure indexed by the remote IP address. It keeps
|
|
|
|
* information on the measured TCP parameters of past TCP sessions to allow
|
|
|
|
* better initial start values to be used with later connections to/from the
|
|
|
|
* same source. Depending on the network parameters (delay, bandwidth, max
|
|
|
|
* MTU, congestion window) between local and remote sites, this can lead to
|
|
|
|
* significant speed-ups for new TCP connections after the first one.
|
2003-11-20 20:07:39 +00:00
|
|
|
*
|
2007-05-27 19:39:26 +00:00
|
|
|
* Due to the tcp_hostcache, all TCP-specific metrics information in the
|
2008-08-28 21:55:40 +00:00
|
|
|
* routing table have been removed. The inpcb no longer keeps a pointer to
|
2007-05-27 19:39:26 +00:00
|
|
|
* the routing entry, and protocol-initiated route cloning has been removed
|
|
|
|
* as well. With these changes, the routing table has gone back to being
|
|
|
|
* more lightwight and only carries information related to packet forwarding.
|
2003-11-20 20:07:39 +00:00
|
|
|
*
|
2007-05-27 19:39:26 +00:00
|
|
|
* tcp_hostcache is designed for multiple concurrent access in SMP
|
|
|
|
* environments and high contention. All bucket rows have their own lock and
|
|
|
|
* thus multiple lookups and modifies can be done at the same time as long as
|
|
|
|
* they are in different bucket rows. If a request for insertion of a new
|
|
|
|
* record can't be satisfied, it simply returns an empty structure. Nobody
|
|
|
|
* and nothing outside of tcp_hostcache.c will ever point directly to any
|
|
|
|
* entry in the tcp_hostcache. All communication is done in an
|
|
|
|
* object-oriented way and only functions of tcp_hostcache will manipulate
|
|
|
|
* hostcache entries. Otherwise, we are unable to achieve good behaviour in
|
|
|
|
* concurrent access situations. Since tcp_hostcache is only caching
|
|
|
|
* information, there are no fatal consequences if we either can't satisfy
|
|
|
|
* any particular request or have to drop/overwrite an existing entry because
|
|
|
|
* of bucket limit memory constrains.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Many thanks to jlemon for basic structure of tcp_syncache which is being
|
|
|
|
* followed here.
|
|
|
|
*/
|
|
|
|
|
2007-10-07 20:44:24 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2003-11-20 20:07:39 +00:00
|
|
|
#include "opt_inet6.h"
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/mutex.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/socketvar.h>
|
|
|
|
#include <sys/sysctl.h>
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
#include <sys/vimage.h>
|
2003-11-20 20:07:39 +00:00
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/ip.h>
|
|
|
|
#include <netinet/in_var.h>
|
|
|
|
#include <netinet/in_pcb.h>
|
|
|
|
#include <netinet/ip_var.h>
|
|
|
|
#ifdef INET6
|
|
|
|
#include <netinet/ip6.h>
|
|
|
|
#include <netinet6/ip6_var.h>
|
|
|
|
#endif
|
|
|
|
#include <netinet/tcp.h>
|
|
|
|
#include <netinet/tcp_var.h>
|
2008-12-02 21:37:28 +00:00
|
|
|
#include <netinet/tcp_hostcache.h>
|
|
|
|
#include <netinet/vinet.h>
|
2003-11-20 20:07:39 +00:00
|
|
|
#ifdef INET6
|
|
|
|
#include <netinet6/tcp6_var.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <vm/uma.h>
|
|
|
|
|
|
|
|
/* Arbitrary values */
|
|
|
|
#define TCP_HOSTCACHE_HASHSIZE 512
|
|
|
|
#define TCP_HOSTCACHE_BUCKETLIMIT 30
|
|
|
|
#define TCP_HOSTCACHE_EXPIRE 60*60 /* one hour */
|
|
|
|
#define TCP_HOSTCACHE_PRUNE 5*60 /* every 5 minutes */
|
|
|
|
|
2008-11-19 09:39:34 +00:00
|
|
|
#ifdef VIMAGE_GLOBALS
|
|
|
|
static struct tcp_hostcache tcp_hostcache;
|
2003-11-20 20:07:39 +00:00
|
|
|
static struct callout tcp_hc_callout;
|
2008-11-19 09:39:34 +00:00
|
|
|
#endif
|
2003-11-20 20:07:39 +00:00
|
|
|
|
|
|
|
static struct hc_metrics *tcp_hc_lookup(struct in_conninfo *);
|
|
|
|
static struct hc_metrics *tcp_hc_insert(struct in_conninfo *);
|
|
|
|
static int sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS);
|
|
|
|
static void tcp_hc_purge(void *);
|
|
|
|
|
2008-09-01 19:25:27 +00:00
|
|
|
SYSCTL_NODE(_net_inet_tcp, OID_AUTO, hostcache, CTLFLAG_RW, 0,
|
|
|
|
"TCP Host cache");
|
2003-11-20 20:07:39 +00:00
|
|
|
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_hostcache, OID_AUTO, cachelimit,
|
|
|
|
CTLFLAG_RDTUN, tcp_hostcache.cache_limit, 0,
|
|
|
|
"Overall entry limit for hostcache");
|
2003-11-20 20:07:39 +00:00
|
|
|
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_hostcache, OID_AUTO, hashsize,
|
|
|
|
CTLFLAG_RDTUN, tcp_hostcache.hashsize, 0,
|
|
|
|
"Size of TCP hostcache hashtable");
|
2003-11-20 20:07:39 +00:00
|
|
|
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_hostcache, OID_AUTO, bucketlimit,
|
|
|
|
CTLFLAG_RDTUN, tcp_hostcache.bucket_limit, 0,
|
|
|
|
"Per-bucket hash limit for hostcache");
|
2003-11-20 20:07:39 +00:00
|
|
|
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_hostcache, OID_AUTO, count,
|
|
|
|
CTLFLAG_RD, tcp_hostcache.cache_count, 0,
|
|
|
|
"Current number of entries in hostcache");
|
2003-11-20 20:07:39 +00:00
|
|
|
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_hostcache, OID_AUTO, expire,
|
|
|
|
CTLFLAG_RW, tcp_hostcache.expire, 0,
|
|
|
|
"Expire time of TCP hostcache entries");
|
2003-11-20 20:07:39 +00:00
|
|
|
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_hostcache, OID_AUTO, prune,
|
|
|
|
CTLFLAG_RW, tcp_hostcache.prune, 0, "Time between purge runs");
|
2007-06-08 13:35:51 +00:00
|
|
|
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_hostcache, OID_AUTO, purge,
|
|
|
|
CTLFLAG_RW, tcp_hostcache.purgeall, 0,
|
|
|
|
"Expire all entires on next purge run");
|
2003-11-20 20:07:39 +00:00
|
|
|
|
|
|
|
SYSCTL_PROC(_net_inet_tcp_hostcache, OID_AUTO, list,
|
2007-03-21 19:34:12 +00:00
|
|
|
CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_SKIP, 0, 0,
|
|
|
|
sysctl_tcp_hc_list, "A", "List of all hostcache entries");
|
2003-11-20 20:07:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
static MALLOC_DEFINE(M_HOSTCACHE, "hostcache", "TCP hostcache");
|
|
|
|
|
|
|
|
#define HOSTCACHE_HASH(ip) \
|
2004-08-16 18:32:07 +00:00
|
|
|
(((ip)->s_addr ^ ((ip)->s_addr >> 7) ^ ((ip)->s_addr >> 17)) & \
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
V_tcp_hostcache.hashmask)
|
2003-11-20 20:07:39 +00:00
|
|
|
|
|
|
|
/* XXX: What is the recommended hash to get good entropy for IPv6 addresses? */
|
2004-08-16 18:32:07 +00:00
|
|
|
#define HOSTCACHE_HASH6(ip6) \
|
2003-11-20 20:07:39 +00:00
|
|
|
(((ip6)->s6_addr32[0] ^ \
|
|
|
|
(ip6)->s6_addr32[1] ^ \
|
|
|
|
(ip6)->s6_addr32[2] ^ \
|
|
|
|
(ip6)->s6_addr32[3]) & \
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
V_tcp_hostcache.hashmask)
|
2003-11-20 20:07:39 +00:00
|
|
|
|
|
|
|
#define THC_LOCK(lp) mtx_lock(lp)
|
|
|
|
#define THC_UNLOCK(lp) mtx_unlock(lp)
|
|
|
|
|
|
|
|
void
|
|
|
|
tcp_hc_init(void)
|
|
|
|
{
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
INIT_VNET_INET(curvnet);
|
2003-11-20 20:07:39 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* Initialize hostcache structures.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
V_tcp_hostcache.cache_count = 0;
|
|
|
|
V_tcp_hostcache.hashsize = TCP_HOSTCACHE_HASHSIZE;
|
|
|
|
V_tcp_hostcache.bucket_limit = TCP_HOSTCACHE_BUCKETLIMIT;
|
|
|
|
V_tcp_hostcache.cache_limit =
|
|
|
|
V_tcp_hostcache.hashsize * V_tcp_hostcache.bucket_limit;
|
|
|
|
V_tcp_hostcache.expire = TCP_HOSTCACHE_EXPIRE;
|
|
|
|
V_tcp_hostcache.prune = TCP_HOSTCACHE_PRUNE;
|
2003-11-20 20:07:39 +00:00
|
|
|
|
2004-08-16 18:32:07 +00:00
|
|
|
TUNABLE_INT_FETCH("net.inet.tcp.hostcache.hashsize",
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
&V_tcp_hostcache.hashsize);
|
2004-08-16 18:32:07 +00:00
|
|
|
TUNABLE_INT_FETCH("net.inet.tcp.hostcache.cachelimit",
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
&V_tcp_hostcache.cache_limit);
|
2004-08-16 18:32:07 +00:00
|
|
|
TUNABLE_INT_FETCH("net.inet.tcp.hostcache.bucketlimit",
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
&V_tcp_hostcache.bucket_limit);
|
|
|
|
if (!powerof2(V_tcp_hostcache.hashsize)) {
|
2004-08-16 18:32:07 +00:00
|
|
|
printf("WARNING: hostcache hash size is not a power of 2.\n");
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
V_tcp_hostcache.hashsize = TCP_HOSTCACHE_HASHSIZE; /* default */
|
2004-08-16 18:32:07 +00:00
|
|
|
}
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
V_tcp_hostcache.hashmask = V_tcp_hostcache.hashsize - 1;
|
2003-11-20 20:07:39 +00:00
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* Allocate the hash table.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
V_tcp_hostcache.hashbase = (struct hc_head *)
|
|
|
|
malloc(V_tcp_hostcache.hashsize * sizeof(struct hc_head),
|
2003-11-20 20:07:39 +00:00
|
|
|
M_HOSTCACHE, M_WAITOK | M_ZERO);
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* Initialize the hash buckets.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
for (i = 0; i < V_tcp_hostcache.hashsize; i++) {
|
|
|
|
TAILQ_INIT(&V_tcp_hostcache.hashbase[i].hch_bucket);
|
|
|
|
V_tcp_hostcache.hashbase[i].hch_length = 0;
|
|
|
|
mtx_init(&V_tcp_hostcache.hashbase[i].hch_mtx, "tcp_hc_entry",
|
2003-11-20 20:07:39 +00:00
|
|
|
NULL, MTX_DEF);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate the hostcache entries.
|
|
|
|
*/
|
2008-08-20 01:05:56 +00:00
|
|
|
V_tcp_hostcache.zone =
|
2008-08-20 01:24:55 +00:00
|
|
|
uma_zcreate("hostcache", sizeof(struct hc_metrics),
|
|
|
|
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
uma_zone_set_max(V_tcp_hostcache.zone, V_tcp_hostcache.cache_limit);
|
2003-11-20 20:07:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up periodic cache cleanup.
|
|
|
|
*/
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
callout_init(&V_tcp_hc_callout, CALLOUT_MPSAFE);
|
2008-08-20 01:05:56 +00:00
|
|
|
callout_reset(&V_tcp_hc_callout, V_tcp_hostcache.prune * hz,
|
|
|
|
tcp_hc_purge, 0);
|
2003-11-20 20:07:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* Internal function: look up an entry in the hostcache or return NULL.
|
2003-11-20 20:07:39 +00:00
|
|
|
*
|
|
|
|
* If an entry has been returned, the caller becomes responsible for
|
|
|
|
* unlocking the bucket row after he is done reading/modifying the entry.
|
|
|
|
*/
|
|
|
|
static struct hc_metrics *
|
|
|
|
tcp_hc_lookup(struct in_conninfo *inc)
|
|
|
|
{
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
INIT_VNET_INET(curvnet);
|
2003-11-20 20:07:39 +00:00
|
|
|
int hash;
|
|
|
|
struct hc_head *hc_head;
|
|
|
|
struct hc_metrics *hc_entry;
|
|
|
|
|
|
|
|
KASSERT(inc != NULL, ("tcp_hc_lookup with NULL in_conninfo pointer"));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hash the foreign ip address.
|
|
|
|
*/
|
|
|
|
if (inc->inc_isipv6)
|
|
|
|
hash = HOSTCACHE_HASH6(&inc->inc6_faddr);
|
|
|
|
else
|
|
|
|
hash = HOSTCACHE_HASH(&inc->inc_faddr);
|
|
|
|
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
hc_head = &V_tcp_hostcache.hashbase[hash];
|
2003-11-20 20:07:39 +00:00
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* Acquire lock for this bucket row; we release the lock if we don't
|
|
|
|
* find an entry, otherwise the caller has to unlock after he is
|
|
|
|
* done.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
|
|
|
THC_LOCK(&hc_head->hch_mtx);
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* Iterate through entries in bucket row looking for a match.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
|
|
|
TAILQ_FOREACH(hc_entry, &hc_head->hch_bucket, rmx_q) {
|
|
|
|
if (inc->inc_isipv6) {
|
|
|
|
if (memcmp(&inc->inc6_faddr, &hc_entry->ip6,
|
|
|
|
sizeof(inc->inc6_faddr)) == 0)
|
|
|
|
return hc_entry;
|
|
|
|
} else {
|
|
|
|
if (memcmp(&inc->inc_faddr, &hc_entry->ip4,
|
|
|
|
sizeof(inc->inc_faddr)) == 0)
|
|
|
|
return hc_entry;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* We were unsuccessful and didn't find anything.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
|
|
|
THC_UNLOCK(&hc_head->hch_mtx);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* Internal function: insert an entry into the hostcache or return NULL if
|
|
|
|
* unable to allocate a new one.
|
2004-08-16 18:32:07 +00:00
|
|
|
*
|
2003-11-20 20:07:39 +00:00
|
|
|
* If an entry has been returned, the caller becomes responsible for
|
|
|
|
* unlocking the bucket row after he is done reading/modifying the entry.
|
|
|
|
*/
|
|
|
|
static struct hc_metrics *
|
|
|
|
tcp_hc_insert(struct in_conninfo *inc)
|
|
|
|
{
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
INIT_VNET_INET(curvnet);
|
2003-11-20 20:07:39 +00:00
|
|
|
int hash;
|
|
|
|
struct hc_head *hc_head;
|
|
|
|
struct hc_metrics *hc_entry;
|
|
|
|
|
|
|
|
KASSERT(inc != NULL, ("tcp_hc_insert with NULL in_conninfo pointer"));
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* Hash the foreign ip address.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
|
|
|
if (inc->inc_isipv6)
|
|
|
|
hash = HOSTCACHE_HASH6(&inc->inc6_faddr);
|
|
|
|
else
|
|
|
|
hash = HOSTCACHE_HASH(&inc->inc_faddr);
|
|
|
|
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
hc_head = &V_tcp_hostcache.hashbase[hash];
|
2003-11-20 20:07:39 +00:00
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* Acquire lock for this bucket row; we release the lock if we don't
|
|
|
|
* find an entry, otherwise the caller has to unlock after he is
|
|
|
|
* done.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
|
|
|
THC_LOCK(&hc_head->hch_mtx);
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* If the bucket limit is reached, reuse the least-used element.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
if (hc_head->hch_length >= V_tcp_hostcache.bucket_limit ||
|
|
|
|
V_tcp_hostcache.cache_count >= V_tcp_hostcache.cache_limit) {
|
2003-11-20 20:07:39 +00:00
|
|
|
hc_entry = TAILQ_LAST(&hc_head->hch_bucket, hc_qhead);
|
|
|
|
/*
|
|
|
|
* At first we were dropping the last element, just to
|
2007-05-27 19:39:26 +00:00
|
|
|
* reacquire it in the next two lines again, which isn't very
|
|
|
|
* efficient. Instead just reuse the least used element.
|
|
|
|
* We may drop something that is still "in-use" but we can be
|
|
|
|
* "lossy".
|
2007-06-07 21:41:50 +00:00
|
|
|
* Just give up if this bucket row is empty and we don't have
|
|
|
|
* anything to replace.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
2007-06-07 21:41:50 +00:00
|
|
|
if (hc_entry == NULL) {
|
|
|
|
THC_UNLOCK(&hc_head->hch_mtx);
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-11-20 20:07:39 +00:00
|
|
|
TAILQ_REMOVE(&hc_head->hch_bucket, hc_entry, rmx_q);
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
V_tcp_hostcache.hashbase[hash].hch_length--;
|
|
|
|
V_tcp_hostcache.cache_count--;
|
|
|
|
V_tcpstat.tcps_hc_bucketoverflow++;
|
2003-11-28 16:33:03 +00:00
|
|
|
#if 0
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
uma_zfree(V_tcp_hostcache.zone, hc_entry);
|
2003-11-28 16:33:03 +00:00
|
|
|
#endif
|
2003-11-20 20:07:39 +00:00
|
|
|
} else {
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* Allocate a new entry, or balk if not possible.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
hc_entry = uma_zalloc(V_tcp_hostcache.zone, M_NOWAIT);
|
2003-11-20 20:07:39 +00:00
|
|
|
if (hc_entry == NULL) {
|
|
|
|
THC_UNLOCK(&hc_head->hch_mtx);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* Initialize basic information of hostcache entry.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
|
|
|
bzero(hc_entry, sizeof(*hc_entry));
|
|
|
|
if (inc->inc_isipv6)
|
2003-12-02 21:25:12 +00:00
|
|
|
bcopy(&inc->inc6_faddr, &hc_entry->ip6, sizeof(hc_entry->ip6));
|
2003-11-20 20:07:39 +00:00
|
|
|
else
|
|
|
|
hc_entry->ip4 = inc->inc_faddr;
|
|
|
|
hc_entry->rmx_head = hc_head;
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
hc_entry->rmx_expire = V_tcp_hostcache.expire;
|
2003-11-20 20:07:39 +00:00
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* Put it upfront.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
|
|
|
TAILQ_INSERT_HEAD(&hc_head->hch_bucket, hc_entry, rmx_q);
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
V_tcp_hostcache.hashbase[hash].hch_length++;
|
|
|
|
V_tcp_hostcache.cache_count++;
|
|
|
|
V_tcpstat.tcps_hc_added++;
|
2003-11-20 20:07:39 +00:00
|
|
|
|
|
|
|
return hc_entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* External function: look up an entry in the hostcache and fill out the
|
|
|
|
* supplied TCP metrics structure. Fills in NULL when no entry was found or
|
|
|
|
* a value is not set.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
tcp_hc_get(struct in_conninfo *inc, struct hc_metrics_lite *hc_metrics_lite)
|
|
|
|
{
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
INIT_VNET_INET(curvnet);
|
2003-11-20 20:07:39 +00:00
|
|
|
struct hc_metrics *hc_entry;
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* Find the right bucket.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
|
|
|
hc_entry = tcp_hc_lookup(inc);
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* If we don't have an existing object.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
|
|
|
if (hc_entry == NULL) {
|
|
|
|
bzero(hc_metrics_lite, sizeof(*hc_metrics_lite));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
hc_entry->rmx_hits++;
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
hc_entry->rmx_expire = V_tcp_hostcache.expire; /* start over again */
|
2003-11-20 20:07:39 +00:00
|
|
|
|
|
|
|
hc_metrics_lite->rmx_mtu = hc_entry->rmx_mtu;
|
|
|
|
hc_metrics_lite->rmx_ssthresh = hc_entry->rmx_ssthresh;
|
|
|
|
hc_metrics_lite->rmx_rtt = hc_entry->rmx_rtt;
|
|
|
|
hc_metrics_lite->rmx_rttvar = hc_entry->rmx_rttvar;
|
|
|
|
hc_metrics_lite->rmx_bandwidth = hc_entry->rmx_bandwidth;
|
|
|
|
hc_metrics_lite->rmx_cwnd = hc_entry->rmx_cwnd;
|
|
|
|
hc_metrics_lite->rmx_sendpipe = hc_entry->rmx_sendpipe;
|
|
|
|
hc_metrics_lite->rmx_recvpipe = hc_entry->rmx_recvpipe;
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* Unlock bucket row.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
|
|
|
THC_UNLOCK(&hc_entry->rmx_head->hch_mtx);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* External function: look up an entry in the hostcache and return the
|
|
|
|
* discovered path MTU. Returns NULL if no entry is found or value is not
|
2004-12-05 22:20:59 +00:00
|
|
|
* set.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
|
|
|
u_long
|
|
|
|
tcp_hc_getmtu(struct in_conninfo *inc)
|
|
|
|
{
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
INIT_VNET_INET(curvnet);
|
2003-11-20 20:07:39 +00:00
|
|
|
struct hc_metrics *hc_entry;
|
|
|
|
u_long mtu;
|
|
|
|
|
|
|
|
hc_entry = tcp_hc_lookup(inc);
|
|
|
|
if (hc_entry == NULL) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
hc_entry->rmx_hits++;
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
hc_entry->rmx_expire = V_tcp_hostcache.expire; /* start over again */
|
2003-11-20 20:07:39 +00:00
|
|
|
|
|
|
|
mtu = hc_entry->rmx_mtu;
|
|
|
|
THC_UNLOCK(&hc_entry->rmx_head->hch_mtx);
|
|
|
|
return mtu;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* External function: update the MTU value of an entry in the hostcache.
|
2003-11-20 20:07:39 +00:00
|
|
|
* Creates a new entry if none was found.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
tcp_hc_updatemtu(struct in_conninfo *inc, u_long mtu)
|
|
|
|
{
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
INIT_VNET_INET(curvnet);
|
2003-11-20 20:07:39 +00:00
|
|
|
struct hc_metrics *hc_entry;
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* Find the right bucket.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
|
|
|
hc_entry = tcp_hc_lookup(inc);
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* If we don't have an existing object, try to insert a new one.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
|
|
|
if (hc_entry == NULL) {
|
|
|
|
hc_entry = tcp_hc_insert(inc);
|
|
|
|
if (hc_entry == NULL)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
hc_entry->rmx_updates++;
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
hc_entry->rmx_expire = V_tcp_hostcache.expire; /* start over again */
|
2003-11-20 20:07:39 +00:00
|
|
|
|
|
|
|
hc_entry->rmx_mtu = mtu;
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* Put it upfront so we find it faster next time.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
|
|
|
TAILQ_REMOVE(&hc_entry->rmx_head->hch_bucket, hc_entry, rmx_q);
|
|
|
|
TAILQ_INSERT_HEAD(&hc_entry->rmx_head->hch_bucket, hc_entry, rmx_q);
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* Unlock bucket row.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
|
|
|
THC_UNLOCK(&hc_entry->rmx_head->hch_mtx);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* External function: update the TCP metrics of an entry in the hostcache.
|
2003-11-20 20:07:39 +00:00
|
|
|
* Creates a new entry if none was found.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml)
|
|
|
|
{
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
INIT_VNET_INET(curvnet);
|
2003-11-20 20:07:39 +00:00
|
|
|
struct hc_metrics *hc_entry;
|
|
|
|
|
|
|
|
hc_entry = tcp_hc_lookup(inc);
|
|
|
|
if (hc_entry == NULL) {
|
|
|
|
hc_entry = tcp_hc_insert(inc);
|
|
|
|
if (hc_entry == NULL)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
hc_entry->rmx_updates++;
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
hc_entry->rmx_expire = V_tcp_hostcache.expire; /* start over again */
|
2003-11-20 20:07:39 +00:00
|
|
|
|
|
|
|
if (hcml->rmx_rtt != 0) {
|
|
|
|
if (hc_entry->rmx_rtt == 0)
|
|
|
|
hc_entry->rmx_rtt = hcml->rmx_rtt;
|
|
|
|
else
|
|
|
|
hc_entry->rmx_rtt =
|
|
|
|
(hc_entry->rmx_rtt + hcml->rmx_rtt) / 2;
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
V_tcpstat.tcps_cachedrtt++;
|
2003-11-20 20:07:39 +00:00
|
|
|
}
|
|
|
|
if (hcml->rmx_rttvar != 0) {
|
|
|
|
if (hc_entry->rmx_rttvar == 0)
|
2004-08-16 18:32:07 +00:00
|
|
|
hc_entry->rmx_rttvar = hcml->rmx_rttvar;
|
2003-11-20 20:07:39 +00:00
|
|
|
else
|
|
|
|
hc_entry->rmx_rttvar =
|
|
|
|
(hc_entry->rmx_rttvar + hcml->rmx_rttvar) / 2;
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
V_tcpstat.tcps_cachedrttvar++;
|
2003-11-20 20:07:39 +00:00
|
|
|
}
|
|
|
|
if (hcml->rmx_ssthresh != 0) {
|
|
|
|
if (hc_entry->rmx_ssthresh == 0)
|
|
|
|
hc_entry->rmx_ssthresh = hcml->rmx_ssthresh;
|
|
|
|
else
|
|
|
|
hc_entry->rmx_ssthresh =
|
|
|
|
(hc_entry->rmx_ssthresh + hcml->rmx_ssthresh) / 2;
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
V_tcpstat.tcps_cachedssthresh++;
|
2003-11-20 20:07:39 +00:00
|
|
|
}
|
|
|
|
if (hcml->rmx_bandwidth != 0) {
|
|
|
|
if (hc_entry->rmx_bandwidth == 0)
|
|
|
|
hc_entry->rmx_bandwidth = hcml->rmx_bandwidth;
|
|
|
|
else
|
|
|
|
hc_entry->rmx_bandwidth =
|
|
|
|
(hc_entry->rmx_bandwidth + hcml->rmx_bandwidth) / 2;
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
/* V_tcpstat.tcps_cachedbandwidth++; */
|
2003-11-20 20:07:39 +00:00
|
|
|
}
|
|
|
|
if (hcml->rmx_cwnd != 0) {
|
|
|
|
if (hc_entry->rmx_cwnd == 0)
|
|
|
|
hc_entry->rmx_cwnd = hcml->rmx_cwnd;
|
|
|
|
else
|
|
|
|
hc_entry->rmx_cwnd =
|
|
|
|
(hc_entry->rmx_cwnd + hcml->rmx_cwnd) / 2;
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
/* V_tcpstat.tcps_cachedcwnd++; */
|
2003-11-20 20:07:39 +00:00
|
|
|
}
|
|
|
|
if (hcml->rmx_sendpipe != 0) {
|
|
|
|
if (hc_entry->rmx_sendpipe == 0)
|
|
|
|
hc_entry->rmx_sendpipe = hcml->rmx_sendpipe;
|
|
|
|
else
|
|
|
|
hc_entry->rmx_sendpipe =
|
|
|
|
(hc_entry->rmx_sendpipe + hcml->rmx_sendpipe) /2;
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
/* V_tcpstat.tcps_cachedsendpipe++; */
|
2004-08-16 18:32:07 +00:00
|
|
|
}
|
2003-11-20 20:07:39 +00:00
|
|
|
if (hcml->rmx_recvpipe != 0) {
|
|
|
|
if (hc_entry->rmx_recvpipe == 0)
|
|
|
|
hc_entry->rmx_recvpipe = hcml->rmx_recvpipe;
|
|
|
|
else
|
|
|
|
hc_entry->rmx_recvpipe =
|
|
|
|
(hc_entry->rmx_recvpipe + hcml->rmx_recvpipe) /2;
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
/* V_tcpstat.tcps_cachedrecvpipe++; */
|
2003-11-20 20:07:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TAILQ_REMOVE(&hc_entry->rmx_head->hch_bucket, hc_entry, rmx_q);
|
|
|
|
TAILQ_INSERT_HEAD(&hc_entry->rmx_head->hch_bucket, hc_entry, rmx_q);
|
|
|
|
THC_UNLOCK(&hc_entry->rmx_head->hch_mtx);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sysctl function: prints the list and values of all hostcache entries in
|
|
|
|
* unsorted order.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
|
|
|
|
{
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
INIT_VNET_INET(curvnet);
|
2003-11-20 20:07:39 +00:00
|
|
|
int bufsize;
|
|
|
|
int linesize = 128;
|
|
|
|
char *p, *buf;
|
|
|
|
int len, i, error;
|
|
|
|
struct hc_metrics *hc_entry;
|
2006-12-12 12:17:58 +00:00
|
|
|
#ifdef INET6
|
|
|
|
char ip6buf[INET6_ADDRSTRLEN];
|
|
|
|
#endif
|
2003-11-20 20:07:39 +00:00
|
|
|
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
bufsize = linesize * (V_tcp_hostcache.cache_count + 1);
|
2003-11-20 20:07:39 +00:00
|
|
|
|
|
|
|
p = buf = (char *)malloc(bufsize, M_TEMP, M_WAITOK|M_ZERO);
|
|
|
|
|
|
|
|
len = snprintf(p, linesize,
|
|
|
|
"\nIP address MTU SSTRESH RTT RTTVAR BANDWIDTH "
|
|
|
|
" CWND SENDPIPE RECVPIPE HITS UPD EXP\n");
|
|
|
|
p += len;
|
|
|
|
|
|
|
|
#define msec(u) (((u) + 500) / 1000)
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
for (i = 0; i < V_tcp_hostcache.hashsize; i++) {
|
|
|
|
THC_LOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
|
|
|
|
TAILQ_FOREACH(hc_entry, &V_tcp_hostcache.hashbase[i].hch_bucket,
|
2003-11-20 20:07:39 +00:00
|
|
|
rmx_q) {
|
|
|
|
len = snprintf(p, linesize,
|
|
|
|
"%-15s %5lu %8lu %6lums %6lums %9lu %8lu %8lu %8lu "
|
|
|
|
"%4lu %4lu %4i\n",
|
|
|
|
hc_entry->ip4.s_addr ? inet_ntoa(hc_entry->ip4) :
|
|
|
|
#ifdef INET6
|
2006-12-12 12:17:58 +00:00
|
|
|
ip6_sprintf(ip6buf, &hc_entry->ip6),
|
2003-11-20 20:07:39 +00:00
|
|
|
#else
|
|
|
|
"IPv6?",
|
|
|
|
#endif
|
|
|
|
hc_entry->rmx_mtu,
|
|
|
|
hc_entry->rmx_ssthresh,
|
|
|
|
msec(hc_entry->rmx_rtt *
|
|
|
|
(RTM_RTTUNIT / (hz * TCP_RTT_SCALE))),
|
|
|
|
msec(hc_entry->rmx_rttvar *
|
|
|
|
(RTM_RTTUNIT / (hz * TCP_RTT_SCALE))),
|
2004-08-11 10:12:16 +00:00
|
|
|
hc_entry->rmx_bandwidth * 8,
|
2003-11-20 20:07:39 +00:00
|
|
|
hc_entry->rmx_cwnd,
|
|
|
|
hc_entry->rmx_sendpipe,
|
|
|
|
hc_entry->rmx_recvpipe,
|
|
|
|
hc_entry->rmx_hits,
|
|
|
|
hc_entry->rmx_updates,
|
|
|
|
hc_entry->rmx_expire);
|
|
|
|
p += len;
|
|
|
|
}
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
|
2003-11-20 20:07:39 +00:00
|
|
|
}
|
|
|
|
#undef msec
|
|
|
|
error = SYSCTL_OUT(req, buf, p - buf);
|
|
|
|
free(buf, M_TEMP);
|
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-05-27 19:39:26 +00:00
|
|
|
* Expire and purge (old|all) entries in the tcp_hostcache. Runs
|
|
|
|
* periodically from the callout.
|
2003-11-20 20:07:39 +00:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
tcp_hc_purge(void *arg)
|
|
|
|
{
|
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
2008-10-02 15:37:58 +00:00
|
|
|
INIT_VNET_INET(curvnet);
|
2004-04-23 13:54:28 +00:00
|
|
|
struct hc_metrics *hc_entry, *hc_next;
|
2003-11-20 20:07:39 +00:00
|
|
|
int all = (intptr_t)arg;
|
|
|
|
int i;
|
|
|
|
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
if (V_tcp_hostcache.purgeall) {
|
2003-11-20 20:07:39 +00:00
|
|
|
all = 1;
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
V_tcp_hostcache.purgeall = 0;
|
2003-11-20 20:07:39 +00:00
|
|
|
}
|
|
|
|
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
for (i = 0; i < V_tcp_hostcache.hashsize; i++) {
|
|
|
|
THC_LOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
|
2008-08-20 01:05:56 +00:00
|
|
|
TAILQ_FOREACH_SAFE(hc_entry,
|
2008-08-20 01:24:55 +00:00
|
|
|
&V_tcp_hostcache.hashbase[i].hch_bucket, rmx_q, hc_next) {
|
2003-11-20 20:07:39 +00:00
|
|
|
if (all || hc_entry->rmx_expire <= 0) {
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
TAILQ_REMOVE(&V_tcp_hostcache.hashbase[i].hch_bucket,
|
2003-11-20 20:07:39 +00:00
|
|
|
hc_entry, rmx_q);
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
uma_zfree(V_tcp_hostcache.zone, hc_entry);
|
|
|
|
V_tcp_hostcache.hashbase[i].hch_length--;
|
|
|
|
V_tcp_hostcache.cache_count--;
|
2003-11-20 20:07:39 +00:00
|
|
|
} else
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
hc_entry->rmx_expire -= V_tcp_hostcache.prune;
|
2003-11-20 20:07:39 +00:00
|
|
|
}
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx);
|
2003-11-20 20:07:39 +00:00
|
|
|
}
|
2008-08-20 01:05:56 +00:00
|
|
|
|
|
|
|
callout_reset(&V_tcp_hc_callout, V_tcp_hostcache.prune * hz,
|
|
|
|
tcp_hc_purge, arg);
|
2003-11-20 20:07:39 +00:00
|
|
|
}
|