X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=factory%2Fsetup-link;h=5c93a3095d80ee69ce8a31bb630a28847170711c;hb=78d3f17e2ae09291601278f0dba93ad4454ca378;hp=52ec65689d5860c738d987787775f8872fa0c6c6;hpb=c14f867404dd1089ec7d022c31cd92c854aa3816;p=vsys.git diff --git a/factory/setup-link b/factory/setup-link index 52ec656..5c93a30 100755 --- a/factory/setup-link +++ b/factory/setup-link @@ -4,11 +4,12 @@ IP=/sbin/ip SLICE=$1 SLICEID=`id -u $SLICE` -read LINKNUM -LINK=${SLICEID}$LINKNUM +read LABEL read REMOTE read KEY +LINK=${LABEL}k$KEY + modprobe ip_gre modprobe etun @@ -18,10 +19,10 @@ $IP tunnel add $EGRE mode gre/eth remote $REMOTE key $KEY $IP link set $EGRE up ### Setup etun -ETUN0=veth$LINK +ETUN0=v$LINK ETUN1=etun$LINK echo $ETUN0,$ETUN1 > /sys/module/etun/parameters/newif -ifconfig $ETUN0 up +ifconfig $ETUN0 mtu 1458 up ifconfig $ETUN1 up ### Setup bridge @@ -31,8 +32,13 @@ brctl addif $BRIDGE $EGRE brctl addif $BRIDGE $ETUN1 ifconfig $BRIDGE up +### Setup iptables so that packets are visible in the vserver +iptables -t mangle -A FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID + ### Create "grab link" script GRAB=/vsys/grab-$ETUN0 +echo $SLICE > $GRAB.acl +rm -f $GRAB cat > $GRAB < /sys/class/net/$ETUN0/new_ns_pid EOF chmod +x $GRAB -echo $SLICE > $GRAB.acl +### Create "bind link" script +BIND=/vsys/bind-link-$ETUN0 +echo $SLICE > $BIND.acl +rm -f $BIND +cat > $BIND < $UNBIND < $DELETE.acl +rm -f $DELETE +cat > $DELETE < /sys/module/etun/parameters/delif + +# Get rid of bridge +ifconfig $BRIDGE down +brctl delbr $BRIDGE + +# Get rid of EGRE tunnel +ip tunnel del $EGRE + +# Clean up files +rm -f $GRAB $GRAB.acl +rm -f $DELETE $DELETE.acl +rm -f $BIND $BIND.acl +rm -f $UNBIND $UNBIND.acl +EOF +chmod +x $DELETE