Skip to content

portmap: pick nftables when iptables is missing even without CAP_NET_ADMIN - #1288

Open
locker95 wants to merge 2 commits into
containernetworking:mainfrom
locker95:fix/nftables-fallback-when-iptables-missing
Open

portmap: pick nftables when iptables is missing even without CAP_NET_ADMIN#1288
locker95 wants to merge 2 commits into
containernetworking:mainfrom
locker95:fix/nftables-fallback-when-iptables-missing

Conversation

@locker95

@locker95 locker95 commented Aug 8, 2026

Copy link
Copy Markdown

SupportsNFTables() goes through knftables and needs CAP_NET_ADMIN. On nft-only systems (or when detection runs without that cap) both probes can fail and we still fell back to iptables, which then also fails.

If iptables isn't available, treat a present nft binary as enough signal to default to the nftables backend. Same helper used for ipmasq defaulting.

Fixes #1280

…ADMIN

SupportsNFTables() needs CAP_NET_ADMIN for knftables.New, so on nft-only
hosts (or when detection runs without that cap) both probes could fail
and we still defaulted to iptables. Fall back to nftables when the nft
binary is on PATH if iptables is unavailable.

Fixes containernetworking#1280

Signed-off-by: Dean Chen <862469039@qq.com>
Restricting PATH to the nft directory still left SupportsIPTables()
true on some runners (iptables resolved outside PATH). Keep the empty-
PATH and iptables-available cases only.

Signed-off-by: Dean Chen <862469039@qq.com>
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.

portmap: nftables auto-detection fails when iptables binary is absent

1 participant