|
|
029dc7 |
From 48455efdfbee0df02c724a594cf8af8c440ded7d Mon Sep 17 00:00:00 2001
|
|
|
029dc7 |
From: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
029dc7 |
Date: Sat, 17 Nov 2018 18:16:45 +0100
|
|
|
029dc7 |
Subject: [PATCH] nft: move chain_cache back to struct nft_handle
|
|
|
029dc7 |
|
|
|
029dc7 |
Place this back into the structure that stores the state information.
|
|
|
029dc7 |
|
|
|
029dc7 |
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
029dc7 |
(cherry picked from commit 1847d9db753825b0bd1cd450b549f4e39f7bcc31)
|
|
|
029dc7 |
Signed-off-by: Phil Sutter <psutter@redhat.com>
|
|
|
029dc7 |
---
|
|
|
029dc7 |
iptables/nft.c | 26 +++++++++++++-------------
|
|
|
029dc7 |
iptables/nft.h | 4 +++-
|
|
|
029dc7 |
2 files changed, 16 insertions(+), 14 deletions(-)
|
|
|
029dc7 |
|
|
|
029dc7 |
diff --git a/iptables/nft.c b/iptables/nft.c
|
|
|
029dc7 |
index f0a60e1f568af..fdb4ead55a873 100644
|
|
|
029dc7 |
--- a/iptables/nft.c
|
|
|
029dc7 |
+++ b/iptables/nft.c
|
|
|
029dc7 |
@@ -809,14 +809,14 @@ 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->tables[i].chain_cache) {
|
|
|
029dc7 |
+ if (h->table[i].chain_cache) {
|
|
|
029dc7 |
if (tablename) {
|
|
|
029dc7 |
- nftnl_chain_list_foreach(h->tables[i].chain_cache,
|
|
|
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->tables[i].chain_cache);
|
|
|
029dc7 |
- h->tables[i].chain_cache = NULL;
|
|
|
029dc7 |
+ nftnl_chain_list_free(h->table[i].chain_cache);
|
|
|
029dc7 |
+ h->table[i].chain_cache = NULL;
|
|
|
029dc7 |
}
|
|
|
029dc7 |
}
|
|
|
029dc7 |
}
|
|
|
029dc7 |
@@ -1276,13 +1276,13 @@ static int nftnl_chain_list_cb(const struct nlmsghdr *nlh, void *data)
|
|
|
029dc7 |
if (!t)
|
|
|
029dc7 |
goto out;
|
|
|
029dc7 |
|
|
|
029dc7 |
- if (!t->chain_cache) {
|
|
|
029dc7 |
- t->chain_cache = nftnl_chain_list_alloc();
|
|
|
029dc7 |
- if (!t->chain_cache)
|
|
|
029dc7 |
+ if (!h->table[t->type].chain_cache) {
|
|
|
029dc7 |
+ h->table[t->type].chain_cache = nftnl_chain_list_alloc();
|
|
|
029dc7 |
+ if (!h->table[t->type].chain_cache)
|
|
|
029dc7 |
goto out;
|
|
|
029dc7 |
}
|
|
|
029dc7 |
|
|
|
029dc7 |
- nftnl_chain_list_add_tail(c, t->chain_cache);
|
|
|
029dc7 |
+ nftnl_chain_list_add_tail(c, h->table[t->type].chain_cache);
|
|
|
029dc7 |
|
|
|
029dc7 |
return MNL_CB_OK;
|
|
|
029dc7 |
out:
|
|
|
029dc7 |
@@ -1303,8 +1303,8 @@ struct nftnl_chain_list *nft_chain_list_get(struct nft_handle *h,
|
|
|
029dc7 |
if (!t)
|
|
|
029dc7 |
return NULL;
|
|
|
029dc7 |
|
|
|
029dc7 |
- if (t->chain_cache)
|
|
|
029dc7 |
- return t->chain_cache;
|
|
|
029dc7 |
+ if (h->table[t->type].chain_cache)
|
|
|
029dc7 |
+ return h->table[t->type].chain_cache;
|
|
|
029dc7 |
retry:
|
|
|
029dc7 |
nlh = nftnl_chain_nlmsg_build_hdr(buf, NFT_MSG_GETCHAIN, h->family,
|
|
|
029dc7 |
NLM_F_DUMP, h->seq);
|
|
|
029dc7 |
@@ -1315,10 +1315,10 @@ retry:
|
|
|
029dc7 |
goto retry;
|
|
|
029dc7 |
}
|
|
|
029dc7 |
|
|
|
029dc7 |
- if (!t->chain_cache)
|
|
|
029dc7 |
- t->chain_cache = nftnl_chain_list_alloc();
|
|
|
029dc7 |
+ if (!h->table[t->type].chain_cache)
|
|
|
029dc7 |
+ h->table[t->type].chain_cache = nftnl_chain_list_alloc();
|
|
|
029dc7 |
|
|
|
029dc7 |
- return t->chain_cache;
|
|
|
029dc7 |
+ return h->table[t->type].chain_cache;
|
|
|
029dc7 |
}
|
|
|
029dc7 |
|
|
|
029dc7 |
static const char *policy_name[NF_ACCEPT+1] = {
|
|
|
029dc7 |
diff --git a/iptables/nft.h b/iptables/nft.h
|
|
|
029dc7 |
index 85c894e80e02e..1c028206221c4 100644
|
|
|
029dc7 |
--- a/iptables/nft.h
|
|
|
029dc7 |
+++ b/iptables/nft.h
|
|
|
029dc7 |
@@ -26,7 +26,6 @@ struct builtin_table {
|
|
|
029dc7 |
enum nft_table_type type;
|
|
|
029dc7 |
struct builtin_chain chains[NF_INET_NUMHOOKS];
|
|
|
029dc7 |
bool initialized;
|
|
|
029dc7 |
- struct nftnl_chain_list *chain_cache;
|
|
|
029dc7 |
};
|
|
|
029dc7 |
|
|
|
029dc7 |
struct nft_handle {
|
|
|
029dc7 |
@@ -40,6 +39,9 @@ struct nft_handle {
|
|
|
029dc7 |
struct list_head err_list;
|
|
|
029dc7 |
struct nft_family_ops *ops;
|
|
|
029dc7 |
struct builtin_table *tables;
|
|
|
029dc7 |
+ struct {
|
|
|
029dc7 |
+ struct nftnl_chain_list *chain_cache;
|
|
|
029dc7 |
+ } table[NFT_TABLE_MAX];
|
|
|
029dc7 |
struct nftnl_rule_list *rule_cache;
|
|
|
029dc7 |
bool restore;
|
|
|
029dc7 |
int8_t config_done;
|
|
|
029dc7 |
--
|
|
|
029dc7 |
2.21.0
|
|
|
029dc7 |
|