8000 fix(classifier): spell the dstnat chain's priority as -100 so nft before 1.0.9 loads the table by bryan-minimal · Pull Request #3179 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

fix(classifier): spell the dstnat chain's priority as -100 so nft before 1.0.9 loads the table - #3179

Merged
bryan-minimal merged 1 commit into
mainfrom
fix/1196-classifier-nft-priority
Nov 9, 2026
Merged

bryan-minimal merged 1 commit into
mainfrom
fix/1196-classifier-nft-priority

Conversation

@bryan-minimal
@bryan-minimal bryan-minimal commented Nov 9, 2026 •
Copy link
Copy Markdown
Member

Refs gominimal/inbox#1196.

What

The classifier table's dstnat chain declared type nat hook output priority dstnat. nft up to 1.0.8 pairs the name dstnat with the prerouting hook only and refuses it on output with invalid priority expression value in this context (the output pairing arrived in nftables 1.0.9, upstream commit 8beafab7; nft's documented matrix still lists prerouting alone). One refused chain fails the whole transaction, so on Debian 12 (nft 1.0.6) and Ubuntu 22.04 (nft 1.0.2) min finalize-install installed no classifier and every host-address box went without per-box egress enforcement.

The chain now says priority -100, the value dstnat names, which every nft accepts on every hook (evaluate_priority takes an integer before any name lookup; the only numeric rule, 1.0.7's "nat chains must have a priority above -200", is cleared). 1.0.9 and later load the same chain as before and list it as priority dstnat again; nothing in the tree reads a listed priority back. scripts/install-host-classifier.sh is the one source for both the host's table (embedded in min, printed and run by finalize-install) and the guest's (embedded in minimald, which renders and loads it), so both are fixed by the one line.

Tests

  • classifier.rs: pre_1_0_9_nft_priority_matrix pins the name/hook matrix old nft enforces; every_base_chain_loads_on_nft_before_1_0_9 parses every type … hook … priority …; line of the native render and the guest render, holds each to that matrix, and pins the dstnat chain as ("nat", "output", "-100").
  • scripts/install_test.sh: the "steer runs at dstnat" check greps priority -100;, and two new want_err checks reject dstnat off prerouting and srcnat off postrouting.

Verification

  • Pre-push (CI's exact commands, lab lane): green at 4612dbc.
  • Lab: scenario 727 (host_ip deny-all egress enforced) x2 and 808 (finalize-install beside a tailscale connmark) x1 on Debian 12, Ubuntu 22.04 and Ubuntu 24.04, the release against this branch. On the two old-nft distros the release ends ENV at the install (the classifier never loads) and this branch reaches a verdict and passes; on Ubuntu 24.04 (nft 1.0.9) both sides pass, the control. Ubuntu 22.04's nft 1.0.2 had not been tried with the numeric form before this; its cell is the real test.

OK: 1196-nft-priority-4612dbcc: 2 expectation(s) on debian-12, ubuntu-22.04: 727-host-ip-egress-fail-open:env->pass 808-finalize-install-with-tailscale-connmark:env->pass

min-regress batch 1196-nft-priority-4612dbcc: base rel-6a01d5ae vs the candidate cand-1196-nft-priority-4612dbcc-1311ef44, per distro:

  • debian-12: 727 {'env-fail': 2} -> {'pass': 2}; 808 {'env-fail': 1} -> {'pass': 1}
  • ubuntu-22.04: 727 {'env-fail': 2} -> {'pass': 2}; 808 {'env-fail': 1} -> {'pass': 1}

Lab evidence (min-regress batch 1196-nft-priority-4612dbcc on the lab box, debian-12, ubuntu-22.04, ubuntu-24.04)

Head: 4612dbccd602b07924d7a8b74416d206e559df6d at 4612dbc (lab name cand-1196-nft-priority-4612dbcc-1311ef44). Base: rel-6a01d5ae (rel-6a01d5ae).

scenario distro base head
727-host-ip-egress-fail-open: 0.7 sweep P1: on a host_ip box, declared egress is shown by session policy but never enforced (fail-open) debian-12 env-fail, env-fail pass, pass
727-host-ip-egress-fail-open: 0.7 sweep P1: on a host_ip box, declared egress is shown by session policy but never enforced (fail-open) ubuntu-22.04 env-fail, env-fail pass, pass
727-host-ip-egress-fail-open: 0.7 sweep P1: on a host_ip box, declared egress is shown by session policy but never enforced (fail-open) ubuntu-24.04 pass, pass pass, pass
808-finalize-install-with-tailscale-connmark: gominimal/inbox#1201: finalize-install refuses deny-all egress over Tailscale's masked CONNMARK rules debian-12 env-fail pass
808-finalize-install-with-tailscale-connmark: gominimal/inbox#1201: finalize-install refuses deny-all egress over Tailscale's masked CONNMARK rules ubuntu-22.04 env-fail pass
808-finalize-install-with-tailscale-connmark: gominimal/inbox#1201: finalize-install refuses deny-all egress over Tailscale's masked CONNMARK rules ubuntu-24.04 pass pass

Fixed since base: 0. Still reproducing on both: 0. Regressed: 0. Passing on both: 2. Inconclusive cells (an environment or setup failure on a side, not counted): 4. A verdict links to the run's trace in Cloud Trace (project access needed); the scenario link is its source with the # issue: it reproduces.

OK: 1196-nft-priority-4612dbcc: 2 expectation(s) on ubuntu-24.04: 727-host-ip-egress-fail-open:pass 808-finalize-install-with-tailscale-connmark:pass

min-regress batch 1196-nft-priority-4612dbcc: base rel-6a01d5ae vs the candidate cand-1196-nft-priority-4612dbcc-1311ef44, per distro:

  • ubuntu-24.04: 727 {'pass': 2} -> {'pass': 2}; 808 {'pass': 1} -> {'pass': 1}

Lab evidence (min-regress batch 1196-nft-priority-4612dbcc on the lab box, debian-12, ubuntu-22.04, ubuntu-24.04)

Head: 4612dbccd602b07924d7a8b74416d206e559df6d at 4612dbc (lab name cand-1196-nft-priority-4612dbcc-1311ef44). Base: rel-6a01d5ae (rel-6a01d5ae).

scenario distro base head
727-host-ip-egress-fail-open: 0.7 sweep P1: on a host_ip box, declared egress is shown by session policy but never enforced (fail-open) debian-12 env-fail, env-fail pass, pass
727-host-ip-egress-fail-open: 0.7 sweep P1: on a host_ip box, declared egress is shown by session policy but never enforced (fail-open) ubuntu-22.04 env-fail, env-fail pass, pass
727-host-ip-egress-fail-open: 0.7 sweep P1: on a host_ip box, declared egress is shown by session policy but never enforced (fail-open) ubuntu-24.04 pass, pass pass, pass
808-finalize-install-with-tailscale-connmark: gominimal/inbox#1201: finalize-install refuses deny-all egress over Tailscale's masked CONNMARK rules debian-12 env-fail pass
808-finalize-install-with-tailscale-connmark: gominimal/inbox#1201: finalize-install refuses deny-all egress over Tailscale's masked CONNMARK rules ubuntu-22.04 env-fail pass
808-finalize-install-with-tailscale-connmark: gominimal/inbox#1201: finalize-install refuses deny-all egress over Tailscale's masked CONNMARK rules ubuntu-24.04 pass pass

Fixed since base: 0. Still reproducing on both: 0. Regressed: 0. Passing on both: 2. Inconclusive cells (an environment or setup failure on a side, not counted): 4. A verdict links to the run's trace in Cloud Trace (project access needed); the scenario link is its source with the # issue: it reproduces.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility with older nftables versions by using a numeric priority for the output NAT chain.
  • Tests
    • Added checks for accepted chain priorities and verified that rendered rulesets use valid priorities across supported environments.

…ore 1.0.9 loads the table

The classifier table's dstnat chain declared `type nat hook output priority
dstnat`. nft up to 1.0.8 pairs the name `dstnat` with the prerouting hook
only and refuses it on output with "invalid priority expression value in
this context" (the output pairing arrived in nftables 1.0.9, upstream commit
8beafab7, and nft's documented matrix still lists prerouting alone). One
refused chain fails the whole transaction, so on Debian 12 (nft 1.0.6) and
Ubuntu 22.04 (nft 1.0.2) `min finalize-install` installed no classifier and
every host-address box went without per-box egress enforcement.

The chain now says `priority -100`, the value `dstnat` names, which every
nft accepts on every hook; 1.0.9 and later load the same chain as before.
The script is the one source for both the host's table and the guest's,
which minimald renders through it, so both are fixed.

Tests: a rendered-table check in minimald that every base chain of the
native and the guest render names its priority in a form nft before 1.0.9
accepts on its hook, with the name/hook matrix pinned on its own, and
install_test.sh asserts the numeric spelling and that no chain names
dstnat or srcnat off the one hook old nft takes it on.

Refs: gominimal/inbox#1196

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai
coderabbitai Bot commented Nov 9, 2026 •
Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The host ruleset now assigns numeric priority -100 to its output NAT chain. Installer and Rust tests check hook-specific priority compatibility, including rendered native and guest chains.

Changes: NFT priority compatibility

Layer / File(s) Summary
Set output NAT priority
scripts/install-host-classifier.sh
The generated output NAT chain uses numeric priority -100 instead of dstnat. Comments describe the compatibility constraint and note that srcnat remains on postrouting.
Validate hook priorities
scripts/install_test.sh, crates/minimald/src/net/classifier.rs
The installer test checks the output NAT priority and rejects dstnat and srcnat on unsupported hooks. Rust tests parse base-chain declarations and check the pre-1.0.9 acceptance matrix for native and guest renders.

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

Suggested reviewers: norrietaylor, agent-137

Merge Risk: Minimal · up to 4612d

The numeric priority is intended to restore compatibility with older nftables versions. No merge-blocking issue remains identified.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title names the main change: the dstnat chain priority is changed from the name to the numeric value -100 so nft versions before 1.0.9 load the table. It follows the Conventional Commit form (type…
Description check Passed The description covers the What, Tests, and Verification content in the template's spirit. It explains the nft 1.0.8 rejection of priority dstnat on output, gives the -100 fix, and lists the classifie…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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.
Full details: Title check

Explanation

The title names the main change: the dstnat chain priority is changed from the name to the numeric value -100 so nft versions before 1.0.9 load the table. It follows the Conventional Commit form (type(scope): summary) and is specific. It is somewhat long at 94 characters, but it is still clear and related to the changeset.

Full details: Description check

Explanation

The description covers the What, Tests, and Verification content in the template's spirit. It explains the nft 1.0.8 rejection of priority dstnat on output, gives the -100 fix, and lists the classifier.rs and install_test.sh test changes. It lists lab evidence for Debian 12, Ubuntu 22.04, and Ubuntu 24.04. The template's Summary heading is not used verbatim, and the Checklist section is absent: it does not say whether docs were updated or whether a BREAKING CHANGE footer applies. The Refs link to the issue is present. These gaps are non-critical, so the description is mostly complete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 3 files.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the chain at night
Numeric hops keep priorities right
The output path is set to shine
While tests inspect each hook in line
Soft paws leave the rules in tune

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 4194d451-6a0a-431e-a375-053beab0c8df
Commits

Reviewing files that changed from the base of the PR and between 620a1ce and 4612dbc.

Files selected for processing: 3

  • crates/minimald/src/net/classifier.rs
  • scripts/install-host-classifier.sh
  • scripts/install_test.sh

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

@bryan-minimal
bryan-minimal marked this pull request as ready for review November 9, 2026 16:53
@bryan-minimal
bryan-minimal requested a review from a team as a code owner November 9, 2026 16:53
@minimal-foundry
minimal-foundry Bot commented Nov 9, 2026 •
Copy link
Copy Markdown
Contributor

Approved: no findings at 4612dbccd602.

Nothing to do.

Clobber: none seen.

@minimal-foundry minimal-foundry Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — approved

Verdict APPROVE — No findings.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Nov 9, 2026
@agent-137 agent-137 left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review on Karl's behalf, at 4612dbccd. This is a comment, not an approval. Nothing was built for it: every point comes from reading the code, and each finding says how it was checked.

  • CI at head 4612dbc: green (34 success, 3 skipped).
  • Existing reviews: minimal-review APPROVE (3/3 personas, no findings) and CodeRabbit APPROVE, both on head.

Should-fix: none.

Nit: none.

No findings. What I checked:

  • Every table is family inet. install-host-classifier.sh:1074 declares table inet and nothing else. In ip, ip6 and inet the name dstnat means -100. It means -300 only in the bridge family, and no table here uses that family. So -100 on hook output is exactly what dstnat stood for.
  • Every other base chain in the render is valid on nft before 1.0.9:
    • filter and mangle on output and postrouting.
    • srcnat on postrouting (line 1110).
    • route ... output priority mangle and prerouting mangle in classifier.rs.
  • No other spelling remains. git grep "priority (dstnat|srcnat)" finds no other dstnat or srcnat priority in crates/ or scripts/.
  • Nothing reads the listed priority back. No code parses "prio" or matches priority dstnat in nft list output. classifier_root_integration.rs:1983 already accepts both mangle and -150.
  • nft 1.0.7's "nat priority above -200" rule is met by -100.
  • The base_chains test parser does not mistake typeof set lines for chain declarations ("typeof" does not start with "type "). The guest render goes through the same script.

Verdict: ready to approve.

@agent-137 agent-137 left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at 4612dbccd. The earlier comment review found nothing that needs fixing, and its nits are optional.

@bryan-minimal
bryan-minimal added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit 6416376 Nov 9, 2026
37 checks passed
@bryan-minimal
bryan-minimal deleted the fix/1196-classifier-nft-priority branch November 9, 2026 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:approved minimal-review approved the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0