Decided to make this an API call.
[nodemanager-topo.git] / teardown-egre-link
1 #!/bin/sh +x
2
3 NODEID=$1
4 KEY=$2
5
6 LINK=${KEY}x${NODEID}
7 EGRE=d$LINK
8 BRIDGE=c$LINK
9 ETUN1=b$LINK
10
11 MARK=`iptables -t mangle -L -v|grep -m 1 $BRIDGE|awk '{print $NF}'`
12
13 # Remove iptables rules.  Sometimes there is more than one.
14 while [ $? -eq 0 ]; do
15     iptables -t mangle -D FORWARD -o $BRIDGE -j MARK --set-mark $MARK
16 done
17
18 # Get rid of etun devices, only need name of one of them
19 echo $ETUN1 > /sys/module/etun/parameters/delif
20
21 # Get rid of bridge
22 ifconfig $BRIDGE down
23 brctl delbr $BRIDGE
24
25 # Get rid of EGRE tunnel
26 ip tunnel del $EGRE
27