From 213bb692b8907c2d458298ff2569c96ed71fb925 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Fri, 15 Mar 2019 13:08:45 +0100 Subject: [PATCH] src: Reject 'export vm json' command Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1646336 Upstream Status: nftables commit 8d51f169e0e83 Conflicts: * Adjusted changes to missing commit a84f9329d2f6c ("src: use location to display error messages"). * Error message changed to not suggest 'nft -j' which doesn't exist in RHEL7. * Man page changes applied manually, upstream converted to asciidoc in between. * Include netlink.h from src/evaluate.c to make NFTNL_OUTPUT_JSON known. Upstream added this in unrelated commit 1524134b0bc01 ("src: osf: load pf.os from expr_evaluate_osf()"). commit 8d51f169e0e832a41d2ed278be903c08bd4fa473 Author: Phil Sutter Date: Mon Dec 17 16:29:56 2018 +0100 src: Reject 'export vm json' command Since libnftnl recently dropped JSON output support, this form of JSON export is not available anymore. Point at 'nft -j list ruleset' command for a replacement in error message. Since 'export' command is not useable anymore, remove it from documentation. Instead point out that 'list ruleset' command serves well for dumping and later restoring. To not cause pointless inconvenience for users wishing to store their ruleset in JSON format, make JSON parser fallback to CMD_ADD if no recognized command property was found. This allows to feed the output of 'nft -j list ruleset' into 'nft -f' without any modification. Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- doc/nft.xml | 23 +++-------------------- src/evaluate.c | 4 ++++ 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/doc/nft.xml b/doc/nft.xml index e6cfb78..a4a4c3f 100644 --- a/doc/nft.xml +++ b/doc/nft.xml @@ -514,11 +514,6 @@ filter input iif $int_ifs accept ruleset family - - export - ruleset - format - @@ -548,17 +543,6 @@ filter input iif $int_ifs accept - - - - - Print the ruleset in machine readable format. The - mandatory format parameter - may be either xml or - json. - - - @@ -568,10 +552,9 @@ filter input iif $int_ifs accept - Note that contrary to what one might assume, the output generated - by export is not parseable by - nft -f. Instead, the output of - list command serves well for that purpose. + By design, list ruleset command output may be used as + input to nft -f. Effectively, this is the nft-equivalent + of iptables-save and iptables-restore. diff --git a/src/evaluate.c b/src/evaluate.c index c8a98f1..b6c70b8 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -3428,6 +3429,9 @@ static int cmd_evaluate_export(struct eval_ctx *ctx, struct cmd *cmd) { if (cmd->export->format == __NFT_OUTPUT_NOTSUPP) return cmd_error(ctx, "this output type is not supported"); + else if (cmd->export->format == NFTNL_OUTPUT_JSON) + return cmd_error(ctx, + "JSON export is not supported"); return cache_update(ctx->nf_sock, ctx->cache, cmd->op, ctx->msgs, ctx->debug_mask & DEBUG_NETLINK, ctx->octx); -- 1.8.3.1