Skip to contentSkip to conversation

man ip-netns: Notice about loose device when do 'del'

PATCH In review Vadim Kochan 2 participants 2 messages Mar 15, 2015 – Mar 20, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 man ip-netns: Notice about loose device when do 'del'

From: Vadim Kochan <[email protected]>

---
v3:
Fixed typos - noticed by Sergei Shtylyov <[email protected]>
v2:
Fixed wrong 'xargs' command - noticed by Christoph Schulz <[email protected]>

 man/man8/ip-netns.8 | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
man/man8/ip-netns.8 +22 -3
index 28a9544..d496675 100644
@@ -46,6 +46,9 @@ ip-netns \- process network namespace management
 A network namespace is logically another copy of the network stack,
 with its own routes, firewall rules, and network devices.
 
+By default process inherits network namespace from its parent. Initially all
+the processes share the same default network namespace from the init process.
+
 By convention a named network namespace is an object at
 .BR "/var/run/netns/" NAME
 that can be opened.  The file descriptor resulting from opening
@@ -88,14 +91,30 @@ network namespace and assigns NAME.
 .sp
 If NAME is present in /var/run/netns it is umounted and the mount
 point is removed.  If this is the last user of the network namespace the
-network namespace will be freed, otherwise the network namespace
-persists until it has no more users.  ip netns delete may fail if
-the mount point is in use in another mount namespace.
+network namespace will be freed and all physical devices will be moved to the
+default one, otherwise the network namespace persists until it has no more
+users. ip netns delete may fail if the mount point is in use in another mount
+namespace.
 
 If
 .B -all
 option was specified then all the network namespace names will be removed.
 
+It is possible to lose the physical device when it was moved to netns and
+then this netns was deleted with a running process:
+
+    $ ip netns add net0
+    $ ip link set dev eth0 netns net0
+    $ ip netns exec net0 SOME_PROCESS_IN_BACKGROUND
+    $ ip netns del net0
+
+and eth0 will appear in the default netns only after SOME_PROCESS_IN_BACKGROUND
+will exit or will be killed. To prevent this the processes running in net0
+should be killed before deleting the netns:
+
+    $ ip netns pids net0 | xargs kill
+    $ ip netns del net0
+
 .TP
 .B ip netns set NAME NETNSID - assign an id to a peer network namespace
 .sp
Signature · 1 line
2.3.1
#1 lore raw

On Sun, 2015-03-15 at 17:49 +0200, Vadim Kochan wrote:
[...]

man/man8/ip-netns.8 ip-netns \- process network namespace management · line 49

Quoted 7 lines
man/man8/ip-netns.8 +1 -0
@@ -46,6 +46,9 @@ ip-netns \- process network namespace management
 A network namespace is logically another copy of the network stack,
 with its own routes, firewall rules, and network devices.
 
+By default process inherits network namespace from its parent. Initially all

Missing "a" before "process".

[...]

man/man8/ip-netns.8 network namespace and assigns NAME. · line 109

Quoted 7 lines
man/man8/ip-netns.8 +7 -0
+It is possible to lose the physical device when it was moved to netns and
+then this netns was deleted with a running process:
+
+    $ ip netns add net0
+    $ ip link set dev eth0 netns net0
+    $ ip netns exec net0 SOME_PROCESS_IN_BACKGROUND
+    $ ip netns del net0

[...]

Use the .RS and .RE macros to begin and end indented text, not spaces.

Ben.

Signature · 2 lines
Ben Hutchings
All extremists should be taken out and shot.