summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlvaro Neira <alvaroneay@gmail.com>2015-03-12 17:33:09 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2015-03-13 12:18:20 +0100
commitd27456460a2867d69a6bbed8aa0019f65ab42eac (patch)
treec9f216ed01188d7e0e784d272c3057f5452a3959 /src
parent1f92b04760f65c28498e7c4e20e8037fe66ecf44 (diff)
ruleset: add nft_ruleset_ctx_free
This function releases the ruleset objects attached in the parse context structure, ie. struct nft_parse_ctx. Moreover, this patch updates the nft_parse_ruleset_file to use it. Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/libnftnl.map1
-rw-r--r--src/ruleset.c23
2 files changed, 24 insertions, 0 deletions
diff --git a/src/libnftnl.map b/src/libnftnl.map
index 7c74fbc..c0b2031 100644
--- a/src/libnftnl.map
+++ b/src/libnftnl.map
@@ -234,4 +234,5 @@ LIBNFTNL_1.2.0 {
nft_ruleset_ctx_get_u32;
nft_ruleset_parse_file_cb;
nft_ruleset_parse_buffer_cb;
+ nft_ruleset_ctx_free;
} LIBNFTNL_1.2;
diff --git a/src/ruleset.c b/src/ruleset.c
index c8747b6..e7f9204 100644
--- a/src/ruleset.c
+++ b/src/ruleset.c
@@ -157,6 +157,29 @@ void *nft_ruleset_attr_get(const struct nft_ruleset *r, uint16_t attr)
}
EXPORT_SYMBOL(nft_ruleset_attr_get);
+void nft_ruleset_ctx_free(const struct nft_parse_ctx *ctx)
+{
+ switch (ctx->type) {
+ case NFT_RULESET_TABLE:
+ nft_table_free(ctx->table);
+ break;
+ case NFT_RULESET_CHAIN:
+ nft_chain_free(ctx->chain);
+ break;
+ case NFT_RULESET_RULE:
+ nft_rule_free(ctx->rule);
+ break;
+ case NFT_RULESET_SET:
+ case NFT_RULESET_SET_ELEMS:
+ nft_set_free(ctx->set);
+ break;
+ case NFT_RULESET_RULESET:
+ case NFT_RULESET_UNSPEC:
+ break;
+ }
+}
+EXPORT_SYMBOL(nft_ruleset_ctx_free);
+
bool nft_ruleset_ctx_is_set(const struct nft_parse_ctx *ctx, uint16_t attr)
{
return ctx->flags & (1 << attr);