diff options
author | Phil Sutter <phil@nwl.cc> | 2020-03-26 04:47:11 +0100 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2020-05-11 14:28:28 +0200 |
commit | c63b7643bb433abdb55d934029eaa51451cb1b8c (patch) | |
tree | 489309acbe03fd1b7bbed0ab36979bfbe7f7787b /iptables | |
parent | 6d8182e9c359ef3167167c5d5cc376da950e5edd (diff) |
nft: cache: Simplify rule and set fetchers
Since no incremental cache fetching happens anymore, code fetching rules
for chains or elements for sets may safely assume that whatever is in
cache also didn't get populated with rules or elements before.
Therefore no (optional) chain name needs to be passed on to
fetch_rule_cache() and fetch_set_cache() doesn't have to select for
which sets in a table to call set_fetch_elem_cb().
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'iptables')
-rw-r--r-- | iptables/nft-cache.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/iptables/nft-cache.c b/iptables/nft-cache.c index 6db261fb..e0c13870 100644 --- a/iptables/nft-cache.c +++ b/iptables/nft-cache.c @@ -295,11 +295,7 @@ static int fetch_set_cache(struct nft_handle *h, return ret; } - if (t && set) { - s = nftnl_set_list_lookup_byname(h->cache->table[t->type].sets, - set); - set_fetch_elem_cb(s, h); - } else if (t) { + if (t) { nftnl_set_list_foreach(h->cache->table[t->type].sets, set_fetch_elem_cb, h); } else { @@ -409,20 +405,14 @@ static int nft_rule_list_update(struct nftnl_chain *c, void *data) } static int fetch_rule_cache(struct nft_handle *h, - const struct builtin_table *t, const char *chain) + const struct builtin_table *t) { int i; if (t) { - struct nftnl_chain_list *list; - struct nftnl_chain *c; - - list = h->cache->table[t->type].chains; + struct nftnl_chain_list *list = + h->cache->table[t->type].chains; - if (chain) { - c = nftnl_chain_list_lookup_byname(list, chain); - return nft_rule_list_update(c, h); - } return nftnl_chain_list_foreach(list, nft_rule_list_update, h); } @@ -457,7 +447,7 @@ __nft_build_cache(struct nft_handle *h, enum nft_cache_level level, 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, chain); + fetch_rule_cache(h, t); } void nft_fake_cache(struct nft_handle *h) |