From: Pablo Neira Ayuso Date: Sat, 24 Jul 2021 10:07:27 +0000 (+0200) Subject: src: expose nft_ctx_clear_vars as API X-Git-Tag: v1.0.0~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e8dff2cb4da818a937f8c0efa1a0d73b632297e;p=thirdparty%2Fnftables.git src: expose nft_ctx_clear_vars as API This function might be useful to recycle the existing nft_ctx to use it with different external variable definitions. Moreover, reset ctx->num_vars to zero. Signed-off-by: Pablo Neira Ayuso --- diff --git a/include/nftables/libnftables.h b/include/nftables/libnftables.h index aaf7388e..8e7151a3 100644 --- a/include/nftables/libnftables.h +++ b/include/nftables/libnftables.h @@ -79,6 +79,7 @@ int nft_ctx_add_include_path(struct nft_ctx *ctx, const char *path); void nft_ctx_clear_include_paths(struct nft_ctx *ctx); int nft_ctx_add_var(struct nft_ctx *ctx, const char *var); +void nft_ctx_clear_vars(struct nft_ctx *ctx); int nft_run_cmd_from_buffer(struct nft_ctx *nft, const char *buf); int nft_run_cmd_from_filename(struct nft_ctx *nft, const char *filename); diff --git a/src/libnftables.c b/src/libnftables.c index de6dc7cd..aa6493aa 100644 --- a/src/libnftables.c +++ b/src/libnftables.c @@ -145,7 +145,8 @@ int nft_ctx_add_var(struct nft_ctx *ctx, const char *var) return 0; } -static void nft_ctx_clear_vars(struct nft_ctx *ctx) +EXPORT_SYMBOL(nft_ctx_clear_vars); +void nft_ctx_clear_vars(struct nft_ctx *ctx) { unsigned int i; @@ -153,6 +154,7 @@ static void nft_ctx_clear_vars(struct nft_ctx *ctx) xfree(ctx->vars[i].key); xfree(ctx->vars[i].value); } + ctx->num_vars = 0; xfree(ctx->vars); } diff --git a/src/libnftables.map b/src/libnftables.map index 46d64a38..d3a795ce 100644 --- a/src/libnftables.map +++ b/src/libnftables.map @@ -26,4 +26,5 @@ local: *; LIBNFTABLES_2 { nft_ctx_add_var; + nft_ctx_clear_vars; } LIBNFTABLES_1;