Re: [PATCH v2 1/3] ipv6: Use the selected nexthop for source address selection

From: netdev-bot+sashiko

Date: Fri Dec 04 2026 - 19:37:37 EST


Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] In ip6_route_get_saddr() (include/net/ip6_route.h), the new
branch treats dst->dev as the device of the selected nexthop whenever…

--

ipv6: Use the selected nexthop for source address selection

This commit passes the dst to ip6_route_get_saddr(). For routes that use
a multipath nexthop group, the source address is then picked for the
device of the path the lookup selected, not for the group's first
nexthop. Both ip6_dst_lookup_tail() and rt6_fill_node() are updated to
pass the dst.

> diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
> index 95f936be32c6c..d5754f6442bbf 100644
> --- a/include/net/ip6_route.h
> +++ b/include/net/ip6_route.h

[ ... ]

> @@ -155,8 +156,12 @@ static inline int ip6_route_get_saddr(struct net *net, struct fib6_info *f6i,
> rcu_read_lock();
>
> l3mdev = dev_get_by_index_rcu(net, l3mdev_index);
> - if (!f6i || !f6i->fib6_prefsrc.plen || l3mdev)
> - dev = f6i ? fib6_info_nh_dev(f6i) : NULL;
> + if (!f6i || !f6i->fib6_prefsrc.plen || l3mdev) {
> + if (dst && f6i && f6i->nh && nexthop_is_multipath(f6i->nh))
> + dev = dst_dev_rcu(dst);

[Severity: Low]
Is dst->dev always the device of the selected nexthop here?

For routes with RTF_LOCAL or RTF_ANYCAST set, ip6_rt_pcpu_alloc() and
ip6_rt_cache_alloc() build their clones with a device from
ip6_rt_get_dev_rcu(), and that function replaces the nexthop device:

net/ipv6/route.c:ip6_rt_get_dev_rcu() {
struct net_device *dev = res->nh->fib_nh_dev;

if (res->fib6_flags & (RTF_LOCAL | RTF_ANYCAST)) {
...
if (netif_is_l3_slave(dev) &&
!rt6_need_strict(&res->f6i->fib6_dst.addr))
dev = l3mdev_master_dev_rcu(dev) ? :
dev_net(dev)->loopback_dev;
else if (!netif_is_l3_master(dev))
dev = dev_net(dev)->loopback_dev;
}
...
}

It looks like such a route can be created with RTN_LOCAL and an
RTA_NH_ID that points at a multipath group. rtm_to_fib6_config() sets
RTF_LOCAL, and fib6_check_nexthop() only rejects source routing, IPv4
nexthops and FDB nexthops.

For that route, ip6_dst_lookup_tail() and rt6_fill_node() would now pass
loopback or the VRF master to ipv6_dev_get_saddr(). Neither is the device
of any nexthop in the group. Local routes with a single nexthop, or with
no nexthop object, still get the real nexthop device from
fib6_info_nh_dev().

For link-local or multicast destinations, or when use_oif_addrs_only is
set, only the addresses of the device passed in are considered. Could
this return ::1 or no usable address? In other cases, the rule 4
(outgoing interface) and VRF master preference would change.

Should the new branch skip routes that have RTF_LOCAL or RTF_ANYCAST in
f6i->fib6_flags?

> + else
> + dev = f6i ? fib6_info_nh_dev(f6i) : NULL;
> + }
> same_vrf = !l3mdev || l3mdev_master_dev_rcu(dev) == l3mdev;
> if (f6i && f6i->fib6_prefsrc.plen && same_vrf)
> *saddr = f6i->fib6_prefsrc.addr;

[ ... ]

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203234720.2428689-1-tmenninger%40everpuredata.com