Skip to content

Commit

Permalink
net: Handle unregister properly when netdev namespace change fails.
Browse files Browse the repository at this point in the history
If rtnl_newlink() fails on it's call to dev_change_net_namespace(), we
have to make use of the ->dellink() method, if present, just like we
do when rtnl_configure_link() fails.

Fixes: 317f481 ("rtnl: allow to create device with IFLA_LINK_NETNSID set")
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Mar 11, 2015
1 parent 7768eed commit 4363890
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions net/core/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -2166,28 +2166,28 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh)
}
}
err = rtnl_configure_link(dev, ifm);
if (err < 0) {
if (ops->newlink) {
LIST_HEAD(list_kill);

ops->dellink(dev, &list_kill);
unregister_netdevice_many(&list_kill);
} else {
unregister_netdevice(dev);
}
goto out;
}

if (err < 0)
goto out_unregister;
if (link_net) {
err = dev_change_net_namespace(dev, dest_net, ifname);
if (err < 0)
unregister_netdevice(dev);
goto out_unregister;
}
out:
if (link_net)
put_net(link_net);
put_net(dest_net);
return err;
out_unregister:
if (ops->newlink) {
LIST_HEAD(list_kill);

ops->dellink(dev, &list_kill);
unregister_netdevice_many(&list_kill);
} else {
unregister_netdevice(dev);
}
goto out;
}
}

Expand Down

0 comments on commit 4363890

Please sign in to comment.