nftables: fixed QueueBypass for system rules - #1672
Open
banana-monkey-tree wants to merge 1 commit into
Open
banana-monkey-tree wants to merge 1 commit into
banana-monkey-tree wants to merge 1 commit into
Conversation
System firewall queue rules always included the bypass flag, even when FwOptions.QueueBypass was false. Pass the configured flag to the verdict builder, as we already do for the interception rules. Add a system-rule test that checks the installed queue flags with bypass disabled and enabled.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Queue rules declared in
system-fw.jsonare always installed with the bypass flag, regardless ofFwOptions.QueueBypass.The daemon's own interception rules honour the setting — the three queue constructions in
firewall/nftables/rules.gousen.getBypassFlag(). The verdict builder used for system rules hardcodedexpr.QueueFlagBypassinstead, next to a// TODO: allow to configure this flag.This shows up with the
mangle_forwardrule shipped insystem-fw.json("Intercept forwarded connections (docker, etc)") — the rule suggested in #1175 for intercepting forwarded traffic. Enabling it withQueueBypassset tofalseinstalls:nftables documents
bypassas letting packets through when no userspace program is listening on the queue, so a rule installed this way does not fail closed the way the interception rules do. I verified the installed flag, not packet delivery with a stopped listener.The fix
Pass
getBypassFlag()intoNewExprVerdictand drop the TODO.AddSystemRuleis its only production caller and already has the flag in scope; both the initial load and later system-rule reloads go through it.The shipped default is
QueueBypass: true, so default installations are unaffected — this changes behaviour only where it was explicitly set tofalse.The test
TestSystemRuleQueueBypassgoes throughInit()with the existing fixture, once with bypass disabled and once enabled, and readsmangle_forwardback from the kernel to compare the installed queue flags. It needsPRIVILEGED_TESTS=1and namespace privileges, as the other tests in that file do, and skips otherwise.Before the change it fails with:
Tested on linux/arm64 with Go 1.27.1; the
nftablesandexprspackages pass.