diff options
author | Phil Sutter <phil@nwl.cc> | 2019-09-25 11:29:59 +0200 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2019-09-30 08:14:55 +0200 |
commit | 2a459ebc0ee53a57a92631fa07f6bf2b4f3fbc8c (patch) | |
tree | e78f5e8800509e44c8dfe204214f73297574ca59 /iptables/xtables-restore.c | |
parent | 3e450a6cc2325f4481dc86f074774dcdfd4947c3 (diff) |
xtables-restore: Minimize caching when flushing
Unless --noflush was given, xtables-restore merely needs the list of
tables to decide whether to delete it or not. Introduce nft_fake_cache()
function which populates table list, initializes chain lists (so
nft_chain_list_get() returns an empty list instead of NULL) and sets
'have_cache' to turn any later calls to nft_build_cache() into nops.
If --noflush was given, call nft_build_cache() just once instead of for
each table line in input.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'iptables/xtables-restore.c')
-rw-r--r-- | iptables/xtables-restore.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/iptables/xtables-restore.c b/iptables/xtables-restore.c index 27e65b97..7f28a05c 100644 --- a/iptables/xtables-restore.c +++ b/iptables/xtables-restore.c @@ -96,6 +96,11 @@ void xtables_restore_parse(struct nft_handle *h, line = 0; + if (!h->noflush) + nft_fake_cache(h); + else + nft_build_cache(h); + /* Grab standard input. */ while (fgets(buffer, sizeof(buffer), p->in)) { int ret = 0; @@ -145,8 +150,6 @@ void xtables_restore_parse(struct nft_handle *h, if (p->tablename && (strcmp(p->tablename, table) != 0)) continue; - nft_build_cache(h); - if (h->noflush == 0) { DEBUGP("Cleaning all chains of table '%s'\n", table); |