opnsense-src/sys
Mark Johnston ce12afaa6f netmap: Fix queue stalls with generic interfaces
In emulated mode, the FreeBSD netmap port attempts to perform zero-copy
transmission.  This works as follows: the kernel ring is populated with
mbuf headers to which netmap buffers are attached.  When transmitting,
the mbuf refcount is initialized to 2, and when the counter value has
been decremented to 1 netmap infers that the driver has freed the mbuf
and thus transmission is complete.

This scheme does not generalize to the situation where netmap is
attaching to a software interface which may transmit packets among
multiple "queues", as is the case with bridge or lagg interfaces.  In
that case, we would be relying on backing hardware drivers to free
transmitted mbufs promptly, but this isn't guaranteed; a driver may
reasonably defer freeing a small number of transmitted buffers
indefinitely.  If such a buffer ends up at the tail of a netmap transmit
ring, further transmits can end up blocked indefinitely.

Fix the problem by removing the zero-copy scheme (which is also not
implemented in the Linux port of netmap).  Instead, the kernel ring is
populated with regular mbuf clusters into which netmap buffers are
copied by nm_os_generic_xmit_frame().  The refcounting scheme is
preserved, and this lets us avoid allocating a fresh cluster per
transmitted packet in the common case.  If the transmit ring is full, a
callout is used to free the "stuck" mbuf, avoiding the queue deadlock
described above.

Furthermore, when recycling mbuf clusters, be sure to fully reinitialize
the mbuf header instead of simply re-setting M_PKTHDR.  Some software
interfaces, like if_vlan, may set fields in the header which should be
reset before the mbuf is reused.

Reviewed by:	vmaffione
MFC after:	1 month
Sponsored by:	Zenarmor
Sponsored by:	OPNsense
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D38065
2023-04-05 12:12:30 -04:00
..
amd64 linux(4): Regen for close_range syscall 2023-04-04 23:23:37 +03:00
arm netlink: add NETLINK to the DEFAULTS for each architecture 2023-04-02 15:27:21 +00:00
arm64 linux(4): Regen for close_range syscall 2023-04-04 23:23:37 +03:00
bsm
cam nvme: fix resv commands with nda device 2023-03-27 14:53:24 +02:00
cddl dtrace/powerpc: Remove accidental commented out line 2023-03-13 11:37:40 -04:00
compat linux(4): Implement close_range over native 2023-04-04 23:24:04 +03:00
conf zfs: merge openzfs/zfs@431083f75 2023-04-03 16:49:30 +02:00
contrib zfs: fix null ap->a_fsizetd NULL pointer derefernce 2023-04-05 09:33:32 +02:00
crypto OpenSSL: Regen an assembly file for arm 2023-03-21 15:13:51 -04:00
ddb ddb: ansify 2023-02-08 00:09:23 +00:00
dev netmap: Fix queue stalls with generic interfaces 2023-04-05 12:12:30 -04:00
dts arm64/rockchip: Remove rk3328-dwc3 overlays 2022-11-16 11:58:32 +01:00
fs pseudofs: Simplify pfs_visible_proc 2023-04-02 11:24:10 +03:00
gdb ddb: use _FLAGS command macros where appropriate 2022-07-05 11:56:55 -03:00
geom graid3: Pre-allocate the timeout event structure 2023-03-30 13:38:15 -04:00
gnu bwn: eliminate dead writes in BWN_GPL_PHY 2022-05-04 09:32:59 -04:00
i386 linux(4): Regen for close_range syscall 2023-04-04 23:23:37 +03:00
isa Adjust function definition in isa's pnp.c to avoid clang 15 warning 2022-07-27 21:13:59 +02:00
kern Regen 2023-04-04 16:19:08 +03:00
kgssapi nfsd: Enable the NFSD_VNET vnet front end macros 2023-02-18 14:59:36 -08:00
libkern ashldi3: Use C89-style function definition 2022-11-27 13:23:25 -07:00
modules Update rack to the latest code used at NF. 2023-04-04 16:05:46 -04:00
net infiniband: Opt-in for net epoch 2023-04-06 00:08:23 +08:00
net80211 net80211: make ieee80211_scan_dump_channels private 2023-03-14 22:17:03 +00:00
netgraph ng_atmllc: remove 2023-03-09 18:04:21 +00:00
netinet tcp_hpts: plug a compiler warn 2023-04-05 14:32:13 +00:00
netinet6 inet6: protect address manipulation with a lock 2023-03-30 08:46:38 +00:00
netipsec ipsec: only update lastused when it changes 2023-02-16 07:33:51 +00:00
netlink netlink: allow exact-match route lookups via RTM_GETROUTE. 2023-04-02 13:47:10 +00:00
netpfil pf: remove pd_refs from pfsync 2023-03-28 01:18:07 +02:00
netsmb
nfs Allow any user to read the NFS stats, for example with nfsstat(1). 2022-12-01 22:21:14 -07:00
nfsclient
nfsserver
nlm nlm: only access refcounts using dedicated primitives 2022-11-24 19:46:43 +00:00
ofed infiniband: Opt-in for net epoch 2023-04-06 00:08:23 +08:00
opencrypto Complete removal of opt_compat.h 2023-02-13 19:07:38 +03:00
powerpc netlink: add NETLINK to the DEFAULTS for each architecture 2023-04-02 15:27:21 +00:00
riscv netlink: add NETLINK to the DEFAULTS for each architecture 2023-04-02 15:27:21 +00:00
rpc svc_rpcsec_gss.c: Separate out the non-vnet initialization 2023-03-01 15:29:25 -08:00
security kdb: Modify securelevel policy 2023-03-30 10:45:00 -04:00
sys Change kqueue1() to be compatible with NetBSD 2023-04-05 06:29:49 +03:00
teken
tests
tools Improve debuggability of VOP_* locking assertions 2023-01-18 22:11:05 -06:00
ufs Improvement in UFS/FFS directory placement when doing mkdir(2). 2023-03-29 21:13:27 -07:00
vm vnode_pager_input: return runningbufspace back 2023-03-26 00:55:29 +02:00
x86 xen/intr: rework xen_intr_resume() for in-place remapping 2023-03-29 09:51:45 +02:00
xdr xdr: ansify 2023-02-13 18:37:31 +00:00
xen xen: switch to using core atomics for synchronization 2023-03-29 09:51:42 +02:00
Makefile Remove dead code in the cscope target 2022-11-11 15:53:57 +00:00
README.md note that some arch independent code can live in dev (e.g. SMBios) 2023-03-03 01:54:07 -08:00

FreeBSD Kernel Source:

This directory contains the source files and build glue that make up the FreeBSD kernel and its modules, including both original and contributed software.

Kernel configuration files are located in the conf/ subdirectory of each architecture. GENERIC is the configuration used in release builds. NOTES contains documentation of all possible entries. LINT is a compile-only configuration used to maximize build coverage and detect regressions.

Source Roadmap:

Directory Description
amd64 AMD64 (64-bit x86) architecture support
arm 32-bit ARM architecture support
arm64 64-bit ARM (AArch64) architecture support
cam Common Access Method storage subsystem - cam(4) and ctl(4)
cddl CDDL-licensed optional sources such as DTrace
conf kernel build glue
compat Linux compatibility layer, FreeBSD 32-bit compatibility
contrib 3rd-party imported software such as OpenZFS
crypto crypto drivers
ddb interactive kernel debugger - ddb(4)
fs most filesystems, excluding UFS, NFS, and ZFS
dev device drivers and other arch independent code
gdb kernel remote GDB stub - gdb(4)
geom GEOM framework - geom(4)
i386 i386 (32-bit x86) architecture support
kern main part of the kernel
libkern libc-like and other support functions for kernel use
modules kernel module infrastructure
net core networking code
net80211 wireless networking (IEEE 802.11) - net80211(4)
netgraph graph-based networking subsystem - netgraph(4)
netinet IPv4 protocol implementation - inet(4)
netinet6 IPv6 protocol implementation - inet6(4)
netipsec IPsec protocol implementation - ipsec(4)
netpfil packet filters - ipfw(4), pf(4), and ipfilter(4)
opencrypto OpenCrypto framework - crypto(7)
powerpc PowerPC/POWER (32 and 64-bit) architecture support
riscv 64-bit RISC-V architecture support
security security facilities - audit(4) and mac(4)
sys kernel headers
tests kernel unit tests
ufs Unix File System - ffs(7)
vm virtual memory system
x86 code shared by AMD64 and i386 architectures