|
|
@@ -1217,6 +1217,23 @@ __be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope)
|
|
|
no_in_dev:
|
|
|
master_idx = l3mdev_master_ifindex_rcu(dev);
|
|
|
|
|
|
+ /* For VRFs, the VRF device takes the place of the loopback device,
|
|
|
+ * with addresses on it being preferred. Note in such cases the
|
|
|
+ * loopback device will be among the devices that fail the master_idx
|
|
|
+ * equality check in the loop below.
|
|
|
+ */
|
|
|
+ if (master_idx &&
|
|
|
+ (dev = dev_get_by_index_rcu(net, master_idx)) &&
|
|
|
+ (in_dev = __in_dev_get_rcu(dev))) {
|
|
|
+ for_primary_ifa(in_dev) {
|
|
|
+ if (ifa->ifa_scope != RT_SCOPE_LINK &&
|
|
|
+ ifa->ifa_scope <= scope) {
|
|
|
+ addr = ifa->ifa_local;
|
|
|
+ goto out_unlock;
|
|
|
+ }
|
|
|
+ } endfor_ifa(in_dev);
|
|
|
+ }
|
|
|
+
|
|
|
/* Not loopback addresses on loopback should be preferred
|
|
|
in this case. It is important that lo is the first interface
|
|
|
in dev_base list.
|