From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Phil Sutter <phil@nwl.cc>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [nft PATCH RFC] libnftables: Implement JSON output support
Date: Wed, 17 Jan 2018 13:44:06 +0100 [thread overview]
Message-ID: <20180117124406.lil7vr2ypmpkhp5d@salvia> (raw)
In-Reply-To: <20180117115140.10751-1-phil@nwl.cc>
Hi Phil,
On Wed, Jan 17, 2018 at 12:51:40PM +0100, Phil Sutter wrote:
> Although technically there already is support for JSON output via 'nft
> export json' command, it is hardly useable since it exports all the gory
> details of nftables VM. Also, libnftables has no control over what is
> exported since the content comes directly from libnftnl.
I'm going to apply this:
http://patchwork.ozlabs.org/patch/844762/
now that nft 0.8.1 is out. Basically, renaming 'nft export json' to
'nft export vm json' so this clearly shows this is the low-level
representation, and we leave room for your high level json
representation.
> Instead, implement JSON format support for regular 'nft list' commands.
>
> Signed-off-by: Phil Sutter <phil@nwl.cc>
> ---
> Note that this is incomplete and merely meant as foundation for a
> discussion about the implementation. A few things I am not happy with:
>
> * The amount of ifdef's introduced is certainly not optimal, though I
> don't see how this could be avoided if JSON support is to be kept
> optional.
Usual trick is to add a header file with function declaration like this:
#ifdef NFT_JSON
int nft_json_parse_blah(...);
#else
static inline int nft_json_parse_blah(...) { return -1; }
#endif
So all ifdef pollution remains only in that json header file. And
place all json code in a single .c file.
> * There is quite some code-duplication involved given that this
> introduces an alternative function for almost any function in the
> affected code path.
You mean, a new callback for each expr/datatype? We should not expose
bitwise/byteorder and such, it's too low level.
> * JSON output is completely numeric. While this is intentional as it
> helps applications parsing e.g. port numbers, other things like e.g.
> TCP header flags become a bit cryptic.
Can't we have list in json too?
next prev parent reply other threads:[~2018-01-17 12:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-17 11:51 [nft PATCH RFC] libnftables: Implement JSON output support Phil Sutter
2018-01-17 12:44 ` Pablo Neira Ayuso [this message]
2018-01-17 12:50 ` Pablo Neira Ayuso
2018-01-17 17:52 ` Phil Sutter
2018-01-17 18:45 ` Pablo Neira Ayuso
2018-01-17 18:56 ` Phil Sutter
2018-01-17 18:59 ` Pablo Neira Ayuso
2018-01-17 19:24 ` Phil Sutter
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=20180117124406.lil7vr2ypmpkhp5d@salvia \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=phil@nwl.cc \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.