git://git.onelab.eu
/
vsys.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Changed interface names to make them shorter, a bit more intuitive
[vsys.git]
/
factory
/
setup-link
diff --git
a/factory/setup-link
b/factory/setup-link
index
be8c949
..
b8c748c
100755
(executable)
--- a/
factory/setup-link
+++ b/
factory/setup-link
@@
-4,29
+4,29
@@
IP=/sbin/ip
SLICE=$1
SLICEID=`id -u $SLICE`
SLICE=$1
SLICEID=`id -u $SLICE`
-read
LABEL
+read
INDEX
read REMOTE
read KEY
read REMOTE
read KEY
-LINK=${
LABEL}k$KEY
+LINK=${
KEY}if${INDEX}
modprobe ip_gre
modprobe etun
### Setup EGRE tunnel
modprobe ip_gre
modprobe etun
### Setup EGRE tunnel
-EGRE=
egre
$LINK
+EGRE=
d
$LINK
$IP tunnel add $EGRE mode gre/eth remote $REMOTE key $KEY
$IP link set $EGRE up
### Setup etun
$IP tunnel add $EGRE mode gre/eth remote $REMOTE key $KEY
$IP link set $EGRE up
### Setup etun
-ETUN0=
v
$LINK
-ETUN1=
etun
$LINK
+ETUN0=
a
$LINK
+ETUN1=
b
$LINK
echo $ETUN0,$ETUN1 > /sys/module/etun/parameters/newif
ifconfig $ETUN0 mtu 1458 up
ifconfig $ETUN1 up
### Setup bridge
echo $ETUN0,$ETUN1 > /sys/module/etun/parameters/newif
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
brctl addbr $BRIDGE
brctl addif $BRIDGE $EGRE
brctl addif $BRIDGE $ETUN1
@@
-37,6
+37,8
@@
iptables -t mangle -A FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID
### Create "grab link" script
GRAB=/vsys/grab-$ETUN0
### Create "grab link" script
GRAB=/vsys/grab-$ETUN0
+echo $SLICE > $GRAB.acl
+rm -f $GRAB
cat > $GRAB <<EOF
#!/bin/sh
cat > $GRAB <<EOF
#!/bin/sh
@@
-45,13
+47,35
@@
read PID
chcontext --ctx 1 -- echo \$PID > /sys/class/net/$ETUN0/new_ns_pid
EOF
chmod +x $GRAB
chcontext --ctx 1 -- echo \$PID > /sys/class/net/$ETUN0/new_ns_pid
EOF
chmod +x $GRAB
-echo $SLICE > $GRAB.acl
+
+### Create script for setting link rate
+BIND=/vsys/rate-$ETUN0
+echo $SLICE > $BIND.acl
+rm -f $BIND
+cat > $BIND <<EOF
+#!/bin/sh
+
+read rt
+read lt
+read burs
+
+tc qdisc add dev $EGRE root tbf rate \$rt latency \$lt burst \$burs
+
+rm -rf $BIND.acl
+touch $BIND.acl
+
+EOF
+chmod +x $BIND
### Create "delete link" script
DELETE=/vsys/delete-$ETUN0
### Create "delete link" script
DELETE=/vsys/delete-$ETUN0
+echo $SLICE > $DELETE.acl
+rm -f $DELETE
cat > $DELETE <<EOF
#!/bin/sh
cat > $DELETE <<EOF
#!/bin/sh
+read NULL
+
# Remove iptables rule
iptables -t mangle -D FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID
# Remove iptables rule
iptables -t mangle -D FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID
@@
-66,11
+90,8
@@
brctl delbr $BRIDGE
ip tunnel del $EGRE
# Clean up files
ip tunnel del $EGRE
# Clean up files
-rm
$GRAB
-rm
$DELETE
-
+rm
-f $GRAB $GRAB.acl
+rm
-f $DELETE $DELETE.acl
+rm -f $BIND $BIND.acl
EOF
chmod +x $DELETE
EOF
chmod +x $DELETE
-echo $SLICE > $DELETE.acl
-
-