Adding rule with "From" option doesn't work

Romary Sonrier romary at sonrier.com
Tue May 3 04:55:35 EDT 2011


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.




More information about the libnl mailing list