Skip to content

Commit

Permalink
ipv6: propagate ipv6_add_dev's error returns out of ipv6_find_idev
Browse files Browse the repository at this point in the history
Currently, ipv6_find_idev returns NULL when ipv6_add_dev fails,
ignoring the specific error value. This results in addrconf_add_dev
returning ENOBUFS in all cases, which is unfortunate in cases such as:

    # ip link add dummyX type dummy
    # ip link set dummyX mtu 1200 up
    # ip addr add 2000::/64 dev dummyX
    RTNETLINK answers: No buffer space available

Commit a317a2f ("ipv6: fail early when creating netdev named all
or default") introduced error returns in ipv6_add_dev. Before that,
that function would simply return NULL for all failures.

Signed-off-by: Sabrina Dubroca <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
qsn authored and davem330 committed Aug 23, 2019
1 parent f6edbf2 commit db0b99f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions net/ipv6/addrconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ static struct inet6_dev *ipv6_find_idev(struct net_device *dev)
if (!idev) {
idev = ipv6_add_dev(dev);
if (IS_ERR(idev))
return NULL;
return idev;
}

if (dev->flags&IFF_UP)
Expand Down Expand Up @@ -2466,8 +2466,8 @@ static struct inet6_dev *addrconf_add_dev(struct net_device *dev)
ASSERT_RTNL();

idev = ipv6_find_idev(dev);
if (!idev)
return ERR_PTR(-ENOBUFS);
if (IS_ERR(idev))
return idev;

if (idev->cnf.disable_ipv6)
return ERR_PTR(-EACCES);
Expand Down Expand Up @@ -3159,7 +3159,7 @@ static void init_loopback(struct net_device *dev)
ASSERT_RTNL();

idev = ipv6_find_idev(dev);
if (!idev) {
if (IS_ERR(idev)) {
pr_debug("%s: add_dev failed\n", __func__);
return;
}
Expand Down Expand Up @@ -3374,7 +3374,7 @@ static void addrconf_sit_config(struct net_device *dev)
*/

idev = ipv6_find_idev(dev);
if (!idev) {
if (IS_ERR(idev)) {
pr_debug("%s: add_dev failed\n", __func__);
return;
}
Expand All @@ -3399,7 +3399,7 @@ static void addrconf_gre_config(struct net_device *dev)
ASSERT_RTNL();

idev = ipv6_find_idev(dev);
if (!idev) {
if (IS_ERR(idev)) {
pr_debug("%s: add_dev failed\n", __func__);
return;
}
Expand Down Expand Up @@ -4773,8 +4773,8 @@ inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh,
IFA_F_MCAUTOJOIN | IFA_F_OPTIMISTIC;

idev = ipv6_find_idev(dev);
if (!idev)
return -ENOBUFS;
if (IS_ERR(idev))
return PTR_ERR(idev);

if (!ipv6_allow_optimistic_dad(net, idev))
cfg.ifa_flags &= ~IFA_F_OPTIMISTIC;
Expand Down

0 comments on commit db0b99f

Please sign in to comment.