svn commit: r336057 - head/sys/netinet

Michael Tuexen tuexen at FreeBSD.org
Sat Jul 7 11:18:27 UTC 2018


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;


More information about the svn-src-all mailing list