Provide a convenient interface to configure dry run mode.

Signed-off-by: Phil Sutter <[email protected]>
---
 include/nftables/nftables.h | 3 +++
 src/libnftables.c           | 5 +++++
 src/main.c                  | 2 +-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/include/nftables/nftables.h b/include/nftables/nftables.h
index b91219d423df9..f0c9bbf3ba3fe 100644
--- a/include/nftables/nftables.h
+++ b/include/nftables/nftables.h
@@ -75,7 +75,10 @@ enum nftables_exit_codes {
 
 struct nft_ctx *nft_ctx_new(uint32_t flags);
 void nft_ctx_free(struct nft_ctx *ctx);
+
 FILE *nft_ctx_set_output(struct nft_ctx *ctx, FILE *fp);
+void nft_ctx_set_dry_run(struct nft_ctx *ctx, bool dry);
+
 void nft_ctx_flush_cache(struct nft_ctx *ctx);
 
 int nft_run_cmd_from_buffer(struct nft_ctx *nft, char *buf, size_t buflen);
diff --git a/src/libnftables.c b/src/libnftables.c
index d88c299c3647e..817f537e32618 100644
--- a/src/libnftables.c
+++ b/src/libnftables.c
@@ -171,6 +171,11 @@ FILE *nft_ctx_set_output(struct nft_ctx *ctx, FILE *fp)
        return old;
 }
 
+void nft_ctx_set_dry_run(struct nft_ctx *ctx, bool dry)
+{
+       ctx->check = dry;
+}
+
 static const struct input_descriptor indesc_cmdline = {
        .type   = INDESC_BUFFER,
        .name   = "<cmdline>",
diff --git a/src/main.c b/src/main.c
index 3c107181305c7..8359367b78654 100644
--- a/src/main.c
+++ b/src/main.c
@@ -187,7 +187,7 @@ int main(int argc, char * const *argv)
                               PACKAGE_NAME, PACKAGE_VERSION, RELEASE_NAME);
                        exit(NFT_EXIT_SUCCESS);
                case OPT_CHECK:
-                       nft->check = true;
+                       nft_ctx_set_dry_run(nft, true);
                        break;
                case OPT_FILE:
                        filename = optarg;
-- 
2.13.1

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to