summaryrefslogtreecommitdiffstats
path: root/iptables
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2020-03-31 03:09:26 +0200
committerPhil Sutter <phil@nwl.cc>2020-05-11 14:28:28 +0200
commit72470c66326d9b5186dd4614bc2d18269324e54b (patch)
tree82c40a0a64fddbd8f7ee1d8a15bbbdd9fbe42b6b /iptables
parent0c3aded0b6d587b962be66b54bdc050d3b3cfdcb (diff)
nft: cache: Eliminate init_chain_cache()
The function is always called immediately after fetch_table_cache(), so merge it into the latter. Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'iptables')
-rw-r--r--iptables/nft-cache.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/iptables/nft-cache.c b/iptables/nft-cache.c
index a0c76705..369692fe 100644
--- a/iptables/nft-cache.c
+++ b/iptables/nft-cache.c
@@ -86,7 +86,7 @@ static int fetch_table_cache(struct nft_handle *h)
char buf[16536];
struct nlmsghdr *nlh;
struct nftnl_table_list *list;
- int ret;
+ int i, ret;
if (h->cache->tables)
return 0;
@@ -104,13 +104,6 @@ static int fetch_table_cache(struct nft_handle *h)
h->cache->tables = list;
- return 1;
-}
-
-static int init_chain_cache(struct nft_handle *h)
-{
- int i;
-
for (i = 0; i < NFT_TABLE_MAX; i++) {
enum nft_table_type type = h->tables[i].type;
@@ -119,9 +112,10 @@ static int init_chain_cache(struct nft_handle *h)
h->cache->table[type].chains = nftnl_chain_list_alloc();
if (!h->cache->table[type].chains)
- return -1;
+ return 0;
}
- return 0;
+
+ return 1;
}
struct nftnl_chain_list_cb_data {
@@ -458,7 +452,6 @@ __nft_build_cache(struct nft_handle *h, enum nft_cache_level level,
switch (h->cache_level) {
case NFT_CL_NONE:
fetch_table_cache(h);
- init_chain_cache(h);
if (level == NFT_CL_TABLES)
break;
/* fall through */
@@ -505,7 +498,6 @@ void nft_build_cache(struct nft_handle *h, struct nftnl_chain *c)
void nft_fake_cache(struct nft_handle *h)
{
fetch_table_cache(h);
- init_chain_cache(h);
h->cache_level = NFT_CL_FAKE;
mnl_genid_get(h, &h->nft_genid);