Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Jan 2024 19:05:13 GMT
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 08cad73479df - stable/14 - tcp/hpts: make stacks responsible for clearing themselves out HPTS
Message-ID:  <202401161905.40GJ5Dxs010112@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=08cad73479df9ba6aab280af1cfd2eacb508a5a7

commit 08cad73479df9ba6aab280af1cfd2eacb508a5a7
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2023-12-04 18:19:46 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2024-01-16 18:47:49 +0000

    tcp/hpts: make stacks responsible for clearing themselves out HPTS
    
    There already is the tfb_tcp_timer_stop_all method that is supposed to stop
    all time events associated with a given tcpcb by given stack.  Some time
    ago it was doing actual callout_stop().  Today bbr/rack just mark their
    internal state as inactive in their tfb_tcp_timer_stop_all methods, but
    tcpcb stays in HPTS wheel and potentially called in from HPTS.  Change the
    methods to also call tcp_hpts_remove().  Note: I'm not sure if internal
    flag is still relevant once we are out of HPTS wheel.
    
    Call the method when connection goes into TCP_CLOSED state, instead of
    calling it later when tcpcb is freed.  Also call it when we switch between
    stacks.
    
    Reviewed by:            tuexen, rrs
    Differential Revision:  https://reviews.freebsd.org/D42857
    
    (cherry picked from commit d2ef52ef3dee38cccb7f54d33ecc2a4b944dad9d)
---
 sys/netinet/tcp_stacks/bbr.c  | 3 +++
 sys/netinet/tcp_stacks/rack.c | 4 ++++
 sys/netinet/tcp_subr.c        | 8 ++------
 sys/netinet/tcp_usrreq.c      | 6 ++----
 4 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c
index 3805a911df41..c643f0321099 100644
--- a/sys/netinet/tcp_stacks/bbr.c
+++ b/sys/netinet/tcp_stacks/bbr.c
@@ -5278,6 +5278,9 @@ bbr_stopall(struct tcpcb *tp)
 
 	bbr = (struct tcp_bbr *)tp->t_fb_ptr;
 	bbr->rc_all_timers_stopped = 1;
+
+	tcp_hpts_remove(tp);
+
 	return (0);
 }
 
diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c
index af03f2e1640c..db8131ffb377 100644
--- a/sys/netinet/tcp_stacks/rack.c
+++ b/sys/netinet/tcp_stacks/rack.c
@@ -8213,8 +8213,12 @@ static int
 rack_stopall(struct tcpcb *tp)
 {
 	struct tcp_rack *rack;
+
 	rack = (struct tcp_rack *)tp->t_fb_ptr;
 	rack->t_timers_stopped = 1;
+
+	tcp_hpts_remove(tp);
+
 	return (0);
 }
 
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 19d71a9e9058..023078d1d4f9 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -2381,9 +2381,6 @@ tcp_discardcb(struct tcpcb *tp)
 	INP_WLOCK_ASSERT(inp);
 
 	tcp_timer_stop(tp);
-	if (tp->t_fb->tfb_tcp_timer_stop_all) {
-		tp->t_fb->tfb_tcp_timer_stop_all(tp);
-	}
 
 	/* free the reassembly queue, if any */
 	tcp_reass_flush(tp);
@@ -2523,9 +2520,8 @@ tcp_close(struct tcpcb *tp)
 		tcp_fastopen_decrement_counter(tp->t_tfo_pending);
 		tp->t_tfo_pending = NULL;
 	}
-#ifdef TCPHPTS
-	tcp_hpts_remove(tp);
-#endif
+	if (tp->t_fb->tfb_tcp_timer_stop_all != NULL)
+		tp->t_fb->tfb_tcp_timer_stop_all(tp);
 	in_pcbdrop(inp);
 	TCPSTAT_INC(tcps_closed);
 	if (tp->t_state != TCPS_CLOSED)
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 767045480abf..f65b09f17a5f 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -1759,10 +1759,8 @@ tcp_ctloutput_set(struct inpcb *inp, struct sockopt *sopt)
 		 * Ensure the new stack takes ownership with a
 		 * clean slate on peak rate threshold.
 		 */
-#ifdef TCPHPTS
-		/* Assure that we are not on any hpts */
-		tcp_hpts_remove(tp);
-#endif
+		if (tp->t_fb->tfb_tcp_timer_stop_all != NULL)
+			tp->t_fb->tfb_tcp_timer_stop_all(tp);
 		if (blk->tfb_tcp_fb_init) {
 			error = (*blk->tfb_tcp_fb_init)(tp, &ptr);
 			if (error) {



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