summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2020-04-06 14:36:30 +0200
committerPhil Sutter <phil@nwl.cc>2020-05-11 14:28:28 +0200
commit6957d381dfd085f7cd0b7844ca14899906a97c2a (patch)
treedcc1e9a0ab0276bc685641dbde76017bf24c9c30
parent72470c66326d9b5186dd4614bc2d18269324e54b (diff)
nft: cache: Init per table set list along with chain list
This simplifies code a bit and also aligns set and chain lists handling in cache. Signed-off-by: Phil Sutter <phil@nwl.cc>
-rw-r--r--iptables/nft-cache.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/iptables/nft-cache.c b/iptables/nft-cache.c
index 369692fe..e042bd83 100644
--- a/iptables/nft-cache.c
+++ b/iptables/nft-cache.c
@@ -113,6 +113,10 @@ static int fetch_table_cache(struct nft_handle *h)
h->cache->table[type].chains = nftnl_chain_list_alloc();
if (!h->cache->table[type].chains)
return 0;
+
+ h->cache->table[type].sets = nftnl_set_list_alloc();
+ if (!h->cache->table[type].sets)
+ return 0;
}
return 1;
@@ -254,21 +258,6 @@ static int fetch_set_cache(struct nft_handle *h,
char buf[16536];
int i, ret;
- if (!t) {
- 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].sets = nftnl_set_list_alloc();
- if (!h->cache->table[type].sets)
- return -1;
- }
- } else if (!h->cache->table[t->type].sets) {
- h->cache->table[t->type].sets = nftnl_set_list_alloc();
- }
-
if (t && set) {
struct nftnl_set *s = nftnl_set_alloc();