Blame SOURCES/0011-nft-Simplify-nftnl_rule_list_chain_save.patch

029dc7
From 014b6acbb382f42dd20577fa1ff6e013526a57d5 Mon Sep 17 00:00:00 2001
029dc7
From: Phil Sutter <phil@nwl.cc>
029dc7
Date: Thu, 20 Dec 2018 16:09:02 +0100
029dc7
Subject: [PATCH] nft: Simplify nftnl_rule_list_chain_save()
029dc7
029dc7
Since there are per table chain caches, The chain list passed to that
029dc7
function is comprised of chains belonging to the right table only.
029dc7
Therefore the table name check can safely be skipped.
029dc7
029dc7
Signed-off-by: Phil Sutter <phil@nwl.cc>
029dc7
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
029dc7
(cherry picked from commit 71f9e474d467dd59582d7a3920eded9613b99000)
029dc7
Signed-off-by: Phil Sutter <psutter@redhat.com>
029dc7
---
029dc7
 iptables/nft.c | 10 +++-------
029dc7
 1 file changed, 3 insertions(+), 7 deletions(-)
029dc7
029dc7
diff --git a/iptables/nft.c b/iptables/nft.c
029dc7
index 7b6fb2b10686d..9d20eb0eac2db 100644
029dc7
--- a/iptables/nft.c
029dc7
+++ b/iptables/nft.c
029dc7
@@ -2381,8 +2381,7 @@ list_save(struct nftnl_rule *r, unsigned int num, unsigned int format)
029dc7
 
029dc7
 static int
029dc7
 nftnl_rule_list_chain_save(struct nft_handle *h, const char *chain,
029dc7
-			 const char *table, struct nftnl_chain_list *list,
029dc7
-			 int counters)
029dc7
+			   struct nftnl_chain_list *list, int counters)
029dc7
 {
029dc7
 	struct nftnl_chain_list_iter *iter;
029dc7
 	struct nftnl_chain *c;
029dc7
@@ -2393,15 +2392,12 @@ nftnl_rule_list_chain_save(struct nft_handle *h, const char *chain,
029dc7
 
029dc7
 	c = nftnl_chain_list_iter_next(iter);
029dc7
 	while (c != NULL) {
029dc7
-		const char *chain_table =
029dc7
-			nftnl_chain_get_str(c, NFTNL_CHAIN_TABLE);
029dc7
 		const char *chain_name =
029dc7
 			nftnl_chain_get_str(c, NFTNL_CHAIN_NAME);
029dc7
 		uint32_t policy =
029dc7
 			nftnl_chain_get_u32(c, NFTNL_CHAIN_POLICY);
029dc7
 
029dc7
-		if (strcmp(table, chain_table) != 0 ||
029dc7
-		    (chain && strcmp(chain, chain_name) != 0))
029dc7
+		if (chain && strcmp(chain, chain_name) != 0)
029dc7
 			goto next;
029dc7
 
029dc7
 		/* this is a base chain */
029dc7
@@ -2458,7 +2454,7 @@ int nft_rule_list_save(struct nft_handle *h, const char *chain,
029dc7
 
029dc7
 	/* Dump policies and custom chains first */
029dc7
 	if (!rulenum)
029dc7
-		nftnl_rule_list_chain_save(h, chain, table, list, counters);
029dc7
+		nftnl_rule_list_chain_save(h, chain, list, counters);
029dc7
 
029dc7
 	/* Now dump out rules in this table */
029dc7
 	iter = nftnl_chain_list_iter_create(list);
029dc7
-- 
029dc7
2.21.0
029dc7