[PATCH nft 1/4] src: do not use the nft_cache_filter object from mnl.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Pass the table and chain strings to mnl_nft_rule_dump() instead.

Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 include/mnl.h |  2 +-
 src/cache.c   |  9 ++++++++-
 src/mnl.c     | 12 +++++-------
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/include/mnl.h b/include/mnl.h
index b006192cf7b2..a4abe1ae3242 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 6494e4743f8d..6ca6bbc6645b 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 5413f8658f9b..6be991a4827c 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();
-- 
2.30.2




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux