From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft 2/2] src: expose nft_ctx_clear_vars as API
Date: Sat, 24 Jul 2021 12:28:24 +0200 [thread overview]
Message-ID: <20210724102824.28011-2-pablo@netfilter.org> (raw)
In-Reply-To: <20210724102824.28011-1-pablo@netfilter.org>
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.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
include/nftables/libnftables.h | 1 +
src/libnftables.c | 4 +++-
src/libnftables.map | 1 +
3 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/nftables/libnftables.h b/include/nftables/libnftables.h
index aaf7388e6db2..8e7151a324b0 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 de6dc7cdae6c..aa6493aae119 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 46d64a38e6e0..d3a795ce8567 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;
--
2.20.1
prev parent reply other threads:[~2021-07-24 10:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-24 10:28 [PATCH nft 1/2] src: fix nft_ctx_clear_include_paths in libnftables.map Pablo Neira Ayuso
2021-07-24 10:28 ` Pablo Neira Ayuso [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210724102824.28011-2-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).