Add 'manual' topology mode for manually specifying rspecs
[nodemanager-topo.git] / setup-egre-link
1 #!/bin/sh +x
2
3 IP=/sbin/ip
4
5 SLICE=$1
6 SLICEID=`id -u $SLICE`
7 NODEID=$2
8 REMOTE=$3
9 KEY=$4
10 RATE=$5
11 VIRTIP=$6
12 VIRTNET=$7
13
14 SUBNET=`expr match "$VIRTNET" '.*\(/[0-9]*\)'`
15 LINK=${KEY}x${NODEID}
16
17 modprobe ip_gre
18
19 ### Setup EGRE tunnel
20 EGRE=d$LINK
21 $IP tunnel add $EGRE  mode gre type eth remote $REMOTE key $KEY ttl 64
22 $IP link set $EGRE up
23
24 ### Setup macvlan
25 MACV=a$LINK
26 ip link add link $EGRE $MACV type macvlan
27
28 ### Put a process in the vserver so we can move the interface there
29 su $SLICE -c "sleep 30 &"
30 PID=`su $SLICE -c "pgrep -n sleep"`
31 $IP link set $MACV netns $PID
32 naddress --add --nid $SLICEID --ip ${VIRTIP}${SUBNET}
33 su $SLICE -c "sudo /sbin/ifconfig $MACV ${VIRTIP}${SUBNET} mtu 1458 up"
34
35 ### Set rate
36 tc qdisc add dev $EGRE root handle 1: htb default 10
37 tc class add dev $EGRE parent 1: classid 1:10 htb rate $RATE ceil $RATE
38