Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Jul 2018 11:18:27 +0000 (UTC)
From:      Michael Tuexen <tuexen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r336057 - head/sys/netinet
Message-ID:  <201807071118.w67BIRrd059180@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tuexen
Date: Sat Jul  7 11:18:26 2018
New Revision: 336057
URL: https://svnweb.freebsd.org/changeset/base/336057

Log:
  When initializing the TCP FO client cookie cache, take into account
  whether the TCP FO support is enabled or not for the client side.
  
  The code in tcp_fastopen_init() implicitly assumed that the sysctl
  variable V_tcp_fastopen_client_enable was initialized to 0. This
  was initially true, but was changed in r335610, which unmasked this
  bug.
  
  Thanks to Pieter de Goeje for reporting the issue on freebsd-net@

Modified:
  head/sys/netinet/tcp_fastopen.c

Modified: head/sys/netinet/tcp_fastopen.c
==============================================================================
--- head/sys/netinet/tcp_fastopen.c	Sat Jul  7 01:58:40 2018	(r336056)
+++ head/sys/netinet/tcp_fastopen.c	Sat Jul  7 11:18:26 2018	(r336057)
@@ -408,7 +408,13 @@ tcp_fastopen_init(void)
 		TAILQ_INIT(&V_tcp_fastopen_ccache.base[i].ccb_entries);
 		mtx_init(&V_tcp_fastopen_ccache.base[i].ccb_mtx, "tfo_ccache_bucket",
 			 NULL, MTX_DEF);
-		V_tcp_fastopen_ccache.base[i].ccb_num_entries = -1; /* bucket disabled */
+		if (V_tcp_fastopen_client_enable) {
+			/* enable bucket */
+			V_tcp_fastopen_ccache.base[i].ccb_num_entries = 0;
+		} else {
+			/* disable bucket */
+			V_tcp_fastopen_ccache.base[i].ccb_num_entries = -1;
+		}
 		V_tcp_fastopen_ccache.base[i].ccb_ccache = &V_tcp_fastopen_ccache;
 	}
 
@@ -824,6 +830,9 @@ sysctl_net_inet_tcp_fastopen_client_enable(SYSCTL_HAND
 			/* enabled -> disabled */
 			for (i = 0; i < V_tcp_fastopen_ccache.buckets; i++) {
 				ccb = &V_tcp_fastopen_ccache.base[i];
+				KASSERT(ccb->ccb_num_entries > -1,
+				    ("%s: ccb->ccb_num_entries %d is negative",
+					__func__, ccb->ccb_num_entries));
 				tcp_fastopen_ccache_bucket_trim(ccb, 0);
 			}
 			V_tcp_fastopen_client_enable = 0;



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