Skip to content

Keep quota firewall enforcement active across transient nftables errors - #54

Open
compnew2006 wants to merge 1 commit into
UserJoo9:mainfrom
compnew2006:codex/qm-05-nft-recovery
Open

compnew2006 wants to merge 1 commit into
UserJoo9:mainfrom
compnew2006:codex/qm-05-nft-recovery

Conversation

@compnew2006

Copy link
Copy Markdown
Contributor

Problem

QuotaManager reconciled enforcement sets by flushing each set and adding its members in separate nft commands. If an addition failed, the previously applied membership could already be gone, and a transient error could disable the engine for later maintenance ticks. A restart could also retain stale set members if the desired membership was empty.

Changes

  • Apply changed IPv4, IPv6, MAC and pending-guest memberships together in an nftables transaction. Update the cache only after success.
  • Clear cache knowledge on startup and restart, so an empty desired set is still reconciled the first time.
  • Validate addresses passed to nft, report transient synchronization failures in logs and the authenticated dashboard API, and retry without restarting or resetting counters. Missing nft or explicit permission loss continues to report the engine unavailable.

Before and after

Scenario Before After
A changed set fails to apply Previously working membership can be cleared first The previous rules stay active until an entire transaction succeeds
The next tick follows a transient apply failure The engine can be marked unavailable and skip future work It retains state and retries the pending membership
A restarted gateway wants an empty set Old members can remain in the kernel The first synchronization applies the desired empty membership

This PR changes enforcement-set reconciliation. It does not change quota policy, the underlying network topology, or database data. If an error affects the whole engine rather than the set transaction, existing unavailable handling still applies.

Verification

  • Reproduced failed-set replacement and stale pre-existing members before implementation.
  • Verified retry, continued counter deltas, reset on startup and restart, and transient error reporting with fake nft runners.
  • Independent focused run passed 61 tests. The Luna worker separately verified 194 API and run-wiring tests. A local DHCP fallback test showed an intermittent failure during a combined run and passed on rerun; the same class of fallback test also failed on the upstream macOS baseline.
  • No real kernel or live gateway was exercised. Verify IPv4 and IPv6 forwarding and apply-failure recovery in an isolated Linux gateway before rollout.

This branch has not been deployed

No deployments
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.

1 participant