]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
monitor: Accept -j flag
authorPhil Sutter <phil@nwl.cc>
Wed, 12 Jun 2019 17:27:37 +0000 (19:27 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 13 Jun 2019 10:39:53 +0000 (12:39 +0200)
Make 'nft -j monitor' equal to 'nft monitor json' and change
documentation to use only the first variant since that is more intuitive
and also consistent with other commands.

While being at it, drop references to XML from monitor section - it was
never supported.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
doc/nft.txt
src/rule.c

index 4fca5c918b7472c0a2362af5077721e1f5c4b4a4..3f1074b8c36e9f834c272b94edbcbec9d3f47840 100644 (file)
@@ -713,7 +713,7 @@ MONITOR
 ~~~~~~~~
 The monitor command allows you to listen to Netlink events produced by the
 nf_tables subsystem, related to creation and deletion of objects. When they
-occur, nft will print to stdout the monitored events in either XML, JSON or
+occur, nft will print to stdout the monitored events in either JSON or
 native nft format. +
 
 To filter events related to a concrete object, use one of the keywords 'tables', 'chains', 'sets', 'rules', 'elements', 'ruleset'. +
@@ -727,14 +727,9 @@ Hit ^C to finish the monitor operation.
 % nft monitor
 --------------------------------------------------
 
-.Listen to added tables, report in XML format
---------------------------------------------
-% nft monitor new tables xml
---------------------------------------------
-
 .Listen to deleted rules, report in JSON format
 -----------------------------------------------
-% nft monitor destroy rules json
+% nft -j monitor destroy rules
 -----------------------------------------------
 
 .Listen to both new and destroyed chains, in native nft format
index 7eb89a00b85b8f1e46bbb55f6e48b4f52e330794..8de5aa62b94ffb637669cf33792c13092f58a37a 100644 (file)
@@ -2435,6 +2435,9 @@ static int do_command_monitor(struct netlink_ctx *ctx, struct cmd *cmd)
                .debug_mask     = ctx->nft->debug_mask,
        };
 
+       if (nft_output_json(&ctx->nft->output))
+               monhandler.format = NFTNL_OUTPUT_JSON;
+
        monhandler.cache_needed = need_cache(cmd);
        if (monhandler.cache_needed) {
                struct rule *rule, *nrule;