From nobody Tue Jul 28 21:20:52 2026 X-Original-To: dev-commits-src-main@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 4h8pKd01fwz6nJs5 for ; Tue, 28 Jul 2026 21:20:53 +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 4h8pKc62bbz3PTc for ; Tue, 28 Jul 2026 21:20:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785273652; 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=K2xjIcqC1YQbR2U4n67eF7rjnG8rLa5W5Ndgc7gIEhvZv+DMX8Li0hNbcOVPQUdkB1D+SY hXbfgXZoHDm2ZocJVCJLqkvPu/765EdM0o/7FsASE+e+zhnQVf7QGwk+gYiTFkJ6UwD9HN AJqchA56QBgt68xwN2yBpMkps+TWBWLv4HQnKQNmy6nf/bnQ7BwTVr6ZMjAqobZDKMLGlY UZTvL2y/iJx17yApGA5PsuFgszncrhNj8In3TrVLQ7ejuSu9G5/vfqnzV4T8t6cXnj/k4q LUhw6gJyYOg5ElmW+sMCfMstwkEtE4skRaM7pCF5hko/l6F4d+Mav4sYpgG2LA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785273652; a=rsa-sha256; cv=none; b=M/fG5IYy4MasGE8y1EnJHcNya5BCHxuHzmam004EwzGuN25Y4QPQbrvSYXK4NZCBbgUCDP u/j7/9yfnGn1xbZg9CW7iJHj9otbgFtJYzE4eKHj4PAnXs5zdEtChinkI5I/b31fHt1C1S HvL+kOxxeClWafTE4wJFY9dGsYwkk7z0IqMZPJZhtKyiVTqopoiFF6lZnBQZzBeH1lfiyl GFaDED5rM3nKbQuOVQesdYMoWLaOazWdIjqurHnr3ae37Q/uaVqOHuZUi16M8QeHz2aSX0 3Z8LhbDAWyjCNz0JZD/nSvmRALjxyxuY1uuhl8RcthZ/m/OTswzDwQafi8Vtww== 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=1785273652; 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=uxsr3P7/Q2aSFJy8RSRvWj0qc/nP2/nqFj6KgCccPihoY+Rt+vD22hTmGijPu0Lj/5fcG8 wfOO/cjLXU9GTXtb2Bj+J4X5Sh7MZpgY8hEcVeXLanIDuKT7Gei58vlrZQ5oqMdgOfk8Pn tN+o/9f/I8d5tpmtEjDwa4smqp5rREpKJ3uzi3nWyHVjgqAIlD9O5LpHtvZckg4Xw8bM2R msC3WBgJg7KOY4U4drP/8BQ/aDcWvr95R6XZYgQTIWB36wZt+sGs4TUz9z9n8kd+OtFmcx 1I/vzAk5OSIUa0L0fBWE9TnvF65g2QRfaHPMsj9A/jDTd8Tj1U05DwSALXuCYQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h8pKc4njHzxJ0 for ; Tue, 28 Jul 2026 21:20:52 +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 the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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 */