From 3ed296118a065caff5600e60d4f7ef18e137f9a0 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 9 Apr 2015 14:15:15 +0200 Subject: src: restore interface to index cache nftables used to have a cache to speed up interface name <-> index lookup, restore it using libmnl. This reduces netlink traffic since if_nametoindex() and if_indextoname() open, send a request, receive the list of interface and close a netlink socket for each call. I think this is also good for consistency since nft -f will operate with the same index number when reloading the ruleset. The cache is populated by when nft_if_nametoindex() and nft_if_indextoname() are used for first time. Then, it it released in the output path. In the interactive mode, it is invalidated after each command. Signed-off-by: Pablo Neira Ayuso --- src/cli.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/cli.c') diff --git a/src/cli.c b/src/cli.c index f3827b81..fbae0ef3 100644 --- a/src/cli.c +++ b/src/cli.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #define CMDLINE_HISTFILE ".nft.history" @@ -123,6 +124,7 @@ static void cli_complete(char *line) nft_run(scanner, state, &msgs); erec_print_list(stdout, &msgs); xfree(line); + iface_cache_release(); } static char **cli_completion(const char *text, int start, int end) -- cgit v1.2.3