IPv6 pod traffic is dropped by the nftables RPF check when WireGuard IPv6 is enabled (Linux 7.1+)
Expected Behavior
With wireguardEnabledV6: true on the nftables dataplane, IPv6 traffic from a pod passes Felix's anti-spoofing check, as IPv4 traffic does.
Current Behavior
On Linux 7.1 and later, every IPv6 packet from a local pod is dropped in raw prerouting by Felix's RPF rule, fib saddr . mark . iif oif 0 (match_builder.go). IPv4 is unaffected, and so is the iptables dataplane.
Possible Solution
The root cause is in the kernel; a fix is below.
- Felix's WireGuard rule sends every lookup without the WireGuard mark to the WireGuard table:
99: not from all fwmark 0x200000/0x200000 lookup 1(wireguard.go). - That table throws the node's own blocks back to
main(wireguard.go). - The RPF lookup carries the packet's workload mark, not the WireGuard mark (static.go), so rule 99 sends it to that table, which throws.
- Since 7.1,
nft_fib_ipv6resolves throughfib6_lookup()(torvalds/linux@1c32b24c234b). Its rule action,fib6_rule_action_alt(), takes the throw as the answer instead of moving on to the next rule, so the lookup returns no interface andoif 0matches. IPv4, and the dst-based IPv6 lookup behind the xtrpfiltermatch, both move on tomainand find the pod's veth.
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -191,7 +191,8 @@ static int fib6_rule_action_alt(struct fib_rule *rule, struct flowi *flp,
oif = (int *)arg->lookup_data;
err = fib6_table_lookup(net, table, *oif, flp6, res, flags);
- if (!err && res->f6i != net->ipv6.fib6_null_entry)
+ if (!err && res->f6i != net->ipv6.fib6_null_entry &&
+ res->fib6_type != RTN_THROW)
err = fib6_rule_saddr(net, rule, flags, flp6,
res->nh->fib_nh_dev);
elseUntil fixed kernels ship, one rule ahead of WireGuard's restores IPv6 pod traffic. It did on our nodes:
ip -6 rule add pref 98 iif lo fwmark 0x80000/0x80000 lookup main- It targets the RPF lookup: nft's fib lookups run with
iif lo, and0x80000is Felix's workload bit under the default mark mask. Pod packets arrive oncali*, notlo, so their routing still goes through rule 99. - The check still runs and now gets
main's answer: a spoofed source resolves to another interface and is dropped. - If the workload bit ever moves, RPF lookups stop matching and the check drops again: it fails closed.
- Felix also uses that bit as a scratch bit in policy chains (policy.go). As far as we can read, none of them run in
mangle-OUTPUT, Felix's only chain that re-routes host traffic (table.go), so host traffic is routed without the bit. Only a socket that sets the bit itself throughSO_MARKwould skip WireGuard. Please correct us if we've missed a path.
Felix could program this rule itself for IPv6 when both the nftables dataplane and WireGuard are on. routerule refuses to manage rules that point at main (route_rule.go), so it would take either a narrow exception there (one rule, owned by its priority) or a small manager in the wireguard package.
Steps to Reproduce (for bugs)
- Run an IPv6 or dual-stack cluster on the nftables dataplane, on Linux 7.1 or later.
- Set
wireguardEnabledV6: truein the default FelixConfiguration. - From a pod, send any IPv6 traffic, for example
ping -6the node it runs on. Nothing answers.
#!/bin/sh
# A throw route ends an nft "fib" lookup on IPv6, but not on IPv4.
#
# pod --veth--> host; the host drops what fails a reverse-path check:
# table 1 throws the pod's block back to main,
# rule 99 sends unmarked lookups to table 1.
#
# Run as root. Exits 1 if any check fails.
set -e
ip netns add host
ip netns add pod
trap 'ip netns del host; ip netns del pod' EXIT
H="ip netns exec host"
P="ip netns exec pod"
$H ip link set lo up
$P ip link set lo up
$H ip link add cali0 address 02:00:00:00:00:01 type veth \
peer name eth0 address 02:00:00:00:00:02 netns pod
$H ip link set cali0 up
$P ip link set eth0 up
# family pod address host address pod block
setup() {
$P ip addr add $2 dev eth0 ${5:-}
$P ip route add $3 dev eth0
$P ip neigh add $3 lladdr 02:00:00:00:00:01 dev eth0 nud permanent
$H ip addr add $3 dev cali0 ${5:-}
$H ip route add $2 dev cali0
$H ip neigh add $2 lladdr 02:00:00:00:00:02 dev cali0 nud permanent
$H ip -$1 route add throw $4 table 1
$H ip -$1 rule add pref 99 not fwmark 0x200000/0x200000 lookup 1
}
setup 4 192.0.2.2 198.51.100.1 192.0.2.0/25
setup 6 2001:db8:1::2 2001:db8:2::1 2001:db8:1::/120 nodad
# a source the host does not route to the pod
$P ip addr add 2001:db8:3::2 dev eth0 nodad
$H nft -f - <<'EOF'
table inet rpf {
chain pre {
type filter hook prerouting priority raw; policy accept;
iifname "cali0" fib saddr . mark . iif oif missing counter drop
}
}
EOF
rc=0
# what expected source destination
check() {
if $P ping -c1 -W1 -I $3 $4 >/dev/null; then got=passes; else got=dropped; fi
[ $got = $2 ] && echo "ok: $1 $got" || { echo "FAIL: $1 $got"; rc=1; }
}
check "ipv4 pod source" passes 192.0.2.2 198.51.100.1
check "ipv6 pod source" passes 2001:db8:1::2 2001:db8:2::1
check "ipv6 spoofed source" dropped 2001:db8:3::2 2001:db8:2::1
exit $rcWithout the kernel fix:
ok: ipv4 pod source passes
FAIL: ipv6 pod source dropped
ok: ipv6 spoofed source droppedWith it, all three lines read ok.
Context
IPv6 pod networking stops entirely on nodes with the flag on: pod egress, and every service reached through its AAAA record.
Your Environment
- Calico v3.32.2
- nftables dataplane, VXLAN,
wireguardEnabledV6: true - Kubernetes v1.36.5
- Debian 13, Linux 7.1.13 (trixie-backports); also reproduced on netdev's
nettree at d24e8ac715de
Source: projectcalico/calico