]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
nft: Use nft_chain_find() in nft_chain_builtin_init()
authorPhil Sutter <phil@nwl.cc>
Tue, 4 Aug 2020 15:02:21 +0000 (17:02 +0200)
committerPhil Sutter <phil@nwl.cc>
Fri, 21 Aug 2020 17:01:04 +0000 (19:01 +0200)
The replaced code is basically identical to nft_chain_find()'s body.

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

index dd66b98e5004c98ad8f95c47de682390e224ec1f..27bb98d184c7c03a77c1b977f137c1fc0a9a622c 100644 (file)
@@ -736,22 +736,17 @@ 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)
 {
-       struct nftnl_chain_list *list;
-       struct nftnl_chain *c;
        int i;
 
        /* Initialize built-in chains if they don't exist yet */
        for (i=0; i < NF_INET_NUMHOOKS && table->chains[i].name != NULL; i++) {
-               list = nft_chain_list_get(h, table->name,
-                                         table->chains[i].name);
-               if (!list)
-                       continue;
-
-               c = nftnl_chain_list_lookup_byname(list, table->chains[i].name);
-               if (c != NULL)
+               if (nft_chain_find(h, table->name, table->chains[i].name))
                        continue;
 
                nft_chain_builtin_add(h, table, &table->chains[i]);
@@ -1388,9 +1383,6 @@ err:
        return NULL;
 }
 
-static struct nftnl_chain *
-nft_chain_find(struct nft_handle *h, const char *table, const char *chain);
-
 int
 nft_rule_append(struct nft_handle *h, const char *chain, const char *table,
                struct nftnl_rule *r, struct nftnl_rule *ref, bool verbose)