Skip to content

fix(proxy-init): filter skip subnets by address family - #863

Closed
lbarrosby wants to merge 1 commit into
linkerd:mainfrom
lbarrosby:fix/skip-subnets-dual-stack
Closed

lbarrosby wants to merge 1 commit into
linkerd:mainfrom
lbarrosby:fix/skip-subnets-dual-stack

Conversation

@lbarrosby

Copy link
Copy Markdown

Picks up #696 by @panic-kbutton, inactive since April 2026, and addresses the review comments left there. The original change is kept and credited with Co-authored-by.

Problem

With dual-stack enabled (--ipv6), proxy-init calls BuildFirewallConfiguration once for iptables and once for ip6tables, and both passes get the full --subnets-to-ignore list. Any IPv4 subnet ends up in an ip6tables command (and any IPv6 subnet in an iptables command), which fails:

ip6tables v1.8.11 (nf_tables): host/network `10.0.0.0/8' not found

linkerd-init exits and the pod never starts. The CNI plugin goes through the same function, so it is affected too. In practice this means config.linkerd.io/skip-subnets (or proxyInit.skipSubnets) can't be used on dual-stack clusters at all, and an IPv6 subnet can't be skipped on a single-stack IPv4 pod.

Solution

Each pass keeps only the subnets of the address family it programs. Subnets of the other family are logged at debug level and skipped, as suggested in the review of #696. The family comes from the parsed mask length, not IP.To4(), so an IPv4-mapped CIDR such as ::ffff:10.0.0.0/104 goes to ip6tables, the only binary that accepts that notation.

Validation

New cases in TestBuildFirewallConfiguration:

  • mixed IPv4/IPv6 subnets, checked in both passes
  • IPv4-only subnets in the IPv6 pass
  • IPv6-only subnets on a single-stack IPv4 pod (the case missing in add proxyInit dual-stack conditional #696)
  • IPv4-mapped IPv6 CIDRs

They fail on main and pass with this change. go test ./proxy-init/... ./pkg/... ./internal/..., go vet and golangci-lint (repo config) are clean. The cni-plugin/integration tests need the CI mounts and weren't run locally.

AI disclosure: written with the help of Claude Code, reviewed and tested by me.

Problem

With dual-stack enabled (--ipv6), proxy-init runs BuildFirewallConfiguration
once for iptables and once for ip6tables, and both passes receive the full
--subnets-to-ignore list. Mixing families, or passing only IPv4 or only IPv6
subnets, makes one of the two commands fail:

    ip6tables v1.8.11 (nf_tables): host/network `10.0.0.0/8' not found

and the linkerd-init container (or the CNI plugin, which shares the same
code path) exits, so the pod never starts.

Solution

Keep only the subnets of the family being programmed in each pass, and log
the skipped ones at debug level. The family is taken from the parsed mask
length, so IPv4-mapped IPv6 CIDRs go to ip6tables, the only binary that
accepts them.

Validation

New cases in TestBuildFirewallConfiguration cover mixed subnets in both
passes, IPv4-only subnets in the IPv6 pass, IPv6-only subnets on a
single-stack IPv4 pod, and IPv4-mapped CIDRs. They fail on main and pass with
this change; go test, go vet and golangci-lint are clean for proxy-init.

Picks up linkerd#696, inactive since April 2026, and
addresses the review comments left there.

Co-authored-by: Kevin Button <kevin@thinkingmachines.ai>
Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
@lbarrosby
lbarrosby requested a review from a team as a code owner November 7, 2026 15:15
@lbarrosby lbarrosby closed this Nov 7, 2026
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