Commit graph

41 commits

Author SHA1 Message Date
ae932c9c46 Offload: follow next-hop MAC changes; veto af-to
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>
2026-11-28 04:22:57 -05:00
1f06ea3817 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>
2026-11-28 04:16:25 -05:00
64240400dc Docs: hardware flow offload is opt-in and keeps pf's decisions
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>
2026-11-28 02:08:48 -05:00
49db816186 gwmirror publish: refuse to delete a series from the share
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>
2026-11-28 01:32:15 -05:00
3277066c5a Release tooling: commit lock per release, escaping symlinks, doc fixes
- 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>
2026-11-27 21:30:15 -05:00
5e215f5997 20-kernel-update: leave kernel.bin where the kernel set put it
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>
2026-11-27 18:54:16 -05:00
f34695776d gwmirror: verify pkg 2.8 catalogues and the major upgrade's set
- 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>
2026-11-27 16:33:59 -05:00
a72fc09862 build.sh: fail early on a kernel set without kernel.bin
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>
2026-11-27 15:20:05 -05:00
8716b582b3 build.sh: build the host pkg from opnsense/pkg, as tools checks
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>
2026-11-23 19:38:52 -05:00
87893ded3e Build 26.7 for FreeBSD 15 only; port caam and cdx to its kernel
- 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>
2026-11-23 19:26:41 -05:00
99d56a310d RELEASE.md: FreeBSD 15 dropped GEOM_BDE from the GATEWAY kernel config
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 16:52:50 -05:00
eedcb25199 RELEASE.md: the broken pf commit on Mono's 26.7 branch
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:17:37 -05:00
67ee1582c9 Turn hardware flow offload off; drop the Mono copyright line
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>
2026-11-22 21:12:19 -05:00
569b1f3b95 26.7.9: core patches and caddy-custom plugin pins
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>
2026-11-22 20:45:30 -05:00
e1b9aa77fd Drop the cross-build leftovers, pilot and migrate-device.sh
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>
2026-11-22 20:41:11 -05:00
5f4afd0155 RELEASE.md: setting the custom mirror from the shell
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 20:25:17 -05:00
f1f299920a RELEASE.md: a gateway that reaches the mirror on another port
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 20:21:15 -05:00
0342256eb9 verify: no Latest/ in the aux repo; Go's source tree is cross-platform
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>
2026-11-22 18:30:09 -05:00
90dd8bb200 finish: sign the aux set's catalogue
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>
2026-11-22 17:34:56 -05:00
1d27c40b84 Scan the image dataset by dataset; report silent failures
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>
2026-11-22 16:40:09 -05:00
f5fa1360bf Pin caddy-custom's plugins at the versions of the 26.1.11 tag
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>
2026-11-22 09:29:09 -05:00
097d18f940 Recover Codeberg tag archives; fetch-patch.sh is now fetch-distfile.sh
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>
2026-11-22 08:45:46 -05:00
1bba2be945 Remove all work directories after each port in tools' ports step
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>
2026-11-20 18:11:57 -05:00
01e09eccd2 RELEASE.md: why a failed Rust fails at once for the rest of a step
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>
2026-11-20 18:02:51 -05:00
98b6a457ad Cap Rust's build jobs by memory; no page-wait kills in the VM
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>
2026-11-20 17:46:16 -05:00
fc2481ecac build: the host pkg's distfiles come from the distfiles set
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>
2026-11-20 13:59:34 -05:00
f31a70765a build: salvage only whole packages with a manifest
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>
2026-11-20 13:52:43 -05:00
1addff9484 build VM: swap disk, small ZFS cache; salvage interrupted ports steps
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>
2026-11-20 13:50:02 -05:00
d8bba11344 build: skip distfiles the set already has; retry GitHub patches
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>
2026-11-19 23:41:58 -05:00
9eceff0663 build: build the ports in one tools step, not in chunks
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>
2026-11-19 23:35:12 -05:00
52f795704a Fetch distfiles as the ports build, repairing failed fetches per chunk
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>
2026-11-19 16:15:18 -05:00
b59c0e41ed Repair distfiles that tools' chroot cannot fetch, and let tools list them
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>
2026-11-19 06:45:58 -05:00
dcc4d129ab Build natively in an emulated arm64 VM on a remote build host
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>
2026-11-18 23:42:04 -05:00
3c3cd5e719 RELEASE.md: publish into a folder of the share
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 15:44:58 -05:00
5665956249 mirror: store the tree under names an SMB share can hold
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>
2026-11-18 14:49:20 -05:00
1ab64f5ba2 Recover GitHub-generated patch distfiles; fix git ownership in the VM
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>
2026-11-18 13:43:10 -05:00
f8276aa54a RELEASE.md: the forks must be publicly readable
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 02:06:57 -05:00
4433e98531 build.sh: never let git prompt for credentials
The hang blamed on Forgejo in the previous commit was git waiting at an
invisible username prompt: the forks are internal to code.karsttech.com
and the build VM has no credentials. Fail at once instead, and correct
the reason for the shallow src fetch (its history is not needed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 01:33:10 -05:00
2c66209351 build.sh: fetch the src fork shallow, time out stalled git transfers
A full clone of opnsense-src from Forgejo hung for 5.5 hours with nothing
transferred. The build never reads src history (tools only describes src
when VERSION is not numeric), so fetch just the ref's commit; core, plugins
and ports keep full history and tags for their version strings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 01:01:28 -05:00
6ddb7ef179 vm.sh: setup runs build.sh setup over ssh, before rsync exists in the VM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 19:24:02 -05:00
ab6b52207f mirror: gwmirror stage/verify/publish, nginx stack, release docs
- gwmirror.py: lay a build into the mirror tree, verify it (signatures,
  catalogues, sizes, hashes, aarch64-only ELF, and over HTTPS also TLS
  expiry, Content-Length, redirects) and publish it with rsync only when
  it verifies; tests cover tampering, untrusted and revoked keys,
  traversal and decompression limits
- server/: unprivileged nginx for a Portainer stack serving the SMB share
  read-only, GET/HEAD only, proxying changelog/bogons from upstream
- monitor/: daily systemd user timer running verify --url
- RELEASE.md: design and runbook; README.md points to it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 18:56:54 -05:00