Skip to content

virtio-linux, microvm-rootfs: add nftables socket support and nft to the guest - #798

Merged
bryan-minimal merged 2 commits into
mainfrom
feat/guest-nftables
Oct 2, 2026
Merged

bryan-minimal merged 2 commits into
mainfrom
feat/guest-nftables

Conversation

@norrietaylor

@norrietaylor norrietaylor commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

What

  • packages/virtio-linux/build.sh: the guest kernel gains the nftables socket expression. NFT_SOCKET joins the want list. NF_SOCKET_IPV4, NF_SOCKET_IPV6, SOCK_CGROUP_DATA and NFT_REJECT_INET are added beside it as asserts. They follow from NFT_SOCKET and from symbols already on. The rest of the ruleset's dependency set is already in the want list and asserted, so it is not repeated: NF_TABLES, NF_TABLES_INET/IPV4/IPV6, NFT_CT, NF_CONNTRACK, NFT_NAT, NF_NAT, NFT_LIMIT, NFT_LOG, NF_LOG_SYSLOG and NFT_REJECT/IPV4/IPV6.
  • packages/microvm-rootfs/build.ncl: the rootfs ships nft and its libraries, so the in-VM classifier can load rules. nftables goes in the guest-tools group and its three missing libraries go in the shared-library closure, each alphabetical within its group. libmnl-1.0.5-r2 and readline-8.3.3-r1 are already pinned, and musl and /bin/sh come from the minirootfs.
  • packages/microvm-rootfs/build.sh: usr/sbin/nft joins the staged-rootfs assert, which carries one entry per root package.

Why

The box-networking guest egress classifier needs nft in the guest. minimal is moving its host-address classifier table (inet minimal_class) into the microVM guest (gominimal/minimal#1812). The guest loads the same ruleset text the native installer renders. That table matches socket cgroupv2 level N "<path>", which needs NFT_SOCKET. Its tristate has no default, so olddefconfig leaves it off, and the kernel ships no modules. The rootfs has no nft binary.

NFT_REDIR is not needed: the table uses dnat, not redirect.

Alpine apks (v3.24 main, same version on both arches)

apk arm64 (aarch64) sha256 amd64 (x86_64) sha256
gmp-6.3.0-r4 4dab6e86b850fe1b5bc0cf2fac17efa4d7f648bea44f3d9019694cc1e1cb12b7 85323ef5bce8ff234736dc2d6592ea37aebdc6348a531e27430bdfe38364d256
jansson-2.15.0-r0 a13822f5ca1772cced4bb7d3d178ec5dee770d8accba5b4816b2ddc413e6f055 7681b41486e1f2b2efce11875c839533464ae8857d30fc49130f0039c6585fdb
libnftnl-1.3.1-r0 8b31395671e910c294d7f0e29d3ac3c7efe9d89264db255f39aa9944dd4b6cac 2f4cf35959fde00fdba0dd35ef12a6739739b504e8319c97e30bd4834f98d924
nftables-1.1.6-r1 e350dc0ae7667486f925a6719add6df562055799baf0e402077ef2b11839ac9e edca96e6160479bd734bb6cdb8412f84f689c6a771fdec75ce2c1c18f3e7cf42

Prerequisite: mirror the apks before CI can pass

Important

Not done by this PR (needs bucket access). The build cannot pass until it is.

The rootfs fetches from the staging mirror, not dl-cdn (see the build.ncl header). These eight objects must be copied there before the microvm-rootfs build can fetch them. Each source is the same path on https://dl-cdn.alpinelinux.org/alpine/v3.24/main/<arch>/:

gs://minimal-staging-archives/alpine/v3.24/main/aarch64/gmp-6.3.0-r4.apk
gs://minimal-staging-archives/alpine/v3.24/main/aarch64/jansson-2.15.0-r0.apk
gs://minimal-staging-archives/alpine/v3.24/main/aarch64/libnftnl-1.3.1-r0.apk
gs://minimal-staging-archives/alpine/v3.24/main/aarch64/nftables-1.1.6-r1.apk
gs://minimal-staging-archives/alpine/v3.24/main/x86_64/gmp-6.3.0-r4.apk
gs://minimal-staging-archives/alpine/v3.24/main/x86_64/jansson-2.15.0-r0.apk
gs://minimal-staging-archives/alpine/v3.24/main/x86_64/libnftnl-1.3.1-r0.apk
gs://minimal-staging-archives/alpine/v3.24/main/x86_64/nftables-1.1.6-r1.apk

Verification

  • Each of the eight apks was fetched from dl-cdn.alpinelinux.org/alpine/v3.24/main/{aarch64,x86_64}/. Its sha256 matches the value pinned in build.ncl.
  • The nftables .PKGINFO depends on so:libgmp.so.10, so:libjansson.so.4, so:libmnl.so.0, so:libnftnl.so.11, so:libreadline.so.8, musl and /bin/sh. libnftnl depends on libmnl and musl, and gmp and jansson depend only on musl. The closure is complete with these four added.
  • The nftables payload carries usr/sbin/nft and usr/lib/libnftables.so.1. Its only install script is .post-upgrade, which migrates old rules-file locations and is moot for a fresh tar overlay.
  • bash -n and shellcheck are clean on both build.sh files.
  • The kernel and rootfs were not built locally. The virtio-linux post-olddefconfig assert and the microvm-rootfs staged-path assert are the checks, and the CI builds run them. The end-to-end check is nft -c -f of the ruleset in gominimal/minimal#1812, run inside a guest booted from this kernel and rootfs. It runs on the minimal side once locked_commit moves here.

Summary by CodeRabbit

  • New Features
    • Guest environments can now use socket-aware network rules to identify host addresses, enabling more precise network traffic handling.
    • Added support for rejecting network traffic across IPv4 and IPv6, along with the required kernel capabilities.
    • Required networking tools are now checked during guest environment setup to catch missing components.

…the guest

The guest minimald loads its host-address classifier table (inet
minimal_class) inside the microVM, from the same ruleset text the native
installer renders. Its `socket cgroupv2 level N` matches need NFT_SOCKET,
which has no default and so stays off after olddefconfig, and the rootfs
ships no nft binary.

virtio-linux: want NFT_SOCKET, and assert NF_SOCKET_IPV4, NF_SOCKET_IPV6,
SOCK_CGROUP_DATA and NFT_REJECT_INET, which follow from it and from
symbols already on. The rest of the table's dependencies (nf_tables core,
ct, nat, limit, log, reject) are already in the want list.

microvm-rootfs: pin nftables-1.1.6-r1 and its missing closure (gmp,
jansson, libnftnl) from Alpine v3.24 main; libmnl and readline are
already pinned. build.sh asserts /usr/sbin/nft lands in the image.
@norrietaylor
norrietaylor requested a review from a team as a code owner October 2, 2026 15:54
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: gominimal/pkgs/.coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: d7d57688-fb3c-4ed1-aad5-f6d98cc93fa3

📥 Commits

Reviewing files that changed from the base of the PR and between 833328b and 44b6bdd.

📒 Files selected for processing (3)
  • packages/microvm-rootfs/build.ncl
  • packages/microvm-rootfs/build.sh
  • packages/virtio-linux/build.sh

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.


📝 Walkthrough

Walkthrough

The guest rootfs build adds nftables and its shared-library dependencies, and checks for nsenter and nft. The kernel build requires five netfilter options.

Changes

Guest nftables support

Layer / File(s) Summary
Require netfilter kernel options
packages/virtio-linux/build.sh
The kernel build checks that five socket-classification and inet-reject options are enabled after olddefconfig.
Include nftables in the guest rootfs
packages/microvm-rootfs/build.ncl, packages/microvm-rootfs/build.sh
The rootfs package declarations add nftables, libnftnl, gmp, and jansson. Staged-rootfs checks require /usr/bin/nsenter and /usr/sbin/nft.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Suggested reviewers: bryan-minimal

Merge Risk: ⚪ Minimal · up to 3effd

No actionable merge-blocking issue is established. The guest-level classifier check remains useful validation when the build is available.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main changes: adding nftables socket support to virtio-linux and adding nft to the microVM guest rootfs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Comment @coderabbitai help to get the list of available commands.

…mirrored to gs://)

The four new apks were pinned but never uploaded, so the build 404'd on
nftables-1.1.6-r1. All eight (4 apks x 2 arches) are now under
gs://minimal-staging-archives/alpine/v3.24/main/, byte-identical to the pins.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@bryan-minimal
bryan-minimal added this pull request to the merge queue Oct 2, 2026
Merged via the queue into main with commit 001dc56 Oct 2, 2026
11 checks passed
@bryan-minimal
bryan-minimal deleted the feat/guest-nftables branch October 2, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants