0

I have an Ubuntu 14.04.1 LTS with 3.13.0-44-generic kernel. My traffic shaper rules:

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

# Add classes for DL device
tc class add dev $devDL parent 1:0 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 sfq divisor $divisor perturb $perturb
tc qdisc add dev $devDL parent 1:12 sfq divisor $divisor perturb $perturb

# 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:0 u32 match ip dst $ip flowid 1:11
    else
        echo $ip
        tc filter add dev $devDL protocol all prio 1 parent 1:0 u32 match ip6 dst $ip flowid 1:11
    fi
    done
    tc filter add dev $devDL protocol all prio 1 parent 1:11 handle 11 flow hash keys dst divisor $divisor baseclass 1:11
fi

tc filter add dev $devDL protocol all prio 2 parent 1:0 u32 match ip dst 0/0 flowid 1:12
tc filter add dev $devDL protocol all prio 2 parent 1:0 u32 match ip6 dst ::/0 flowid 1:12
tc filter add dev $devDL protocol all prio 2 parent 1:12 handle 12 flow hash keys dst divisor $divisor baseclass 1:12

HTB discipline works fine, but sfq external classifier does not work as expected. Two hosts of the same class with running torrent clients do not share bandwidth equally. One client can pick up a lot more of the shared bandwidth.

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

Where is my mistake?

1

I made some errors in the config. Here's the corrected version:

# Add disciplines 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

SFQ qdisc MUST have a handle, and SFQ external classifier MUST use this handle to link to it. Shaper now works as needed.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy