* rtnl_newlink() cleanup on namespace change
@ 2015-03-10 22:43 David Miller
2015-03-10 23:44 ` Cong Wang
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2015-03-10 22:43 UTC (permalink / raw)
To: netdev; +Cc: xiyou.wangcong
Cong, I was reviewing commit 7afb8886a05be68e376655539a064ec672de8a8e
("rtnetlink: call ->dellink on failure when ->newlink exists") during
a stable backport and I noticed that the function, after the change
you made, subsequently goes:
if (link_net) {
err = dev_change_net_namespace(dev, dest_net, ifname);
if (err < 0)
unregister_netdevice(dev);
}
Isn't the potential ->dellink() unwinding necessary in this path too?
If not, why not?
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: rtnl_newlink() cleanup on namespace change
2015-03-10 22:43 rtnl_newlink() cleanup on namespace change David Miller
@ 2015-03-10 23:44 ` Cong Wang
2015-03-11 2:00 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Cong Wang @ 2015-03-10 23:44 UTC (permalink / raw)
To: David Miller; +Cc: Linux Kernel Network Developers
On Tue, Mar 10, 2015 at 3:43 PM, David Miller <davem@davemloft.net> wrote:
>
> Cong, I was reviewing commit 7afb8886a05be68e376655539a064ec672de8a8e
> ("rtnetlink: call ->dellink on failure when ->newlink exists") during
> a stable backport and I noticed that the function, after the change
> you made, subsequently goes:
>
> if (link_net) {
> err = dev_change_net_namespace(dev, dest_net, ifname);
> if (err < 0)
> unregister_netdevice(dev);
> }
>
> Isn't the potential ->dellink() unwinding necessary in this path too?
>
Right, I wasn't aware of the link_net change.
Do you want me to send a fix?
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: rtnl_newlink() cleanup on namespace change
2015-03-10 23:44 ` Cong Wang
@ 2015-03-11 2:00 ` David Miller
2015-03-11 16:35 ` Cong Wang
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2015-03-11 2:00 UTC (permalink / raw)
To: xiyou.wangcong; +Cc: netdev
From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Tue, 10 Mar 2015 16:44:06 -0700
> On Tue, Mar 10, 2015 at 3:43 PM, David Miller <davem@davemloft.net> wrote:
>>
>> Cong, I was reviewing commit 7afb8886a05be68e376655539a064ec672de8a8e
>> ("rtnetlink: call ->dellink on failure when ->newlink exists") during
>> a stable backport and I noticed that the function, after the change
>> you made, subsequently goes:
>>
>> if (link_net) {
>> err = dev_change_net_namespace(dev, dest_net, ifname);
>> if (err < 0)
>> unregister_netdevice(dev);
>> }
>>
>> Isn't the potential ->dellink() unwinding necessary in this path too?
>>
>
> Right, I wasn't aware of the link_net change.
> Do you want me to send a fix?
I took care of it, as follows:
====================
[PATCH] 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: 317f4810e45e ("rtnl: allow to create device with IFLA_LINK_NETNSID set")
Signed-off-by: David S. Miller <davem@davemloft.net>
---
net/core/rtnetlink.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 25b4b5d..ee0608b 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2166,28 +2166,28 @@ replay:
}
}
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;
}
}
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: rtnl_newlink() cleanup on namespace change
2015-03-11 2:00 ` David Miller
@ 2015-03-11 16:35 ` Cong Wang
0 siblings, 0 replies; 4+ messages in thread
From: Cong Wang @ 2015-03-11 16:35 UTC (permalink / raw)
To: David Miller; +Cc: Linux Kernel Network Developers
On Tue, Mar 10, 2015 at 7:00 PM, David Miller <davem@davemloft.net> wrote:
> From: Cong Wang <xiyou.wangcong@gmail.com>
> Date: Tue, 10 Mar 2015 16:44:06 -0700
>
>> On Tue, Mar 10, 2015 at 3:43 PM, David Miller <davem@davemloft.net> wrote:
>>>
>>> Cong, I was reviewing commit 7afb8886a05be68e376655539a064ec672de8a8e
>>> ("rtnetlink: call ->dellink on failure when ->newlink exists") during
>>> a stable backport and I noticed that the function, after the change
>>> you made, subsequently goes:
>>>
>>> if (link_net) {
>>> err = dev_change_net_namespace(dev, dest_net, ifname);
>>> if (err < 0)
>>> unregister_netdevice(dev);
>>> }
>>>
>>> Isn't the potential ->dellink() unwinding necessary in this path too?
>>>
>>
>> Right, I wasn't aware of the link_net change.
>> Do you want me to send a fix?
>
> I took care of it, as follows:
Thanks, it looks good.
>
> ====================
> [PATCH] 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: 317f4810e45e ("rtnl: allow to create device with IFLA_LINK_NETNSID set")
> Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Cong Wang <xiyou.wangcong@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-03-11 16:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-10 22:43 rtnl_newlink() cleanup on namespace change David Miller
2015-03-10 23:44 ` Cong Wang
2015-03-11 2:00 ` David Miller
2015-03-11 16:35 ` Cong Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).