summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2022-01-12 01:33:58 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2022-01-15 18:15:23 +0100
commitafbd102211dcc52dfdc2332e171d21e769f7e70e (patch)
tree23d0ad17ccb5bd0b14c5a401cf498f60d97979fa
parent345d9260f7fe8ba62fd1700489a1d78cd533f59d (diff)
src: do not use the nft_cache_filter object from mnl.c
Pass the table and chain strings to mnl_nft_rule_dump() instead. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--include/mnl.h2
-rw-r--r--src/cache.c9
-rw-r--r--src/mnl.c12
3 files changed, 14 insertions, 9 deletions
diff --git a/include/mnl.h b/include/mnl.h
index b006192c..a4abe1ae 100644
--- a/include/mnl.h
+++ b/include/mnl.h
@@ -34,7 +34,7 @@ int mnl_nft_rule_del(struct netlink_ctx *ctx, struct cmd *cmd);
int mnl_nft_rule_replace(struct netlink_ctx *ctx, struct cmd *cmd);
struct nftnl_rule_list *mnl_nft_rule_dump(struct netlink_ctx *ctx, int family,
- const struct nft_cache_filter *filter);
+ const char *table, const char *chain);
int mnl_nft_chain_add(struct netlink_ctx *ctx, struct cmd *cmd,
unsigned int flags);
diff --git a/src/cache.c b/src/cache.c
index 6494e474..6ca6bbc6 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -478,8 +478,15 @@ static int rule_cache_init(struct netlink_ctx *ctx, const struct handle *h,
const struct nft_cache_filter *filter)
{
struct nftnl_rule_list *rule_cache;
+ const char *table;
+ const char *chain;
- rule_cache = mnl_nft_rule_dump(ctx, h->family, filter);
+ if (filter) {
+ table = filter->list.table;
+ chain = filter->list.chain;
+ }
+
+ rule_cache = mnl_nft_rule_dump(ctx, h->family, table, chain);
if (rule_cache == NULL) {
if (errno == EINTR)
return -1;
diff --git a/src/mnl.c b/src/mnl.c
index 5413f865..6be991a4 100644
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -654,7 +654,7 @@ err_free:
}
struct nftnl_rule_list *mnl_nft_rule_dump(struct netlink_ctx *ctx, int family,
- const struct nft_cache_filter *filter)
+ const char *table, const char *chain)
{
char buf[MNL_SOCKET_BUFFER_SIZE];
struct nftnl_rule_list *nlr_list;
@@ -662,16 +662,14 @@ struct nftnl_rule_list *mnl_nft_rule_dump(struct netlink_ctx *ctx, int family,
struct nlmsghdr *nlh;
int ret;
- if (filter && filter->list.table) {
+ if (table) {
nlr = nftnl_rule_alloc();
if (!nlr)
memory_allocation_error();
- nftnl_rule_set_str(nlr, NFTNL_RULE_TABLE,
- filter->list.table);
- if (filter->list.chain)
- nftnl_rule_set_str(nlr, NFTNL_RULE_CHAIN,
- filter->list.chain);
+ nftnl_rule_set_str(nlr, NFTNL_RULE_TABLE, table);
+ if (chain)
+ nftnl_rule_set_str(nlr, NFTNL_RULE_CHAIN, chain);
}
nlr_list = nftnl_rule_list_alloc();