[cc lang=”c”]
#!/bin/sh
#
# Incoming traffic control
#
DEV=venet0
#
tc qdisc del dev $DEV root
#
tc qdisc add dev $DEV root handle 1: htb default 10
#
tc class add dev $DEV parent 1: classid 1:1 htb rate 100mbps burst 15k
tc class add dev $DEV parent 1:1 classid 1:30 htb rate 2.5mbps ceil 2.5mbps burst 15k
#
tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10
#
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip dst #IP_VM# flowid 1:30
#
echo;echo “tc configuration for $DEV:”
tc qdisc show dev $DEV
tc class show dev $DEV
tc filter show dev $DEV
#
# Outgoing traffic control
#
DEV=vmbr0
#
tc qdisc del dev $DEV root
#
tc qdisc add dev $DEV root handle 1: htb default 10
#
tc class add dev $DEV parent 1: classid 1:1 htb rate 100mbps burst 15k
tc class add dev $DEV parent 1:1 classid 1:30 htb rate 2.5mbps ceil 2.5mbps burst 15k
#
tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10
#
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip src #IP_VM# flowid 1:30
#
echo;echo “tc configuration for $DEV:”
tc qdisc show dev $DEV
tc class show dev $DEV
tc filter show dev $DEV
[/cc]