All of lore.kernel.org
 help / color / mirror / Atom feed
* cleanup in workq and dst_destroy
@ 2007-11-16 16:32 Daniel Lezcano
       [not found] ` <473DC604.9070601-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Lezcano @ 2007-11-16 16:32 UTC (permalink / raw)
  To: Denis V. Lunev, Eric W. Biederman
  Cc: Linux Containers, Benjamin Thery, Pavel Emelianov

Hi all,

while doing ipv6 namespace, we were faced to a problem with the loopback 
and the dst_destroy function.

When the network namespace exits, the cleanup function is called by 
schedule_work and this function will browse the net ops list to call the 
different exit methods for the registered subsystems.

The different subsystems will shutdown their resources and in particular 
addrconf subsystem will ifdown the loopback. This function will call
rt6_ifdown
  -> fib6_clean_all
   -> fib6_clean_node
    -> fib6_clean_tree
     -> fib6_clean_node
      -> fib6_del
       -> fib6_del_route
        -> rt6_release
         ->dst_free
          -> __dst_free

The __dst_free function will schedule_delayed_work the dst_gc_work function.

The dst_gc_work will call dst_destroy and finally this one will call 
dst->ops->destroy ops function which is ip6_dst_destroy.

The problem here is we have the workq blocked because we are running 
inside the netns cleanup function. So the delayed work will not run 
until we exits the cleanup function. But the loopback is still 
referenced by the ip6 routes, the netdev_unregister will loop 
indefinitly => dead lock.

By the way, this bug appears with ipv6 but it is perhaps pending with ipv4.

Benjamin as proposed to create a separate workq for the network 
namespace, so in the worst case we have the unregister looping until the 
ip6 route are shut downed. Is it an acceptable solution ?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: cleanup in workq and dst_destroy
       [not found] ` <473DC604.9070601-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
@ 2007-11-16 17:06   ` Denis V. Lunev
       [not found]     ` <473DCE16.8020809-3ImXcnM4P+0@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Denis V. Lunev @ 2007-11-16 17:06 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Linux Containers, Denis V. Lunev, Benjamin Thery,
	Eric W. Biederman, Pavel Emelianov

Daniel Lezcano wrote:
> Hi all,
> 
> while doing ipv6 namespace, we were faced to a problem with the loopback
> and the dst_destroy function.
> 
> When the network namespace exits, the cleanup function is called by
> schedule_work and this function will browse the net ops list to call the
> different exit methods for the registered subsystems.
> 
> The different subsystems will shutdown their resources and in particular
> addrconf subsystem will ifdown the loopback. This function will call
> rt6_ifdown
>  -> fib6_clean_all
>   -> fib6_clean_node
>    -> fib6_clean_tree
>     -> fib6_clean_node
>      -> fib6_del
>       -> fib6_del_route
>        -> rt6_release
>         ->dst_free
>          -> __dst_free
> 
> The __dst_free function will schedule_delayed_work the dst_gc_work
> function.
> 
> The dst_gc_work will call dst_destroy and finally this one will call
> dst->ops->destroy ops function which is ip6_dst_destroy.
> 
> The problem here is we have the workq blocked because we are running
> inside the netns cleanup function. So the delayed work will not run
> until we exits the cleanup function. But the loopback is still
> referenced by the ip6 routes, the netdev_unregister will loop
> indefinitly => dead lock.
> 
> By the way, this bug appears with ipv6 but it is perhaps pending with ipv4.
> 
> Benjamin as proposed to create a separate workq for the network
> namespace, so in the worst case we have the unregister looping until the
> ip6 route are shut downed. Is it an acceptable solution ?
> 

we are doing this staff in the special thread. There are a lot of
difficult things to perform like synchronize_net & netdev_run_todo inside

Regards,
	Den

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: cleanup in workq and dst_destroy
       [not found]     ` <473DCE16.8020809-3ImXcnM4P+0@public.gmane.org>
@ 2007-11-19  8:46       ` Daniel Lezcano
       [not found]         ` <47414D64.9040304-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Lezcano @ 2007-11-19  8:46 UTC (permalink / raw)
  To: Denis V. Lunev
  Cc: Linux Containers, Denis V. Lunev, Benjamin Thery,
	Eric W. Biederman, Pavel Emelianov

Denis V. Lunev wrote:
> Daniel Lezcano wrote:
>> Hi all,
>>
>> while doing ipv6 namespace, we were faced to a problem with the loopback
>> and the dst_destroy function.
>>
>> When the network namespace exits, the cleanup function is called by
>> schedule_work and this function will browse the net ops list to call the
>> different exit methods for the registered subsystems.
>>
>> The different subsystems will shutdown their resources and in particular
>> addrconf subsystem will ifdown the loopback. This function will call
>> rt6_ifdown
>>  -> fib6_clean_all
>>   -> fib6_clean_node
>>    -> fib6_clean_tree
>>     -> fib6_clean_node
>>      -> fib6_del
>>       -> fib6_del_route
>>        -> rt6_release
>>         ->dst_free
>>          -> __dst_free
>>
>> The __dst_free function will schedule_delayed_work the dst_gc_work
>> function.
>>
>> The dst_gc_work will call dst_destroy and finally this one will call
>> dst->ops->destroy ops function which is ip6_dst_destroy.
>>
>> The problem here is we have the workq blocked because we are running
>> inside the netns cleanup function. So the delayed work will not run
>> until we exits the cleanup function. But the loopback is still
>> referenced by the ip6 routes, the netdev_unregister will loop
>> indefinitly => dead lock.
>>
>> By the way, this bug appears with ipv6 but it is perhaps pending with ipv4.
>>
>> Benjamin as proposed to create a separate workq for the network
>> namespace, so in the worst case we have the unregister looping until the
>> ip6 route are shut downed. Is it an acceptable solution ?
>>
> 
> we are doing this staff in the special thread. There are a lot of
> difficult things to perform like synchronize_net & netdev_run_todo inside

The special thread ? do you mean keventd_wq ?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: cleanup in workq and dst_destroy
       [not found]         ` <47414D64.9040304-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
@ 2007-11-19  8:58           ` Denis V. Lunev
       [not found]             ` <4741501C.1090002-3ImXcnM4P+0@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Denis V. Lunev @ 2007-11-19  8:58 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Linux Containers, Denis V. Lunev, Benjamin Thery,
	Eric W. Biederman, Pavel Emelianov

Daniel Lezcano wrote:
> Denis V. Lunev wrote:
>> Daniel Lezcano wrote:
>>> Hi all,
>>>
>>> while doing ipv6 namespace, we were faced to a problem with the loopback
>>> and the dst_destroy function.
>>>
>>> When the network namespace exits, the cleanup function is called by
>>> schedule_work and this function will browse the net ops list to call the
>>> different exit methods for the registered subsystems.
>>>
>>> The different subsystems will shutdown their resources and in particular
>>> addrconf subsystem will ifdown the loopback. This function will call
>>> rt6_ifdown
>>>  -> fib6_clean_all
>>>   -> fib6_clean_node
>>>    -> fib6_clean_tree
>>>     -> fib6_clean_node
>>>      -> fib6_del
>>>       -> fib6_del_route
>>>        -> rt6_release
>>>         ->dst_free
>>>          -> __dst_free
>>>
>>> The __dst_free function will schedule_delayed_work the dst_gc_work
>>> function.
>>>
>>> The dst_gc_work will call dst_destroy and finally this one will call
>>> dst->ops->destroy ops function which is ip6_dst_destroy.
>>>
>>> The problem here is we have the workq blocked because we are running
>>> inside the netns cleanup function. So the delayed work will not run
>>> until we exits the cleanup function. But the loopback is still
>>> referenced by the ip6 routes, the netdev_unregister will loop
>>> indefinitly => dead lock.
>>>
>>> By the way, this bug appears with ipv6 but it is perhaps pending with
>>> ipv4.
>>>
>>> Benjamin as proposed to create a separate workq for the network
>>> namespace, so in the worst case we have the unregister looping until the
>>> ip6 route are shut downed. Is it an acceptable solution ?
>>>
>>
>> we are doing this staff in the special thread. There are a lot of
>> difficult things to perform like synchronize_net & netdev_run_todo inside
> 
> The special thread ? do you mean keventd_wq ?
> 
I mean that network namespace deletion, i.e. all subsystem ->exit calls
should be run outside of all current mechanisms in the separate thread,
specially designated to namespace(s) stop.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: cleanup in workq and dst_destroy
       [not found]             ` <4741501C.1090002-3ImXcnM4P+0@public.gmane.org>
@ 2007-11-19  9:03               ` Daniel Lezcano
  2007-11-19  9:16               ` Benjamin Thery
  1 sibling, 0 replies; 7+ messages in thread
From: Daniel Lezcano @ 2007-11-19  9:03 UTC (permalink / raw)
  To: Denis V. Lunev
  Cc: Linux Containers, Benjamin Thery, Eric W. Biederman,
	Pavel Emelianov

Denis V. Lunev wrote:
> Daniel Lezcano wrote:
>> Denis V. Lunev wrote:
>>> Daniel Lezcano wrote:
>>>> Hi all,
>>>>
>>>> while doing ipv6 namespace, we were faced to a problem with the loopback
>>>> and the dst_destroy function.
>>>>
>>>> When the network namespace exits, the cleanup function is called by
>>>> schedule_work and this function will browse the net ops list to call the
>>>> different exit methods for the registered subsystems.
>>>>
>>>> The different subsystems will shutdown their resources and in particular
>>>> addrconf subsystem will ifdown the loopback. This function will call
>>>> rt6_ifdown
>>>>  -> fib6_clean_all
>>>>   -> fib6_clean_node
>>>>    -> fib6_clean_tree
>>>>     -> fib6_clean_node
>>>>      -> fib6_del
>>>>       -> fib6_del_route
>>>>        -> rt6_release
>>>>         ->dst_free
>>>>          -> __dst_free
>>>>
>>>> The __dst_free function will schedule_delayed_work the dst_gc_work
>>>> function.
>>>>
>>>> The dst_gc_work will call dst_destroy and finally this one will call
>>>> dst->ops->destroy ops function which is ip6_dst_destroy.
>>>>
>>>> The problem here is we have the workq blocked because we are running
>>>> inside the netns cleanup function. So the delayed work will not run
>>>> until we exits the cleanup function. But the loopback is still
>>>> referenced by the ip6 routes, the netdev_unregister will loop
>>>> indefinitly => dead lock.
>>>>
>>>> By the way, this bug appears with ipv6 but it is perhaps pending with
>>>> ipv4.
>>>>
>>>> Benjamin as proposed to create a separate workq for the network
>>>> namespace, so in the worst case we have the unregister looping until the
>>>> ip6 route are shut downed. Is it an acceptable solution ?
>>>>
>>> we are doing this staff in the special thread. There are a lot of
>>> difficult things to perform like synchronize_net & netdev_run_todo inside
>> The special thread ? do you mean keventd_wq ?
>>
> I mean that network namespace deletion, i.e. all subsystem ->exit calls
> should be run outside of all current mechanisms in the separate thread,
> specially designated to namespace(s) stop.


ah, ok. I didn't caught the meaning of the previous sentence.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: cleanup in workq and dst_destroy
       [not found]             ` <4741501C.1090002-3ImXcnM4P+0@public.gmane.org>
  2007-11-19  9:03               ` Daniel Lezcano
@ 2007-11-19  9:16               ` Benjamin Thery
       [not found]                 ` <4741546D.6010500-6ktuUTfB/bM@public.gmane.org>
  1 sibling, 1 reply; 7+ messages in thread
From: Benjamin Thery @ 2007-11-19  9:16 UTC (permalink / raw)
  To: Denis V. Lunev
  Cc: Linux Containers, Denis V. Lunev, Eric W. Biederman,
	Pavel Emelianov

Denis V. Lunev wrote:
> Daniel Lezcano wrote:
>> Denis V. Lunev wrote:
>>> Daniel Lezcano wrote:
>>>> Hi all,
>>>>
>>>> while doing ipv6 namespace, we were faced to a problem with the loopback
>>>> and the dst_destroy function.
>>>>
>>>> When the network namespace exits, the cleanup function is called by
>>>> schedule_work and this function will browse the net ops list to call the
>>>> different exit methods for the registered subsystems.
>>>>
>>>> The different subsystems will shutdown their resources and in particular
>>>> addrconf subsystem will ifdown the loopback. This function will call
>>>> rt6_ifdown
>>>>  -> fib6_clean_all
>>>>   -> fib6_clean_node
>>>>    -> fib6_clean_tree
>>>>     -> fib6_clean_node
>>>>      -> fib6_del
>>>>       -> fib6_del_route
>>>>        -> rt6_release
>>>>         ->dst_free
>>>>          -> __dst_free
>>>>
>>>> The __dst_free function will schedule_delayed_work the dst_gc_work
>>>> function.
>>>>
>>>> The dst_gc_work will call dst_destroy and finally this one will call
>>>> dst->ops->destroy ops function which is ip6_dst_destroy.
>>>>
>>>> The problem here is we have the workq blocked because we are running
>>>> inside the netns cleanup function. So the delayed work will not run
>>>> until we exits the cleanup function. But the loopback is still
>>>> referenced by the ip6 routes, the netdev_unregister will loop
>>>> indefinitly => dead lock.
>>>>
>>>> By the way, this bug appears with ipv6 but it is perhaps pending with
>>>> ipv4.
>>>>
>>>> Benjamin as proposed to create a separate workq for the network
>>>> namespace, so in the worst case we have the unregister looping until the
>>>> ip6 route are shut downed. Is it an acceptable solution ?
>>>>
>>> we are doing this staff in the special thread. There are a lot of
>>> difficult things to perform like synchronize_net & netdev_run_todo inside
>> The special thread ? do you mean keventd_wq ?
>>
> I mean that network namespace deletion, i.e. all subsystem ->exit calls
> should be run outside of all current mechanisms in the separate thread,
> specially designated to namespace(s) stop.

Interesting.
How do you create the thread? Do you use a special workqueue to replace the 
use of the global keventd workqueue, as I proposed, or do you use another 
mechanism to create the thread?
I mean do you create one thread per exiting namespace (each time a namespace
is exiting you spawn a new thread for the cleanup) or do you create a workqueue
at system init where you'll queue all cleanup routines (cleanup_net) for all
exiting namespaces?

Currently, on our side, we have a small patch that creates a special 
workqueue in net_ns_init(), and we queue clean_net() in this workqueue
in __put_net(). 

Benjamin

-- 
B e n j a m i n   T h e r y  - BULL/DT/Open Software R&D

   http://www.bull.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: cleanup in workq and dst_destroy
       [not found]                 ` <4741546D.6010500-6ktuUTfB/bM@public.gmane.org>
@ 2007-11-19  9:29                   ` Denis V. Lunev
  0 siblings, 0 replies; 7+ messages in thread
From: Denis V. Lunev @ 2007-11-19  9:29 UTC (permalink / raw)
  To: Benjamin Thery
  Cc: Linux Containers, Denis V. Lunev, Eric W. Biederman,
	Pavel Emelianov

Benjamin Thery wrote:
> Denis V. Lunev wrote:
>> Daniel Lezcano wrote:
>>> Denis V. Lunev wrote:
>>>> Daniel Lezcano wrote:
>>>>> Hi all,
>>>>>
>>>>> while doing ipv6 namespace, we were faced to a problem with the loopback
>>>>> and the dst_destroy function.
>>>>>
>>>>> When the network namespace exits, the cleanup function is called by
>>>>> schedule_work and this function will browse the net ops list to call the
>>>>> different exit methods for the registered subsystems.
>>>>>
>>>>> The different subsystems will shutdown their resources and in particular
>>>>> addrconf subsystem will ifdown the loopback. This function will call
>>>>> rt6_ifdown
>>>>>  -> fib6_clean_all
>>>>>   -> fib6_clean_node
>>>>>    -> fib6_clean_tree
>>>>>     -> fib6_clean_node
>>>>>      -> fib6_del
>>>>>       -> fib6_del_route
>>>>>        -> rt6_release
>>>>>         ->dst_free
>>>>>          -> __dst_free
>>>>>
>>>>> The __dst_free function will schedule_delayed_work the dst_gc_work
>>>>> function.
>>>>>
>>>>> The dst_gc_work will call dst_destroy and finally this one will call
>>>>> dst->ops->destroy ops function which is ip6_dst_destroy.
>>>>>
>>>>> The problem here is we have the workq blocked because we are running
>>>>> inside the netns cleanup function. So the delayed work will not run
>>>>> until we exits the cleanup function. But the loopback is still
>>>>> referenced by the ip6 routes, the netdev_unregister will loop
>>>>> indefinitly => dead lock.
>>>>>
>>>>> By the way, this bug appears with ipv6 but it is perhaps pending with
>>>>> ipv4.
>>>>>
>>>>> Benjamin as proposed to create a separate workq for the network
>>>>> namespace, so in the worst case we have the unregister looping until the
>>>>> ip6 route are shut downed. Is it an acceptable solution ?
>>>>>
>>>> we are doing this staff in the special thread. There are a lot of
>>>> difficult things to perform like synchronize_net & netdev_run_todo inside
>>> The special thread ? do you mean keventd_wq ?
>>>
>> I mean that network namespace deletion, i.e. all subsystem ->exit calls
>> should be run outside of all current mechanisms in the separate thread,
>> specially designated to namespace(s) stop.
> 
> Interesting.
> How do you create the thread? Do you use a special workqueue to replace the 
> use of the global keventd workqueue, as I proposed, or do you use another 
> mechanism to create the thread?
> I mean do you create one thread per exiting namespace (each time a namespace
> is exiting you spawn a new thread for the cleanup) or do you create a workqueue
> at system init where you'll queue all cleanup routines (cleanup_net) for all
> exiting namespaces?
> 
> Currently, on our side, we have a small patch that creates a special 
> workqueue in net_ns_init(), and we queue clean_net() in this workqueue
> in __put_net(). 

I think 1 thread in the system is enough. It should accept queued
requests for namespace cleanup. so, this looks pretty same as you do..

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-11-19  9:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-16 16:32 cleanup in workq and dst_destroy Daniel Lezcano
     [not found] ` <473DC604.9070601-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2007-11-16 17:06   ` Denis V. Lunev
     [not found]     ` <473DCE16.8020809-3ImXcnM4P+0@public.gmane.org>
2007-11-19  8:46       ` Daniel Lezcano
     [not found]         ` <47414D64.9040304-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2007-11-19  8:58           ` Denis V. Lunev
     [not found]             ` <4741501C.1090002-3ImXcnM4P+0@public.gmane.org>
2007-11-19  9:03               ` Daniel Lezcano
2007-11-19  9:16               ` Benjamin Thery
     [not found]                 ` <4741546D.6010500-6ktuUTfB/bM@public.gmane.org>
2007-11-19  9:29                   ` Denis V. Lunev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.