The existing parser cannot handle certain inputs. Example: "map": { "table": "test", [..] "map": "verdict", "elem": [ [ "*", { "jump": { "target": "testchain" [..] }, { "chain": { "family": "ip", "table": "test", "name": "testchain", ... This will fail to load because the generated transaction adds the element containing the jump to 'testchain' before the 'add chain'. The normal (bison) parser does not have this issue, elements get added to the map, the map is added to the table. Then, *after* parsing, the 'add chain' and 'add element' commands are generated via command expansion. Change the json parser to do the same and avoid cmd_alloc where possible. Patch 4 is the main change, patch 5 adds test cases that did not work before. json parser still cannot handle several existing tests due to lack of 'typeof' support (dump would contain base types like 'integer' which are rejected as they lack the needed key length information). Florian Westphal (5): parser_json: move some code around parser_json: move list_add into json_parse_cmd parser_json: add and use CMD_ERR helpers parser_json: defer command allocation to nft_cmd_expand tests: shell: add more json-nft dumps src/parser_json.c | 331 ++++++++--- .../dumps/0011endless_jump_loop_1.json-nft | 75 +++ .../testcases/maps/dumps/0011vmap_0.json-nft | 145 +++++ .../dumps/map_catchall_double_free_2.json-nft | 46 ++ .../maps/dumps/vmap_mark_bitwise_0.json-nft | 158 +++++ .../maps/dumps/vmap_timeout.json-nft | 229 ++++++++ .../dumps/0008create_verdict_map_0.json-nft | 78 +++ .../sets/dumps/sets_with_ifnames.json-nft | 551 ++++++++++++++++++ 8 files changed, 1516 insertions(+), 97 deletions(-) create mode 100644 tests/shell/testcases/chains/dumps/0011endless_jump_loop_1.json-nft create mode 100644 tests/shell/testcases/maps/dumps/0011vmap_0.json-nft create mode 100644 tests/shell/testcases/maps/dumps/map_catchall_double_free_2.json-nft create mode 100644 tests/shell/testcases/maps/dumps/vmap_mark_bitwise_0.json-nft create mode 100644 tests/shell/testcases/maps/dumps/vmap_timeout.json-nft create mode 100644 tests/shell/testcases/sets/dumps/0008create_verdict_map_0.json-nft create mode 100644 tests/shell/testcases/sets/dumps/sets_with_ifnames.json-nft -- 2.43.0