]> git.ipfire.org Git - thirdparty/nftables.git/commit
parser_bison: allow to use variable to add/create/delete elements
authorPablo Neira Ayuso <pablo@netfilter.org>
Fri, 21 Oct 2016 10:17:55 +0000 (11:17 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 21 Oct 2016 10:17:55 +0000 (12:17 +0200)
commita3ebc989d32e880ba19dae62db1f1164a9402ee2
tree5e0f0fbe24e1ccc44010b58bea20dfea4b127805
parent9604b087a97d58822b4e72676dea429304561c44
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>
src/parser_bison.y
tests/shell/testcases/nft-f/0010variable_0 [new file with mode: 0755]