Skip to content

Commit 64e724f

Browse files
Brian Haleydavem330
authored andcommitted
ipv6: Don't add routes to ipv6 disabled interfaces.
If the interface has IPv6 disabled, don't add a multicast or link-local route since we won't be adding a link-local address. Reported-by: Mahesh Kelkar <[email protected]> Signed-off-by: Brian Haley <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent be2b6e6 commit 64e724f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

net/ipv6/addrconf.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,7 +1760,10 @@ static struct inet6_dev *addrconf_add_dev(struct net_device *dev)
17601760

17611761
idev = ipv6_find_idev(dev);
17621762
if (!idev)
1763-
return NULL;
1763+
return ERR_PTR(-ENOBUFS);
1764+
1765+
if (idev->cnf.disable_ipv6)
1766+
return ERR_PTR(-EACCES);
17641767

17651768
/* Add default multicast route */
17661769
addrconf_add_mroute(dev);
@@ -2129,8 +2132,9 @@ static int inet6_addr_add(struct net *net, int ifindex, struct in6_addr *pfx,
21292132
if (!dev)
21302133
return -ENODEV;
21312134

2132-
if ((idev = addrconf_add_dev(dev)) == NULL)
2133-
return -ENOBUFS;
2135+
idev = addrconf_add_dev(dev);
2136+
if (IS_ERR(idev))
2137+
return PTR_ERR(idev);
21342138

21352139
scope = ipv6_addr_scope(pfx);
21362140

@@ -2377,7 +2381,7 @@ static void addrconf_dev_config(struct net_device *dev)
23772381
}
23782382

23792383
idev = addrconf_add_dev(dev);
2380-
if (idev == NULL)
2384+
if (IS_ERR(idev))
23812385
return;
23822386

23832387
memset(&addr, 0, sizeof(struct in6_addr));
@@ -2468,7 +2472,7 @@ static void addrconf_ip6_tnl_config(struct net_device *dev)
24682472
ASSERT_RTNL();
24692473

24702474
idev = addrconf_add_dev(dev);
2471-
if (!idev) {
2475+
if (IS_ERR(idev)) {
24722476
printk(KERN_DEBUG "init ip6-ip6: add_dev failed\n");
24732477
return;
24742478
}

0 commit comments

Comments
 (0)