On 7/5/24 8:52 AM, Nicolas Dichtel wrote: > diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h > index a18ed24fed94..a7c27f0c6bce 100644 > --- a/include/net/ip6_route.h > +++ b/include/net/ip6_route.h > @@ -127,18 +127,23 @@ void rt6_age_exceptions(struct fib6_info *f6i, struct fib6_gc_args *gc_args, > > static inline int ip6_route_get_saddr(struct net *net, struct fib6_info *f6i, > const struct in6_addr *daddr, > - unsigned int prefs, > + unsigned int prefs, int l3mdev_index, > struct in6_addr *saddr) > { > + struct net_device *l3mdev; > + struct net_device *dev; > + bool same_vrf; > int err = 0; > > - if (f6i && f6i->fib6_prefsrc.plen) { > + rcu_read_lock(); > + l3mdev = dev_get_by_index_rcu(net, l3mdev_index); > + dev = f6i ? fib6_info_nh_dev(f6i) : NULL; > + same_vrf = l3mdev == NULL || l3mdev_master_dev_rcu(dev) == l3mdev; !l3mdev; checkpatch should complain > + if (f6i && f6i->fib6_prefsrc.plen && same_vrf) > *saddr = f6i->fib6_prefsrc.addr; > - } else { > - struct net_device *dev = f6i ? fib6_info_nh_dev(f6i) : NULL; > - > - err = ipv6_dev_get_saddr(net, dev, daddr, prefs, saddr); > - } > + else > + err = ipv6_dev_get_saddr(net, same_vrf ? dev : l3mdev, daddr, prefs, saddr); > + rcu_read_unlock(); > > return err; > } lot of logic lines jammed together. put a new line after the read_lock() and before the unlock().