git: 918fa4227d5b - main - tcp: remove tcp_timer_suspend()

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Wed, 07 Dec 2022 17:53:18 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=918fa4227d5bb74e882649785284c76e24e8f259

commit 918fa4227d5bb74e882649785284c76e24e8f259
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2022-12-07 17:00:48 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2022-12-07 17:00:48 +0000

    tcp: remove tcp_timer_suspend()
    
    It was a temporary code added together with RACK to fight against
    TCP timer races.
---
 sys/netinet/tcp_stacks/bbr.c  |   4 --
 sys/netinet/tcp_stacks/rack.c |   4 --
 sys/netinet/tcp_timer.c       | 108 ------------------------------------------
 sys/netinet/tcp_timer.h       |  10 ----
 sys/netinet/tcp_var.h         |   2 -
 5 files changed, 128 deletions(-)

diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c
index 250418d87150..edba270c151b 100644
--- a/sys/netinet/tcp_stacks/bbr.c
+++ b/sys/netinet/tcp_stacks/bbr.c
@@ -9919,10 +9919,6 @@ bbr_stop_all_timers(struct tcpcb *tp)
 		bbr = (struct tcp_bbr *)tp->t_fb_ptr;
 		bbr->rc_in_persist = 1;
 	}
-	tcp_timer_suspend(tp, TT_PERSIST);
-	tcp_timer_suspend(tp, TT_REXMT);
-	tcp_timer_suspend(tp, TT_KEEP);
-	tcp_timer_suspend(tp, TT_DELACK);
 }
 
 static void
diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c
index c3aed32e02ea..a93fb18398fe 100644
--- a/sys/netinet/tcp_stacks/rack.c
+++ b/sys/netinet/tcp_stacks/rack.c
@@ -7100,10 +7100,6 @@ rack_stop_all_timers(struct tcpcb *tp)
 		rack = (struct tcp_rack *)tp->t_fb_ptr;
 		rack->rc_in_persist = 1;
 	}
-	tcp_timer_suspend(tp, TT_PERSIST);
-	tcp_timer_suspend(tp, TT_REXMT);
-	tcp_timer_suspend(tp, TT_KEEP);
-	tcp_timer_suspend(tp, TT_DELACK);
 }
 
 static void
diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c
index a0eb4b0aad2d..d67a062eab5b 100644
--- a/sys/netinet/tcp_timer.c
+++ b/sys/netinet/tcp_timer.c
@@ -976,114 +976,6 @@ tcp_timer_active(struct tcpcb *tp, uint32_t timer_type)
 	return callout_active(t_callout);
 }
 
-/*
- * Stop the timer from running, and apply a flag
- * against the timer_flags that will force the
- * timer never to run. The flag is needed to assure
- * a race does not leave it running and cause
- * the timer to possibly restart itself (keep and persist
- * especially do this).
- */
-int
-tcp_timer_suspend(struct tcpcb *tp, uint32_t timer_type)
-{
-	struct callout *t_callout;
-	uint32_t t_flags;
-
-	switch (timer_type) {
-		case TT_DELACK:
-			t_flags = TT_DELACK_SUS;
-			t_callout = &tp->tt_delack;
-			break;
-		case TT_REXMT:
-			t_flags = TT_REXMT_SUS;
-			t_callout = &tp->tt_rexmt;
-			break;
-		case TT_PERSIST:
-			t_flags = TT_PERSIST_SUS;
-			t_callout = &tp->tt_persist;
-			break;
-		case TT_KEEP:
-			t_flags = TT_KEEP_SUS;
-			t_callout = &tp->tt_keep;
-			break;
-		case TT_2MSL:
-			t_flags = TT_2MSL_SUS;
-			t_callout = &tp->tt_2msl;
-			break;
-		default:
-			panic("tp:%p bad timer_type 0x%x", tp, timer_type);
-	}
-	tp->tt_flags |= t_flags;
-	return (callout_stop(t_callout));
-}
-
-void
-tcp_timers_unsuspend(struct tcpcb *tp, uint32_t timer_type)
-{
-
-	switch (timer_type) {
-		case TT_DELACK:
-			if (tp->tt_flags & TT_DELACK_SUS) {
-				tp->tt_flags &= ~TT_DELACK_SUS;
-				if (tp->t_flags & TF_DELACK) {
-					/* Delayed ack timer should be up activate a timer */
-					tp->t_flags &= ~TF_DELACK;
-					tcp_timer_activate(tp, TT_DELACK,
-					    tcp_delacktime);
-				}
-			}
-			break;
-		case TT_REXMT:
-			if (tp->tt_flags & TT_REXMT_SUS) {
-				tp->tt_flags &= ~TT_REXMT_SUS;
-				if (SEQ_GT(tp->snd_max, tp->snd_una) &&
-				    (tcp_timer_active((tp), TT_PERSIST) == 0) &&
-				    tp->snd_wnd) {
-					/* We have outstanding data activate a timer */
-					tcp_timer_activate(tp, TT_REXMT,
-                                            tp->t_rxtcur);
-				}
-			}
-			break;
-		case TT_PERSIST:
-			if (tp->tt_flags & TT_PERSIST_SUS) {
-				tp->tt_flags &= ~TT_PERSIST_SUS;
-				if (tp->snd_wnd == 0) {
-					/* Activate the persists timer */
-					tp->t_rxtshift = 0;
-					tcp_setpersist(tp);
-				}
-			}
-			break;
-		case TT_KEEP:
-			if (tp->tt_flags & TT_KEEP_SUS) {
-				tp->tt_flags &= ~TT_KEEP_SUS;
-				tcp_timer_activate(tp, TT_KEEP,
-					    TCPS_HAVEESTABLISHED(tp->t_state) ?
-					    TP_KEEPIDLE(tp) : TP_KEEPINIT(tp));
-			}
-			break;
-		case TT_2MSL:
-			if (tp->tt_flags &= TT_2MSL_SUS) {
-				struct socket *so = tptosocket(tp);
-
-				tp->tt_flags &= ~TT_2MSL_SUS;
-				if ((tp->t_state == TCPS_FIN_WAIT_2) &&
-				    (so == NULL ||	/* XXXGL: needed? */
-				    (so->so_rcv.sb_state & SBS_CANTRCVMORE))) {
-					/* Star the 2MSL timer */
-					tcp_timer_activate(tp, TT_2MSL,
-					    (tcp_fast_finwait2_recycle) ?
-					    tcp_finwait2_timeout : TP_MAXIDLE(tp));
-				}
-			}
-			break;
-		default:
-			panic("tp:%p bad timer_type 0x%x", tp, timer_type);
-	}
-}
-
 static void
 tcp_timer_discard(void *ptp)
 {
diff --git a/sys/netinet/tcp_timer.h b/sys/netinet/tcp_timer.h
index e72ab5f90546..f53a66084fa1 100644
--- a/sys/netinet/tcp_timer.h
+++ b/sys/netinet/tcp_timer.h
@@ -155,16 +155,6 @@ static const char *tcptimers[] =
 #define TT_2MSL		0x0010
 #define TT_MASK		(TT_DELACK|TT_REXMT|TT_PERSIST|TT_KEEP|TT_2MSL)
 
-/*
- * Suspend flags - used when suspending a timer
- * from ever running again.
- */
-#define TT_DELACK_SUS	0x0100
-#define TT_REXMT_SUS	0x0200
-#define TT_PERSIST_SUS	0x0400
-#define TT_KEEP_SUS	0x0800
-#define TT_2MSL_SUS	0x1000
-
 #define TT_STOPPED	0x00010000
 
 #define	TP_KEEPINIT(tp)	((tp)->t_keepinit ? (tp)->t_keepinit : tcp_keepinit)
diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h
index 3f18f0af39cd..9e130fcdf124 100644
--- a/sys/netinet/tcp_var.h
+++ b/sys/netinet/tcp_var.h
@@ -1187,8 +1187,6 @@ struct tcptemp *
 	 tcpip_maketemplate(struct inpcb *);
 void	 tcpip_fillheaders(struct inpcb *, uint16_t, void *, void *);
 void	 tcp_timer_activate(struct tcpcb *, uint32_t, u_int);
-int	 tcp_timer_suspend(struct tcpcb *, uint32_t);
-void	 tcp_timers_unsuspend(struct tcpcb *, uint32_t);
 int	 tcp_timer_active(struct tcpcb *, uint32_t);
 void	 tcp_timer_stop(struct tcpcb *, uint32_t);
 void	 tcp_trace(short, short, struct tcpcb *, void *, struct tcphdr *, int);