diff options
Diffstat (limited to 'iptables')
-rw-r--r-- | iptables/nft.c | 17 | ||||
-rw-r--r-- | iptables/nft.h | 1 | ||||
-rw-r--r-- | iptables/xtables-restore.c | 7 |
3 files changed, 23 insertions, 2 deletions
diff --git a/iptables/nft.c b/iptables/nft.c index fde1b2a3..a2f36b7e 100644 --- a/iptables/nft.c +++ b/iptables/nft.c @@ -1611,6 +1611,23 @@ retry: h->nft_genid = genid_start; } +void nft_fake_cache(struct nft_handle *h) +{ + int i; + + fetch_table_cache(h); + for (i = 0; i < NFT_TABLE_MAX; i++) { + enum nft_table_type type = h->tables[i].type; + + if (!h->tables[i].name) + continue; + + h->cache->table[type].chains = nftnl_chain_list_alloc(); + } + h->have_cache = true; + mnl_genid_get(h, &h->nft_genid); +} + void nft_build_cache(struct nft_handle *h) { if (!h->have_cache) diff --git a/iptables/nft.h b/iptables/nft.h index 43463d7f..bcac8e22 100644 --- a/iptables/nft.h +++ b/iptables/nft.h @@ -73,6 +73,7 @@ int mnl_talk(struct nft_handle *h, struct nlmsghdr *nlh, void *data); int nft_init(struct nft_handle *h, const struct builtin_table *t); void nft_fini(struct nft_handle *h); +void nft_fake_cache(struct nft_handle *h); void nft_build_cache(struct nft_handle *h); /* 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); |