Blame SOURCES/0016-nft-Reduce-indenting-level-in-flush_chain_cache.patch

029dc7
From 3614b4bee283ea6d08207ccc5e2efa3ebfad321c Mon Sep 17 00:00:00 2001
029dc7
From: Phil Sutter <phil@nwl.cc>
029dc7
Date: Thu, 20 Dec 2018 16:09:07 +0100
029dc7
Subject: [PATCH] nft: Reduce indenting level in flush_chain_cache()
029dc7
029dc7
Instead of doing all in one go, make two separate decisions:
029dc7
029dc7
1) If table has no chain cache, either continue or return depending on
029dc7
   whether we're flushing for a specific table.
029dc7
029dc7
2) With chain cache present, flushing strategy once more depends on
029dc7
   whether we're flushing for a specific table: If given, just remove
029dc7
   all rules and return. If not, free the cache and set to NULL (so that
029dc7
   it will be repopulated later), then continue the loop.
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 d4b0d248cc057e39608c7c1c1203dd3f1ea96645)
029dc7
Signed-off-by: Phil Sutter <psutter@redhat.com>
029dc7
---
029dc7
 iptables/nft.c | 22 +++++++++++++---------
029dc7
 1 file changed, 13 insertions(+), 9 deletions(-)
029dc7
029dc7
diff --git a/iptables/nft.c b/iptables/nft.c
029dc7
index befd9f4dd9026..997d7bc58fd00 100644
029dc7
--- a/iptables/nft.c
029dc7
+++ b/iptables/nft.c
029dc7
@@ -815,16 +815,20 @@ static void flush_chain_cache(struct nft_handle *h, const char *tablename)
029dc7
 		if (tablename && strcmp(h->tables[i].name, tablename))
029dc7
 			continue;
029dc7
 
029dc7
-		if (h->table[i].chain_cache) {
029dc7
-			if (tablename) {
029dc7
-				nftnl_chain_list_foreach(h->table[i].chain_cache,
029dc7
-							 __flush_chain_cache, NULL);
029dc7
-				break;
029dc7
-			} else {
029dc7
-				nftnl_chain_list_free(h->table[i].chain_cache);
029dc7
-				h->table[i].chain_cache = NULL;
029dc7
-			}
029dc7
+		if (!h->table[i].chain_cache) {
029dc7
+			if (tablename)
029dc7
+				return;
029dc7
+			continue;
029dc7
 		}
029dc7
+
029dc7
+		if (tablename) {
029dc7
+			nftnl_chain_list_foreach(h->table[i].chain_cache,
029dc7
+						 __flush_chain_cache, NULL);
029dc7
+			return;
029dc7
+		}
029dc7
+
029dc7
+		nftnl_chain_list_free(h->table[i].chain_cache);
029dc7
+		h->table[i].chain_cache = NULL;
029dc7
 	}
029dc7
 }
029dc7
 
029dc7
-- 
029dc7
2.21.0
029dc7