From nobody Tue Jul 28 21:20:52 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4h8pKk4rw4z6nJpM for ; Tue, 28 Jul 2026 21:20:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4h8pKk1Hpjz3PqH for ; Tue, 28 Jul 2026 21:20:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785273658; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SxjKiNXwCL/XlYGF+G5yF9ZypdLba4/me8JyzmTg2UI=; b=rdrNbKRnH+x++kAZMfNlzQTAuJ1Q2E8mdFC5DA60DbZ6aPPLAKt6F7seB3xaqktlqTsZuo AV8hicfU5XCkcn7e+hU9x+CLHaB2iUKpRADJWE0SRcnNSo7saReDQS4jizmM0KDP2HwR5v xRqAArzoruiVVy0dhJndo9qVpg7mT2uPgVgSuCFMGP3rXesYNd5gQfml/8dWAc3eKNXTBF gQZEkJKtMN3Z1sc7ruwhTCD2POHwJe9MW57UE8lwgMQDWgotn/nLn4fvm7oOzqk3R6kk7N /vUBjjOuKhtKc6BuffGPpIlAQDl82R2D2LetBig3Tj/Y4anyDaQTxPVfCUvfeg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785273658; a=rsa-sha256; cv=none; b=vmGyWqfhPi2UR3H58pcLe0cvz7ojkzPYXw95AsAuzKOf70RezVTsTnNosFf5xdqyRa60ro setejuXJWC+8G4vy9V8Q+DdLGztYjO/nKTSp9rjsdxnaEnQyJMyKMz3amuCuVb8UJSoadI pSPxvd2jzXc6USEVVGAyS79Ig3hgSpEE/GLtObC6PC288Cp2CW52F+lnr3sbaNx+dIjRsn /LRMk2en8TSeO2a6uJ4wXV52k7a7A9porkaANeIHqPg+Pkzfkv56uWPSGFHgBfACyPSWhy XG34VdwfGCujlivhSBB6A/TwoEFzGQOkRpCjHMn+2XLUTUHf2/rEbdFcaI85kw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785273658; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SxjKiNXwCL/XlYGF+G5yF9ZypdLba4/me8JyzmTg2UI=; b=WRqOTCq1kmuEQT7Tqt1bew5RnkiYowXc8WI6Z1vpeDLdbVVk3r9Zb1EUVodhq+8D4FwVAX 1P4GlNtmF9NUotcE94557QHmVRiT+ttaz1BlA/CFZxkIVMO06wUUR7GjXhuQMARHv3IUbD qVUo6hgVJmro95AMknehtCf2N0ONGlz80XVk0mGwv5ID4irYzkNCTYpsmwQocJ97r4f7eQ wgwb/EY7mzgQmKy6T4rbHRix0BzJW2hm1y2CPgOufx9eiBUNrynhHWUvIqXLcHzk+J7qdh rHhCnI3hVZRIJvCwUd0AyyzSIz4UMdvIF1TDQuD0EoJdSeYRi34cR68KcylWiw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h8pKj6cDfzxHh for ; Tue, 28 Jul 2026 21:20:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1f7b5 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 28 Jul 2026 21:20:52 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Richard Scheffenegger Subject: git: 5de91610cc74 - main - tcp_hostcache: limit scope of struct hc_metrics_lite and rename with tcp_ prefix List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5de91610cc744815244c1adfe202408dbfc9dbf2 Auto-Submitted: auto-generated Date: Tue, 28 Jul 2026 21:20:52 +0000 Message-Id: <6a691d34.1f7b5.2170b8c3@gitrepo.freebsd.org> The branch main has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=5de91610cc744815244c1adfe202408dbfc9dbf2 commit 5de91610cc744815244c1adfe202408dbfc9dbf2 Author: Richard Scheffenegger AuthorDate: 2026-07-28 20:38:32 +0000 Commit: Richard Scheffenegger CommitDate: 2026-07-28 21:13:08 +0000 tcp_hostcache: limit scope of struct hc_metrics_lite and rename with tcp_ prefix Restrict the scope of the struct hc_metrics_lite to the kernel only. Update the naming to align with other kernel structures and add a tcp_ prefix. Reviewed by: glebius MFC after: 2 weeks Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D58440 --- sys/netinet/tcp_hostcache.c | 69 +++++++++++++++++++++++---------------------- sys/netinet/tcp_input.c | 10 +++---- sys/netinet/tcp_subr.c | 2 +- sys/netinet/tcp_var.h | 10 ++++--- 4 files changed, 47 insertions(+), 44 deletions(-) diff --git a/sys/netinet/tcp_hostcache.c b/sys/netinet/tcp_hostcache.c index fbf81b1f2303..2ed035b6fd06 100644 --- a/sys/netinet/tcp_hostcache.c +++ b/sys/netinet/tcp_hostcache.c @@ -53,7 +53,7 @@ * entry if a hash is full. Value updates for an entry shall be atomic. * * TCP stack(s) communication with tcp_hostcache() is done via KBI functions - * tcp_hc_*() and the hc_metrics_lite structure. + * tcp_hc_*() and the tcp_hc_metrics structure. * * Since tcp_hostcache is only caching information, there are no fatal * consequences if we either can't allocate a new entry or have to drop @@ -371,12 +371,12 @@ tcp_hc_lookup(const struct in_conninfo *inc) */ void tcp_hc_get(const struct in_conninfo *inc, - struct hc_metrics_lite *hc_metrics_lite) + struct tcp_hc_metrics *hc_metrics) { struct hc_metrics *hc_entry; if (!V_tcp_use_hostcache) { - bzero(hc_metrics_lite, sizeof(*hc_metrics_lite)); + bzero(hc_metrics, sizeof(*hc_metrics)); return; } @@ -389,17 +389,17 @@ tcp_hc_get(const struct in_conninfo *inc, * If we don't have an existing object. */ if (hc_entry == NULL) { - bzero(hc_metrics_lite, sizeof(*hc_metrics_lite)); + bzero(hc_metrics, sizeof(*hc_metrics)); return; } - hc_metrics_lite->hc_mtu = atomic_load_32(&hc_entry->hc_mtu); - hc_metrics_lite->hc_ssthresh = atomic_load_32(&hc_entry->hc_ssthresh); - hc_metrics_lite->hc_rtt = atomic_load_32(&hc_entry->hc_rtt); - hc_metrics_lite->hc_rttvar = atomic_load_32(&hc_entry->hc_rttvar); - hc_metrics_lite->hc_cwnd = atomic_load_32(&hc_entry->hc_cwnd); - hc_metrics_lite->hc_sendpipe = atomic_load_32(&hc_entry->hc_sendpipe); - hc_metrics_lite->hc_recvpipe = atomic_load_32(&hc_entry->hc_recvpipe); + hc_metrics->hc_mtu = atomic_load_32(&hc_entry->hc_mtu); + hc_metrics->hc_ssthresh = atomic_load_32(&hc_entry->hc_ssthresh); + hc_metrics->hc_rtt = atomic_load_32(&hc_entry->hc_rtt); + hc_metrics->hc_rttvar = atomic_load_32(&hc_entry->hc_rttvar); + hc_metrics->hc_cwnd = atomic_load_32(&hc_entry->hc_cwnd); + hc_metrics->hc_sendpipe = atomic_load_32(&hc_entry->hc_sendpipe); + hc_metrics->hc_recvpipe = atomic_load_32(&hc_entry->hc_recvpipe); smr_exit(V_tcp_hostcache.smr); } @@ -436,9 +436,9 @@ tcp_hc_getmtu(const struct in_conninfo *inc) void tcp_hc_updatemtu(const struct in_conninfo *inc, uint32_t mtu) { - struct hc_metrics_lite hcml = { .hc_mtu = mtu }; + struct tcp_hc_metrics hcm = { .hc_mtu = mtu }; - return (tcp_hc_update(inc, &hcml)); + return (tcp_hc_update(inc, &hcm)); } /* @@ -446,7 +446,7 @@ tcp_hc_updatemtu(const struct in_conninfo *inc, uint32_t mtu) * Creates a new entry if none was found. */ void -tcp_hc_update(const struct in_conninfo *inc, struct hc_metrics_lite *hcml) +tcp_hc_update(const struct in_conninfo *inc, struct tcp_hc_metrics *hcm) { struct hc_head *hc_head; struct hc_metrics *hc_entry, *hc_prev; @@ -543,59 +543,60 @@ tcp_hc_update(const struct in_conninfo *inc, struct hc_metrics_lite *hcml) * Fill in data. Use atomics, since an existing entry is * accessible by readers in SMR section. */ - if (hcml->hc_mtu != 0) { - atomic_store_32(&hc_entry->hc_mtu, hcml->hc_mtu); + if (hcm->hc_mtu != 0) { + atomic_store_32(&hc_entry->hc_mtu, hcm->hc_mtu); } - if (hcml->hc_rtt != 0) { + if (hcm->hc_rtt != 0) { if (hc_entry->hc_rtt == 0) - v = hcml->hc_rtt; + v = hcm->hc_rtt; else v = ((uint64_t)hc_entry->hc_rtt + - (uint64_t)hcml->hc_rtt) / 2; + (uint64_t)hcm->hc_rtt) / 2; atomic_store_32(&hc_entry->hc_rtt, v); TCPSTAT_INC(tcps_cachedrtt); } - if (hcml->hc_rttvar != 0) { + if (hcm->hc_rttvar != 0) { if (hc_entry->hc_rttvar == 0) - v = hcml->hc_rttvar; + v = hcm->hc_rttvar; else v = ((uint64_t)hc_entry->hc_rttvar + - (uint64_t)hcml->hc_rttvar) / 2; + (uint64_t)hcm->hc_rttvar) / 2; atomic_store_32(&hc_entry->hc_rttvar, v); TCPSTAT_INC(tcps_cachedrttvar); } - if (hcml->hc_ssthresh != 0) { + if (hcm->hc_ssthresh != 0) { if (hc_entry->hc_ssthresh == 0) - v = hcml->hc_ssthresh; + v = hcm->hc_ssthresh; else - v = (hc_entry->hc_ssthresh + hcml->hc_ssthresh) / 2; + v = (hc_entry->hc_ssthresh + + hcm->hc_ssthresh) / 2; atomic_store_32(&hc_entry->hc_ssthresh, v); TCPSTAT_INC(tcps_cachedssthresh); } - if (hcml->hc_cwnd != 0) { + if (hcm->hc_cwnd != 0) { if (hc_entry->hc_cwnd == 0) - v = hcml->hc_cwnd; + v = hcm->hc_cwnd; else v = ((uint64_t)hc_entry->hc_cwnd + - (uint64_t)hcml->hc_cwnd) / 2; + (uint64_t)hcm->hc_cwnd) / 2; atomic_store_32(&hc_entry->hc_cwnd, v); /* TCPSTAT_INC(tcps_cachedcwnd); */ } - if (hcml->hc_sendpipe != 0) { + if (hcm->hc_sendpipe != 0) { if (hc_entry->hc_sendpipe == 0) - v = hcml->hc_sendpipe; + v = hcm->hc_sendpipe; else v = ((uint64_t)hc_entry->hc_sendpipe + - (uint64_t)hcml->hc_sendpipe) /2; + (uint64_t)hcm->hc_sendpipe) / 2; atomic_store_32(&hc_entry->hc_sendpipe, v); /* TCPSTAT_INC(tcps_cachedsendpipe); */ } - if (hcml->hc_recvpipe != 0) { + if (hcm->hc_recvpipe != 0) { if (hc_entry->hc_recvpipe == 0) - v = hcml->hc_recvpipe; + v = hcm->hc_recvpipe; else v = ((uint64_t)hc_entry->hc_recvpipe + - (uint64_t)hcml->hc_recvpipe) /2; + (uint64_t)hcm->hc_recvpipe) / 2; atomic_store_32(&hc_entry->hc_recvpipe, v); /* TCPSTAT_INC(tcps_cachedrecvpipe); */ } diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 37706343d621..bfef374af2d9 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -359,7 +359,7 @@ cc_ack_received(struct tcpcb *tp, struct tcphdr *th, uint16_t nsegs, void cc_conn_init(struct tcpcb *tp) { - struct hc_metrics_lite metrics; + struct tcp_hc_metrics metrics; struct inpcb *inp = tptoinpcb(tp); u_int maxseg; int rtt; @@ -3714,12 +3714,12 @@ tcp_xmit_timer(struct tcpcb *tp, int rtt) */ void tcp_mss_update(struct tcpcb *tp, int offer, int mtuoffer, - struct hc_metrics_lite *metricptr, struct tcp_ifcap *cap) + struct tcp_hc_metrics *metricptr, struct tcp_ifcap *cap) { int mss = 0; uint32_t maxmtu = 0; struct inpcb *inp = tptoinpcb(tp); - struct hc_metrics_lite metrics; + struct tcp_hc_metrics metrics; #ifdef INET6 int isipv6 = ((inp->inp_vflag & INP_IPV6) != 0) ? 1 : 0; size_t min_protoh = isipv6 ? @@ -3765,7 +3765,7 @@ tcp_mss_update(struct tcpcb *tp, int offer, int mtuoffer, * if there was no cache hit. */ if (metricptr != NULL) - bzero(metricptr, sizeof(struct hc_metrics_lite)); + bzero(metricptr, sizeof(struct tcp_hc_metrics)); return; } @@ -3876,7 +3876,7 @@ tcp_mss(struct tcpcb *tp, int offer) uint32_t bufsize; struct inpcb *inp = tptoinpcb(tp); struct socket *so; - struct hc_metrics_lite metrics; + struct tcp_hc_metrics metrics; struct tcp_ifcap cap; KASSERT(tp != NULL, ("%s: tp == NULL", __func__)); diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 7c56a7a77cb5..af381b0b4102 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -2479,7 +2479,7 @@ tcp_discardcb(struct tcpcb *tp) * say srtt etc into the general one used by other stacks. */ if (tp->t_rttupdated >= 4) { - struct hc_metrics_lite metrics; + struct tcp_hc_metrics metrics; uint32_t ssthresh; bzero(&metrics, sizeof(metrics)); diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index fa8fdb570897..4f1e8fa9fd49 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -906,7 +906,8 @@ struct tcpopt { */ #define TO_SYN 0x01 /* parse SYN-only options */ -struct hc_metrics_lite { /* must stay in sync with hc_metrics */ +#ifdef _KERNEL +struct tcp_hc_metrics { uint32_t hc_mtu; /* MTU for this path */ uint32_t hc_ssthresh; /* outbound gateway buffer limit */ uint32_t hc_rtt; /* estimated round trip time */ @@ -915,6 +916,7 @@ struct hc_metrics_lite { /* must stay in sync with hc_metrics */ uint32_t hc_sendpipe; /* outbound delay-bandwidth product */ uint32_t hc_recvpipe; /* inbound delay-bandwidth product */ }; +#endif /* _KERNEL */ #ifndef _NETINET_IN_PCB_H_ struct in_conninfo; @@ -1480,7 +1482,7 @@ uint32_t tcp_maxmtu6(struct in_conninfo *, struct tcp_ifcap *); void tcp6_use_min_mtu(struct tcpcb *); u_int tcp_maxseg(const struct tcpcb *); u_int tcp_fixed_maxseg(const struct tcpcb *); -void tcp_mss_update(struct tcpcb *, int, int, struct hc_metrics_lite *, +void tcp_mss_update(struct tcpcb *, int, int, struct tcp_hc_metrics *, struct tcp_ifcap *); void tcp_mss(struct tcpcb *, int); int tcp_mssopt(struct in_conninfo *); @@ -1510,10 +1512,10 @@ void tcp_hc_init(void); #ifdef VIMAGE void tcp_hc_destroy(void); #endif -void tcp_hc_get(const struct in_conninfo *, struct hc_metrics_lite *); +void tcp_hc_get(const struct in_conninfo *, struct tcp_hc_metrics *); uint32_t tcp_hc_getmtu(const struct in_conninfo *); void tcp_hc_updatemtu(const struct in_conninfo *, uint32_t); -void tcp_hc_update(const struct in_conninfo *, struct hc_metrics_lite *); +void tcp_hc_update(const struct in_conninfo *, struct tcp_hc_metrics *); void cc_after_idle(struct tcpcb *tp); extern struct protosw tcp_protosw; /* shared for TOE */