]> git.ipfire.org Git - thirdparty/nftables.git/commit
JSON: Add support for echo option
authorPhil Sutter <phil@nwl.cc>
Fri, 26 Oct 2018 13:01:38 +0000 (15:01 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 29 Oct 2018 10:15:08 +0000 (11:15 +0100)
commitbb32d8db9a125d9676f87866e48ffbf0221ec16a
treebfbeaf0ffb248aad38fab54b7630e2fe67e64ca7
parent21d678639b28b99c301262c163128fdf67397ca6
JSON: Add support for echo option

The basic principle is to not return a JSON object freshly created from
netlink responses, but just update the existing user-provided one to
make sure callers get back exactly what they expect.

To achieve that, keep the parsed JSON object around in a global variable
('cur_root') and provide a custom callback to insert handles into it
from received netlink messages. The tricky bit here is updating rules
since unique identification is problematic. Therefore drop possibly
present handles from input and later assume updates are received in
order so the first rule not having a handle set is the right one.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/json.h
include/netlink.h
include/nftables.h
src/libnftables.c
src/monitor.c
src/parser_json.c
tests/json_echo/run-test.py [new file with mode: 0755]