Re: IPv4/IPv6 sysctl unregistration deadlock
From: Patrick McHardy <hidden>
Date: 2009-02-25 07:18:50
Patrick McHardy wrote:
Herbert Xu wrote:quoted
On Wed, Feb 25, 2009 at 06:23:33AM +0100, Patrick McHardy wrote:quoted
An easy fix would be to keep track of whether sysctl unregistration is in progress in IPv4/IPv6 and ignore new requests from that point on. Its not very elegant though, so I was wondering whether anyone has a better suggestion.We could make the unregistration asynchronous and invoke a callback when it's done. Then we can simply hold a net_device refcount and relinquish it in the callbackThat sounds simple enough. I'll see if I can come up with a patch, thanks.
Unfortunately its more complicated than I thought because of device renames, where the sysctl pointer is reused after unregistration and the rename/unregistration/re-registration should be atomic. Deferring unregistration means we can't perform the new registration immediately unless we allow multiple registrations for a single device to be active simulaneously, which introduces a whole new set of problems. Simply ignoring the request during unregistration doesn't seem so bad after all, the main problem is that it intoduces a different race on renames where a write to the "forwarding" file returns success, but the change doesn't take effect. We could return -ENOENT, but that seems a bit strange after open() returned success. Maybe -EBUSY, although I would prefer to make this transparent to userspace. Another alternative would be to simply not take the RTNL in the sysctl handler since we're already taking dev_base_lock before performing any forwaring changes. But in case of IPv4 we need it for disabling LRO. I think I'm stuck. Will rethink it after some coffee :)