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