A couple of questions about flnl_lookup() function.

Thomas Graf tgraf at infradead.org
Wed Mar 28 04:28:13 EDT 2012


On Wed, Mar 28, 2012 at 06:42:13AM +0400, Gavrilenko Eugene wrote:
> Thank you for your explanations about 'next-hop-selector' and multi-path routing.
> 
> I think I need to describe my task in more details.
> I need to implement some kind of virtual routing system (like VRF) in user space. 
> It will consist of several routing tables and must perform basic operations on this tables, such as 'add route', 'remove route', 'find next hop' and so on.
> But I couldn't find any implementation of routing subsystem in user space!
> Therefore I decided to use native Linux routing subsystem.

There is OpenVSwitch which doesn't do routing but perform a L2 lookup
in userspace and modifies neighbour tables in the kernel accordingly.
A concept that might interest you.

> As I figure out Netlink have full information about next-hop (in fib_result->fi->fib_nh[nh_sel]) in nl_fib_lookup(), but copies to reply  message next hop selector only. 
> It seems I need to implement my own netlink protocol with my own message's type to perform FIB lookup.
> I think I need to write my own kernel module which will call fib_table_lookup() directly, but will copy full info about next hop to reply.
> Is it right? Or, may be, you know a better solution?

It's probably a better idea to extend FIB_LOOKUP and add the fields
required to identify the route properly. By adding the prefix and ifindex
to the result you should be able to reliabbly perform a RTM_GETROUTE
afterwards and query the exact route details.

It should be safe to extend the result structure as long as you add the
fields to the end of the structure. The kernel and userspace should not
care about extensions as long as the minimal size is kept stable.



More information about the libnl mailing list