Subject: A question about deleting a network namespace while something is executing in another

From: Rick Jones <[email-masked]>
Date: Thu, 19 Sep 2013 15:10:54 -0700

I've been messing about (as a user) with network namespaces and 
something I call the "thing1/thing2" problem and have a question.  In a 
3.5 kernel if I do:

root@tardy:~# ip netns add thing1
root@tardy:~# ip netns add thing2
root@tardy:~# ip netns exec thing2 sleep 15 &
[1] 27247
root@tardy:~# ip netns del thing1
Cannot remove /var/run/netns/thing1: Device or resource busy
root@tardy:~#
[1]+  Done                    ip netns exec thing2 sleep 15
root@tardy:~# ip netns del thing1
root@tardy:~#

You can see that netns thing1 cannot be deleted while there is an active 
ip netns exec in thing2.

I see the same thing on a 3.8 kernel, and a 3.10 kernel.  In a 3.11.0 
kernel though I see:

~# ip netns add thing1
~# ip netns add thing2
~# ip netns exec thing2 sleep 15 &
[1] 2264
~# ip netns del thing1
~#
~# uname -a
Linux lefty 3.11.0-7-generic #13-Ubuntu SMP Tue Sep 10 20:55:38 UTC 2013 
x86_64 x86_64 x86_64 GNU/Linux

which suggests that the limitation on deleting a namespace while 
something was executing in another was removed.  Happiness and joy ensues.

However...  if I now go to a 3.11.1 kernel built from a clone of 
linux-stable I see:

~# uname -a
Linux lucy 3.11.1 #9 SMP Thu Sep 19 17:11:50 UTC 2013 x86_64 x86_64 
x86_64 GNU/Linux
~# ip netns add thing1
~# ip netns add thing2
~# ip netns exec thing2 sleep 15 &
[1] 22766
~# ip netns del thing1
Cannot remove /var/run/netns/thing1: Device or resource busy
root@qu-stbaz1-perf0001:~#
[1]+  Done                    ip netns exec thing2 sleep 15
~# ip netns del thing1

Did an enhancement get (inadvertently) reverted?  Or perhaps something 
not get added to 3.11.1 that was put into the  3.11.0-7-generic kernel 
(admittedly, I've a slightly mixed set of lineages - the 3.5, 3.8 and 
3.11.0 kernels have passed through Canonical, and the 3.10 and 3.11.1 
kernels came from linux-stable.

And here is 3.12.0rc1, from linux-stable:
~# ip netns add thing1
~# ip netns add thing2
~# ip netns exec thing2 sleep 15 &
[1] 3490
~# ip netns del thing1
Cannot remove /var/run/netns/thing1: Device or resource busy
~#
[1]+  Done                    ip netns exec thing2 sleep 15
~# ip netns del thing1
root@qu-stbaz1-perf0001:~# uname -a
Linux lucy 3.12.0-rc1 #10 SMP Thu Sep 19 21:24:36 UTC 2013 x86_64 x86_64 
x86_64 GNU/Linux

rick jones