Blame SOURCES/0021-nft-Drop-nft_chain_list_find.patch

8cce6c
From 6e0de300158a6f3e8151903952b2a95f4487bedc Mon Sep 17 00:00:00 2001
8cce6c
From: Phil Sutter <phil@nwl.cc>
8cce6c
Date: Thu, 20 Dec 2018 16:09:13 +0100
8cce6c
Subject: [PATCH] nft: Drop nft_chain_list_find()
8cce6c
8cce6c
Replace the function by nftnl_chain_list_lookup_byname() as provided by
8cce6c
libnftnl.
8cce6c
8cce6c
Signed-off-by: Phil Sutter <phil@nwl.cc>
8cce6c
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
8cce6c
(cherry picked from commit 63dc7a0d86a1b86b10c5e04dd910497b9d8fcfaf)
8cce6c
Signed-off-by: Phil Sutter <psutter@redhat.com>
8cce6c
---
8cce6c
 iptables/nft.c | 31 ++-----------------------------
8cce6c
 iptables/nft.h |  2 --
8cce6c
 2 files changed, 2 insertions(+), 31 deletions(-)
8cce6c
8cce6c
diff --git a/iptables/nft.c b/iptables/nft.c
8cce6c
index 842ed2b805bee..883fb3db2c671 100644
8cce6c
--- a/iptables/nft.c
8cce6c
+++ b/iptables/nft.c
8cce6c
@@ -697,7 +697,7 @@ static void nft_chain_builtin_init(struct nft_handle *h,
8cce6c
 	/* Initialize built-in chains if they don't exist yet */
8cce6c
 	for (i=0; i < NF_INET_NUMHOOKS && table->chains[i].name != NULL; i++) {
8cce6c
 
8cce6c
-		c = nft_chain_list_find(list, table->chains[i].name);
8cce6c
+		c = nftnl_chain_list_lookup_byname(list, table->chains[i].name);
8cce6c
 		if (c != NULL)
8cce6c
 			continue;
8cce6c
 
8cce6c
@@ -1699,33 +1699,6 @@ err:
8cce6c
 	return ret == 0 ? 1 : 0;
8cce6c
 }
8cce6c
 
8cce6c
-struct nftnl_chain *
8cce6c
-nft_chain_list_find(struct nftnl_chain_list *list, const char *chain)
8cce6c
-{
8cce6c
-	struct nftnl_chain_list_iter *iter;
8cce6c
-	struct nftnl_chain *c;
8cce6c
-
8cce6c
-	iter = nftnl_chain_list_iter_create(list);
8cce6c
-	if (iter == NULL)
8cce6c
-		return NULL;
8cce6c
-
8cce6c
-	c = nftnl_chain_list_iter_next(iter);
8cce6c
-	while (c != NULL) {
8cce6c
-		const char *chain_name =
8cce6c
-			nftnl_chain_get_str(c, NFTNL_CHAIN_NAME);
8cce6c
-
8cce6c
-		if (strcmp(chain, chain_name) != 0)
8cce6c
-			goto next;
8cce6c
-
8cce6c
-		nftnl_chain_list_iter_destroy(iter);
8cce6c
-		return c;
8cce6c
-next:
8cce6c
-		c = nftnl_chain_list_iter_next(iter);
8cce6c
-	}
8cce6c
-	nftnl_chain_list_iter_destroy(iter);
8cce6c
-	return NULL;
8cce6c
-}
8cce6c
-
8cce6c
 static struct nftnl_chain *
8cce6c
 nft_chain_find(struct nft_handle *h, const char *table, const char *chain)
8cce6c
 {
8cce6c
@@ -1735,7 +1708,7 @@ nft_chain_find(struct nft_handle *h, const char *table, const char *chain)
8cce6c
 	if (list == NULL)
8cce6c
 		return NULL;
8cce6c
 
8cce6c
-	return nft_chain_list_find(list, chain);
8cce6c
+	return nftnl_chain_list_lookup_byname(list, chain);
8cce6c
 }
8cce6c
 
8cce6c
 bool nft_chain_exists(struct nft_handle *h,
8cce6c
diff --git a/iptables/nft.h b/iptables/nft.h
8cce6c
index 6568257feddc7..dfdffd69342db 100644
8cce6c
--- a/iptables/nft.h
8cce6c
+++ b/iptables/nft.h
8cce6c
@@ -83,8 +83,6 @@ struct nftnl_chain;
8cce6c
 int nft_chain_set(struct nft_handle *h, const char *table, const char *chain, const char *policy, const struct xt_counters *counters);
8cce6c
 struct nftnl_chain_list *nft_chain_list_get(struct nft_handle *h,
8cce6c
 					    const char *table);
8cce6c
-struct nftnl_chain *nft_chain_list_find(struct nftnl_chain_list *list,
8cce6c
-					const char *chain);
8cce6c
 int nft_chain_save(struct nft_handle *h, struct nftnl_chain_list *list);
8cce6c
 int nft_chain_user_add(struct nft_handle *h, const char *chain, const char *table);
8cce6c
 int nft_chain_user_del(struct nft_handle *h, const char *chain, const char *table, bool verbose);
8cce6c
-- 
8cce6c
2.20.1
8cce6c