]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
nft: cache: Improve fake cache integration
authorPhil Sutter <phil@nwl.cc>
Tue, 7 Apr 2020 11:47:54 +0000 (13:47 +0200)
committerPhil Sutter <phil@nwl.cc>
Mon, 11 May 2020 12:28:28 +0000 (14:28 +0200)
With NFT_CL_FAKE being highest cache level while at the same time
__nft_build_cache() treating it equal to NFT_CL_TABLES, no special
handling for fake cache is required anymore.

Signed-off-by: Phil Sutter <phil@nwl.cc>
iptables/nft-cache.c
iptables/nft-cache.h
iptables/xtables-restore.c

index e0c138707133008921eebf46c9f8087731eeaee1..2c6a170881eb321f948acca882147c10bdda1680 100644 (file)
@@ -442,6 +442,8 @@ __nft_build_cache(struct nft_handle *h, enum nft_cache_level level,
 
        if (h->cache_level >= NFT_CL_TABLES)
                fetch_table_cache(h);
+       if (h->cache_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)
@@ -450,15 +452,6 @@ __nft_build_cache(struct nft_handle *h, enum nft_cache_level level,
                fetch_rule_cache(h, t);
 }
 
-void nft_fake_cache(struct nft_handle *h)
-{
-       fetch_table_cache(h);
-
-       h->cache_level = NFT_CL_FAKE;
-       h->cache_init = true;
-       mnl_genid_get(h, &h->nft_genid);
-}
-
 static void __nft_flush_cache(struct nft_handle *h)
 {
        if (!h->cache_index) {
@@ -570,10 +563,7 @@ void nft_rebuild_cache(struct nft_handle *h)
                h->cache_init = false;
        }
 
-       if (h->cache_level == NFT_CL_FAKE)
-               nft_fake_cache(h);
-       else
-               __nft_build_cache(h, h->cache_level, NULL, NULL, NULL);
+       __nft_build_cache(h, h->cache_level, NULL, NULL, NULL);
 }
 
 void nft_cache_build(struct nft_handle *h)
index 8c63d8d566c19bd0be78af4e8aa603bcc6741d6a..01dd15e145fd444ba5f7d075ee9e0a3f555a5fea 100644 (file)
@@ -4,7 +4,6 @@
 struct nft_handle;
 
 void nft_cache_level_set(struct nft_handle *h, int level);
-void nft_fake_cache(struct nft_handle *h);
 void nft_rebuild_cache(struct nft_handle *h);
 void nft_release_cache(struct nft_handle *h);
 void flush_chain_cache(struct nft_handle *h, const char *tablename);
index 0b0febdf6ef018c45b7dd23314d3be315133707e..28ef366c302af14af4e80f008a8d18833789d0c9 100644 (file)
@@ -261,7 +261,7 @@ void xtables_restore_parse(struct nft_handle *h,
        char buffer[10240] = {};
 
        if (!h->noflush)
-               nft_fake_cache(h);
+               nft_cache_level_set(h, NFT_CL_FAKE);
 
        line = 0;
        while (fgets(buffer, sizeof(buffer), p->in)) {