]> git.ipfire.org Git - thirdparty/nftables.git/commit
JSON: Sort out rule position and handles in general
authorPhil Sutter <phil@nwl.cc>
Mon, 28 May 2018 16:50:59 +0000 (18:50 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 1 Jun 2018 07:16:48 +0000 (09:16 +0200)
commitfb557b55460843ad04939488f95524e0c4951589
tree5fa122aed1f9c31256b670de9023fb2689c35292
parentb32e20c51028cef839f8f40e95673c320a930f2b
JSON: Sort out rule position and handles in general

First of all, don't print the position property when listing rules. This
was there only because libnftnl JSON output has it too, but since the
preferred way to *add* a rule at some location is via 'handle' keyword,
keeping "position" in output would be non-intuitive. Changing "position"
property name to "handle" instead is also a no-go since that would clash
with the real rule handle.

Secondly, turn all handle output on regardless of octx->handle setting.
For a programmatic API like JSON, this should be fine.

Thirdly, fix rule locations when parsing JSON: Respect "handle" property
for CMD_INSERT and CMD_ADD and ignore "pos" at all (actually even a
typo, should have read "position"). Also support "index" property
recently added to standard syntax.

Finally, adjust nft-test.py for the above changes: There is no
"position" property to drop from rule output, and "handle" property will
always be present.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/json.c
src/parser_json.c
tests/py/nft-test.py