Using libnl to create u32 hashkey
Adrian Ban
adrian.ban at mantech.ro
Thu Nov 24 08:57:42 EST 2011
Hi everybody,
I'm happy to announce that I've almost finished the new functions for
hash filter :).
This is an output of my binary on eth0:
filter parent 1: protocol ip pref 1 u32
filter parent 1: protocol ip pref 1 u32 fh 5: ht divisor 256
filter parent 1: protocol ip pref 1 u32 fh 4: ht divisor 256
filter parent 1: protocol ip pref 1 u32 fh 3: ht divisor 256
filter parent 1: protocol ip pref 1 u32 fh 2: ht divisor 256
filter parent 1: protocol ip pref 1 u32 fh 1: ht divisor 256
filter parent 1: protocol ip pref 1 u32 fh 1:a:800 order 2048 key ht 1
bkt a link 2: (rule hit 0 success 0)
match 0a000000/ff000000 at 12 (success 0 )
hash mask 00ff0000 at 12
filter parent 1: protocol ip pref 1 u32 fh 1:2e:800 order 2048 key ht 1
bkt 2e link 3: (rule hit 0 success 0)
match 2e000000/ff000000 at 12 (success 0 )
hash mask 00ff0000 at 12
filter parent 1: protocol ip pref 1 u32 fh 1:59:800 order 2048 key ht 1
bkt 59 link 4: (rule hit 0 success 0)
match 59000000/ff000000 at 12 (success 0 )
hash mask 00ff0000 at 12
filter parent 1: protocol ip pref 1 u32 fh 1:ac:800 order 2048 key ht 1
bkt ac link 5: (rule hit 0 success 0)
match ac000000/ff000000 at 12 (success 0 )
hash mask 00ff0000 at 12
filter parent 1: protocol ip pref 1 u32 fh 800: ht divisor 1
filter parent 1: protocol ip pref 2 u32
filter parent 1: protocol ip pref 2 u32 fh 801: ht divisor 1
filter parent 1: protocol ip pref 2 u32 fh 801::800 order 2048 key ht
801 bkt 0 link 1: (rule hit 0 success 0)
match 00000000/00000000 at 12 (success 0 )
hash mask ff000000 at 12
And this is the output of my TC script on imq0:
filter parent 1: protocol ip pref 1 u32
filter parent 1: protocol ip pref 1 u32 fh 5: ht divisor 256
filter parent 1: protocol ip pref 1 u32 fh 4: ht divisor 256
filter parent 1: protocol ip pref 1 u32 fh 3: ht divisor 256
filter parent 1: protocol ip pref 1 u32 fh 2: ht divisor 256
filter parent 1: protocol ip pref 1 u32 fh 1: ht divisor 256
filter parent 1: protocol ip pref 1 u32 fh 1:a:800 order 2048 key ht 1
bkt a link 2: (rule hit 0 success 0)
match 0a000000/ff000000 at 16 (success 0 )
hash mask 00ff0000 at 16
filter parent 1: protocol ip pref 1 u32 fh 1:2e:800 order 2048 key ht 1
bkt 2e link 3: (rule hit 0 success 0)
match 2e000000/ff000000 at 16 (success 0 )
hash mask 00ff0000 at 16
filter parent 1: protocol ip pref 1 u32 fh 1:59:800 order 2048 key ht 1
bkt 59 link 4: (rule hit 0 success 0)
match 59000000/ff000000 at 16 (success 0 )
hash mask 00ff0000 at 16
filter parent 1: protocol ip pref 1 u32 fh 1:ac:800 order 2048 key ht 1
bkt ac link 5: (rule hit 0 success 0)
match ac000000/ff000000 at 16 (success 0 )
hash mask 00ff0000 at 16
filter parent 1: protocol ip pref 1 u32 fh 800: ht divisor 1
filter parent 1: protocol ip pref 2 u32
filter parent 1: protocol ip pref 2 u32 fh 801: ht divisor 1
filter parent 1: protocol ip pref 2 u32 fh 801::800 order 2048 key ht
801 bkt 0 link 1: (rule hit 0 success 0)
match 00000000/00000000 at 16 (success 0 )
hash mask ff000000 at 16
As you can see the filters are generated correctly. I'm just doing the
last test before submit the patch and an example of how to use the new
functions with few explanations in the example source.
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
More information about the libnl
mailing list