summaryrefslogtreecommitdiffstats
path: root/tests/shell/testcases
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2016-10-21 11:17:55 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2016-10-21 12:17:55 +0200
commita3ebc989d32e880ba19dae62db1f1164a9402ee2 (patch)
tree5e0f0fbe24e1ccc44010b58bea20dfea4b127805 /tests/shell/testcases
parent9604b087a97d58822b4e72676dea429304561c44 (diff)
parser_bison: allow to use variable to add/create/delete elements
Using variable definitions from element command doesn't work, eg. -test.nft- define whitelist_v4 = { 1.1.1.1 } table inet filter { set whitelist_v4 { type ipv4_addr; } } add element inet filter whitelist_v4 $whitelist_v4 -EOF- # nft -f test.nft test.nft:7:38-38: Error: syntax error, unexpected '$', expecting '{' add element inet filter whitelist_v4 $whitelist_v4 ^ Fix this by using set_block_expr rule for every element command. This patch also comes with a new regression test. Reported-by: Leon Merten Lohse <leon@green-side.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'tests/shell/testcases')
-rwxr-xr-xtests/shell/testcases/nft-f/0010variable_022
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/shell/testcases/nft-f/0010variable_0 b/tests/shell/testcases/nft-f/0010variable_0
new file mode 100755
index 00000000..2df71b13
--- /dev/null
+++ b/tests/shell/testcases/nft-f/0010variable_0
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+set -e
+
+tmpfile=$(mktemp)
+if [ ! -w $tmpfile ] ; then
+ echo "Failed to create tmp file" >&2
+ exit 0
+fi
+
+trap "rm -rf $tmpfile" EXIT # cleanup if aborted
+
+RULESET="define whitelist_v4 = { 1.1.1.1 }
+
+table inet filter {
+ set whitelist_v4 { type ipv4_addr; }
+}
+add element inet filter whitelist_v4 \$whitelist_v4
+"
+
+echo "$RULESET" > $tmpfile
+$NFT -f $tmpfile