Using libnl to create u32 hashkey

Adrian Ban adrian.ban at mantech.ro
Thu Nov 24 18:11:59 EST 2011


Hi,

Here is the patch for u32 hash filters for libnl3.
Attached you have the patch and the source code for HTB qdisc, class and 
hash filters.

The prio problem is was fixed in the release 3.2.3. First time I've 
compiled my code on 3.0 version (the Debian libnl3).

Only one problem remains: HTB rate/ceil doesn't work correctly.
For example I set a HTB class rate/ceil to 1500000 bytes this is the output:

class htb 1:5 parent 1:1 leaf 5: prio 5 rate 12000Kbit ceil 12000Kbit 
burst 1599b cburst 1599b
  Sent 401941549 bytes 283591 pkt (dropped 0, overlimits 0 requeues 0)
  rate 22271Kbit 1963pps backlog 0b 0p requeues 0
  lended: 18610 borrowed: 0 giants: 0
  tokens: -25601 ctokens: -25601

If I set the rate/ceil to 2000000 the output is:

class htb 1:5 parent 1:1 leaf 5: prio 5 rate 16000Kbit ceil 16000Kbit 
burst 1600b cburst 1600b
  Sent 166400947 bytes 116667 pkt (dropped 0, overlimits 0 requeues 0)
  rate 15848Kbit 1388pps backlog 0b 5p requeues 0
  lended: 8049 borrowed: 0 giants: 0
  tokens: -259039 ctokens: -259039

The difference between those two setups is that on the second you can 
see that rate line has a 5p which varies between 5 an 15. First is fixed 
to 0.

Any idea? I thing that some parameters are calculated wrong in 
rtnl_tc_build_rate_table.

Best regards,
Adrian

On 11/24/2011 2:01 AM, Adrian Ban wrote:
> Ups .. I've already found a little bug:
>
>     hash mask ff000000 at 0
> vs
>     hash mask ff000000 at 16
>
> Seems that the offset for the hash mask doesn't work correctly.  I'll 
> check this tomorrow and I'll return with a feedback :).
>
> Regards,
> Adrian
>
> On 11/22/2011 1:25 PM, Thomas Graf wrote:
>> On Mon, Nov 21, 2011 at 11:18:09PM +0200, Adrian Ban wrote:
>>> Hi,
>>>
>>> I'm using libnl3 to a little project. My problem is that I didn't
>>> find any documentation about u32 hashkey filters.
>>> I want to build something like this:
>>>
>>> $TC filter add dev $DEVin  parent 0x01:0x0000 prio 1 protocol ip u32
>>> $TC filter add dev $DEVin  parent 0x01:0x0000 prio 1 protocol ip
>>> handle 1: u32 divisor 256
>>>
>>> $TC filter add dev $DEVin parent 0x01:0x0000 prio 2 protocol ip u32 \
>>>        match ip dst 0.0.0.0/0 \
>>>        hashkey mask 0xff000000 at 16 \
>>>        link 1:
>>> $TC filter add dev $DEVin parent 0x01:0x0000 prio 1 protocol ip
>>> handle 2: u32 divisor 256
>>> $TC filter add dev $DEVin parent 0x01:0x0000 prio 1 protocol ip u32
>>> ht 1:a: \
>>>        match ip dst 10.0.0.0/8 \
>>>        hashkey mask 0x00FF0000 at 16 \
>>>        link 2:
>>> $TC filter add dev $DEVin parent 0x01:0x0000 prio 1 protocol ip
>>> handle 3: u32 divisor 256
>>> $TC filter add dev $DEVin parent 0x01:0x0000 prio 1 protocol ip u32
>>> ht 1:2e: \
>>>        match ip dst 46.0.0.0/8 \
>>>        hashkey mask 0x00FF0000 at 16 \
>>>        link 3:
>>>
>>> There is any solution to make such things with libnl?
>> This is not yet fully implemented. For example there is no function that
>> would allow setting the divisor yet.
>
>
> _______________________________________________
> libnl mailing list
> libnl at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/libnl
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: complex-HTB-with-hash-filters.c
URL: <http://lists.infradead.org/pipermail/libnl/attachments/20111125/eceef3cb/attachment-0001.c>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: libnl3-u32-addons.diff
URL: <http://lists.infradead.org/pipermail/libnl/attachments/20111125/eceef3cb/attachment-0001.ksh>


More information about the libnl mailing list