From bb6b4c4c794a9090547f562f2bba8cf5f0048127 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Wed, 11 Aug 2021 12:08:41 +0200 Subject: evaluate: expand variable containing set into multiple mappings # cat x.nft define interfaces = { eth0, eth1 } table ip x { chain y { type filter hook input priority 0; policy accept; iifname vmap { lo : accept, $interfaces : drop } } } # nft -f x.nft # nft list ruleset table ip x { chain y { type filter hook input priority 0; policy accept; iifname vmap { "lo" : accept, "eth0" : drop, "eth1" : drop } } } Signed-off-by: Pablo Neira Ayuso --- tests/shell/testcases/maps/0012map_0 | 17 +++++++++++++++++ tests/shell/testcases/maps/dumps/0012map_0.nft | 12 ++++++++++++ 2 files changed, 29 insertions(+) create mode 100755 tests/shell/testcases/maps/0012map_0 create mode 100644 tests/shell/testcases/maps/dumps/0012map_0.nft (limited to 'tests/shell/testcases') diff --git a/tests/shell/testcases/maps/0012map_0 b/tests/shell/testcases/maps/0012map_0 new file mode 100755 index 00000000..dd93c482 --- /dev/null +++ b/tests/shell/testcases/maps/0012map_0 @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +EXPECTED="define interfaces = { eth0, eth1 } + +table ip x { + map z { + type ifname : verdict + elements = { \$interfaces : drop, lo : accept } + } + chain y { + iifname vmap { lo : accept, \$interfaces : drop } + } +}" + +$NFT -f - <<< "$EXPECTED" diff --git a/tests/shell/testcases/maps/dumps/0012map_0.nft b/tests/shell/testcases/maps/dumps/0012map_0.nft new file mode 100644 index 00000000..e734fc1c --- /dev/null +++ b/tests/shell/testcases/maps/dumps/0012map_0.nft @@ -0,0 +1,12 @@ +table ip x { + map z { + type ifname : verdict + elements = { "lo" : accept, + "eth0" : drop, + "eth1" : drop } + } + + chain y { + iifname vmap { "lo" : accept, "eth0" : drop, "eth1" : drop } + } +} -- cgit v1.2.3