svn commit: r306464 - head/sys/netinet
Hiren Panchasara
hiren at FreeBSD.org
Fri Sep 30 00:10:59 UTC 2016
Author: hiren
Date: Fri Sep 30 00:10:57 2016
New Revision: 306464
URL: https://svnweb.freebsd.org/changeset/base/306464
Log:
This adds a sysctl which allows you to disable the TCP hostcache. This is handy
during testing of network related changes where cached entries may pollute your
results, or during known congestion events where you don't want to unfairly
penalize hosts.
Prior to r232346 this would have meant you would break any connection with a sub
1500 MTU, as the hostcache was authoritative. All entries as they stand today
should simply be used to pre populate values for efficiency.
Submitted by: Jason Wolfe (j at nitrology dot com)
Reviewed by: rwatson, sbruno, rrs , bz (earlier version)
MFC after: 2 weeks
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D6198
Modified:
head/sys/netinet/tcp_hostcache.c
Modified: head/sys/netinet/tcp_hostcache.c
==============================================================================
--- head/sys/netinet/tcp_hostcache.c Thu Sep 29 23:41:57 2016 (r306463)
+++ head/sys/netinet/tcp_hostcache.c Fri Sep 30 00:10:57 2016 (r306464)
@@ -124,6 +124,12 @@ static void tcp_hc_purge(void *);
static SYSCTL_NODE(_net_inet_tcp, OID_AUTO, hostcache, CTLFLAG_RW, 0,
"TCP Host cache");
+VNET_DEFINE(int, tcp_use_hostcache) = 1;
+#define V_tcp_use_hostcache VNET(tcp_use_hostcache)
+SYSCTL_INT(_net_inet_tcp_hostcache, OID_AUTO, enable, CTLFLAG_VNET | CTLFLAG_RW,
+ &VNET_NAME(tcp_use_hostcache), 0,
+ "Enable the TCP hostcache");
+
SYSCTL_UINT(_net_inet_tcp_hostcache, OID_AUTO, cachelimit, CTLFLAG_VNET | CTLFLAG_RDTUN,
&VNET_NAME(tcp_hostcache.cache_limit), 0,
"Overall entry limit for hostcache");
@@ -276,6 +282,9 @@ tcp_hc_lookup(struct in_conninfo *inc)
struct hc_head *hc_head;
struct hc_metrics *hc_entry;
+ if (!V_tcp_use_hostcache)
+ return NULL;
+
KASSERT(inc != NULL, ("tcp_hc_lookup with NULL in_conninfo pointer"));
/*
@@ -332,6 +341,9 @@ tcp_hc_insert(struct in_conninfo *inc)
struct hc_head *hc_head;
struct hc_metrics *hc_entry;
+ if (!V_tcp_use_hostcache)
+ return NULL;
+
KASSERT(inc != NULL, ("tcp_hc_insert with NULL in_conninfo pointer"));
/*
@@ -421,6 +433,9 @@ tcp_hc_get(struct in_conninfo *inc, stru
{
struct hc_metrics *hc_entry;
+ if (!V_tcp_use_hostcache)
+ return;
+
/*
* Find the right bucket.
*/
@@ -452,7 +467,7 @@ tcp_hc_get(struct in_conninfo *inc, stru
/*
* 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
+ * discovered path MTU. Returns 0 if no entry is found or value is not
* set.
*/
u_long
@@ -461,6 +476,9 @@ tcp_hc_getmtu(struct in_conninfo *inc)
struct hc_metrics *hc_entry;
u_long mtu;
+ if (!V_tcp_use_hostcache)
+ return 0;
+
hc_entry = tcp_hc_lookup(inc);
if (hc_entry == NULL) {
return 0;
@@ -482,6 +500,9 @@ tcp_hc_updatemtu(struct in_conninfo *inc
{
struct hc_metrics *hc_entry;
+ if (!V_tcp_use_hostcache)
+ return;
+
/*
* Find the right bucket.
*/
@@ -521,6 +542,9 @@ tcp_hc_update(struct in_conninfo *inc, s
{
struct hc_metrics *hc_entry;
+ if (!V_tcp_use_hostcache)
+ return;
+
hc_entry = tcp_hc_lookup(inc);
if (hc_entry == NULL) {
hc_entry = tcp_hc_insert(inc);
More information about the svn-src-head
mailing list