Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Oct 2016 01:38:29 +0000 (UTC)
From:      Hiren Panchasara <hiren@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r307242 - stable/11/sys/netinet
Message-ID:  <201610140138.u9E1cTR5030089@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hiren
Date: Fri Oct 14 01:38:29 2016
New Revision: 307242
URL: https://svnweb.freebsd.org/changeset/base/307242

Log:
  MFC r306464
  
  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.

Modified:
  stable/11/sys/netinet/tcp_hostcache.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netinet/tcp_hostcache.c
==============================================================================
--- stable/11/sys/netinet/tcp_hostcache.c	Fri Oct 14 01:23:21 2016	(r307241)
+++ stable/11/sys/netinet/tcp_hostcache.c	Fri Oct 14 01:38:29 2016	(r307242)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201610140138.u9E1cTR5030089>