Skip to contentSkip to conversation

Question about netlink

DISCUSSION Krishna Kumar 3 participants 4 messages Jul 8, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

Some of the netlink routines (eg rtnetlink_dump_ifinfo or inet6_dump_ifaddr) seem to get user arguments from cb->args['n']. However I was not able to figure out where the arguments are being set, can anyone help ?

netlink_dump_start() is where the cb gets allocated (initialized to 0), and that calls netlink_dump(), which calls the assigned routine. I couldn't find where the args gets initialized to user provided values. Any pointer to what to look for is very much appreciated.

Thanks,

- KK

#1 lore raw

In article <[email protected]> (at Tue, 08 Jul 2003 11:43:47 -0700), Krishna Kumar <[email protected]> says:

Quoted 3 lines

Some of the netlink routines (eg rtnetlink_dump_ifinfo or inet6_dump_ifaddr) seem to get user arguments from cb->args['n']. However I was not able to figure out where the arguments are being set, can anyone help ?

Take a look at net/core/rtnelink.c:rtnetlink_dump_ifinfo()
net/core/neighbour.c:neigh_dump_{info,table}()
and seek the truth. :-)

--yoshfuji

#2 lore raw

I am still not convinced how it works, though I have been trying to seek the truth for some time now :-).

These routines 'get' the value of args[0] and then 'set' it to the resultant value. How is this value set in the first place to the user provided value ? It seems to be initialized to ZERO in netlink_dump_start(). The only way it seems to use the value is if it gets called twice from netlink_dump(), the first time cb->args will be set to zero's while the second time it will have the values set by the first invocation to the same routine. Am I missing something or is 'args' not intended for user specified arguments ? If so, how should we access the arguments passed by the user ?

Thanks,

- KK

Quoted 14 lines · YOSHIFUJI Hideaki

In article <[email protected]> (at Tue, 08 Jul 2003 11:43:47 -0700), Krishna Kumar <[email protected]> says:

Quoted 3 lines

Some of the netlink routines (eg rtnetlink_dump_ifinfo or inet6_dump_ifaddr) seem to get user arguments from cb->args['n']. However I was not able to figure out where the arguments are being set, can anyone help ?

Take a look at net/core/rtnelink.c:rtnetlink_dump_ifinfo()
net/core/neighbour.c:neigh_dump_{info,table}()
and seek the truth. :-)

--yoshfuji

#3 lore raw

Hello!

Quoted 2 lines

These routines 'get' the value of args[0] and then 'set' it to the resultant value. How is this value set in the first place to the user provided value ?

It is not. Zero values means that dump starts from the very beginning. It is supposed to be done at the first entry to the ->dump(), but selective dumps are not implemented in the most of ->dump() methods.

Quoted 2 lines

missing something or is 'args' not intended for user specified arguments ? If so, how should we access the arguments passed by the user ?

The pointer to nlmsg header is kept in cb->nlh. So, you can refer to it to get user supplied values of selector to rewind the dump to required point at the first entry or to select some specific entries while scanning a table.

F.e. look into sch_api.c:tc_dump_tclass(), it scopes dump to a netdevice (tcp_ifindex), and filters answers to a specific qdisc (tcp_parent). It is also partial. More finegrain selection is not required, but desired, feel free to implement. F.e. implementation of "ip route ls root 3ffe::/24", which translates to selection of a root node for fib6_walk() to a more specific place and filtering out some nodes while walking, would be cool.

Alexey