minor improvement
authorIan Kelling <iank@fsf.org>
Tue, 20 Oct 2020 19:49:27 +0000 (15:49 -0400)
committerIan Kelling <iank@fsf.org>
Tue, 20 Oct 2020 19:49:27 +0000 (15:49 -0400)
newns

diff --git a/newns b/newns
index 26874a14949742fd449609038ec4059dc8423081..a3a932511a5b326967208bcd8f8f3b707d7beb0e 100755 (executable)
--- a/newns
+++ b/newns
@@ -143,7 +143,6 @@ if $install_error; then
 fi
 ####   end sanity checking ####
 
-
 v0=veth0-$nn
 v1=veth1-$nn
 ip_base=10.173
@@ -153,13 +152,14 @@ if ! $create && [[ $(readlink /proc/self/ns/net) == "$(readlink /proc/1/ns/net)"
 fi
 
 # make the default network namespace be named
+
+mkdir -p /run/netns
 target=/run/netns/default
 if [[ ! -e $target && ! -L $target ]]; then
-  mkdir -p /run/netns
-  ln -s /proc/1/ns/net $target
+  # -f to avoid a race condition with running twice
+  ln -sf /proc/1/ns/net $target
 fi
 
-
 ipd() { ip -n default "$@"; }