Using libnl to create u32 hashkey
Adrian Ban
adrian.ban at mantech.ro
Thu Nov 24 12:14:35 EST 2011
Hi,
I've found something interesting. When I'm adding a filter which has a
flowid/classid the output of the tc command is like this:
filter parent 1: protocol ip pref 1 u32 fh c:15:800 order 2048 key ht c
bkt 15 *flowid 1:2e (rule hit 0 success 0)
match 2e336815/ffffffff at 16 (success 0 )
After a quick look in the tc command I found this:
if (tb[TCA_U32_CLASSID]) {
SPRINT_BUF(b1);
fprintf(f, "%sflowid %s ",
!sel || !(sel->flags&TC_U32_TERMINAL) ? "*" : "",
sprint_tc_classid(*(__u32*)RTA_DATA(tb[TCA_U32_CLASSID]), b1));
And this:
} else if (matches(*argv, "classid") == 0 ||
strcmp(*argv, "flowid") == 0) {
unsigned handle;
NEXT_ARG();
if (get_tc_classid(&handle, *argv)) {
fprintf(stderr, "Illegal \"classid\"\n");
return -1;
}
addattr_l(n, MAX_MSG, TCA_U32_CLASSID, &handle, 4);
sel.sel.flags |= TC_U32_TERMINAL;
I've added a new function which set the flag of the selector with
TC_U32_TERMINAL. After this the output of the tc command shows:
filter parent 1: protocol ip pref 1 u32 fh c:15:800 order 2048 key ht c
bkt 15 flowid 1:2e (rule hit 0 success 0)
match 2e336815/ffffffff at 16 (success 0 )
What is the difference between an U32 classifier without TC_U32_TERMINAL
and with TC_U32_TERMINAL?
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