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>
Tested on a gateway on 2026-11-28 (26.7.9, cmm run by hand): NATed LAN
flows and port forwards were offloaded through OPNsense's automatic
route-to/reply-to rules, only offloaded states were sloppy (502 for 253
flows), no events were lost, pfctl -k stopped an offloaded download at
once with its hardware flows removed, pf saw TCP connections close
(22 TCP state deletions in a minute), and stopping cmm emptied the
hardware tables.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two problems found while preparing the gateway test.
pf_notify reported s->kif as a state's interface. A floating state
(OPNsense's default) has kif "all", so cmm's check that the routes leave
by the states' interfaces failed for every flow and nothing would have
been offloaded. Events now carry orig_kif, the interface the state was
created on.
OPNsense's automatic rules put route-to on the force-gateway rule, which
matches every NATed flow leaving WAN, and reply-to on WAN rules (port
forwards). The blanket route veto kept all of it on the software path.
pf_notify now passes a route-to/reply-to target in the event (which grows
to 160 bytes, the ring to 20 MiB), and cmm offloads such a flow only
while the main routing table sends those packets out of the same
interface to the same next hop: route-to for the original direction,
reply-to for the reply. A route change already tears flows down and
re-runs that check. dup-to, a target without an interface, and one in
another address family still veto.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
publish mirrors the staged tree with rsync --delete-after, and the share
holds the only copy of series that are no longer built (26.1). A staging
tree rebuilt after /scratch was lost, holding only the current series,
would have deleted 26.1 from the live mirror. publish now stops, before
verifying, when the destination has a directory in its top two levels
(an ABI, a series, releases/<series>) that the staged tree lacks; names
are printed quoted. Retiring a series means deleting it from the share
by hand.
RELEASE.md documents the guard and how to restore the staged tree from
the share.
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>
pf_notify (kernel):
- V1: every event carries a veto mask: route-to/reply-to/dup-to, policy
routing (rtable), dummynet and ALTQ (shaper, limiters), log all and
pflow, scrub/set-tos/set-prio/max-mss. Hardware forwarding takes the
main routing table and skips all of it.
- V3: states are no longer all made sloppy at insert. CMM reports the
states it puts into hardware (PFN_IOC_OFFLOADED); only those are.
- V5: a DELETE that cannot be queued discards the ring and makes the
next read a RESYNC; INSERT and READY leave room for DELETEs. Counter
updates refresh a state's expiry only when packets moved, so an idle
offloaded flow expires and is removed.
cmm:
- A flow keeps both of its pf states (in, out). It is offloaded only
with both seen, neither vetoed, and pf's interfaces matching the
routes the hardware will use, which also catches route-to and policy
routing structurally. A DELETE of either state removes it (the NAT
companion's DELETE was ignored when it arrived first). A third state
for one flow keeps it on the software path.
- RESYNC wipes CDX and forgets every flow; READY rebuilds them.
- V4: bridge flows are refused while pf filters bridged traffic
(net.link.bridge.pfil_member or pfil_bridge).
- V2: cdx is built without DPA_IPSEC_OFFLOAD and cmm opens no PF_KEY
socket; a stub answers the SA lookups the conntrack code makes.
Builds clean against the 26.7.9 kernel; not yet tested on hardware.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- K2: config/lock-<version> gives tools, src, ports, plugins and core
their exact commits; build stops when a checkout differs (a tag moved
upstream, or src moved on), and fetches tags without --force.
build.sh lock resolves and writes them. lock-26.7.9 is what 26.7.9 was
built from, checked against the upstream tags.
- K3: verify --root reports symlinks that lead outside the tree or
nowhere, which publish (rsync -L) would follow; such a path is now
reported instead of crashing verify.
- K6: RELEASE.md no longer says core trusts only our key (it also trusts
upstream's, for changelog and bogons), and names no host or user.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Security fixes from the audit:
- V8 caam: the HMAC raw key (up to 128 bytes) was copied into a buffer
of the split key's size (32 bytes for MD5, 48 for SHA-1), reachable
through /dev/crypto. The buffer now fits both. caam_dma_free() zeroes
every buffer itself, which also fixes the QI path clearing twice the
split key buffer's size at each session teardown.
- V6 mwifiex: the uap_passphrase sysctl, readable by every local user,
is write-only; mwifiex_uap says to keep the passphrase in a 0600
/etc/rc.conf.d/mwifiex_uap.
- V9 dpaa_wifi: hardware frame lengths were copied into a 4 KB cluster
unchecked, and scatter/gather frames read as one buffer. One helper
now takes only contiguous frames within the buffer, at any length.
- V11: cdx frees IPsec keys and shared descriptors with zfree(); fmc's
state file moves from /tmp (symlink attack by any local user) to
/var/run.
- The firmware object pcieuart9098_combo_v1.bin.fwo is a build output
and no longer tracked.
caam, ina2xx and lp5812 were ported from Linux and relabelled BSD-2 by
the vendor (8f9b3bf, 84e318c, ac81eea). They are GPL-2.0-only again,
with the Linux sources' copyright holders; LICENSING.md lists them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The hook deleted /boot/kernel/kernel.bin once it was on the FAT
partition, so the health audit always reported it missing (seen on the
gateway after the 26.7.9 upgrade). It now leaves the kernel set's files
alone and returns early, without a space check or a log line, when the
kernel and device tree on the FAT partition are already the same.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The custom stop killed whatever pid the pid file held, ignored whether
that worked, removed the file and printed "Stopped cmm." On the gateway
cmm was still running right after it. rc.subr's own start, stop and
status (command=) send SIGTERM and wait for the exit, and only act on a
pid file that names a running cmm.
Tested through FreeBSD's rc.subr with a stand-in cmm that takes 2
seconds to exit, and with a stale pid file naming another process.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- pkg 2.8 (26.7) writes a package's catalogue checksum as "2$" and its
BLAKE2b-512 in pkg's base32; accept it next to pkg 2.3's SHA-256 hex
and check each against its own digest, read once for both. Latest/
signatures stay over the SHA-256: a BLAKE2b catalogue checks them when
deep, and only their key when shallow, as for the sets.
- TarSource members share the set's file object, which every read
seeks, and verify_repo reads them from eight threads: the 26.7.9
upgrade set failed at random packages. Reads now take turns.
- Report the upgrade set's results under its path, not ".".
- Clean up the trust objects' temporary directories.
Tests: the root and URL verify tests run again with BLAKE2b catalogues,
a pkg 2.8.4 checksum pins the encoding, and the upgrade set gets its
own tests (parallel reads of large packages, a tampered package in a
signed set, a bad .abi_hint).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
U-Boot boots boot/kernel/kernel.bin, and the gateway's 20-kernel-update
skips a kernel set without one, leaving the old kernel in place. FreeBSD
15 builds it only with WITH_KERNEL_BIN, which the 26.7.9 image build was
the first to notice; check the kernel set right after it is built.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since 26.7 the ports tree builds pkg from opnsense/pkg (2.8.4) and tools
compares the host's pkg with it; ports-mgmt/pkg is FreeBSD's 2.9.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- caam: the bus activate, deactivate and release resource methods take
no type and rid in FreeBSD 15.
- cdx: sys/cdefs.h defines __maybe_unused now; define it only if missing.
- 26.1 is end of life and no longer built: remove patches/26.1 and
make-26.1.conf, default to 26.7 and FreeBSD 15.1 throughout, and move
the build examples in README.md and RELEASE.md to 26.7.9. The 26.1
tree on the mirror stays, for gateways that still have to upgrade.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The security audit of the vendor's fastpath found that offloaded flows
ignore pf route-to/reply-to and gateway rules (VPN-as-gateway traffic can
leave on WAN), that pf_notify marks every pf state sloppy while cmm runs,
that bridged traffic is offloaded without pf, that hardware flows can
outlive their pf state, and that the IPsec exception path panics. New
images no longer enable cmm, and RELEASE.md gives the commands for a
gateway that was installed from the vendor's image. The board modules
still load; nothing is offloaded without cmm.
rc.d/20-kernel-update is our rewrite: its Mono copyright line goes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FreeBSD 15 names its ports repository FreeBSD-ports instead of FreeBSD,
so the release_N override created a second repository, which had no
mirror_type "srv" for its pkg+https URL and failed. setup now overrides
the first repository /etc/pkg/FreeBSD.conf defines, with mirror_type.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The CMM restart on interface reassignment moves to the MVC assignment
API, which replaced interfaces_assign.php in 26.7. The mirror patch is
unchanged but for the plist, where upstream's trusted key changed. Both
apply to core 26.7.9 with git am. caddy-custom's plugins are pinned at
their versions of 2026-11-11, when 26.7.9 was tagged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The build runs natively on arm64 since 2026-11-18: setup no longer installs
qemu-user-static and aarch64-binutils (and refuses a non-aarch64 host),
GATEWAY.conf drops PRODUCT_WANTS_CROSS, build no longer asks tools for an
xtools set, finish no longer moves one aside, and mk-image.sh no longer
sets up xtools or removes qemu. The pilot command, which timed ports
before the first full build, goes too.
Gateways are migrated with the shell commands in RELEASE.md, as
ApolloGuardian was, instead of migrate-device.sh; that includes the
custom mirror for a proxy that is not on 443 inside the LAN, and the
major upgrade's UPGRADE_RELEASE.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
drivers/mwifiex/Makefile links the vendor mlan sources and the firmware
from _vendor/ into its directory when building, and removes them on clean.
Those links were committed by accident (absolute /usr/deps/_vendor paths,
dangling everywhere else), and Portainer refuses to clone a repository
that contains symlinks. They are ignored now; the modules build the same.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tools makes Latest/ for the main repository only, and upstream's aux
repository has none either, so verify no longer requires it there. The Go
toolchain in aux ships ELF test data and race-detector objects for every
platform under /usr/local/go<N>/src/; that tree is exempt from the aarch64
check, nothing else of the Go packages is.
The first real 26.1.11 mirror now verifies clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tools signs the aux repository's catalogue only in a packages step run
with the key; its sign-packages re-signs the packages set's catalogue but
not the aux set's. Build runs without the key, so the aux catalogue stayed
unsigned and gwmirror verify rejected it. finish now unpacks the aux set,
signs its catalogue with pkg repo and repacks it before tools signs the set.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
finish's scan imported the image's pool with every dataset mounted under
an altroot. The pool's own dataset needs a mountpoint inside the read-only
root, so nothing was mounted, find scanned an empty directory, and the
export then failed with "pool is busy". The pool is now imported without
mounting, and each dataset is mounted read-only by itself. The root must
have /bin/sh, so an empty scan cannot pass. The export is retried, since
the pool stays busy for a while after the import and after an unmount.
build.sh now says when set -e stops it, and vm.sh sign returns finish's
exit status, not tee's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xcaddy fetches www/caddy-custom's plugins while it builds, at their
newest versions; caddy-l4 v0.1.3 (2026-11-09) needs caddy 2.11.7 and the
ports tree has 2.11.4, so the port failed. config/make-<series>.conf,
added to tools' make.conf by ports_make_conf, pins tools' plugin list at
the versions of 2026-07-01, when 26.1.11 was tagged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codeberg now compresses tag archives with GNU gzip instead of git's own,
so sysutils/sysinfo's 1.0.4 archive is 15546 bytes, not distinfo's 15618,
and FreeBSD's distfile cache serves the new one too. git archive of the
tag with git's gzip at level 6 reproduces the original exactly (SHA256
checked by the port). The FETCH_CMD wrapper does that for Codeberg tag
archives, after checking owner, repository and tag strictly, and is
renamed for the second kind of repair.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tools ran make clean after each port, which cleans every dependency with
the port's own flavor: a dependency with another flavor, or none, looks
for the wrong work-<flavor> and keeps its work directory. After a failure
tools removes the dependencies it built, and the stale directory claims
they are installed, so every later port needing them failed at once
(Rust: cmake not found; libxslt.so not found). build now has tools'
ports.sh remove every work directory instead, and stops if ports.sh no
longer has the two cleans it replaces.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ports tree's clean passes a flavored port's FLAVOR on to its
dependencies, so a dependency without flavors looks for work-<flavor> and
keeps its half-built work directory; its build tools are removed, and
every later port that needs it fails at once until the next step.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Rust build in the 12 GB VM lost two llvm-tblgen 2.8 hours in:
FreeBSD kills a process that has waited 30 seconds for a page, and the
emulated VM's pageout took that long with the swap unused. setup turns
those kills off (vm.pfault_oom_attempts=-1), and build caps lang/rust,
which builds its own LLVM with a job per CPU, at one job per 768 MB
through tools' make.conf.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
host_pkg fetched pkg's distfiles again for every build of the host
pkg, and GitHub turned one of its patches away four times in a row,
which stopped the build. It now seeds them into the distfiles set
(repair_distfiles, which skips what the set has) and extracts them
from there. port_distfiles names a port's entries in the set, for
both host_pkg and distfiles_in_set (whose awk now reads them from
the environment).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FreeBSD's tar lists an empty file as an empty archive, so a package
file cut off at zero bytes passed salvage_ports' check. A salvaged
package must now also hold +MANIFEST.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A 16 GB VM (18 GB in qemu, 7 GB of it ZFS cache) and the HTPC's other
work ran the HTPC out of memory, and its reboot lost 12 hours of the
ports step. The VM now gets a swap disk of its own (swap.qcow2, serial
gwswap, cache=none: off ZFS, where swap can deadlock, and past the
host's page cache), and setup caps the VM's ZFS cache at 2 GB
(vm_memory). The VM itself goes down to 12 GB in vm.conf.
Tools writes the packages set only when a ports step ends. build now
first adds what an interrupted step had finished (salvage_ports): the
runtime packages in the stage's packages directory, when the stage
belongs to the same series, version and ports commit, each checked to
be a whole archive. Build-only dependencies are rebuilt.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The restarted build stopped at seeding pkg's distfiles: GitHub
answered "Service Unavailable" for a patch the distfiles set already
held. repair_distfiles now skips a port whose distfiles and patch
files are all in the set (distfiles_in_set), and fetch-patch.sh tries
GitHub's current patch three times, a minute apart.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tools caches the build-only dependencies it builds (cmake, autoconf,
the Rust and Go compilers) for the rest of a ports step only, and the
packages set keeps just the listed ports and their runtime
dependencies. Each chunk therefore rebuilt them: the second chunk
started by rebuilding the autotools the first had built.
The step also runs without an argument now: an argument makes tools
stop at the first failed port, while without one it goes on with the
others and fails at the end. ports_list served only the chunks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tools' distfiles step walks every port's whole dependency tree again,
one make at a time: 70 of 266 ports in 9 hours under emulation. It
also walks the default flavor's tree for flavored ports (QEMU's desktop
dependencies for qemu@guestagent) and fails there on a port the build
never needs (gstreamer1-plugins-bad, missing from its distinfo). The
ports step fetches what it builds anyway, so the step is dropped, and
with it the tools patch that only fixed it.
pkg's distfiles are seeded into the distfiles set (which tools
extracts into the ports chroot) before the first chunk. A chunk whose
log shows "Couldn't fetch it" or "Giving up on fetching files" has
those ports repaired with fetch-patch.sh and runs once more.
fetch_failures accepts only port names, tested against real and
crafted logs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Natively, the first fetch in tools' distfiles chroot builds pkg, whose
GitHub patches no longer match distinfo, and tools' fetch loop records
a failure in a path outside the chroot, which under sh -e ended the
loop with no port named. patches/tools/0001 records failures inside
the chroot (as tools' ports step does); build.sh applies patches/tools
to every series. pkg's distfiles go into the set before the step, via
fetch-patch.sh; repairs are appended to the set instead of rewriting
a set of many gigabytes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Excluding all of dist/ (to keep the VM's build output from --delete)
also skipped dist/.keep, so the VM's checkout looked dirty and
build.sh would refuse to build.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Debian's qemu-system-arm only recommends ipxe-qemu, so the virtio NIC's
efi-virtio.rom is missing from the image and qemu refused to start. The
VM never network-boots: drop the ROM. A qemu that exits at once now
shows its log instead of vm.sh waiting minutes to say it stopped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
qemu-user cannot run cargo, so no Rust port (py-cryptography and its
dependents) can be cross-built. The build VM is now FreeBSD arm64 under
full-system emulation (qemu-system-aarch64, TCG), run by the new
release/vmhost.sh in a rootless podman container on the build host
GW_VMHOST. vm.sh drives it over ssh and reaches the VM's loopback-only
ssh port through the host (ProxyJump). Settings may live in
$GW_KEYDIR/vm.conf.
The image download probes its sources, resumes stalled transfers and
falls back to a mirror that keeps old releases; the checksum always comes
from FreeBSD itself.
build.sh builds the ports in chunks of PORTS_CHUNK (20) with timings, so
progress is visible and a failure costs one chunk, then runs the whole
list once more to bundle the set. ports_list evaluates ports.conf like
tools' list_config does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its distfiles stayed in /usr/ports/distfiles, the lower layer of the
unionfs mount tools puts in every chroot, and the ports step's
rm -rf of distfiles/ there failed with "Operation not supported".
Fetch and build it under /var/tmp instead and remove that afterwards.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The mirror share refuses ":" in names, ignores case, and lists device
names such as "aux" under a mangled 8.3 name, which rsync would delete as
an unknown file (the real directory). So FreeBSD:<N>:aarch64 is stored
as FreeBSD_<N>_aarch64 and a series' aux repository as aux-repo, in the
staged tree and on the share alike; nginx rewrites the client URLs onto
them, and gwmirror reads and writes through the same mapping.
verify --root, and therefore publish, now fails on any other name the
share cannot store (reserved characters, device names, trailing dot or
space, names differing only in case).
Checked with the real nginx image in podman: a deep verify --url of a
staged fixture passes, aux included, with the live changelog/bogons proxy.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first pilot stopped building the host pkg: GitHub now abbreviates the
object names on the index lines of its generated commit patches with 10
digits instead of 9, so OPNsense's patches of ports-mgmt/pkg no longer
match distinfo, and nothing caches OPNsense's own distfiles.
- release/fetch-patch.sh: FETCH_CMD that, when fetch(1) fails for a
GitHub commit/pull/compare patch, shortens the abbreviations until the
size matches; the port's checksum target verifies the SHA256.
- build.sh: run tools' distfiles step on its own, repair the ports it
could not fetch on the host into the distfiles set, and rerun it; the
pilot fetches its ports' distfiles too; host pkg uses the wrapper.
- vm.sh sync: files owned by root in the VM. They kept the workstation's
uid, git refused the "dubious" repository, and that defeated the dirty
check silently. build.sh now fails when git cannot read /usr/deps, and
the package target refuses a version without the commit count.
- migrate-device.sh: FreeBSD grep rejects the empty alternative in the
fingerprint file check, so it failed on every device. Found by running
release/tests on the build VM, now part of the documented test run.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>