]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
nft: cache: Move nft_chain_find() over
authorPhil Sutter <phil@nwl.cc>
Thu, 10 Sep 2020 14:19:44 +0000 (16:19 +0200)
committerPhil Sutter <phil@nwl.cc>
Mon, 21 Dec 2020 17:33:21 +0000 (18:33 +0100)
It is basically just a cache lookup, hence fits better in here.

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

index 109524c3fbc7900d0f2751e7f517f47ae638463d..929fa0fa152c1c904467cbd1810bcb15134b077c 100644 (file)
@@ -165,6 +165,20 @@ static int fetch_table_cache(struct nft_handle *h)
        return 1;
 }
 
+struct nftnl_chain *
+nft_chain_find(struct nft_handle *h, const char *table, const char *chain)
+{
+       const struct builtin_table *t;
+       struct nftnl_chain_list *list;
+
+       t = nft_table_builtin_find(h, table);
+       if (!t)
+               return NULL;
+
+       list = h->cache->table[t->type].chains;
+       return list ? nftnl_chain_list_lookup_byname(list, chain) : NULL;
+}
+
 int nft_cache_add_chain(struct nft_handle *h, const struct builtin_table *t,
                        struct nftnl_chain *c)
 {
index 52ad2d396199ea65246a46f3e015310cf38a603e..085594c26457b1c1bd9bb7fe6a3bea6cf93ca707 100644 (file)
@@ -16,6 +16,9 @@ void nft_cache_build(struct nft_handle *h);
 int nft_cache_add_chain(struct nft_handle *h, const struct builtin_table *t,
                        struct nftnl_chain *c);
 
+struct nftnl_chain *
+nft_chain_find(struct nft_handle *h, const char *table, const char *chain);
+
 struct nftnl_set_list *
 nft_set_list_get(struct nft_handle *h, const char *table, const char *set);
 
index afe7fe9ed05c5acf3c50bb389cff9ee928d3459c..9b40b3c3b96311e86baac95024d2b04095ec3d63 100644 (file)
@@ -738,9 +738,6 @@ nft_chain_builtin_find(const struct builtin_table *t, const char *chain)
        return found ? &t->chains[i] : NULL;
 }
 
-static struct nftnl_chain *
-nft_chain_find(struct nft_handle *h, const char *table, const char *chain);
-
 static void nft_chain_builtin_init(struct nft_handle *h,
                                   const struct builtin_table *table)
 {
@@ -1837,20 +1834,6 @@ out:
        return ret == 0 ? 1 : 0;
 }
 
-static struct nftnl_chain *
-nft_chain_find(struct nft_handle *h, const char *table, const char *chain)
-{
-       const struct builtin_table *t;
-       struct nftnl_chain_list *list;
-
-       t = nft_table_builtin_find(h, table);
-       if (!t)
-               return NULL;
-
-       list = h->cache->table[t->type].chains;
-       return list ? nftnl_chain_list_lookup_byname(list, chain) : NULL;
-}
-
 bool nft_chain_exists(struct nft_handle *h,
                      const char *table, const char *chain)
 {