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
Add backslash
[vsys.git]
/
factory
/
setup-link
diff --git
a/factory/setup-link
b/factory/setup-link
index
5c93a30
..
cc800ce
100755
(executable)
--- a/
factory/setup-link
+++ b/
factory/setup-link
@@
-1,32
+1,29
@@
#!/bin/sh +x
#!/bin/sh +x
-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 ip_gre
-modprobe etun
### Setup EGRE tunnel
### 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
### 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
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
@@
-36,7
+33,7
@@
ifconfig $BRIDGE up
iptables -t mangle -A FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID
### Create "grab link" script
iptables -t mangle -A FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID
### Create "grab link" script
-GRAB=/vsys/grab-$ETUN0
+GRAB=/vsys/
local_
grab-$ETUN0
echo $SLICE > $GRAB.acl
rm -f $GRAB
cat > $GRAB <<EOF
echo $SLICE > $GRAB.acl
rm -f $GRAB
cat > $GRAB <<EOF
@@
-44,22
+41,21
@@
cat > $GRAB <<EOF
read PID
read PID
-chcontext --ctx 1 -- echo \$PID > /sys/class/net/$ETUN0/new_ns_pid
+ip link set $ETUN0 netns \$PID
EOF
chmod +x $GRAB
EOF
chmod +x $GRAB
-### Create
"bind link" script
-BIND=/vsys/
bind-link
-$ETUN0
+### Create
script for setting link rate
+BIND=/vsys/
local_rate
-$ETUN0
echo $SLICE > $BIND.acl
rm -f $BIND
cat > $BIND <<EOF
#!/bin/sh
read rt
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
+tc qdisc add dev $EGRE root handle 1: htb default 10
+tc class add dev $EGRE parent 1: classid 1:10 htb rate \$rt ceil \$rt
rm -rf $BIND.acl
touch $BIND.acl
rm -rf $BIND.acl
touch $BIND.acl
@@
-67,20
+63,8
@@
touch $BIND.acl
EOF
chmod +x $BIND
EOF
chmod +x $BIND
-### Create "unbind link" script
-UNBIND=/vsys/unbind-link-$ETUN0
-touch $UNBIND.acl
-rm -f $UNBIND
-cat > $UNBIND <<EOF
-#!/bin/sh
-
-tc qdisc del root dev $EGRE
-
-EOF
-chmod +x $UNBIND
-
### Create "delete link" script
### Create "delete link" script
-DELETE=/vsys/delete-$ETUN0
+DELETE=/vsys/
local_
delete-$ETUN0
echo $SLICE > $DELETE.acl
rm -f $DELETE
cat > $DELETE <<EOF
echo $SLICE > $DELETE.acl
rm -f $DELETE
cat > $DELETE <<EOF
@@
-92,7
+76,7
@@
read NULL
iptables -t mangle -D FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID
# Get rid of etun devices, only need name of one of them
iptables -t mangle -D FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID
# Get rid of etun devices, only need name of one of them
-echo $ETUN1 > /sys/module/etun/parameters/delif
+ip link delete dev $ETUN1
# Get rid of bridge
ifconfig $BRIDGE down
# Get rid of bridge
ifconfig $BRIDGE down
@@
-105,6
+89,5
@@
ip tunnel del $EGRE
rm -f $GRAB $GRAB.acl
rm -f $DELETE $DELETE.acl
rm -f $BIND $BIND.acl
rm -f $GRAB $GRAB.acl
rm -f $DELETE $DELETE.acl
rm -f $BIND $BIND.acl
-rm -f $UNBIND $UNBIND.acl
EOF
chmod +x $DELETE
EOF
chmod +x $DELETE