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