From d100e2d811749bf34bb6aeac322052c56661c124 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 16 Jul 2020 14:36:28 +0200 Subject: src: allow to use variables in flowtable and chain devices This patch adds support for using variables for devices in the chain and flowtable definitions, eg. define if_main = lo table netdev filter1 { chain Main_Ingress1 { type filter hook ingress device $if_main priority -500; policy accept; } } Signed-off-by: Pablo Neira Ayuso --- src/parser_bison.y | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/parser_bison.y') diff --git a/src/parser_bison.y b/src/parser_bison.y index 572e584c..d2d7694a 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -1945,6 +1945,11 @@ flowtable_expr : '{' flowtable_list_expr '}' $2->location = @$; $$ = $2; } + | variable_expr + { + $1->location = @$; + $$ = $1; + } ; flowtable_list_expr : flowtable_expr_member @@ -1967,6 +1972,11 @@ flowtable_expr_member : STRING strlen($1) * BITS_PER_BYTE, $1); xfree($1); } + | variable_expr + { + datatype_set($1->sym->expr, &ifname_type); + $$ = $1; + } ; data_type_atom_expr : type_identifier @@ -2206,6 +2216,12 @@ dev_spec : DEVICE string compound_expr_add($$, expr); } + | DEVICE variable_expr + { + datatype_set($2->sym->expr, &ifname_type); + $$ = compound_expr_alloc(&@$, EXPR_LIST); + compound_expr_add($$, $2); + } | DEVICES '=' flowtable_expr { $$ = $3; -- cgit v1.2.3