diff options
author | Florian Westphal <fw@strlen.de> | 2023-08-02 17:48:24 +0200 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2023-08-03 13:06:19 +0200 |
commit | 28d202216535ac54216f825e511a92d9acea5d3c (patch) | |
tree | caa956ef26c7bd09dce77b799be9b855992d7544 /src | |
parent | 5c25c5a35cbd27911d233efd01efcb9be35c85af (diff) |
parser: deduplicate map with data interval
Its copypasted, the copy is same as original
except that it specifies a map key that maps to an interval.
Add an exra rule that returns 0 or EXPR_F_INTERVAL, then
use that in a single rule.
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/parser_bison.y | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/parser_bison.y b/src/parser_bison.y index 36172713..56378293 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -727,7 +727,7 @@ int nft_lex(void *, void *, void *); %type <set> map_block_alloc map_block %destructor { set_free($$); } map_block_alloc -%type <val> map_block_obj_type +%type <val> map_block_obj_type map_block_data_interval %type <flowtable> flowtable_block_alloc flowtable_block %destructor { flowtable_free($$); } flowtable_block_alloc @@ -2225,6 +2225,10 @@ map_block_obj_type : COUNTER close_scope_counter { $$ = NFT_OBJECT_COUNTER; } | SYNPROXY close_scope_synproxy { $$ = NFT_OBJECT_SYNPROXY; } ; +map_block_data_interval : INTERVAL { $$ = EXPR_F_INTERVAL; } + | { $$ = 0; } + ; + map_block : /* empty */ { $$ = $<set>-1; } | map_block common_block | map_block stmt_separator @@ -2234,22 +2238,12 @@ map_block : /* empty */ { $$ = $<set>-1; } $$ = $1; } | map_block TYPE - data_type_expr COLON data_type_expr - stmt_separator close_scope_type - { - $1->key = $3; - $1->data = $5; - - $1->flags |= NFT_SET_MAP; - $$ = $1; - } - | map_block TYPE - data_type_expr COLON INTERVAL data_type_expr + data_type_expr COLON map_block_data_interval data_type_expr stmt_separator close_scope_type { $1->key = $3; $1->data = $6; - $1->data->flags |= EXPR_F_INTERVAL; + $1->data->flags |= $5; $1->flags |= NFT_SET_MAP; $$ = $1; |