diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-10-21 11:17:55 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-10-21 12:17:55 +0200 |
commit | a3ebc989d32e880ba19dae62db1f1164a9402ee2 (patch) | |
tree | 5e0f0fbe24e1ccc44010b58bea20dfea4b127805 /src | |
parent | 9604b087a97d58822b4e72676dea429304561c44 (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 'src')
-rw-r--r-- | src/parser_bison.y | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/parser_bison.y b/src/parser_bison.y index 36dbc8d8..baf0a539 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -748,7 +748,7 @@ add_cmd : TABLE table_spec handle_merge(&$3->handle, &$2); $$ = cmd_alloc(CMD_ADD, CMD_OBJ_SET, &$2, &@$, $5); } - | ELEMENT set_spec set_expr + | ELEMENT set_spec set_block_expr { $$ = cmd_alloc(CMD_ADD, CMD_OBJ_SETELEM, &$2, &@$, $3); } @@ -797,7 +797,7 @@ create_cmd : TABLE table_spec handle_merge(&$3->handle, &$2); $$ = cmd_alloc(CMD_CREATE, CMD_OBJ_SET, &$2, &@$, $5); } - | ELEMENT set_spec set_expr + | ELEMENT set_spec set_block_expr { $$ = cmd_alloc(CMD_CREATE, CMD_OBJ_SETELEM, &$2, &@$, $3); } @@ -829,7 +829,7 @@ delete_cmd : TABLE table_spec { $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_SET, &$2, &@$, NULL); } - | ELEMENT set_spec set_expr + | ELEMENT set_spec set_block_expr { $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_SETELEM, &$2, &@$, $3); } |