net: Handle unregister properly when netdev namespace change fails.
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: 317f4810e4
("rtnl: allow to create device with IFLA_LINK_NETNSID set")
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
7768eed8bf
commit
4363890079
1 changed files with 13 additions and 13 deletions
|
@ -2166,7 +2166,19 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh)
|
|||
}
|
||||
}
|
||||
err = rtnl_configure_link(dev, ifm);
|
||||
if (err < 0) {
|
||||
if (err < 0)
|
||||
goto out_unregister;
|
||||
if (link_net) {
|
||||
err = dev_change_net_namespace(dev, dest_net, ifname);
|
||||
if (err < 0)
|
||||
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);
|
||||
|
||||
|
@ -2177,18 +2189,6 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh)
|
|||
}
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (link_net) {
|
||||
err = dev_change_net_namespace(dev, dest_net, ifname);
|
||||
if (err < 0)
|
||||
unregister_netdevice(dev);
|
||||
}
|
||||
out:
|
||||
if (link_net)
|
||||
put_net(link_net);
|
||||
put_net(dest_net);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh)
|
||||
|
|
Loading…
Reference in a new issue