4

I am trying to limit the maximum bandwidth for a range of ports (collectively) using tc. Below is the script:

tc qdisc add dev eth0 root handle 1: htb default 10;
tc class add dev eth0 parent 1: classid 1:1 htb rate 75kbit;
tc qdisc add dev eth0 parent 1:1 handle 2: sfq perturb 10
tc filter add dev eth0 parent 1: protocol ip u32 match ip sport 5000 0xffff flowid 1:1;
tc filter add dev eth0 parent 1: protocol ip u32 match ip sport 5001 0xffff flowid 1:1;

The above script runs fine, but the bandwidth on those ports is not limited.

When I check the status, I cannot find any filter for those ports:

$ tc class show dev eth0
class htb 1:1 root leaf 2: prio 0 rate 75000bit ceil 75000bit burst 1599b cburst 1599b

$ tc qdisc show dev eth0
qdisc htb 1: root refcnt 9 r2q 10 default 10 direct_packets_stat 49 direct_qlen 1000
qdisc sfq 2: parent 1:1 limit 127p quantum 1514b depth 127 divisor 1024 perturb 10sec 

$ tc filter show dev eth0
filter parent 1: protocol ip pref 49152 u32 
filter parent 1: protocol ip pref 49152 u32 fh 800: ht divisor 1 
filter parent 1: protocol ip pref 49152 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1 
  match 13880000/ffff0000 at 20

From above output, I can recoginize the class and qdisc being applied, but I can't see filter for ports 5000 and 5001 in the above output.

Is this the expected output for filter? How do I resolve this so that the bandwidth limit is enforced?

John Elaine
  • 359
  • 5
  • 22

0 Answers0