Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Nov 2016 14:45:08 +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: r308832 - in head/sys/netinet: . tcp_stacks
Message-ID:  <201611191445.uAJEj95P006067@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tuexen
Date: Sat Nov 19 14:45:08 2016
New Revision: 308832
URL: https://svnweb.freebsd.org/changeset/base/308832

Log:
  Ensure that TCP state changes to state-closing are reported via dtrace.
  This does not cover state changes from TIME-WAIT.
  
  Reviewed by:		gnn
  MFC after:		3 weeks
  Sponsored by:		Netflix
  Differential Revision:	https://reviews.freebsd.org/D8443

Modified:
  head/sys/netinet/tcp_input.c
  head/sys/netinet/tcp_stacks/fastpath.c
  head/sys/netinet/tcp_subr.c
  head/sys/netinet/tcp_timewait.c

Modified: head/sys/netinet/tcp_input.c
==============================================================================
--- head/sys/netinet/tcp_input.c	Sat Nov 19 14:40:18 2016	(r308831)
+++ head/sys/netinet/tcp_input.c	Sat Nov 19 14:45:08 2016	(r308832)
@@ -2206,7 +2206,6 @@ tcp_do_segment(struct mbuf *m, struct tc
 				case TCPS_LAST_ACK:
 					so->so_error = ECONNRESET;
 				close:
-					tcp_state_change(tp, TCPS_CLOSED);
 					/* FALLTHROUGH */
 				default:
 					tp = tcp_close(tp);

Modified: head/sys/netinet/tcp_stacks/fastpath.c
==============================================================================
--- head/sys/netinet/tcp_stacks/fastpath.c	Sat Nov 19 14:40:18 2016	(r308831)
+++ head/sys/netinet/tcp_stacks/fastpath.c	Sat Nov 19 14:45:08 2016	(r308832)
@@ -750,7 +750,6 @@ tcp_do_slowpath(struct mbuf *m, struct t
 				case TCPS_LAST_ACK:
 					so->so_error = ECONNRESET;
 				close:
-					tcp_state_change(tp, TCPS_CLOSED);
 					/* FALLTHROUGH */
 				default:
 					tp = tcp_close(tp);

Modified: head/sys/netinet/tcp_subr.c
==============================================================================
--- head/sys/netinet/tcp_subr.c	Sat Nov 19 14:40:18 2016	(r308831)
+++ head/sys/netinet/tcp_subr.c	Sat Nov 19 14:45:08 2016	(r308832)
@@ -1502,6 +1502,7 @@ 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. */
+		TCPSTATES_DEC(tp->t_state);
 		if (tp->t_fb->tfb_tcp_fb_fini)
 			(*tp->t_fb->tfb_tcp_fb_fini)(tp, 1);
 		refcount_release(&tp->t_fb->tfb_refcnt);
@@ -1531,6 +1532,7 @@ 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. */
+		TCPSTATES_DEC(tp->t_state);
 		if (tp->t_fb->tfb_tcp_fb_fini)
 			(*tp->t_fb->tfb_tcp_fb_fini)(tp, 1);
 		refcount_release(&tp->t_fb->tfb_refcnt);
@@ -1577,7 +1579,8 @@ tcp_close(struct tcpcb *tp)
 #endif
 	in_pcbdrop(inp);
 	TCPSTAT_INC(tcps_closed);
-	TCPSTATES_DEC(tp->t_state);
+	if (tp->t_state != TCPS_CLOSED)
+		tcp_state_change(tp, TCPS_CLOSED);
 	KASSERT(inp->inp_socket != NULL, ("tcp_close: inp_socket NULL"));
 	so = inp->inp_socket;
 	soisdisconnected(so);

Modified: head/sys/netinet/tcp_timewait.c
==============================================================================
--- head/sys/netinet/tcp_timewait.c	Sat Nov 19 14:40:18 2016	(r308831)
+++ head/sys/netinet/tcp_timewait.c	Sat Nov 19 14:45:08 2016	(r308832)
@@ -340,6 +340,7 @@ tcp_twstart(struct tcpcb *tp)
 		tcp_twrespond(tw, TH_ACK);
 	inp->inp_ppcb = tw;
 	inp->inp_flags |= INP_TIMEWAIT;
+	TCPSTATES_INC(TCPS_TIME_WAIT);
 	tcp_tw_2msl_reset(tw, 0);
 
 	/*



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