aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2008-11-05 19:00:24 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-05 19:00:24 -0500
commit0a36b345ab99d6b3c96999e7e3b79bd243cf9bf7 (patch)
tree1f5eb878a142fff7cabea6e34a2ee589f333158d /net
parentae33bc40c0d96d02f51a996482ea7e41c5152695 (diff)
net: Don't leak packets when a netns is going down
I have been tracking for a while a case where when the network namespace exits the cleanup gets stck in an endless precessess of: unregister_netdevice: waiting for lo to become free. Usage count = 3 unregister_netdevice: waiting for lo to become free. Usage count = 3 unregister_netdevice: waiting for lo to become free. Usage count = 3 unregister_netdevice: waiting for lo to become free. Usage count = 3 unregister_netdevice: waiting for lo to become free. Usage count = 3 unregister_netdevice: waiting for lo to become free. Usage count = 3 unregister_netdevice: waiting for lo to become free. Usage count = 3 It turns out that if you listen on a multicast address an unsubscribe packet is sent when the network device goes down. If you shutdown the network namespace without carefully cleaning up this can trigger the unsubscribe packet to be sent over the loopback interface while the network namespace is going down. All of which is fine except when we drop the packet and forget to free it leaking the skb and the dst entry attached to. As it turns out the dst entry hold a reference to the idev which holds the dev and keeps everything from being cleaned up. Yuck! By fixing my earlier thinko and add the needed kfree_skb and everything cleans up beautifully. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/dev.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 811507c39805..a0c60607f1a7 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2253,8 +2253,10 @@ int netif_receive_skb(struct sk_buff *skb)
2253 rcu_read_lock(); 2253 rcu_read_lock();
2254 2254
2255 /* Don't receive packets in an exiting network namespace */ 2255 /* Don't receive packets in an exiting network namespace */
2256 if (!net_alive(dev_net(skb->dev))) 2256 if (!net_alive(dev_net(skb->dev))) {
2257 kfree_skb(skb);
2257 goto out; 2258 goto out;
2259 }
2258 2260
2259#ifdef CONFIG_NET_CLS_ACT 2261#ifdef CONFIG_NET_CLS_ACT
2260 if (skb->tc_verd & TC_NCLS) { 2262 if (skb->tc_verd & TC_NCLS) {