Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Mar 2018 12:48:10 +0000 (UTC)
From:      "Jonathan T. Looney" <jtl@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r331485 - in head/sys: amd64/conf conf dev/tcp_log netinet
Message-ID:  <201803241248.w2OCmAHi013779@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jtl
Date: Sat Mar 24 12:48:10 2018
New Revision: 331485
URL: https://svnweb.freebsd.org/changeset/base/331485

Log:
  Make the TCP blackbox code committed in r331347 be an optional feature
  controlled by the TCP_BLACKBOX option.
  
  Enable this as part of amd64 GENERIC. For now, leave it disabled on
  other platforms.
  
  Sponsored by:	Netflix, Inc.

Modified:
  head/sys/amd64/conf/GENERIC
  head/sys/conf/NOTES
  head/sys/conf/files
  head/sys/conf/options
  head/sys/dev/tcp_log/tcp_log_dev.h
  head/sys/netinet/tcp_log_buf.h
  head/sys/netinet/tcp_subr.c
  head/sys/netinet/tcp_usrreq.c

Modified: head/sys/amd64/conf/GENERIC
==============================================================================
--- head/sys/amd64/conf/GENERIC	Sat Mar 24 12:43:34 2018	(r331484)
+++ head/sys/amd64/conf/GENERIC	Sat Mar 24 12:48:10 2018	(r331485)
@@ -32,6 +32,7 @@ options 	INET6			# IPv6 communications protocols
 options 	IPSEC			# IP (v4/v6) security
 options 	IPSEC_SUPPORT		# Allow kldload of ipsec and tcpmd5
 options 	TCP_OFFLOAD		# TCP offload
+options 	TCP_BLACKBOX		# Enhanced TCP event logging
 options 	TCP_HHOOK		# hhook(9) framework for TCP
 options		TCP_RFC7413		# TCP Fast Open
 options 	SCTP			# Stream Control Transmission Protocol

Modified: head/sys/conf/NOTES
==============================================================================
--- head/sys/conf/NOTES	Sat Mar 24 12:43:34 2018	(r331484)
+++ head/sys/conf/NOTES	Sat Mar 24 12:48:10 2018	(r331485)
@@ -979,6 +979,8 @@ device		lagg
 # TCPPCAP enables code which keeps the last n packets sent and received
 # on a TCP socket.
 #
+# TCP_BLACKBOX enables enhanced TCP event logging.
+#
 # TCP_HHOOK enables the hhook(9) framework hooks for the TCP stack.
 #
 # RADIX_MPATH provides support for equal-cost multi-path routing.
@@ -1000,6 +1002,7 @@ options 	IPSTEALTH		#support for stealth forwarding
 options 	PF_DEFAULT_TO_DROP	#drop everything by default
 options 	TCPDEBUG
 options 	TCPPCAP
+options 	TCP_BLACKBOX
 options 	TCP_HHOOK
 options 	RADIX_MPATH
 

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Sat Mar 24 12:43:34 2018	(r331484)
+++ head/sys/conf/files	Sat Mar 24 12:48:10 2018	(r331485)
@@ -3163,7 +3163,7 @@ dev/syscons/star/star_saver.c	optional star_saver
 dev/syscons/syscons.c		optional sc
 dev/syscons/sysmouse.c		optional sc
 dev/syscons/warp/warp_saver.c	optional warp_saver
-dev/tcp_log/tcp_log_dev.c	optional inet | inet6
+dev/tcp_log/tcp_log_dev.c	optional tcp_blackbox inet | tcp_blackbox inet6
 dev/tdfx/tdfx_linux.c		optional tdfx_linux tdfx compat_linux
 dev/tdfx/tdfx_pci.c		optional tdfx pci
 dev/ti/if_ti.c			optional ti pci
@@ -4312,7 +4312,7 @@ netinet/tcp_debug.c		optional tcpdebug
 netinet/tcp_fastopen.c		optional inet tcp_rfc7413 | inet6 tcp_rfc7413
 netinet/tcp_hostcache.c		optional inet | inet6
 netinet/tcp_input.c		optional inet | inet6
-netinet/tcp_log_buf.c		optional inet | inet6
+netinet/tcp_log_buf.c		optional tcp_blackbox inet | tcp_blackbox inet6
 netinet/tcp_lro.c		optional inet | inet6
 netinet/tcp_output.c		optional inet | inet6
 netinet/tcp_offload.c		optional tcp_offload inet | tcp_offload inet6

Modified: head/sys/conf/options
==============================================================================
--- head/sys/conf/options	Sat Mar 24 12:43:34 2018	(r331484)
+++ head/sys/conf/options	Sat Mar 24 12:48:10 2018	(r331485)
@@ -452,6 +452,7 @@ SLIP_IFF_OPTS		opt_slip.h
 TCPDEBUG
 TCPPCAP		opt_global.h
 SIFTR
+TCP_BLACKBOX		opt_global.h
 TCP_HHOOK		opt_inet.h
 TCP_OFFLOAD		opt_inet.h # Enable code to dispatch TCP offloading
 TCP_RFC7413		opt_inet.h

Modified: head/sys/dev/tcp_log/tcp_log_dev.h
==============================================================================
--- head/sys/dev/tcp_log/tcp_log_dev.h	Sat Mar 24 12:43:34 2018	(r331484)
+++ head/sys/dev/tcp_log/tcp_log_dev.h	Sat Mar 24 12:48:10 2018	(r331485)
@@ -81,8 +81,9 @@ struct tcp_log_dev_info {
 };
 STAILQ_HEAD(log_infoh, tcp_log_dev_info);
 
-
+#ifdef TCP_BLACKBOX
 MALLOC_DECLARE(M_TCPLOGDEV);
 int tcp_log_dev_add_log(struct tcp_log_dev_queue *entry);
+#endif /* TCP_BLACKBOX */
 #endif /* _KERNEL */
 #endif /* !__tcp_log_dev_h__ */

Modified: head/sys/netinet/tcp_log_buf.h
==============================================================================
--- head/sys/netinet/tcp_log_buf.h	Sat Mar 24 12:43:34 2018	(r331484)
+++ head/sys/netinet/tcp_log_buf.h	Sat Mar 24 12:48:10 2018	(r331485)
@@ -331,6 +331,7 @@ struct tcp_log_dev_log_queue {
 	} while (0)
 
 
+#ifdef TCP_BLACKBOX
 extern bool tcp_log_verbose;
 void tcp_log_drain(struct tcpcb *tp);
 int tcp_log_dump_tp_logbuf(struct tcpcb *tp, char *reason, int how, bool force);
@@ -348,6 +349,20 @@ int tcp_log_state_change(struct tcpcb *tp, int state);
 void tcp_log_tcpcbinit(struct tcpcb *tp);
 void tcp_log_tcpcbfini(struct tcpcb *tp);
 void tcp_log_flowend(struct tcpcb *tp);
+#else /* !TCP_BLACKBOX */
+#define tcp_log_verbose	(false)
+
+static inline struct tcp_log_buffer *
+tcp_log_event_(struct tcpcb *tp, struct tcphdr *th, struct sockbuf *rxbuf,
+    struct sockbuf *txbuf, uint8_t eventid, int errornum, uint32_t len,
+    union tcp_log_stackspecific *stackinfo, int th_hostorder,
+    const char *output_caller, const char *func, int line,
+    const struct timeval *tv)
+{
+
+	return (NULL);
+}
+#endif /* TCP_BLACKBOX */
 
 #endif	/* _KERNEL */
 #endif	/* __tcp_log_buf_h__ */

Modified: head/sys/netinet/tcp_subr.c
==============================================================================
--- head/sys/netinet/tcp_subr.c	Sat Mar 24 12:43:34 2018	(r331484)
+++ head/sys/netinet/tcp_subr.c	Sat Mar 24 12:48:10 2018	(r331485)
@@ -848,8 +848,10 @@ tcp_init(void)
 	/* Setup the tcp function block list */
 	init_tcp_functions();
 	register_tcp_functions(&tcp_def_funcblk, M_WAITOK);
+#ifdef TCP_BLACKBOX
 	/* Initialize the TCP logging data. */
 	tcp_log_init();
+#endif
 
 	if (tcp_soreceive_stream) {
 #ifdef INET
@@ -1431,8 +1433,10 @@ tcp_newtcpcb(struct inpcb *inp)
 	 */
 	tcp_pcap_tcpcb_init(tp);
 #endif
+#ifdef TCP_BLACKBOX
 	/* Initialize the per-TCPCB log data. */
 	tcp_log_tcpcbinit(tp);
+#endif
 	if (tp->t_fb->tfb_tcp_fb_init) {
 		(*tp->t_fb->tfb_tcp_fb_init)(tp);
 	}
@@ -1650,7 +1654,9 @@ tcp_discardcb(struct tcpcb *tp)
 	inp->inp_ppcb = NULL;
 	if (tp->t_timers->tt_draincnt == 0) {
 		/* We own the last reference on tcpcb, let's free it. */
+#ifdef TCP_BLACKBOX
 		tcp_log_tcpcbfini(tp);
+#endif
 		TCPSTATES_DEC(tp->t_state);
 		if (tp->t_fb->tfb_tcp_fb_fini)
 			(*tp->t_fb->tfb_tcp_fb_fini)(tp, 1);
@@ -1681,7 +1687,9 @@ tcp_timer_discard(void *ptp)
 	tp->t_timers->tt_draincnt--;
 	if (tp->t_timers->tt_draincnt == 0) {
 		/* We own the last reference on this tcpcb, let's free it. */
+#ifdef TCP_BLACKBOX
 		tcp_log_tcpcbfini(tp);
+#endif
 		TCPSTATES_DEC(tp->t_state);
 		if (tp->t_fb->tfb_tcp_fb_fini)
 			(*tp->t_fb->tfb_tcp_fb_fini)(tp, 1);
@@ -1775,7 +1783,9 @@ tcp_drain(void)
 			if ((tcpb = intotcpcb(inpb)) != NULL) {
 				tcp_reass_flush(tcpb);
 				tcp_clean_sackreport(tcpb);
+#ifdef TCP_BLACKBOX
 				tcp_log_drain(tcpb);
+#endif
 #ifdef TCPPCAP
 				if (tcp_pcap_aggressive_free) {
 					/* Free the TCP PCAP queues. */
@@ -2957,7 +2967,9 @@ tcp_inptoxtp(const struct inpcb *inp, struct xtcpcb *x
 		bcopy(tp->t_fb->tfb_tcp_block_name, xt->xt_stack,
 		    TCP_FUNCTION_NAME_LEN_MAX);
 		bzero(xt->xt_logid, TCP_LOG_ID_LEN);
+#ifdef TCP_BLACKBOX
 		(void)tcp_log_get_id(tp, xt->xt_logid);
+#endif
 	}
 
 	xt->xt_len = sizeof(struct xtcpcb);

Modified: head/sys/netinet/tcp_usrreq.c
==============================================================================
--- head/sys/netinet/tcp_usrreq.c	Sat Mar 24 12:43:34 2018	(r331484)
+++ head/sys/netinet/tcp_usrreq.c	Sat Mar 24 12:48:10 2018	(r331485)
@@ -1837,6 +1837,7 @@ unlock_and_done:
 			goto unlock_and_done;
 		}
 
+#ifdef TCP_BLACKBOX
 		case TCP_LOG:
 			INP_WUNLOCK(inp);
 			error = sooptcopyin(sopt, &optval, sizeof optval,
@@ -1885,6 +1886,7 @@ unlock_and_done:
 				 */
 			}
 			break;
+#endif
 
 		default:
 			INP_WUNLOCK(inp);
@@ -1971,6 +1973,7 @@ unlock_and_done:
 			INP_WUNLOCK(inp);
 			error = sooptcopyout(sopt, &optval, sizeof optval);
 			break;
+#ifdef TCP_BLACKBOX
 		case TCP_LOG:
 			optval = tp->t_logstate;
 			INP_WUNLOCK(inp);
@@ -1990,6 +1993,7 @@ unlock_and_done:
 			INP_WUNLOCK(inp);
 			error = EINVAL;
 			break;
+#endif
 		default:
 			INP_WUNLOCK(inp);
 			error = ENOPROTOOPT;



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