FS#60694 - [nftables] Add json(/xml) support via libjansson

Attached to Project: Arch Linux
Opened by Markus R. (mqus) - Sunday, 04 November 2018, 01:47 GMT
Last edited by Sébastien Luttringer (seblu) - Thursday, 06 December 2018, 03:30 GMT
Task Type Feature Request
Category Packages: Extra
Status Closed
Assigned To Sébastien Luttringer (seblu)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
In the wiki and manpage there are some parts which explain support/output with json/xml.
When I tried the commands, they didn't work (Examples below).

So I started to look and found out that nft actually somehow depends (optionally) on libjansson (See https://git.netfilter.org/nftables/tree/configure.ac#n92 and https://git.netfilter.org/nftables/tree/include/json.h#n23 ). This is sadly not mentioned neither in the INSTALL file, nor on the netfilter.org page nor in the wiki.

Could we please add json[1] support? It would be perfect if this could be an optional dependency but I don't know if this would be possible here.

[1] Maybe also xml support but I wouldn't use it and have no idea how complicated that would be.

Additional info:
* package version(s): v0.9.0
* config and/or log files etc.


Steps to reproduce:
```
$ sudo nft export ruleset json
Error: this output type is not supported
export ruleset json
^^^^^^^^^^^^^^^^^^^^
```
Or also (--help explains that -j enables json output):

```
$ sudo nft list ruleset -j
table inet filter {

chain input {
type filter hook input priority 0; policy accept;
ct state { established, related } accept
ct state invalid drop
iifname "lo" accept
ip protocol icmp accept
ip6 nexthdr ipv6-icmp accept
reject
}

chain forward {
type filter hook forward priority 0; policy accept;
drop
}

chain output {
type filter hook output priority 0; policy accept;
}
}
```
(this is obviously not json but the default output)
This task depends upon

Closed by  Sébastien Luttringer (seblu)
Thursday, 06 December 2018, 03:30 GMT
Reason for closing:  Implemented
Additional comments about closing:  nftables-1:0.9.0-2
Comment by Sébastien Luttringer (seblu) - Thursday, 06 December 2018, 03:19 GMT
jansson is in community, and nft is in extra. So, as far I remember, extra packages could not depends on packages into community.
But, looking at jansson deps, I found several which are already in extra, like ctags, libnm, smbclient, etc.

So, maybe the rule changed and I missed it. So, I will add the link to jansson to get json output.
Comment by Sébastien Luttringer (seblu) - Thursday, 06 December 2018, 03:30 GMT
There is no xml option so far in configure so i'm skipping it.

Loading...