]> git.baikalelectronics.ru Git - kernel.git/commit
net: Don't leak packets when a netns is going down
authorEric W. Biederman <ebiederm@xmission.com>
Thu, 6 Nov 2008 00:00:24 +0000 (16:00 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 6 Nov 2008 00:00:24 +0000 (16:00 -0800)
commit273dcbf01f823a555eca0a3b996c42b66f139503
tree1f5eb878a142fff7cabea6e34a2ee589f333158d
parent5c92eeb31c07d5f4ccb8fc1ea31e6b17e2549594
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>
net/core/dev.c