Qdisc HTB root overlimits and requeues

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello!

I created script for traffic shaping. After run, there are many overlimits
and requeues in tc stat for htb root discipline. Is this normal or something
going wrong?

Here is script:

#!/bin/sh
### BEGIN INIT INFO
# Provides: trafficshaper
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop trafficshaper
# Description: trafficshaper
### END INIT INFO

PATH=/sbin:/bin:/usr/bin

. /lib/init/vars.sh
. /lib/lsb/init-functions

# Reads config file (will override defaults above)
[ -r /etc/default/trafficshaper ] && . /etc/default/trafficshaper

# Devices calculation
devDL=$dev
devUL=ifb0

# Flush discuiplines for DL and UL devices
delete_qdisc () {
    tc qdisc del dev $devDL ingress 2>/dev/null
    tc qdisc del dev $devUL root 2>/dev/null
    tc qdisc del dev $devDL root 2>/dev/null
}

case "$1" in
    start|"")
	log_daemon_msg "Starting trafficshaper" "ok"

	# Global constants
	divisor=2048
	quantum=1514
	perturb=10

	reNum="\([0-9]*\)[a-zA-Z]*"
	reStr="[0-9]*\([a-zA-Z]*\)"

	# Bandwidth calculation
	bwPrivateDL=`expr \( $bwDL : $reNum \) / 2``expr $bwDL : $reStr`
	bwPublicDL=$bwPrivateDL

	bwPrivateUL=`expr \( $bwUL : $reNum \) / 2``expr $bwUL : $reStr`
	bwPublicUL=$bwPrivateUL

	# Delete discuiplines for DL and UL devices
	delete_qdisc

	ifconfig $devUL txqueuelen 1000 2>/dev/null
	ifconfig $devUL up 2>/dev/null

	# Add discuiplines for DL device
	tc qdisc add dev $devDL root handle 1: htb default 12

	# Add classes for DL device
	tc class add dev $devDL parent 1: classid 1:1 htb rate $bwDL ceil
$bwDL quantum $quantum
	tc class add dev $devDL parent 1:1 classid 1:11 htb prio 1 rate
$bwPrivateDL ceil $bwDL quantum $quantum
	tc class add dev $devDL parent 1:1 classid 1:12 htb prio 2 rate
$bwPublicDL ceil $bwPublicDL quantum $quantum

	tc qdisc add dev $devDL parent 1:11 handle 11: sfq divisor $divisor
perturb $perturb
	tc qdisc add dev $devDL parent 1:12 handle 12: sfq divisor $divisor
perturb $perturb

	tc filter add dev $devDL protocol all prio 1 parent 11: handle 11
flow hash keys dst divisor $divisor baseclass 1:11
	tc filter add dev $devDL protocol all prio 2 parent 12: handle 12
flow hash keys dst divisor $divisor baseclass 1:12

	# Add filters for DL device
	if [ -s $filePrivate ]; then
	    for ip in `grep -v "#" $filePrivate`; do
		if [ `expr index $ip :` = 0 ]; then
		    tc filter add dev $devDL protocol all prio 1 parent 1:
u32 match ip dst $ip flowid 1:11
		else
		    echo $ip
		    tc filter add dev $devDL protocol all prio 1 parent 1:
u32 match ip6 dst $ip flowid 1:11
		fi
	    done
	fi

	tc filter add dev $devDL protocol all prio 2 parent 1: u32 match ip
dst 0/0 flowid 1:12
	tc filter add dev $devDL protocol all prio 2 parent 1: u32 match ip6
dst ::/0 flowid 1:12

	# Add discuiplines for UL device
	tc qdisc add dev $devUL root handle 2: htb default 22

	# Add classes for UL device
	tc class add dev $devUL parent 2: classid 2:2 htb rate $bwUL ceil
$bwUL quantum $quantum
	tc class add dev $devUL parent 2:2 classid 2:21 htb prio 1 rate
$bwPrivateUL ceil $bwUL quantum $quantum
	tc class add dev $devUL parent 2:2 classid 2:22 htb prio 2 rate
$bwPublicUL ceil $bwPublicUL quantum $quantum

	tc qdisc add dev $devUL parent 2:21 handle 21: sfq divisor $divisor
perturb $perturb
	tc qdisc add dev $devUL parent 2:22 handle 22: sfq divisor $divisor
perturb $perturb

	tc filter add dev $devUL protocol all prio 1 parent 21: handle 21
flow hash keys src divisor $divisor baseclass 2:21
	tc filter add dev $devUL protocol all prio 2 parent 22: handle 22
flow hash keys src divisor $divisor baseclass 2:22

	# Add filters for UL device
	if [ -s $filePrivate ]; then
	    for ip in `grep -v "#" $filePrivate`; do
		if [ `expr index $ip :` = 0 ]; then
		    tc filter add dev $devUL protocol all prio 1 parent 2:
u32 match ip src $ip flowid 2:21
		else
		    tc filter add dev $devUL protocol all prio 1 parent 2:
u32 match ip6 src $ip flowid 2:21
		fi
	    done
	fi

	tc filter add dev $devUL protocol all prio 2 parent 2: u32 match ip
src 0/0 flowid 2:22
	tc filter add dev $devUL protocol all prio 2 parent 2: u32 match ip6
src ::/0 flowid 2:22

	# Add mirred redirect discuiplines for UL device
	tc qdisc add dev $devDL ingress
	tc filter add dev $devDL parent ffff: protocol all u32 match u32 0 0
action mirred egress redirect dev $devUL

	log_end_msg 0
	;;

    stop)
	log_daemon_msg "Stopping trafficshaper" "ok"

	# Delete discuiplines for DL and UL devices
	delete_qdisc

	log_end_msg 0
	;;

    restart|force-reload)
	$0 stop
	$0 start
	;;

    *)
	echo "Usage: trafficshaper [start|stop|restart|force-reload]" >&2
	exit 3
	;;
esac

:

And there is tc show output:

# tc -s qdisc show dev eth0

qdisc htb 1: root refcnt 6 r2q 10 default 12 direct_packets_stat 5
direct_qlen 1000
 Sent 147698795 bytes 958679 pkt (dropped 0, overlimits 43066 requeues 148)
 backlog 0b 0p requeues 148
qdisc sfq 11: parent 1:11 limit 127p quantum 1514b depth 127 divisor 2048
perturb 10sec
 Sent 81156975 bytes 527521 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
qdisc sfq 12: parent 1:12 limit 127p quantum 1514b depth 127 divisor 2048
perturb 10sec
 Sent 66541452 bytes 431152 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
qdisc ingress ffff: parent ffff:fff1 ----------------
 Sent 2333918666 bytes 1999165 pkt (dropped 421, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0

# tc -s class show dev eth0

class htb 1:11 parent 1:1 leaf 11: prio 1 rate 30000Kbit ceil 60000Kbit
burst 1593b cburst 1590b
 Sent 82530637 bytes 547960 pkt (dropped 0, overlimits 0 requeues 0)
 rate 0bit 0pps backlog 0b 0p requeues 0
 lended: 521119 borrowed: 5867 giants: 0
 tokens: 6097 ctokens: 3048

class htb 1:1 root rate 60000Kbit ceil 60000Kbit burst 1590b cburst 1590b
 Sent 150027823 bytes 987451 pkt (dropped 0, overlimits 0 requeues 0)
 rate 0bit 0pps backlog 0b 0p requeues 0
 lended: 5867 borrowed: 0 giants: 0
 tokens: 3215 ctokens: 3215

class htb 1:12 parent 1:1 leaf 12: prio 2 rate 30000Kbit ceil 30000Kbit
burst 1593b cburst 1593b
 Sent 67497186 bytes 439491 pkt (dropped 0, overlimits 0 requeues 0)
 rate 0bit 0pps backlog 0b 0p requeues 0
 lended: 437399 borrowed: 0 giants: 0
 tokens: 6431 ctokens: 6431

Is my script correct or I'm something missing?

Thank's.

--
To unsubscribe from this list: send the line "unsubscribe lartc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux