Re: [PATCH net v2] ipv6: socket SO_BINDTODEVICE lookup routing fail without IPv6 rule.
From: David Ahern
Date: Sun Jan 19 2025 - 18:22:01 EST
On 1/13/25 8:11 PM, Shiming Cheng (成诗明) wrote:
>
> ip -6 -netns test1 rule add from all unreachable pri 1
> ip -netns test1 rule add from all unreachable pri 1
The bug is in ipv4, ip_route_output_key_hash_rc():
err = fib_lookup(net, fl4, res, 0);
if (err) {
res->fi = NULL;
res->table = NULL;
if (fl4->flowi4_oif &&
(ipv4_is_multicast(fl4->daddr) || !fl4->flowi4_l3mdev)) {
...
The fib lookup should fail because of the unreachable rule, but the
output side is overlooking it for this legacy reason.
ip6_route_output_flags does not have this exception and so it is rightly
failing.