]> git.proxmox.com Git - mirror_iproute2.git/commit
Improve batch and dump times by caching link lookups
authorDavid Ahern <dsahern@gmail.com>
Wed, 13 Feb 2019 23:56:30 +0000 (15:56 -0800)
committerDavid Ahern <dsahern@gmail.com>
Sat, 23 Feb 2019 02:51:20 +0000 (18:51 -0800)
commit55870dfe7f8b1d14c4b52fb689f6d91cbf28a60c
tree645b1ed4a35d02fd14dbf414e2cd1939245e8e65
parentdb1aafd883262752304064a5afc06b41417d5c84
Improve batch and dump times by caching link lookups

ip route uses ll_name_to_index and ll_index_to_name to convert between
device names and indices. At the moment both use for the ioctl based glibc
functions if_nametoindex and if_indextoname and does not cache the result.
When using a batch file or dumping large number of routes this means the
same device lookups can be done repeatedly adding unnecessary overhead
(socket + ioctl + close for each device lookup).

Add a new function, ll_link_get, to send a netlink based RTM_GETLINK. If
successful, cache the result in idx_head and name_head so future lookups
can re-use the entry. Update ll_name_to_index and ll_index_to_name to use
ll_link_get and only fallback to the glibc functions if it fails.

With this change the time to install 720,022 routes with 2 ecmp nexthops
where the nexthop device is given is reduced from 31.4 seconds to 19.2
seconds. A dump of those routes drops from 13.3 to 2.8 seconds.

Signed-off-by: David Ahern <dsahern@gmail.com>
lib/ll_map.c