NETLINK_FIB_LOOKUP and NETLINK_ROUTE

Thomas Graf tgraf at suug.ch
Sat Jan 12 05:50:54 EST 2013


On 01/11/13 at 04:30pm, Kevin Wilson wrote:
> Hi,
> Why do we need NETLINK_FIB_LOOKUP ?
> I see that NETLINK_FIB_LOOKUP is used in a libnl util named nl-fib-lookup,
> and that NETLINK_FIB_LOOKUP is also used in lib/fib_lookup/lookup.c.
> 
> Is there anything in which NETLINK_FIB_LOOKUP is better than using RTM_GETROUTE?
> 
> With NETLINK_FIB_LOOKUP, we call nl_fib_input() which eventually calls
> fib_table_lookup().
> 
> In the kernel we have these two registrations:
> rtnl_register(PF_INET, RTM_GETROUTE, inet_rtm_getroute, NULL, NULL);
> rtnl_register(PF_INET, RTM_GETROUTE, NULL, inet_dump_fib, NULL);
> The first is for doit action and the second is for dumpit action.
> 
> inet_rtm_getroute() finds routing entry by ip_route_input()/ip_route_output(),
> which eventually calls also fib_table_lookup().
> 
> I saw here:
> http://lists.openwall.net/netdev/2009/05/25/33
> ...	
> ...
> "This was added when fib_trie was introduced and in this case we're comparing
>  NETLINK_FIB_LOOKUP result with a userland program doing longest prefix match
>  on the same routing table.
> ...
> 
> iproute normally dumps the table, it doesn't look up a particular route
>  as done via the RX softirq."
> 
> But
> Indeed, "ip route" calls inet_dump_fib()
> But,
> "ip route get" calls inet_rtm_getroute(), which as said above, performs
> also a fib lookup.
> Example:
> ip route get 192.168.1.100
> 192.168.1.100 dev p2p1  src 192.168.1.10
>     cache
> 
> Maybe using NETLINK_FIB_LOOKUP should be replaced with lookup with RTM_GETROUTE
> of NETLINK_ROUTE?
> I don't see anything in which NETLINK_FIB_LOOKUP is better than
> using RTM_GETROUTE.

NETLINK_FIB_LOOKUP is pretty much there for legacy reasons. It used to
be the only way to simulate a real route lookup from user space but is
pretty much obsoleted by RTM_GETROUTE these days.



More information about the libnl mailing list