git: 597798a0e5ff - main - tcp: use sparse initializer for host cache metrics

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Fri, 18 Sep 2026 22:02:22 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=597798a0e5ffd425e67695ab753f8426f59c3a74

commit 597798a0e5ffd425e67695ab753f8426f59c3a74
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2026-09-18 21:58:39 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2026-09-18 21:58:39 +0000

    tcp: use sparse initializer for host cache metrics
    
    Reviewed by:            tuexen
    Differential Revision:  https://reviews.freebsd.org/D59453
---
 sys/netinet/tcp_subr.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 6d3f6a88a1c9..1be803ed443f 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -2479,10 +2479,8 @@ tcp_discardcb(struct tcpcb *tp)
 	 * say srtt etc into the general one used by other stacks.
 	 */
 	if (tp->t_rttupdated >= 4) {
-		struct tcp_hc_metrics metrics;
 		uint32_t ssthresh;
 
-		bzero(&metrics, sizeof(metrics));
 		/*
 		 * Update the ssthresh always when the conditions below
 		 * are satisfied. This gives us better new start value
@@ -2510,15 +2508,14 @@ tcp_discardcb(struct tcpcb *tp)
 			    );
 		} else
 			ssthresh = 0;
-		metrics.hc_ssthresh = ssthresh;
-
-		metrics.hc_rtt = tp->t_srtt;
-		metrics.hc_rttvar = tp->t_rttvar;
-		metrics.hc_cwnd = tp->snd_cwnd;
-		metrics.hc_sendpipe = so->so_snd.sb_hiwat;
-		metrics.hc_recvpipe = so->so_rcv.sb_hiwat;
-
-		tcp_hc_update(&inp->inp_inc, &metrics);
+		tcp_hc_update(&inp->inp_inc, &(struct tcp_hc_metrics){
+		    .hc_ssthresh = ssthresh,
+		    .hc_rtt = tp->t_srtt,
+		    .hc_rttvar = tp->t_rttvar,
+		    .hc_cwnd = tp->snd_cwnd,
+		    .hc_sendpipe = so->so_snd.sb_hiwat,
+		    .hc_recvpipe = so->so_rcv.sb_hiwat,
+		    });
 	}
 
 	refcount_release(&tp->t_fb->tfb_refcnt);