mbox series

[nft,v3,0/2] Support for variables in map expressions

Message ID 20240429192756.1347369-1-jeremy@azazel.net
Headers show
Series Support for variables in map expressions | expand

Message

Jeremy Sowden April 29, 2024, 7:27 p.m. UTC
The first patch replaces the current assertion failure for invalid
mapping expression in stateful-object statements with an error message.
This brings it in line with map statements.

It is possible to use a variable to initialize a map, which is then used
in a map statement, but if one tries to use the variable directly, nft
rejects it.  The second patch adds support for doing this.

Changes since v2

  * Patch 2: error-checking (and test-cases) added for variables that do
    not contain maps

Changes since v1

  * Patch 1 is new.
  * Patch 2 updated to add support for map variables in stateful object
    statements.

Jeremy Sowden (2):
  evaluate: handle invalid mapping expressions in stateful object
    statements gracefully.
  evaluate: add support for variables in map expressions

 src/evaluate.c                                |  17 +-
 .../shell/testcases/maps/0024named_objects_1  |  31 ++++
 .../shell/testcases/maps/0024named_objects_2  |  23 +++
 .../shell/testcases/maps/anonymous_snat_map_1 |  16 ++
 .../shell/testcases/maps/anonymous_snat_map_2 |  23 +++
 .../maps/dumps/0024named_objects_1.json-nft   | 147 ++++++++++++++++++
 .../maps/dumps/0024named_objects_1.nft        |  23 +++
 .../maps/dumps/anonymous_snat_map_1.json-nft  |  58 +++++++
 .../maps/dumps/anonymous_snat_map_1.nft       |   5 +
 9 files changed, 341 insertions(+), 2 deletions(-)
 create mode 100755 tests/shell/testcases/maps/0024named_objects_1
 create mode 100755 tests/shell/testcases/maps/0024named_objects_2
 create mode 100755 tests/shell/testcases/maps/anonymous_snat_map_1
 create mode 100755 tests/shell/testcases/maps/anonymous_snat_map_2
 create mode 100644 tests/shell/testcases/maps/dumps/0024named_objects_1.json-nft
 create mode 100644 tests/shell/testcases/maps/dumps/0024named_objects_1.nft
 create mode 100644 tests/shell/testcases/maps/dumps/anonymous_snat_map_1.json-nft
 create mode 100644 tests/shell/testcases/maps/dumps/anonymous_snat_map_1.nft

Comments

Pablo Neira Ayuso May 23, 2024, 4:23 p.m. UTC | #1
On Mon, Apr 29, 2024 at 08:27:51PM +0100, Jeremy Sowden wrote:
> The first patch replaces the current assertion failure for invalid
> mapping expression in stateful-object statements with an error message.
> This brings it in line with map statements.
> 
> It is possible to use a variable to initialize a map, which is then used
> in a map statement, but if one tries to use the variable directly, nft
> rejects it.  The second patch adds support for doing this.

LGTM, thanks for your patience.

Applied thanks.