[LARTC] CBQ + 802.1Q VLAN

Ricardo linux@netcomp.com.br
Fri, 6 Aug 2004 15:16:55 -0300


This is a multi-part message in MIME format.

------=_NextPart_000_002A_01C47BC8.6900EB00
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

    I need to shape traffic from some IP on one LAN, but I'm in trouble. =
There is a linux 2.4.26 connected to the Internet (eth0) / LAN(eth1) =
doing NAT. I'm using VLANs in the LAN Interface, that is connected to a =
3Com SuperStack II in a 802.1Q tagged port.
=20
I want to create a class that will limit the traffic at 384Kbit/s.
I want to create two leaf classes that limit the traffic at 256Kbit/s =
for each one.
I want to attach two sfq qdiscs so the classes are treated equally.
I want to put filters that put one IP address for each 256 class (supose =
that are only two computers on LAN).
When one computer is downloading a file from internet it need to never =
be more than 256Kbit.
When both computers are downloading files at the same time, they need to =
never be more than 384Kbit together.
I want to attach the qdisc on eth1 (and no one on each VLAN ex. eth1.1, =
eth1.2, eth1.3 ...) so all VLAN traffic will be processed.

The config:

# root qdisc
tc qdisc add dev eth0 root handle 1:0 cbq bandwidth 100Mbit avpkt 1000 =
cell 8
tc qdisc add dev eth1 root handle 1:0 cbq bandwidth 100Mbit avpkt 1000 =
cell 8

# root class
tc class add dev eth0 parent 1:0 classid 1:1 cbq bandwidth 100Mbit rate =
384Kbit weight 38Kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1000 =
bounded
tc class add dev eth1 parent 1:0 classid 1:1 cbq bandwidth 100Mbit rate =
384Kbit weight 38Kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1000 =
bounded

# leaf class 1 & 2
tc class add dev eth0 parent 1:1 classid 1:10 cbq bandwidth 100Mbit rate =
256Kbit weight 25Kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1000
tc class add dev eth0 parent 1:1 classid 1:20 cbq bandwidth 100Mbit rate =
256Kbit weight 25Kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1000
tc class add dev eth1 parent 1:1 classid 1:10 cbq bandwidth 100Mbit rate =
256Kbit weight 25Kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1000
tc class add dev eth1 parent 1:1 classid 1:20 cbq bandwidth 100Mbit rate =
256Kbit weight 25Kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1000

# sfq
tc qdisc add dev eth0 parent 1:10 handle 100: sfq
tc qdisc add dev eth0 parent 1:20 handle 200: sfq
tc qdisc add dev eth1 parent 1:10 handle 100: sfq
tc qdisc add dev eth1 parent 1:20 handle 200: sfq

# filters
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 match ip src =
10.0.0.2/32 flowid 1:10
tc filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst =
10.0.0.2/32 flowid 1:10

tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 match ip src =
10.0.0.3/32 flowid 1:20
tc filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip dst =
10.0.0.3/32 flowid 1:20

When I start a download from one computer the speed is limited at =
256Kbit/s (this is OK)
When I start a download from both machines the speed for each one is =
256Kbit/s. They are getting 512Kbit/s together and the 384Kb parent link =
is not working.
What is wrong ???

Regards

Ricardo

STATS:

### eth0: queueing disciplines

qdisc sfq 200: quantum 1514b perturb 10sec=20
 Sent 0 bytes 0 pkts (dropped 0, overlimits 0)=20

 qdisc sfq 100: quantum 1514b perturb 10sec=20
 Sent 0 bytes 0 pkts (dropped 0, overlimits 0)=20

 qdisc cbq 1: rate 100Mbit (bounded,isolated) prio no-transmit
 Sent 711595 bytes 7024 pkts (dropped 0, overlimits 0)=20
  borrowed 0 overactions 0 avgidle 60 undertime 0

=20
### eth0: traffic classes

class cbq 1: root rate 100Mbit (bounded,isolated) prio no-transmit
 Sent 711595 bytes 7024 pkts (dropped 0, overlimits 0)=20
  borrowed 0 overactions 0 avgidle 60 undertime 0
class cbq 1:10 parent 1:1 leaf 100: rate 256Kbit prio no-transmit
 Sent 0 bytes 0 pkts (dropped 0, overlimits 0)=20
  borrowed 0 overactions 0 avgidle 707804 undertime 0
class cbq 1:1 parent 1: rate 384Kbit (bounded) prio no-transmit
 Sent 0 bytes 0 pkts (dropped 0, overlimits 0)=20
  borrowed 0 overactions 0 avgidle 471277 undertime 0
class cbq 1:20 parent 1:1 leaf 200: rate 256Kbit prio no-transmit
 Sent 0 bytes 0 pkts (dropped 0, overlimits 0)=20
  borrowed 0 overactions 0 avgidle 707804 undertime 0

### eth0: filtering rules

filter parent 1: protocol ip pref 1 u32=20
filter parent 1: protocol ip pref 1 u32 fh 800: ht divisor 1=20
filter parent 1: protocol ip pref 1 u32 fh 800::800 order 2048 key ht =
800 bkt 0 flowid 1:10=20
  match 0a000002/ffffffff at 12
filter parent 1: protocol ip pref 1 u32 fh 800::801 order 2049 key ht =
800 bkt 0 flowid 1:20=20
  match 0a000003/ffffffff at 12

### eth1: queueing disciplines

qdisc sfq 200: quantum 1514b perturb 10sec=20
 Sent 4541217 bytes 3268 pkts (dropped 0, overlimits 0)=20
 backlog 14p=20

 qdisc sfq 100: quantum 1514b perturb 10sec=20
 Sent 4341261 bytes 3054 pkts (dropped 0, overlimits 0)=20
 backlog 25p=20

 qdisc cbq 1: rate 100Mbit (bounded,isolated) prio no-transmit
 Sent 10606524 bytes 9897 pkts (dropped 0, overlimits 11757)=20
 backlog 39p=20
  borrowed 0 overactions 0 avgidle 60 undertime 0

=20
### eth1: traffic classes

class cbq 1: root rate 100Mbit (bounded,isolated) prio no-transmit
 Sent 10550332 bytes 9859 pkts (dropped 0, overlimits 0)=20
  borrowed 0 overactions 0 avgidle 62 undertime 0
class cbq 1:10 parent 1:1 leaf 100: rate 256Kbit prio no-transmit
 Sent 4306071 bytes 3029 pkts (dropped 0, overlimits 1011237)=20
 backlog 25p=20
  borrowed 35 overactions 2478 avgidle -26542 undertime 21120
class cbq 1:1 parent 1: rate 384Kbit (bounded) prio no-transmit
 Sent 8826036 bytes 6283 pkts (dropped 0, overlimits 0)=20
  borrowed 212 overactions 0 avgidle -220835 undertime 222548
class cbq 1:20 parent 1:1 leaf 200: rate 256Kbit prio no-transmit
 Sent 4519965 bytes 3254 pkts (dropped 0, overlimits 1017602)=20
 backlog 14p=20
  borrowed 177 overactions 2484 avgidle -30709 undertime 21214

### eth1: filtering rules

filter parent 1: protocol ip pref 1 u32=20
filter parent 1: protocol ip pref 1 u32 fh 800: ht divisor 1=20
filter parent 1: protocol ip pref 1 u32 fh 800::800 order 2048 key ht =
800 bkt 0 flowid 1:10=20
  match 0a000002/ffffffff at 16
filter parent 1: protocol ip pref 1 u32 fh 800::801 order 2049 key ht =
800 bkt 0 flowid 1:20=20
  match 0a000003/ffffffff at 16
------=_NextPart_000_002A_01C47BC8.6900EB00
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1458" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; I need to shape =
traffic from=20
some IP on&nbsp;one LAN, but&nbsp;I'm in&nbsp;trouble.&nbsp;There =
is&nbsp;a=20
linux&nbsp;2.4.26 connected to the Internet (eth0) / LAN(eth1) doing=20
NAT.&nbsp;I'm using VLANs in the LAN Interface, that is connected to a =
3Com=20
SuperStack II in a 802.1Q tagged port.<BR>&nbsp;</DIV>
<DIV>
<DIV>I want to create a class&nbsp;that will limit the&nbsp;traffic at=20
384Kbit/s.</DIV>
<DIV>I want to create&nbsp;two leaf classes that limit the&nbsp;traffic =
at=20
256Kbit/s for each one.</DIV>
<DIV>I want to attach two&nbsp;sfq qdiscs so the classes are treated=20
equally.</DIV>
<DIV>I want to&nbsp;put&nbsp;filters that&nbsp;put&nbsp;one IP address =
for=20
each&nbsp;256 class (supose that are only two&nbsp;computers =
on&nbsp;LAN).</DIV>
<DIV>When one computer is downloading a file from internet it need to =
never be=20
more than 256Kbit.</DIV>
<DIV>When both&nbsp;computers&nbsp;are downloading files at the same =
time,=20
they&nbsp;need to&nbsp;never be more than 384Kbit together.</DIV>
<DIV>I want to&nbsp;attach the qdisc on eth1 (and no one on each VLAN=20
ex.&nbsp;eth1.1, eth1.2, eth1.3 ...) so all VLAN traffic will be=20
processed.</DIV>
<DIV>&nbsp;</DIV>
<DIV>The&nbsp;config:</DIV>
<DIV>&nbsp;</DIV>
<DIV># root qdisc</DIV>
<DIV>tc qdisc add dev eth0 root handle 1:0 cbq bandwidth 100Mbit avpkt =
1000 cell=20
8<BR>tc qdisc add dev eth1 root handle 1:0 cbq bandwidth 100Mbit avpkt =
1000 cell=20
8<BR></DIV>
<DIV># root class</DIV>
<DIV>
<DIV>tc class add dev eth0 parent 1:0 classid 1:1 cbq bandwidth 100Mbit =
rate=20
384Kbit weight 38Kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1000=20
bounded</DIV>
<DIV>
<DIV>tc class add dev eth1 parent 1:0 classid 1:1 cbq bandwidth 100Mbit =
rate=20
384Kbit weight 38Kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1000=20
bounded</DIV>
<DIV>&nbsp;</DIV>
<DIV># leaf class 1 &amp; 2</DIV></DIV></DIV>
<DIV>tc class add dev eth0 parent 1:1 classid 1:10 cbq bandwidth 100Mbit =
rate=20
256Kbit weight 25Kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt =
1000<BR>tc=20
class add dev eth0 parent 1:1 classid 1:20 cbq bandwidth 100Mbit rate =
256Kbit=20
weight 25Kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1000</DIV>
<DIV>tc class add dev eth1 parent 1:1 classid 1:10 cbq bandwidth 100Mbit =
rate=20
256Kbit weight 25Kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt =
1000<BR>tc=20
class add dev eth1 parent 1:1 classid 1:20 cbq bandwidth 100Mbit rate =
256Kbit=20
weight 25Kbit prio 8 allot 1514 cell 8 maxburst 20 avpkt 1000</DIV>
<DIV>&nbsp;</DIV>
<DIV># sfq</DIV>
<DIV>tc qdisc add dev eth0 parent 1:10 handle 100: sfq<BR>tc qdisc add =
dev eth0=20
parent 1:20 handle 200: sfq</DIV>
<DIV>tc qdisc add dev eth1 parent 1:10 handle 100: sfq<BR>tc qdisc add =
dev eth1=20
parent 1:20 handle 200: sfq</DIV>
<DIV>&nbsp;</DIV>
<DIV># filters</DIV>
<DIV>tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 match =
ip&nbsp;src=20
10.0.0.2/32 flowid 1:10<BR>tc filter add dev eth1 parent 1:0 protocol ip =
prio 1=20
u32 match ip dst 10.0.0.2/32 flowid 1:10<BR></DIV>
<DIV>tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 match =
ip&nbsp;src=20
10.0.0.3/32 flowid 1:20</DIV>
<DIV>tc filter add dev eth1 parent 1:0 protocol ip prio 1 u32 match ip =
dst=20
10.0.0.3/32 flowid 1:20</DIV>
<DIV>&nbsp;</DIV>
<DIV>
<DIV>When I start a download from one computer the speed is limited at =
256Kbit/s=20
(this is OK)</DIV>
<DIV>When I start a download from both machines the speed for each =
one&nbsp;is=20
256Kbit/s. They are getting 512Kbit/s together and the 384Kb parent link =
is not=20
working.</DIV>
<DIV>What&nbsp;is wrong ???</DIV></DIV>
<DIV>&nbsp;</DIV>
<DIV>
<DIV>Regards</DIV>
<DIV>&nbsp;</DIV>
<DIV>Ricardo</DIV></DIV>
<DIV>&nbsp;</DIV>
<DIV>STATS:</DIV>
<DIV>&nbsp;</DIV>
<DIV>### eth0: queueing disciplines</DIV>
<DIV>&nbsp;</DIV>
<DIV>qdisc sfq 200: quantum 1514b perturb 10sec <BR>&nbsp;Sent 0 bytes 0 =
pkts=20
(dropped 0, overlimits 0) </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;qdisc sfq 100: quantum 1514b perturb 10sec <BR>&nbsp;Sent 0 =
bytes 0=20
pkts (dropped 0, overlimits 0) </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;qdisc cbq 1: rate 100Mbit (bounded,isolated) prio=20
no-transmit<BR>&nbsp;Sent 711595 bytes 7024 pkts (dropped 0, overlimits =
0)=20
<BR>&nbsp; borrowed 0 overactions 0 avgidle 60 undertime 0</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;<BR>### eth0: traffic classes</DIV>
<DIV>&nbsp;</DIV>
<DIV>class cbq 1: root rate 100Mbit (bounded,isolated) prio=20
no-transmit<BR>&nbsp;Sent 711595 bytes 7024 pkts (dropped 0, overlimits =
0)=20
<BR>&nbsp; borrowed 0 overactions 0 avgidle 60 undertime 0<BR>class cbq =
1:10=20
parent 1:1 leaf 100: rate 256Kbit prio no-transmit<BR>&nbsp;Sent 0 bytes =
0 pkts=20
(dropped 0, overlimits 0) <BR>&nbsp; borrowed 0 overactions 0 avgidle =
707804=20
undertime 0<BR>class cbq 1:1 parent 1: rate 384Kbit (bounded) prio=20
no-transmit<BR>&nbsp;Sent 0 bytes 0 pkts (dropped 0, overlimits 0) =
<BR>&nbsp;=20
borrowed 0 overactions 0 avgidle 471277 undertime 0<BR>class cbq 1:20 =
parent 1:1=20
leaf 200: rate 256Kbit prio no-transmit<BR>&nbsp;Sent 0 bytes 0 pkts =
(dropped 0,=20
overlimits 0) <BR>&nbsp; borrowed 0 overactions 0 avgidle 707804 =
undertime=20
0</DIV>
<DIV>&nbsp;</DIV>
<DIV>### eth0: filtering rules</DIV>
<DIV>&nbsp;</DIV>
<DIV>filter parent 1: protocol ip pref 1 u32 <BR>filter parent 1: =
protocol ip=20
pref 1 u32 fh 800: ht divisor 1 <BR>filter parent 1: protocol ip pref 1 =
u32 fh=20
800::800 order 2048 key ht 800 bkt 0 flowid 1:10 <BR>&nbsp; match=20
0a000002/ffffffff at 12<BR>filter parent 1: protocol ip pref 1 u32 fh =
800::801=20
order 2049 key ht 800 bkt 0 flowid 1:20 <BR>&nbsp; match =
0a000003/ffffffff at=20
12</DIV>
<DIV>&nbsp;</DIV>
<DIV>### eth1: queueing disciplines</DIV>
<DIV>&nbsp;</DIV>
<DIV>qdisc sfq 200: quantum 1514b perturb 10sec <BR>&nbsp;Sent 4541217 =
bytes=20
3268 pkts (dropped 0, overlimits 0) <BR>&nbsp;backlog 14p </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;qdisc sfq 100: quantum 1514b perturb 10sec <BR>&nbsp;Sent =
4341261=20
bytes 3054 pkts (dropped 0, overlimits 0) <BR>&nbsp;backlog 25p </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;qdisc cbq 1: rate 100Mbit (bounded,isolated) prio=20
no-transmit<BR>&nbsp;Sent 10606524 bytes 9897 pkts (dropped 0, =
overlimits 11757)=20
<BR>&nbsp;backlog 39p <BR>&nbsp; borrowed 0 overactions 0 avgidle 60 =
undertime=20
0</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;<BR>### eth1: traffic classes</DIV>
<DIV>&nbsp;</DIV>
<DIV>class cbq 1: root rate 100Mbit (bounded,isolated) prio=20
no-transmit<BR>&nbsp;Sent 10550332 bytes 9859 pkts (dropped 0, =
overlimits 0)=20
<BR>&nbsp; borrowed 0 overactions 0 avgidle 62 undertime 0<BR>class cbq =
1:10=20
parent 1:1 leaf 100: rate 256Kbit prio no-transmit<BR>&nbsp;Sent 4306071 =
bytes=20
3029 pkts (dropped 0, overlimits 1011237) <BR>&nbsp;backlog 25p =
<BR>&nbsp;=20
borrowed 35 overactions 2478 avgidle -26542 undertime 21120<BR>class cbq =
1:1=20
parent 1: rate 384Kbit (bounded) prio no-transmit<BR>&nbsp;Sent 8826036 =
bytes=20
6283 pkts (dropped 0, overlimits 0) <BR>&nbsp; borrowed 212 overactions =
0=20
avgidle -220835 undertime 222548<BR>class cbq 1:20 parent 1:1 leaf 200: =
rate=20
256Kbit prio no-transmit<BR>&nbsp;Sent 4519965 bytes 3254 pkts (dropped =
0,=20
overlimits 1017602) <BR>&nbsp;backlog 14p <BR>&nbsp; borrowed 177 =
overactions=20
2484 avgidle -30709 undertime 21214</DIV>
<DIV>&nbsp;</DIV>
<DIV>### eth1: filtering rules</DIV>
<DIV>&nbsp;</DIV>
<DIV>filter parent 1: protocol ip pref 1 u32 <BR>filter parent 1: =
protocol ip=20
pref 1 u32 fh 800: ht divisor 1 <BR>filter parent 1: protocol ip pref 1 =
u32 fh=20
800::800 order 2048 key ht 800 bkt 0 flowid 1:10 <BR>&nbsp; match=20
0a000002/ffffffff at 16<BR>filter parent 1: protocol ip pref 1 u32 fh =
800::801=20
order 2049 key ht 800 bkt 0 flowid 1:20 <BR>&nbsp; match =
0a000003/ffffffff at=20
16</DIV></FONT></DIV></BODY></HTML>

------=_NextPart_000_002A_01C47BC8.6900EB00--