README: how to turn hardware flow offload on and off, and its caveats

Offload stays off by default: it is only needed for multi-gigabit
throughput on the 10 GbE ports. The README says how to turn it on and
off (in /etc/rc.conf.local; onestop, since rc.subr refuses a plain stop
once it is disabled) and lists the caveats: no TCP sequence checks for
offloaded flows, Suricata/Zenarmor/NetFlow/tcpdump see only their first
packets, VLAN and rule counters miss hardware traffic, the MAC address
gap, what is untested, and the reboot after an update. RELEASE.md keeps
the design and points there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jeremy Karst 2026-11-28 04:16:25 -05:00
parent 64240400dc
commit 1f06ea3817
3 changed files with 66 additions and 18 deletions

View file

@ -52,7 +52,7 @@ kernel boot
└─► kldload cdx fci pf_notify auto_bridge
└─► dpa_app /etc/cdx_pcd.xml /etc/cdx_cfg.xml /etc/cdx_sp.xml
└─► service cmm start (only with cmm_enable="YES"; images
ship "NO", see RELEASE.md)
ship "NO", see README.md)
```
## Fastpath Modules

View file

@ -67,6 +67,52 @@ on performance or functionality.
| Port 4 | dtsec3 | 10 GbE SFP+ |
| Port 5 | dtsec4 | 10 GbE SFP+ |
## Hardware flow offload (off by default)
The fast-path stack can forward established connections in FMan hardware
instead of through pf. It is only worth turning on for throughput pf cannot
reach in software, i.e. multi-gigabit traffic on the 10 GbE ports. Images
ship with it off (`cmm_enable="NO"` in `/etc/rc.conf.local`); the board
modules load either way.
Turn it on (the setting belongs in `/etc/rc.conf.local`, which overrides
`/etc/rc.conf`):
```sh
sh
sysrc -f /etc/rc.conf.local cmm_enable=YES
service cmm start
```
Turn it off:
```sh
sh
sysrc -f /etc/rc.conf.local cmm_enable=NO
service cmm onestop
```
pf still decides every connection: filtering, NAT, port forwards and routing
stay pf's, and killing a state removes its hardware flow. Flows whose rules
need pf for every packet (shaper, policy routing to another gateway, scrub,
MSS clamping, `log (all)`) stay in software. Caveats for offloaded flows:
- pf no longer checks their TCP sequence numbers (their states are sloppy).
- Suricata, Zenarmor, Insight/NetFlow and tcpdump see only their first
packets. Leave offload off if you rely on them.
- VLAN interface counters and per-rule counters miss hardware traffic
(physical port counters and per-state counters include it). Captive
portal accounting probably does too.
- cmm does not notice a next hop's MAC address changing (a new ISP modem, a
LAN host with a new NIC but the same IP) and keeps sending its flows to
the old one. Run `service cmm restart` after such a change.
- Not tested: IPv6, links with different MTUs (PPPoE, VPN), CARP/pfsync.
- After updating `mono-gateway`, reboot so the loaded `pf_notify.ko`
matches the new cmm; until then nothing is offloaded.
How cmm decides what to offload: [RELEASE.md](RELEASE.md), "Hardware flow
offload".
## Build instructions
The whole release, not just this package, has to be built for aarch64:

View file

@ -336,20 +336,15 @@ release/vm.sh pull-out 15.1 26.7 # -> /scratch/mono-opnsense/out/26.7
e.g. `26.1.11_74`. That always upgrades the previous build, and also the
vendor's `26.1.5_N` packages.
### Hardware flow offload (opt-in)
### Hardware flow offload (off by default)
With cmm running, FMan forwards established flows in hardware: pf decides a
flow's first packets, then the hardware forwards the rest with pf's
translation, and pf's states and counters follow it. Images set
translation, and pf's states and counters follow it. It is only needed for
multi-gigabit throughput on the 10 GbE ports, so images set
`cmm_enable="NO"` (`rc.d/rc.conf.local`): the board modules load, but
nothing is offloaded until cmm is turned on. `/etc/rc.conf.local` overrides
`/etc/rc.conf`, so set it there:
```sh
sh
sysrc -f /etc/rc.conf.local cmm_enable=YES
service cmm start
```
nothing is offloaded until cmm is turned on. Turning it on and off, and its
caveats for users, are in README.md ("Hardware flow offload").
A flow goes into hardware only where that does what pf would have done
(`fastpath/pf_notify/`, `fastpath/cmm/cmm_conn.c`, ARCHITECTURE.md):
@ -370,11 +365,18 @@ A flow goes into hardware only where that does what pf would have done
if deletion events are ever lost, cmm drops every hardware flow
(`net.pfnotify.resyncs`).
Offloaded packets never reach the host, so whatever watches interfaces in
software misses them: Suricata (IDS and IPS), Insight/NetFlow, tcpdump.
Leave cmm off if forwarded traffic must pass through those. IPsec is not
offloaded (the vendor's IPsec offload was removed); it runs in FreeBSD's
stack, with CAAM through crypto(9).
Offloaded packets never reach the host, so software that watches
interfaces (Suricata, Zenarmor, Insight/NetFlow, tcpdump) misses them, and
so do counters kept in software (VLAN interfaces, pf rules); physical ports
count in hardware, and cmm copies the hardware's counts into pf's states.
IPsec is not offloaded (the vendor's IPsec offload was removed); it runs in
FreeBSD's stack, with CAAM through crypto(9).
Known gap: cmm resolves a next hop's MAC address when it programs the route
and only reacts to changes of the next hop's address or interface
(`cmm_route_handle_change()`; `cmm_neigh_invalidate()` has no caller), so a
next hop that changes its MAC keeps receiving at the old one until cmm is
restarted.
After updating `mono-gateway` with cmm on, reboot: until then the new cmm
and the loaded `pf_notify.ko` differ, and cmm offloads nothing (it logs
@ -627,8 +629,8 @@ reboot
the Wi-Fi card is fitted;
- System > Firmware > Status > Audit > Health is clean.
**10. Turn off hardware flow offload** for now (see "Hardware flow offload
(opt-in)" for turning it on later). The vendor image's `/etc/rc.conf.local`
**10. Turn off hardware flow offload** (see "Hardware flow offload (off by
default)"; README.md has how to turn it on later). The vendor image's `/etc/rc.conf.local`
enables cmm and no package manages that file:
```sh