Skip to content

recipes-kernel/linux/generic/gyroidos.cfg: build NAT/nft-compat targets into the Kernel#317

Open
aevykk wants to merge 1 commit into
gyroidos:mainfrom
aevykk:kernel-nat-config
Open

recipes-kernel/linux/generic/gyroidos.cfg: build NAT/nft-compat targets into the Kernel#317
aevykk wants to merge 1 commit into
gyroidos:mainfrom
aevykk:kernel-nat-config

Conversation

@aevykk

@aevykk aevykk commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

The image runs iptables-nft. When cmld sets up container NAT it shells out to iptables -t nat (DNAT/SNAT for port forwarding, MASQUERADE for outbound). The DNAT/SNAT/MASQUERADE targets and the nat chain type were loadable modules (nf_nat, nft_compat, xt_nat, nft_chain_nat) with nothing preloading them, so the first NAT rule after boot relied on the kernel's on-demand module autoloader.

That autoload occasionally races: iptables' revision probe runs before the target module finishes registering, and the rule insert fails with "Extension DNAT revision 0 not supported" / RULE_INSERT ENOENT. Being a race it only fails sometimes; once the module is loaded the retry would succeed. NAT is fundamental to container networking, so force the stack builtin to remove the race window entirely rather than depend on first-use autoload.

Follows the existing gyroidos.cfg pattern that already forces IP_NF_NAT and friends to =y; this just extends it to the nft-backend targets iptables-nft actually uses. NETFILTER_XT_MATCH_ADDRTYPE (the -m addrtype match) is already builtin here.

…ts into the Kernel

The image runs iptables-nft. When cmld sets up container NAT it shells out to
`iptables -t nat` (DNAT/SNAT for port forwarding, MASQUERADE for outbound). The
DNAT/SNAT/MASQUERADE targets and the nat chain type were loadable modules
(nf_nat, nft_compat, xt_nat, nft_chain_nat) with nothing preloading them, so the
first NAT rule after boot relied on the kernel's on-demand module autoloader.

That autoload occasionally races: iptables' revision probe runs before the
target module finishes registering, and the rule insert fails with "Extension
DNAT revision 0 not supported" / RULE_INSERT ENOENT. Being a race it only fails
sometimes; once the module is loaded the retry would succeed. NAT is fundamental
to container networking, so force the stack builtin to remove the race window
entirely rather than depend on first-use autoload.

Follows the existing gyroidos.cfg pattern that already forces IP_NF_NAT and
friends to =y; this just extends it to the nft-backend targets iptables-nft
actually uses. NETFILTER_XT_MATCH_ADDRTYPE (the `-m addrtype` match) is already
builtin here.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Leander Seidlitz <leander.seidlitz@aisec.fraunhofer.de>
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