Adding rule with "From" option doesn't work [PATCH]
Romary Sonrier
romary at sonrier.com
Tue May 3 05:26:21 EDT 2011
OK i found the bug, is is the patch !!
Can someone push it into the git tree ?
Regards,
Romary Sonrier
=========================
My analysis:
I guess that the pay load is *struct fib_rule_hdr*
struct fib_rule_hdr {
__u8 family;
__u8 dst_len;
__u8 src_len;
__u8 tos;
__u8 table;
__u8 res1; /* reserved */
__u8 res2; /* reserved */
__u8 action;
__u32 flags;
};
> [PAYLOAD] 12 octets
> 02 00 00 00 0a 00 00 01 00 00 00 00 ............
so
family = 02 , fine
table = 10, fine
but
src_len =0 !!!! should be 32
Le 03/05/2011 10:55, Romary Sonrier a écrit :
> Thanks for the tips... here is the debug output :
>
> -- Debug: Sent Message:
> -------------------------- BEGIN NETLINK MESSAGE
> ---------------------------
> [HEADER] 16 octets
> .nlmsg_len = 44
> .nlmsg_type = 32 <route/rule::new>
> .nlmsg_flags = 1029 <REQUEST,ACK,ATOMIC>
> .nlmsg_seq = 1304412847
> .nlmsg_pid = 19007
> [PAYLOAD] 12 octets
> 02 00 00 00 0a 00 00 01 00 00 00 00 ............
> [ATTR 02] 4 octets
> 7f 00 00 01 ....
> [ATTR 06] 4 octets
> 64 00 00 00 d...
> --------------------------- END NETLINK MESSAGE
> ---------------------------
> -- Debug: Received Message:
> -------------------------- BEGIN NETLINK MESSAGE
> ---------------------------
> [HEADER] 16 octets
> .nlmsg_len = 36
> .nlmsg_type = 2 <ERROR>
> .nlmsg_flags = 0 <>
> .nlmsg_seq = 1304412847
> .nlmsg_pid = 19007
> [ERRORMSG] 20 octets
> .error = 0 "Success"
> [ORIGINAL MESSAGE] 16 octets
> .nlmsg_len = 16
> .nlmsg_type = 32 <0x20>
> .nlmsg_flags = 1029 <REQUEST,ACK,ATOMIC>
> .nlmsg_seq = 1304412847
> .nlmsg_pid = 19007
> --------------------------- END NETLINK MESSAGE
> ---------------------------
>
>
>
> Le 03/05/2011 10:34, Thomas Graf a écrit :
>> On Tue, May 03, 2011 at 10:03:38AM +0200, Romary Sonrier wrote:
>>> Hello guys,
>>>
>>> I am using libnl 3.0 from git (cc33b0940f8ca0a34c9fbc085963e7887adc4db7)
>>>
>>> I am trying to add rules to the kernel routing engine, using libnl.
>>> (kernel 2.6.35-28-generic x86_64 GNU/Linux / Ubuntu)
>>>
>>> What i'm trying to do would be , with iproute2 :*ip rule add from
>>> 127.0.0.1 table 10 prio 100*
>>>
>>> There is not any tool like src/nl-rule-add.c yet, so i did my own , you
>>> can find it as attachement.
>>>
>>> It seems that the call :*rtnl_rule_set_src(rule, a)* doesn't have any
>>> effect.
>>>
>>> Do you have any idea?
>>>
>>> I tried to compare with iproute2 code source, but that's not that easy.
>>> They use a struct "struct rtmsg", that is not use in libnl.
>>>
>>> Any help would be welcome....
>> Can you run your program like this:
>>
>> NLCB=debug src/nl-rule-add
>>
>> and post the output? That allows veryfing the netlink message that is being
>> sent to the kernel.
>
> _______________________________________________
> libnl mailing list
> libnl at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/libnl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/libnl/attachments/20110503/1d083348/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libnl_lib_route_rule.patch
Type: text/x-patch
Size: 982 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/libnl/attachments/20110503/1d083348/attachment.bin>
More information about the libnl
mailing list