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