]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: expose nft_ctx_clear_vars as API
authorPablo Neira Ayuso <pablo@netfilter.org>
Sat, 24 Jul 2021 10:07:27 +0000 (12:07 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sat, 24 Jul 2021 11:55:58 +0000 (13:55 +0200)
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 <pablo@netfilter.org>
include/nftables/libnftables.h
src/libnftables.c
src/libnftables.map

index aaf7388e6db2bb12cbca70a36af21294c4ea04b3..8e7151a324b05178208b8a39720fd3a912f96ddd 100644 (file)
@@ -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);
index de6dc7cdae6c84e85ae1ca7011b386f8a8cba863..aa6493aae11908d04bdd7c3eaa5a93d4b04d7594 100644 (file)
@@ -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);
 }
 
index 46d64a38e6e08d2b4e6bec4c474eb76478bdedfe..d3a795ce8567cbc1e471ad74a38965afcc832a72 100644 (file)
@@ -26,4 +26,5 @@ local: *;
 
 LIBNFTABLES_2 {
   nft_ctx_add_var;
+  nft_ctx_clear_vars;
 } LIBNFTABLES_1;