dev='eth0.111'
rate='1Mbit'
ceil="$rate"
mark='3'
iptables -D OUTPUT -t mangle -o $dev -j MARK --set-mark $mark
tc qdisc del dev $dev root
tc qdisc add dev $dev root handle 1:0 htb default 10
tc class add dev $dev parent 1:0 classid 1:10 htb rate $rate ceil $rate prio 0
tc filter add dev $dev parent 1:0 prio 0 protocol ip handle $mark fw flowid 1:$mark
iptables -A OUTPUT -t mangle -o $dev -j MARK --set-mark $mark
root_device='eth0'
tc qdisc del dev $root_device dev root
tc qdisc add dev $root_device root handle 1: htb default 10
tc class replace dev $root_device parent 1:0 classid 1:$vlan_id htb rate $rate ceil $ceil prio 0
tc filter replace dev $root_device protocol 802.1q parent 1:0 prio 1 handle 800::$vlan_id u32 match ip dst "$subnet" match ip protocol 1 0xff flowid 1:$vlan_id
tc qdisc del dev $dev root
tc qdisc add dev $dev root handle 1: htb default 10
tc class add dev $dev parent 1:0 classid 1:10 htb rate $rate ceil $rate prio 0