Skip to content

Commit 1893ff2

Browse files
dsaherndavem330
authored andcommitted
net/ipv6: Add l3mdev check to ipv6_chk_addr_and_flags
Lookup the L3 master device for the passed in device. Only consider addresses on netdev's with the same master device. If the device is not enslaved or is NULL, then the l3mdev is NULL which means only devices not enslaved (ie, in the default domain) are considered. Signed-off-by: David Ahern <dsahern@gmail.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 232378e commit 1893ff2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

net/ipv6/addrconf.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,22 +1856,37 @@ int ipv6_chk_addr(struct net *net, const struct in6_addr *addr,
18561856
}
18571857
EXPORT_SYMBOL(ipv6_chk_addr);
18581858

1859+
/* device argument is used to find the L3 domain of interest. If
1860+
* skip_dev_check is set, then the ifp device is not checked against
1861+
* the passed in dev argument. So the 2 cases for addresses checks are:
1862+
* 1. does the address exist in the L3 domain that dev is part of
1863+
* (skip_dev_check = true), or
1864+
*
1865+
* 2. does the address exist on the specific device
1866+
* (skip_dev_check = false)
1867+
*/
18591868
int ipv6_chk_addr_and_flags(struct net *net, const struct in6_addr *addr,
18601869
const struct net_device *dev, bool skip_dev_check,
18611870
int strict, u32 banned_flags)
18621871
{
18631872
unsigned int hash = inet6_addr_hash(net, addr);
1873+
const struct net_device *l3mdev;
18641874
struct inet6_ifaddr *ifp;
18651875
u32 ifp_flags;
18661876

18671877
rcu_read_lock();
18681878

1879+
l3mdev = l3mdev_master_dev_rcu(dev);
18691880
if (skip_dev_check)
18701881
dev = NULL;
18711882

18721883
hlist_for_each_entry_rcu(ifp, &inet6_addr_lst[hash], addr_lst) {
18731884
if (!net_eq(dev_net(ifp->idev->dev), net))
18741885
continue;
1886+
1887+
if (l3mdev_master_dev_rcu(ifp->idev->dev) != l3mdev)
1888+
continue;
1889+
18751890
/* Decouple optimistic from tentative for evaluation here.
18761891
* Ban optimistic addresses explicitly, when required.
18771892
*/

0 commit comments

Comments
 (0)