Re: git: 3fade68cfdf9 - main - iflib: accurately count bytes/segments for TSO

From: Roger Pau Monné <royger_at_freebsd.org>
Date: Mon, 20 Apr 2026 10:43:35 UTC
On Mon, Apr 20, 2026 at 11:56:18AM +0200, Michael Tuexen wrote:
> 
> 
> > On 20. Apr 2026, at 10:26, Roger Pau Monné <royger@freebsd.org> wrote:
> > 
> > On Fri, Apr 17, 2026 at 05:35:06PM +0000, Andrew Gallatin wrote:
> >> The branch main has been updated by gallatin:
> >> 
> >> URL: https://cgit.FreeBSD.org/src/commit/?id=3fade68cfdf95ee0b517b5d69b270bd8da633404
> >> 
> >> commit 3fade68cfdf95ee0b517b5d69b270bd8da633404
> >> Author:     Andrew Gallatin <gallatin@FreeBSD.org>
> >> AuthorDate: 2026-04-17 15:45:22 +0000
> >> Commit:     Andrew Gallatin <gallatin@FreeBSD.org>
> >> CommitDate: 2026-04-17 17:34:27 +0000
> >> 
> >>    iflib: accurately count bytes/segments for TSO
> >> 
> >>    When using software based ifnet counters, iflib has not factored
> >>    TSO into account when reporting the segments and bytes sent.
> >>    So it will underreport NIC bandwidth by a small percent,
> >>    and will undercount sent segments by a large factor.
> >>    Fix this by calculating the number of added segments the NIC
> >>    will send, and add header size multiplied by that number
> >>    to arrive at a correct accounting of segments and bytes sent.
> >>    This makes these software counters directly comparable to
> >>    hardware counters.
> >> 
> >>    Doing this requires moving the calculation into iflib_encap() where
> >>    we have already parsed the packet and know the header size, MSS, etc.
> > 
> > Hello,
> > 
> > This causes a reliable crash on my box when I attempt to ssh into it:
> > 
> > panic: Assertion mp != NULL && *mp != NULL failed at /usr/src/sys/net/iflib.c:3922
> > cpuid = 11
> > time = 1776673321
> > KDB: stack backtrace:
> > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe0115bbf3e0
> > vpanic() at vpanic+0x136/frame 0xfffffe0115bbf510
> > panic() at panic+0x43/frame 0xfffffe0115bbf570
> > iflib_txq_drain() at iflib_txq_drain+0x429/frame 0xfffffe0115bbf5f0
> > drain_ring_lockless() at drain_ring_lockless+0x8a/frame 0xfffffe0115bbf640
> > ifmp_ring_enqueue() at ifmp_ring_enqueue+0x332/frame 0xfffffe0115bbf690
> > iflib_if_transmit() at iflib_if_transmit+0x273/frame 0xfffffe0115bbf710
> > bridge_enqueue() at bridge_enqueue+0x214/frame 0xfffffe0115bbf760
> > bridge_output() at bridge_output+0x10a/frame 0xfffffe0115bbf7b0
> > ether_output() at ether_output+0x689/frame 0xfffffe0115bbf840
> > ip_output() at ip_output+0x183d/frame 0xfffffe0115bbf960
> > tcp_default_output() at tcp_default_output+0x21d8/frame 0xfffffe0115bbfb30
> > tcp_usr_send() at tcp_usr_send+0x5d0/frame 0xfffffe0115bbfbe0
> > sosend_generic_locked() at sosend_generic_locked+0x59b/frame 0xfffffe0115bbfc90
> > sosend_generic() at sosend_generic+0x61/frame 0xfffffe0115bbfce0
> > sousrsend() at sousrsend+0x79/frame 0xfffffe0115bbfd40
> > dofilewrite() at dofilewrite+0x81/frame 0xfffffe0115bbfd90
> > sys_write() at sys_write+0x127/frame 0xfffffe0115bbfe00
> > amd64_syscall() at amd64_syscall+0x169/frame 0xfffffe0115bbff30
> > fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe0115bbff30
> > --- syscall (4, FreeBSD ELF64, write), rip = 0x297fd795023a, rsp = 0x297fccb77d98, rbp = 0x297fccb77dc0 ---
> > KDB: enter: panic
> > [ thread pid 3093 tid 100634 ]
> > Stopped at      kdb_enter+0x33: movq    $0,0x15dd302(%rip)
> > db>
> > 
> > My network config is:
> > 
> > ifconfig_igc0="DHCP"
> > cloned_interfaces="bridge0"
> > ifconfig_bridge0="addm igc0"
> Can you check if
> https://cgit.FreeBSD.org/src/commit/?id=cca22c36c306dfabe13b1d1de10e8d27ef3c3bce <https://cgit.freebsd.org/src/commit/?id=cca22c36c306dfabe13b1d1de10e8d27ef3c3bce>
> fixes the issue for you?

Oh, yes it does.  I could swear I've tested it (as I've fetched the
repo this morning), but I clearly didn't.

Sorry for the noise.

Thanks, Roger.