Skip to contentSkip to conversation

Add U32 Filter with libnl

LARTC Gerrit Brehmer 1 participant 1 message Sep 23, 2007

lore
Share & tools
lore
#0 lore raw

Hello,

I try to add a U32 source port filter with libnl. My filter can be succesfully added with the library (no error occured) but the filter is not active.
If I run "tc filter show dev eth0" I get:

filter parent 1: protocol ip pref 100 u32 filter parent 1: protocol ip pref 100 u32 fh 800: ht divisor 1 filter parent 1: protocol ip pref 100 u32 fh 800::800 order 2048 key ht 800 bkt 0 *flowid 1:20
match 00160000/ffff0000 at 20
filter parent 1: protocol ip pref 100 u32 fh 800::801 order 2049 key ht 800 bkt 0 *flowid 1:11
match 00160000/ffff0000 at 20

I don't know what's the meaning of the "*" before flowid is. Because if I add a filter with tc tool i get this extra info not and this filter functions normal:

filter parent 1: protocol ip pref 100 u32 fh 800::802 order 2050 key ht 800 bkt 0 flowid 1:20
match 00160000/ffff0000 at 20

To create a filter with libnl I do the following things:
rtnl_cls * pFilter = rtnl_cls_alloc(); rtnl_cls_set_ifindex(pFilter, m_networkDeviceIdx); /* eth0 */ rtnl_cls_set_kind(pFilter, "u32"); rtnl_cls_set_prio(pFilter, 100); rtnl_cls_set_protocol(pFilter, ETH_P_IP);

// setting parent class id
rtnl_tc_str2handle("1:", &handle);
rtnl_cls_set_parent(pFilter, handle);

// source port filter rtnl_u32_add_key_uint16(pFilter, 22, 0xffff, U32_SPORT, 0);

// setting flowid
sprintf(pBuffer, "1:%i", parentId); /* flowid 1:20 */

rtnl_tc_str2handle(pBuffer, &handle); rtnl_u32_set_classid(pFilter, handle);
        
        // add filter

if (rtnl_cls_add(m_pNetlinkHandle, pFilter, NLM_F_REPLACE) < 0)
...

Thanks in advance for your help!
Gerrit

___________________________________________________________
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
_______________________________________________
LARTC mailing list
[email protected]
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc