updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / sova / qos2
blob48bb1f4df6ef5fe328cfe9cf81876ad88cbb7f56
1 #!/bin/bash
3 # SOVA QoS settings.
5 # WARNING! Remember to put '$true' in any function you intend to leave empty
6 # (e.g. you don't need to use the 'custom_variables' function)
7 # to make sure the script doesn't break.
9 binaries_paths()
11 ### get full paths
12 # the 'exit 0' binary
13 true="`which true`"
15 tc="`which tc`"
16 ip="`which ip`"
17 sv6="`which stripipv6`"
18 iptables="`which iptables`"
19 modprobe="`which modprobe`"
22 custom_variables()
24 # define whatever you need here
26 ### interfaces to redirect traffic from
27 if_to_redir=(vlan334 vlan364 eth1 eth2)
29 ### HTB specific settings
30 quantum="1514"
32 ### router total uplink and downlink (e.g. 100mbit for FastEthernet)
33 global_outgoing="100mbit"
34 global_incoming="100mbit"
37 start_qos()
39 ###
40 ### init part
41 ###
43 ### load the ifb module...
44 $modprobe ifb
46 sleep 1
48 for ctr1 in ifb0 ifb1
50 # ...bring the interfaces up...
51 $ip link set $ctr1 up
52 $sv6 $ctr1
54 sleep 1
56 # ...and set up root queues on them
57 $tc qdisc add dev $ctr1 root handle 1:0 htb
58 done
60 # also, set total badwidth available for the interfaces
61 $tc class add dev ifb0 parent 1:0 classid 1:1 htb \
62 rate $global_incoming quantum $quantum
64 $tc class add dev ifb1 parent 1:0 classid 1:1 htb \
65 rate $global_outgoing quantum $quantum
67 sleep 1
69 ### redirect all incoming and outgoing traffic to ifb0 and ifb1
70 for ctr1 in ${if_to_redir[*]}
72 # the incoming (ifb0)
73 $tc qdisc add dev $ctr1 ingress handle ffff:
75 $tc filter add dev $ctr1 parent ffff: protocol ip u32 \
76 match u32 0 0 action mirred egress redirect dev ifb0 \
77 2> /dev/null > /dev/null
79 # the outgoing (ifb1)
80 $tc qdisc add dev $ctr1 root handle 1:0 htb
82 $tc filter add dev $ctr1 parent 1:0 protocol ip u32 \
83 match u32 0 0 action mirred egress redirect dev ifb1 \
84 2> /dev/null > /dev/null
85 done
87 sleep 1
89 ###
90 ### specific queues
91 ###
94 stop_qos()
96 for ctr2 in ifb0 ifb1 ${if_to_redir[*]}
98 $tc qdisc del root dev $ctr2
99 done
101 for ctr3 in ${if_to_redir[*]}
103 $tc qdisc del dev $ctr3 ingress
104 done
107 # EOF