git: 18b83b626a4f - main - tcp: reduce the size of t_rttupdated in tcpcb
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 26 Jan 2023 17:32:10 UTC
The branch main has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=18b83b626a4f596f1686140b99473125be9e33bf commit 18b83b626a4f596f1686140b99473125be9e33bf Author: Richard Scheffenegger <rscheff@FreeBSD.org> AuthorDate: 2023-01-26 17:07:11 +0000 Commit: Richard Scheffenegger <rscheff@FreeBSD.org> CommitDate: 2023-01-26 17:08:00 +0000 tcp: reduce the size of t_rttupdated in tcpcb During tcp session start, various mechanisms need to track a few initial RTTs before becoming active. Prevent overflows of the corresponding tracking counter and reduce the size of tcpcb simultaneously. Reviewed By: #transport, tuexen, guest-ccui Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D21117 --- sys/netinet/tcp_input.c | 3 ++- sys/netinet/tcp_stacks/bbr.c | 3 ++- sys/netinet/tcp_stacks/rack.c | 3 ++- sys/netinet/tcp_usrreq.c | 2 +- sys/netinet/tcp_var.h | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 606f6649d73d..72faf53299e4 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -3537,7 +3537,8 @@ tcp_xmit_timer(struct tcpcb *tp, int rtt) INP_WLOCK_ASSERT(tptoinpcb(tp)); TCPSTAT_INC(tcps_rttupdated); - tp->t_rttupdated++; + if (tp->t_rttupdated < UCHAR_MAX) + tp->t_rttupdated++; #ifdef STATS stats_voi_update_abs_u32(tp->t_stats, VOI_TCP_RTT, imax(0, rtt * 1000 / hz)); diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c index 1080d53116b4..d54d213c82dd 100644 --- a/sys/netinet/tcp_stacks/bbr.c +++ b/sys/netinet/tcp_stacks/bbr.c @@ -6366,7 +6366,8 @@ tcp_bbr_xmit_timer_commit(struct tcp_bbr *bbr, struct tcpcb *tp, uint32_t cts) tp->t_rttvar = rtt_ticks << (TCP_RTTVAR_SHIFT - 1); } KMOD_TCPSTAT_INC(tcps_rttupdated); - tp->t_rttupdated++; + if (tp->t_rttupdated < UCHAR_MAX) + tp->t_rttupdated++; #ifdef STATS stats_voi_update_abs_u32(tp->t_stats, VOI_TCP_RTT, imax(0, rtt_ticks)); #endif diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index 25a4f8dd3197..17c671705cab 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -7646,7 +7646,8 @@ tcp_rack_xmit_timer_commit(struct tcp_rack *rack, struct tcpcb *tp) } rack->rc_srtt_measure_made = 1; KMOD_TCPSTAT_INC(tcps_rttupdated); - tp->t_rttupdated++; + if (tp->t_rttupdated < UCHAR_MAX) + tp->t_rttupdated++; #ifdef STATS if (rack_stats_gets_ms_rtt == 0) { /* Send in the microsecond rtt used for rxt timeout purposes */ diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 61c077ea66c6..47e635ba1faa 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -3068,7 +3068,7 @@ db_print_tcpcb(struct tcpcb *tp, const char *name, int indent) tp->t_rttvar, tp->t_rxtshift, tp->t_rttmin); db_print_indent(indent); - db_printf("t_rttupdated: %lu max_sndwnd: %u t_softerror: %d\n", + db_printf("t_rttupdated: %u max_sndwnd: %u t_softerror: %d\n", tp->t_rttupdated, tp->max_sndwnd, tp->t_softerror); db_print_indent(indent); diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 9fca3e016d4a..5afd492189e3 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -230,7 +230,6 @@ struct tcpcb { uint32_t snd_ssthresh_prev; /* ssthresh prior to retransmit */ tcp_seq snd_recover_prev; /* snd_recover prior to retransmit */ int t_sndzerowin; /* zero-window updates sent */ - u_long t_rttupdated; /* number of times rtt sampled */ int snd_numholes; /* number of holes seen by sender */ u_int t_badrxtwin; /* window for retransmit recovery */ TAILQ_HEAD(sackhole_head, sackhole) snd_holes; @@ -276,6 +275,7 @@ struct tcpcb { uint32_t t_dsack_bytes; /* dsack bytes received */ uint32_t t_dsack_tlp_bytes; /* dsack bytes received for TLPs sent */ uint32_t t_dsack_pack; /* dsack packets we have eceived */ + uint8_t t_rttupdated; /* number of times rtt sampled */ /* TCP Fast Open */ uint8_t t_tfo_client_cookie_len; /* TFO client cookie length */ uint32_t t_end_info_status; /* Status flag of end info */