Using libnl to create u32 hashkey
Adrian Ban
adrian.ban at mantech.ro
Tue Nov 22 06:46:30 EST 2011
Hi,
I saw that. For this reason I've made a function that set the divisor:
#include <netlink/netlink.h>
#include <netlink/route/tc.h>
#include <netlink/route/classifier.h>
#include "include/rtnl_u32.h"
int rtnl_u32_set_divisor(struct rtnl_cls *mycls, uint16_t divisor)
{
struct rtnl_u32 *u;
if (!(u = (struct rtnl_u32*)rtnl_tc_data(TC_CAST(mycls))))
return -NLE_NOMEM;
printf("Mask before set : 0x%X\n", u->cu_mask);
u->cu_divisor = divisor;
u->cu_mask |= U32_ATTR_DIVISOR;
printf("Divisor is set to : 0x%X\n", u->cu_divisor);
printf("Mask is set to : 0x%X\n", u->cu_mask);
return 0;
}
and the include/rtnl_u32.h contain:
/** @cond SKIP */
#define U32_ATTR_DIVISOR 0x001
#define U32_ATTR_HASH 0x002
#define U32_ATTR_CLASSID 0x004
#define U32_ATTR_LINK 0x008
#define U32_ATTR_PCNT 0x010
#define U32_ATTR_SELECTOR 0x020
#define U32_ATTR_ACTION 0x040
#define U32_ATTR_POLICE 0x080
#define U32_ATTR_INDEV 0x100
/** @endcond */
struct rtnl_u32
{
uint32_t cu_divisor;
uint32_t cu_hash;
uint32_t cu_classid;
uint32_t cu_link;
struct nl_data * cu_pcnt;
struct nl_data * cu_selector;
struct nl_data * cu_act;
struct nl_data * cu_police;
char cu_indev[IFNAMSIZ];
int cu_mask;
};
I success to add this in filters:
filter parent 1: protocol ip pref 1 u32
filter parent 1: protocol ip pref 1 u32 fh 1: ht divisor 256
filter parent 1: protocol ip pref 1 u32 fh 800: ht divisor 1
I'm still working, but maybe this helps.
Best 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