Re: git: 7146ad04f18e - main - tcp: refactor tcp_autosndbuf() and associated sysctls

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Thu, 22 Oct 2026 13:10:32 UTC
> On 22. Oct 2026, at 12:51, Kristof Provost <kp@FreeBSD.org> wrote:
> 
> On 22 Oct 2026, at 11:29, Kristof Provost wrote:
> On 22 Oct 2026, at 5:31, Gleb Smirnoff wrote:
> The branch main has been updated by glebius:
> URL: https://cgit.FreeBSD.org/src/commit/?id=7146ad04f18e7f0767a4d44cff43c1c67ea98cec
> commit 7146ad04f18e7f0767a4d44cff43c1c67ea98cec
> Author: Gleb Smirnoff glebius@FreeBSD.org
> AuthorDate: 2026-10-22 03:27:47 +0000
> Commit: Gleb Smirnoff glebius@FreeBSD.org
> CommitDate: 2026-10-22 03:27:47 +0000
> tcp: refactor tcp_autosndbuf() and associated sysctls
> 
> Rename tcp_sndbuf_autoscale() to tcp_autosndbuf(). This matches
> complementary tcp_autorcvbuf() that was factored out as a separate
> function a few months before tcp_sndbuf_autoscale() was. Move the large
> comment to the header of the function. Use unsigned types for all sizing
> sysctls and variables and use bool for the switching sysctl. Add a
> comment above net.inet.tcp.sendbuf_auto_lowat (default to off) providing a
> reference to its origins. Add DTrace probe tcp::send-autoresize,
> complementary to the existing tcp::receive-autoresize.
> 
> Rack has its own function, just enable the DTrace probe there.
> 
> Reviewed by: tuexen
> Differential Revision: https://reviews.freebsd.org/D60732
> 
> sys/netinet/in_kdtrace.c | 4 ++
> sys/netinet/in_kdtrace.h | 1 +
> sys/netinet/tcp_output.c | 142 +++++++++++++++++++++---------------------
> sys/netinet/tcp_stacks/bbr.c | 2 +-
> sys/netinet/tcp_stacks/rack.c | 5 +-
> sys/netinet/tcp_var.h | 10 +--
> 6 files changed, 85 insertions(+), 79 deletions(-)
> …
> index 09295544855f..d11a2b745382 100644
> --- a/sys/netinet/tcp_output.c
> +++ b/sys/netinet/tcp_output.c
> …
> void
> -tcp_sndbuf_autoscale(struct tcpcb *tp, struct socket *so, uint32_t sendwin)
> +tcp_autosndbuf(struct tcpcb *tp, u_int sendwin)
> {
> …
>     • SOCK_RECVBUF_LOCK_ASSERT(so);
> Is this assert right? I’d think autosndbuf is about the send buffer, not the receive buffer.
> With this patch the system does just work for me:
> diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c
> index d11a2b745382..b5f36d83f5a2 100644
> --- a/sys/netinet/tcp_output.c
> +++ b/sys/netinet/tcp_output.c
> @@ -2154,7 +2154,7 @@ tcp_autosndbuf(struct tcpcb *tp, u_int sendwin)
> struct socket *so = tptosocket(tp);
> u_int lowat, newsize;
> 
> - SOCK_RECVBUF_LOCK_ASSERT(so);
> + SOCK_SENDBUF_LOCK_ASSERT(so);
> 
> if (!V_tcp_do_autosndbuf || (so->so_snd.sb_flags & SB_AUTOSIZE) == 0)
> return;
The patch looks good to me. Sorry for no catching that when reviewing the patch.

Best regards
Michael
> 
> —
> Kristof