diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-08-29 17:16:35 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-08-29 20:30:29 +0200 |
commit | a26d13e2b099d750e5333a563f5d802bf568eb59 (patch) | |
tree | eccffa3782d27b62721568d4cedc810eee409cf9 /tests/shell/testcases/nft-f/0009variable_0 | |
parent | 7a3d6802ddcb40d2339a461762afdb0328a3beb7 (diff) |
parser_bison: allow variable references in set elements definition
Andreas reports that he cannot use variables in set definitions:
define s-ext-2-int = 10.10.10.10 . 25, 10.10.10.10 . 143
set s-ext-2-int {
type ipv4_addr . inet_service
elements = { $s-ext-2-int }
}
This syntax is not correct though, since the curly braces should be
placed in the variable definition itself, so we have context to handle
this variable as a list of set elements.
The correct syntax that works after this patch is:
define s-ext-2-int = { 10.10.10.10 . 25, 10.10.10.10 . 143 }
table inet forward {
set s-ext-2-int {
type ipv4_addr . inet_service
elements = $s-ext-2-int
}
}
Reported-by: Andreas Hainke <andreas.hainke@foteviken.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'tests/shell/testcases/nft-f/0009variable_0')
-rwxr-xr-x | tests/shell/testcases/nft-f/0009variable_0 | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/shell/testcases/nft-f/0009variable_0 b/tests/shell/testcases/nft-f/0009variable_0 new file mode 100755 index 00000000..4d387074 --- /dev/null +++ b/tests/shell/testcases/nft-f/0009variable_0 @@ -0,0 +1,23 @@ +#!/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 concat-set-variable = { 10.10.10.10 . 25, 10.10.10.10 . 143 } + +table inet forward { + set concat-set-variable { + type ipv4_addr . inet_service + elements = \$concat-set-variable + } +}" + +echo "$RULESET" > $tmpfile +$NFT -f $tmpfile |