aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rwxr-xr-xutils/osmo-gsm-tester_netns_setup.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/utils/osmo-gsm-tester_netns_setup.sh b/utils/osmo-gsm-tester_netns_setup.sh
new file mode 100755
index 0000000..1600c44
--- /dev/null
+++ b/utils/osmo-gsm-tester_netns_setup.sh
@@ -0,0 +1,22 @@
+#!/bin/bash -e
+
+ifname="$1"
+netns="$2"
+shift
+shift
+
+
+
+if [ -f "/var/run/netns/${netns}" ]; then
+ echo "netns $netns already exists"
+else
+ echo "Creating netns $netns"
+ ip netns add "$netns"
+fi
+
+if [ -d "/sys/class/net/${ifname}" ]; then
+ echo "Moving iface $ifname to netns $netns"
+ ip link set $ifname netns $netns
+else
+ ip netns exec $netns ls "/sys/class/net/${ifname}" >/dev/null && echo "iface $ifname already in netns $netns"
+fi