netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nft 0/5] parser_json: fix up transaction ordering
@ 2024-03-07 12:26 Florian Westphal
  2024-03-07 12:26 ` [PATCH nft 1/5] parser_json: move some code around Florian Westphal
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Florian Westphal @ 2024-03-07 12:26 UTC (permalink / raw)
  To: netfilter-devel; +Cc: phil, Florian Westphal

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-03-07 17:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-07 12:26 [PATCH nft 0/5] parser_json: fix up transaction ordering Florian Westphal
2024-03-07 12:26 ` [PATCH nft 1/5] parser_json: move some code around Florian Westphal
2024-03-07 12:26 ` [PATCH nft 2/5] parser_json: move list_add into json_parse_cmd Florian Westphal
2024-03-07 14:31   ` Phil Sutter
2024-03-07 15:10     ` Florian Westphal
2024-03-07 15:52       ` Phil Sutter
2024-03-07 16:44         ` Florian Westphal
2024-03-07 17:58           ` Phil Sutter
2024-03-07 12:26 ` [PATCH nft 3/5] parser_json: add and use CMD_ERR helpers Florian Westphal
2024-03-07 12:26 ` [PATCH nft 4/5] parser_json: defer command allocation to nft_cmd_expand Florian Westphal
2024-03-07 12:26 ` [PATCH nft 5/5] tests: shell: add more json-nft dumps Florian Westphal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).