X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=factory%2Fsetup-link;h=cc800ce8701183a867df118d1b754a4f96295b77;hb=ec3b7dbe56acbc80e7d22dc88a70146f25aed42c;hp=ba8cb4215ff8c7c1eb1c980c836c2658114f9cb6;hpb=6cfa5641aec9f21862cb6a6772ccd2a4cbb5481f;p=vsys.git diff --git a/factory/setup-link b/factory/setup-link index ba8cb42..cc800ce 100755 --- a/factory/setup-link +++ b/factory/setup-link @@ -1,32 +1,29 @@ #!/bin/sh +x -IP=/sbin/ip - SLICE=$1 SLICEID=`id -u $SLICE` -read LABEL +read INDEX read REMOTE read KEY -LINK=${LABEL}k$KEY +LINK=${KEY}if${INDEX} modprobe ip_gre -modprobe etun ### Setup EGRE tunnel -EGRE=egre$LINK -$IP tunnel add $EGRE mode gre/eth remote $REMOTE key $KEY -$IP link set $EGRE up +EGRE=d$LINK +ip tunnel add $EGRE mode gre type eth remote $REMOTE key $KEY ttl 64 +ip link set $EGRE up ### Setup etun -ETUN0=v$LINK -ETUN1=etun$LINK -echo $ETUN0,$ETUN1 > /sys/module/etun/parameters/newif +ETUN0=a$LINK +ETUN1=b$LINK +ip link add name $ETUN0 type veth peer name $ETUN1 ifconfig $ETUN0 mtu 1458 up ifconfig $ETUN1 up ### Setup bridge -BRIDGE=br$LINK +BRIDGE=c$LINK brctl addbr $BRIDGE brctl addif $BRIDGE $EGRE brctl addif $BRIDGE $ETUN1 @@ -36,22 +33,40 @@ ifconfig $BRIDGE up iptables -t mangle -A FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID ### Create "grab link" script -GRAB=/vsys/grab-$ETUN0 -rm -f $GRAB $GRAB.acl +GRAB=/vsys/local_grab-$ETUN0 +echo $SLICE > $GRAB.acl +rm -f $GRAB cat > $GRAB < /sys/class/net/$ETUN0/new_ns_pid +ip link set $ETUN0 netns \$PID EOF chmod +x $GRAB -sleep 1 -echo $SLICE > $GRAB.acl + +### Create script for setting link rate +BIND=/vsys/local_rate-$ETUN0 +echo $SLICE > $BIND.acl +rm -f $BIND +cat > $BIND < $DELETE.acl +rm -f $DELETE cat > $DELETE < /sys/module/etun/parameters/delif +ip link delete dev $ETUN1 # Get rid of bridge ifconfig $BRIDGE down @@ -73,10 +88,6 @@ ip tunnel del $EGRE # Clean up files rm -f $GRAB $GRAB.acl rm -f $DELETE $DELETE.acl - +rm -f $BIND $BIND.acl EOF chmod +x $DELETE -sleep 1 -echo $SLICE > $DELETE.acl - -