Problems HTB Classes with libnl3

Adrian Ban adrian.ban at euroweb.ro
Tue Jul 5 03:12:15 EDT 2011


Hi,

I got some problems with HTB classes when I'm using the libnl3. It's a 
strange behavior when I'm setting the rbuffer and cbuffer with value of 
1500 bytes for example I got a value of:

class htb 1:5 parent 1:1 leaf 5: prio 0 rate 574640bit ceil 8000Kbit 
burst 95b cburst 96b

when I'm running the "tc class show dev ifb0".

When I'm running the code and dump the class information I got:

Download
     rate = 574647
     ceil = 8000000
Upload
     rate = 574647
     ceil = 8000000
Class  ID: 1:1
Qdisc Class ID: 5:
Parent ID: 1:5
Class rate burst: 1500
class htb dev ifb0 id 01:05 parent 01:01 rate 70.15KiB/s (561Kbit) log 
2147483648
    ceil 976.56KiB/s (8Mbit) log 2147483648 prio 100 rbuffer 1.46KiB 
cbuffer 1.46KiB
qdisc sfq dev ifb0 id 05: parent 01:05 quantum 0 perturb 10s
   refcnt 0 limit 0 divisor 0

The stripped code I've used:

     uint32_t htbBuffer;
...
     htbBuffer=1500;
     rtnl_htb_set_rbuffer(ClassHTB, htbBuffer);


To correct this I've found this formula:

     htbBuffer=floor(((classRate/1000)*KERNEL_HZ)*15.626);
     rtnl_htb_set_rbuffer(ClassHTB, htbBuffer);

Where classRate is the rate calculated in bytes for that class and 
KERNEL_HZ is 10:

Download
     rate = 574647
     ceil = 8000000
Upload
     rate = 574647
     ceil = 8000000
Class  ID: 1:1
Qdisc Class ID: 5:
Parent ID: 1:5
Class rate burst: 24000
class htb dev ifb0 id 01:05 parent 01:01 rate 70.15KiB/s (561Kbit) log 
2147483648
    ceil 976.56KiB/s (8Mbit) log 2147483648 prio 100 rbuffer 23.44KiB 
cbuffer 152.60KiB
qdisc sfq dev ifb0 id 05: parent 01:05 quantum 0 perturb 10s
   refcnt 0 limit 0 divisor 0

And the TC output is:

class htb 1:5 parent 1:1 leaf 5: prio 0 rate 574640bit ceil 8000Kbit 
burst 1535b cburst 10000b

Also I got problems with setting the prio for a class:

     rtnl_htb_set_prio(ClassHTB, 100);

But the prio is still 0.

I'm doing something wrong?

Best regards,
Adrian

-------------- next part --------------
A non-text attachment was scrubbed...
Name: adrian_ban.vcf
Type: text/x-vcard
Size: 257 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/libnl/attachments/20110705/0d8bba3d/attachment.vcf>


More information about the libnl mailing list