Changes for robustness when deleting a sliver
[nodemanager-topo.git] / setup-egre-link
index 829756d..cef4108 100755 (executable)
@@ -10,6 +10,7 @@ KEY=$4
 RATE=$5
 VIRTIP=$6
 
+VIRTNET=`echo $VIRTIP|sed "s/\.[23]$/.0/"`
 LINK=${KEY}x${NODEID}
 
 modprobe ip_gre
@@ -38,12 +39,12 @@ ifconfig $BRIDGE up
 iptables -t mangle -A FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID
 
 ### Put a process in the vserver so we can move the interface there
-su $SLICE -c "sleep 60" &
+su $SLICE -c "sleep 30" &
 sleep 1
 PID=`su $SLICE -c "pgrep sleep"`
 chcontext --ctx 1 -- echo $PID > /sys/class/net/$ETUN0/new_ns_pid 
 sleep 1
-su $SLICE -c "sudo /sbin/ifconfig $ETUN0 $VIRTIP/24 up"
+su $SLICE -c "sudo /sbin/ifconfig $ETUN0 $VIRTIP/24 up; sudo /sbin/route add -net $VIRTNET/24 dev $ETUN0"
 
 ### Set rate
 tc qdisc add dev $EGRE root handle 1: htb default 10