Skip to content

Commit 5968e2e

Browse files
committed
smoke: allow external debugging of network namespaces
Since recently, the smoke tests are executed in a "grout" netns which is reused across test runs. Smoke tests do create additional namespaces to act as routers connected to grout. The issue is that creating "nested" network namespaces with iproute2 is not possible. The file created in /run/netns has a reference which is unusable outside of the process that has created it. ~# ip netns Error: Peer netns reference is invalid. Error: Peer netns reference is invalid. grout ns-a ns-b ~# ip netns exec ns-b ip link show setting the network namespace "ns-b" failed: Invalid argument The only way to have namespaces which are visible/accessible from everywhere is to create them from the base namespace (the netns of PID 1). Fixes: 4853d4d ("smoke: make private netns work for single tests") Fixes: 4d5fa1c ("main,smoke: run in private netns") Signed-off-by: Robin Jarry <rjarry@redhat.com> Reviewed-by: Maxime Leroy <maxime@leroys.fr>
1 parent dbd902f commit 5968e2e

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

smoke/_init.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ builddir=${1-}
112112

113113
netns_add() {
114114
local ns="$1"
115-
ip netns add "$ns"
115+
nsenter -t 1 -n -m ip netns add "$ns"
116116
cat >> $tmp/cleanup <<EOF
117-
ip netns pids "$ns" | xargs -r kill --timeout 500 KILL
118-
ip netns del "$ns"
117+
nsenter -t 1 -n -m ip netns pids "$ns" | xargs -r kill --timeout 500 KILL
118+
nsenter -t 1 -n -m ip netns del "$ns"
119119
EOF
120120
ip -n "$ns" link set lo up
121121
}

smoke/_init_frr.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,14 @@ EOF
266266
fi
267267
tailpid=$(pgrep -g0 tail | tail -n1)
268268

269-
ip netns add $namespace
269+
nsenter -t 1 -n -m ip netns add $namespace
270270
frrinit.sh start $namespace
271271

272272
cat >> $tmp/cleanup <<EOF
273273
frrinit.sh stop $namespace
274274
kill $tailpid
275-
ip netns pids $namespace | xargs -r kill --timeout 500 KILL
276-
ip netns del $namespace
275+
nsenter -t 1 -n -m ip netns pids $namespace | xargs -r kill --timeout 500 KILL
276+
nsenter -t 1 -n -m ip netns del $namespace
277277
EOF
278278

279279
SECONDS=0

0 commit comments

Comments
 (0)