Fix for OpenVPN support
[nodemanager-topo.git] / setup-egre-link
index 829756d..16c366a 100755 (executable)
@@ -9,7 +9,9 @@ REMOTE=$3
 KEY=$4
 RATE=$5
 VIRTIP=$6
+VIRTNET=$7
 
+SUBNET=`expr match "$VIRTNET" '.*\(/[0-9]*\)'`
 LINK=${KEY}x${NODEID}
 
 modprobe ip_gre
@@ -38,12 +40,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}${SUBNET} up; sudo /sbin/route add -net $VIRTNET dev $ETUN0"
 
 ### Set rate
 tc qdisc add dev $EGRE root handle 1: htb default 10