Using libnl to create u32 hashkey

Thomas Graf tgraf at infradead.org
Tue Nov 22 07:07:48 EST 2011


On Tue, Nov 22, 2011 at 01:46:30PM +0200, Adrian Ban wrote:
> 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;
> 
> }

Great, feel free to send patches.



More information about the libnl mailing list