bpf: clat: fix redirect for outgoing packets

bpf_redirect_neigh() looks up the next hop in the routing table and
then redirects the packet to the given ifindex. The problem is that
the routing table might contain a default route with lower metric on a
different device; in that case the FIB lookup returns a next hop on
the other device, and the packet can't be delivered.

Use bpf_redirect() instead; the IPv4 already has the right L2
destination because the IPv4 default route points to the IPv6 gateway.
This commit is contained in:
Beniamino Galvani 2026-01-11 23:11:48 +01:00
parent 02814a0a60
commit e079501ebc

View file

@ -554,7 +554,7 @@ clat_handle_v4(struct __sk_buff *skb)
eth->h_proto = bpf_htons(ETH_P_IPV6);
*ip6h = dst_hdr;
ret = bpf_redirect_neigh(skb->ifindex, NULL, 0, 0);
ret = bpf_redirect(skb->ifindex, 0);
out:
return ret;
}