* [Patch] rtnetlink: call ->dellink on failure when ->newlink exists
@ 2015-02-13 21:56 Cong Wang
2015-02-15 16:31 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Cong Wang @ 2015-02-13 21:56 UTC (permalink / raw)
To: netdev; +Cc: davem, ignacy.gawedzki, Cong Wang
Ignacy reported that when eth0 is down and add a vlan device
on top of it like:
ip link add link eth0 name eth0.1 up type vlan id 1
We will get a refcount leak:
unregister_netdevice: waiting for eth0.1 to become free. Usage count = 2
The problem is when rtnl_configure_link() fails in rtnl_newlink(),
we simply call unregister_device(), but for stacked device like vlan,
we almost do nothing when we unregister the upper device, more work
is done when we unregister the lower device, so call its ->dellink().
Reported-by: Ignacy Gawedzki <ignacy.gawedzki@green-communications.fr>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
net/core/rtnetlink.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 5be499b..ab293a3 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2162,7 +2162,14 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh)
}
err = rtnl_configure_link(dev, ifm);
if (err < 0) {
- unregister_netdevice(dev);
+ if (ops->newlink) {
+ LIST_HEAD(list_kill);
+
+ ops->dellink(dev, &list_kill);
+ unregister_netdevice_many(&list_kill);
+ } else {
+ unregister_netdevice(dev);
+ }
goto out;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [Patch] rtnetlink: call ->dellink on failure when ->newlink exists
2015-02-13 21:56 [Patch] rtnetlink: call ->dellink on failure when ->newlink exists Cong Wang
@ 2015-02-15 16:31 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2015-02-15 16:31 UTC (permalink / raw)
To: xiyou.wangcong; +Cc: netdev, ignacy.gawedzki
From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Fri, 13 Feb 2015 13:56:53 -0800
> Ignacy reported that when eth0 is down and add a vlan device
> on top of it like:
>
> ip link add link eth0 name eth0.1 up type vlan id 1
>
> We will get a refcount leak:
>
> unregister_netdevice: waiting for eth0.1 to become free. Usage count = 2
>
> The problem is when rtnl_configure_link() fails in rtnl_newlink(),
> we simply call unregister_device(), but for stacked device like vlan,
> we almost do nothing when we unregister the upper device, more work
> is done when we unregister the lower device, so call its ->dellink().
>
> Reported-by: Ignacy Gawedzki <ignacy.gawedzki@green-communications.fr>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-02-15 16:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-13 21:56 [Patch] rtnetlink: call ->dellink on failure when ->newlink exists Cong Wang
2015-02-15 16:31 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox