Skip to contentSkip to conversation

src: fix nft_ctx_clear_include_paths in libnftables.map

PATCH New Pablo Neira Ayuso 1 participant 2 messages Jul 24, 2021 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/2 src: fix nft_ctx_clear_include_paths in libnftables.map

There a typo that prevents exposing the function as API.

Fixes 16543a0136c0 ("libnftables: export public symbols only")
---
 src/libnftables.map | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/libnftables.map +1 -1
index c0185349ede4..46d64a38e6e0 100644
@@ -1,7 +1,7 @@
 LIBNFTABLES_1 {
 global:
   nft_ctx_add_include_path;
-  nft_ctx_clear_include_pat;
+  nft_ctx_clear_include_paths;
   nft_ctx_new;
   nft_ctx_buffer_output;
   nft_ctx_unbuffer_output;
Signature · 1 line
2.20.1
author maintainer
#1 lore raw

PATCH 2/2 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 variables definition.

Moreover, reset ctx->num_vars to zero.

---
 include/nftables/libnftables.h | 1 +
 src/libnftables.c              | 4 +++-
 src/libnftables.map            | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)
include/nftables/libnftables.h +1 -0
index aaf7388e6db2..8e7151a324b0 100644
@@ -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);
src/libnftables.c +3 -1
index de6dc7cdae6c..aa6493aae119 100644
@@ -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);
 }
 
src/libnftables.map +1 -0
index 46d64a38e6e0..d3a795ce8567 100644
@@ -26,4 +26,5 @@ local: *;
 
 LIBNFTABLES_2 {
   nft_ctx_add_var;
+  nft_ctx_clear_vars;
 } LIBNFTABLES_1;
Signature · 1 line
2.20.1