aboutsummaryrefslogtreecommitdiffstats
path: root/utils/osmo-gsm-tester_netns_setup.sh
blob: 1600c440fd54301aa00df9e387ffbeda34bb678f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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