diff options
author | Phil Sutter <phil@nwl.cc> | 2020-04-07 14:05:34 +0200 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2020-05-11 14:28:28 +0200 |
commit | 6d1d5aa5c93eca890e28b508ef426b7844caf2b7 (patch) | |
tree | df9e2d692c8344a37ba5f4a41968704ee97c81e3 /iptables/nft-cache.c | |
parent | b301f2ed198804015c4434f925c75e0bd224c4ef (diff) |
nft: cache: Introduce struct nft_cache_req
This embedded struct collects cache requirement info gathered from parsed
nft_cmds and is interpreted by __nft_build_cache().
While being at it, remove unused parameters passed to the latter
function, nft_handle pointer is sufficient.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'iptables/nft-cache.c')
-rw-r--r-- | iptables/nft-cache.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/iptables/nft-cache.c b/iptables/nft-cache.c index 2c6a1708..305f2c12 100644 --- a/iptables/nft-cache.c +++ b/iptables/nft-cache.c @@ -26,10 +26,12 @@ void nft_cache_level_set(struct nft_handle *h, int level) { - if (level <= h->cache_level) + struct nft_cache_req *req = &h->cache_req; + + if (level <= req->level) return; - h->cache_level = level; + req->level = level; } static int genid_cb(const struct nlmsghdr *nlh, void *data) @@ -430,26 +432,26 @@ static int fetch_rule_cache(struct nft_handle *h, } static void -__nft_build_cache(struct nft_handle *h, enum nft_cache_level level, - const struct builtin_table *t, const char *set, - const char *chain) +__nft_build_cache(struct nft_handle *h) { + struct nft_cache_req *req = &h->cache_req; + if (h->cache_init) return; h->cache_init = true; mnl_genid_get(h, &h->nft_genid); - if (h->cache_level >= NFT_CL_TABLES) + if (req->level >= NFT_CL_TABLES) fetch_table_cache(h); - if (h->cache_level == NFT_CL_FAKE) + if (req->level == NFT_CL_FAKE) return; - if (h->cache_level >= NFT_CL_CHAINS) - fetch_chain_cache(h, t, chain); - if (h->cache_level >= NFT_CL_SETS) - fetch_set_cache(h, t, set); - if (h->cache_level >= NFT_CL_RULES) - fetch_rule_cache(h, t); + if (req->level >= NFT_CL_CHAINS) + fetch_chain_cache(h, NULL, NULL); + if (req->level >= NFT_CL_SETS) + fetch_set_cache(h, NULL, NULL); + if (req->level >= NFT_CL_RULES) + fetch_rule_cache(h, NULL); } static void __nft_flush_cache(struct nft_handle *h) @@ -563,12 +565,12 @@ void nft_rebuild_cache(struct nft_handle *h) h->cache_init = false; } - __nft_build_cache(h, h->cache_level, NULL, NULL, NULL); + __nft_build_cache(h); } void nft_cache_build(struct nft_handle *h) { - __nft_build_cache(h, h->cache_level, NULL, NULL, NULL); + __nft_build_cache(h); } void nft_release_cache(struct nft_handle *h) |