cmm put a next hop's MAC into CDX when it programmed the route and then
only watched the next hop's address and interface. A next hop that
changed its MAC (a new ISP modem, an IP reused by another LAN host) kept
receiving its flows at the old MAC, possibly another host's, and new
flows reused the stale route until cmm was restarted. Neighbors no route
used also stayed cached as resolved, so a later route to the same IP got
the old MAC without asking the kernel.
cmm_neigh_check() now re-reads the ARP and NDP tables (one dump per
family) and marks every cached neighbor whose MAC changed or is gone;
cmm_route_check_neighbors() deregisters the routes using it and their
offloaded flows, which re-offload once the next hop resolves again. It
runs every maintenance cycle (30 s) and after route-socket changes, and
cmm_route_handle_change() also treats a different MAC as a change. The
last reference to a neighbor frees it. The link-layer table parser is
shared by both lookups and bounds-checks each entry's length.
pf_notify vetoes af-to (NAT64) states: their two keys are in different
address families, which cmm cannot program.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
RELEASE.md: the "offload: off" section becomes "opt-in": how to turn cmm
on (in /etc/rc.conf.local, which overrides rc.conf), which flows go into
hardware and which stay in pf, what offloaded packets still skip
(Suricata, Insight/NetFlow, tcpdump), the reboot after an update, and
what was wrong with the vendor's offload.
ARCHITECTURE.md: pf_notify's RESYNC event, vetoes, route-to target and
orig_kif, the DELETE reserve, sloppy only for offloaded states, and the
flow lifecycle with the offload conditions; the PF_KEY socket is gone
with the IPsec code; cmm only starts with cmm_enable="YES".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cdx no longer builds it, so it goes: cdx's dpa_ipsec_freebsd.c and
cdx_dpa_ipsec_freebsd.c, the vendor control_ipsec.c and query_ipsec.c,
and cmm's PF_KEY handling (cmm_ipsec.c). FreeBSD's IPsec stack handles
all IPsec; flows into a tunnel never match the hardware's routes, so
cmm keeps them on the software path.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fix a bug in pf_notify where pfn_mark_notified() was called before
pfn_queue_event(). If the ring buffer was full, the READY event was
dropped but the state was already marked as notified — it would never
re-fire, leaving the connection permanently in the software path.
Move pfn_mark_notified() inside the lock, after successful ring_put().
On drop, the state is NOT marked, so the next packet re-triggers READY.
Enlarge the ring buffer from 4K to 128K entries and the notified hash
from 16K to 128K entries, both dynamically allocated (~17 MB total).
Add ring_hwm and ring_used diagnostic sysctls.
With the one-shot ordering fix and larger ring, the polling fallback
in CMM is no longer necessary. Remove cmm_conn_poll() and all
associated code (DIOCGETSTATESV2, epoch-based GC, -p flag, /dev/pf).
CMM now requires pf_notify.ko and uses push events exclusively.
Add cmm_conn_maintenance() as a 30-second timer that retries offload
for pending connections (e.g., after route changes) and runs route GC.
Delete cmm_offload.c/h (poll-path eligibility, now dead code) and
cmm_deny_check() (poll-path deny wrapper).
Add a kevent registration safety check that skips invalid fds to
prevent a single bad fd from killing the entire kqueue setup.