|
|
8cce6c |
From c10f5977915b1b7ddfb6557f9f6b18cd4140c26b Mon Sep 17 00:00:00 2001
|
|
|
8cce6c |
From: Phil Sutter <phil@nwl.cc>
|
|
|
8cce6c |
Date: Thu, 20 Dec 2018 16:09:09 +0100
|
|
|
8cce6c |
Subject: [PATCH] nft: Simplify nft_rule_insert() a bit
|
|
|
8cce6c |
|
|
|
8cce6c |
Fetch rule list right on top instead of in each branch separately.
|
|
|
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 88bd4f28878bc7d41daa23098d68bf1bf6f5cea2)
|
|
|
8cce6c |
Signed-off-by: Phil Sutter <psutter@redhat.com>
|
|
|
8cce6c |
---
|
|
|
8cce6c |
iptables/nft.c | 5 +----
|
|
|
8cce6c |
1 file changed, 1 insertion(+), 4 deletions(-)
|
|
|
8cce6c |
|
|
|
8cce6c |
diff --git a/iptables/nft.c b/iptables/nft.c
|
|
|
8cce6c |
index 7d08a0884adde..469448f42cd6d 100644
|
|
|
8cce6c |
--- a/iptables/nft.c
|
|
|
8cce6c |
+++ b/iptables/nft.c
|
|
|
8cce6c |
@@ -2091,8 +2091,8 @@ nft_rule_add(struct nft_handle *h, const char *chain,
|
|
|
8cce6c |
int nft_rule_insert(struct nft_handle *h, const char *chain,
|
|
|
8cce6c |
const char *table, void *data, int rulenum, bool verbose)
|
|
|
8cce6c |
{
|
|
|
8cce6c |
+ struct nftnl_rule_list *list = nft_rule_list_get(h);
|
|
|
8cce6c |
struct nftnl_rule *r, *new_rule;
|
|
|
8cce6c |
- struct nftnl_rule_list *list;
|
|
|
8cce6c |
uint64_t handle = 0;
|
|
|
8cce6c |
|
|
|
8cce6c |
/* If built-in chains don't exist for this table, create them */
|
|
|
8cce6c |
@@ -2102,7 +2102,6 @@ int nft_rule_insert(struct nft_handle *h, const char *chain,
|
|
|
8cce6c |
nft_fn = nft_rule_insert;
|
|
|
8cce6c |
|
|
|
8cce6c |
if (rulenum > 0) {
|
|
|
8cce6c |
- list = nft_rule_list_get(h);
|
|
|
8cce6c |
if (list == NULL)
|
|
|
8cce6c |
goto err;
|
|
|
8cce6c |
|
|
|
8cce6c |
@@ -2123,8 +2122,6 @@ int nft_rule_insert(struct nft_handle *h, const char *chain,
|
|
|
8cce6c |
|
|
|
8cce6c |
handle = nftnl_rule_get_u64(r, NFTNL_RULE_HANDLE);
|
|
|
8cce6c |
DEBUGP("adding after rule handle %"PRIu64"\n", handle);
|
|
|
8cce6c |
- } else {
|
|
|
8cce6c |
- nft_rule_list_get(h);
|
|
|
8cce6c |
}
|
|
|
8cce6c |
|
|
|
8cce6c |
new_rule = nft_rule_add(h, chain, table, data, handle, verbose);
|
|
|
8cce6c |
--
|
|
|
8cce6c |
2.20.1
|
|
|
8cce6c |
|