Re: git: 7146ad04f18e - main - tcp: refactor tcp_autosndbuf() and associated sysctls
Date: Thu, 22 Oct 2026 09:29:30 UTC
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.
I’m seeing this panic whenever I try to ssh into my dev box:
panic: mutex so_rcv not owned at /usr/src/sys/netinet/tcp_output.c:2157
cpuid = 4
time = 1792657806
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x36/frame
0xfffffe00343b34a0
vpanic() at vpanic+0x149/frame 0xfffffe00343b35d0
panic() at panic+0x43/frame 0xfffffe00343b3630
__mtx_assert() at __mtx_assert+0xa9/frame 0xfffffe00343b3640
tcp_autosndbuf() at tcp_autosndbuf+0x32/frame 0xfffffe00343b3670
tcp_default_output() at tcp_default_output+0x651/frame
0xfffffe00343b3840
tcp_do_segment() at tcp_do_segment+0x2db5/frame 0xfffffe00343b3940
tcp_input_with_port() at tcp_input_with_port+0x10ec/frame
0xfffffe00343b3a90
tcp_input() at tcp_input+0xb/frame 0xfffffe00343b3aa0
ip_input() at ip_input+0x271/frame 0xfffffe00343b3b00
netisr_dispatch_src() at netisr_dispatch_src+0xbf/frame
0xfffffe00343b3b60
ether_demux() at ether_demux+0x17a/frame 0xfffffe00343b3ba0
ether_nh_input() at ether_nh_input+0x3b4/frame 0xfffffe00343b3bf0
netisr_dispatch_src() at netisr_dispatch_src+0xbf/frame
0xfffffe00343b3c50
ether_input() at ether_input+0xe9/frame 0xfffffe00343b3cb0
iflib_rxeof() at iflib_rxeof+0x919/frame 0xfffffe00343b3de0
_task_fn_rx() at _task_fn_rx+0xce/frame 0xfffffe00343b3e30
gtaskqueue_run_locked() at gtaskqueue_run_locked+0x1a8/frame
0xfffffe00343b3ec0
gtaskqueue_thread_loop() at gtaskqueue_thread_loop+0xd3/frame
0xfffffe00343b3ef0
fork_exit() at fork_exit+0x82/frame 0xfffffe00343b3f30
fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe00343b3f30
--- trap 0xafafafaf, rip = 0xafafafafafafafaf, rsp =
0xafafafafafafafaf, rbp = 0xafafafafafafafaf ---
—
Kristof