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