path: root/utils/osmo-gsm-tester_netns_setup.sh
diff options
authorPau Espin Pedrol <pespin@sysmocom.de>2019-04-04 16:08:27 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2019-04-04 16:10:14 +0200
commit4c8cd7b9a58d9100fe49b16f281ff24d3e7f81db (patch)
tree0683be94f4554c2c9d7d543986fd0e002d2fdd28 /utils/osmo-gsm-tester_netns_setup.sh
parentb27827b7bc76cee7a573318e9d4f58d85cb2dd80 (diff)
modem: Move modem iface to its netns before using it
We used to do that once after ofono startup for all iface (modem-netns-setup.py), but then if a modem crashes the interface is re-created on the default netns, and tests fail until manual re-run of modem-netns-setup.py. This way now we always make sure the iface is moved to the expected netns before it is used. Related: OS#3881 Change-Id: I506309c424aa46684c4516a1a0217343ecbf32c6
Diffstat (limited to 'utils/osmo-gsm-tester_netns_setup.sh')
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
+if [ -f "/var/run/netns/${netns}" ]; then
+ echo "netns $netns already exists"
+ echo "Creating netns $netns"
+ ip netns add "$netns"
+if [ -d "/sys/class/net/${ifname}" ]; then
+ echo "Moving iface $ifname to netns $netns"
+ ip link set $ifname netns $netns
+ ip netns exec $netns ls "/sys/class/net/${ifname}" >/dev/null && echo "iface $ifname already in netns $netns"