From e3d9ed3c09b5cef5ea5a5eaf13783c44dda7f276 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Fri, 29 Oct 2021 21:40:07 +0100 Subject: parser: add new `limit_bytes` rule Refactor the `N byte-unit` expression out of the `limit_bytes_burst` rule into a separate `limit_bytes` rule. Signed-off-by: Jeremy Sowden Signed-off-by: Pablo Neira Ayuso --- src/parser_bison.y | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/parser_bison.y b/src/parser_bison.y index c25af6ba..3acd8031 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -689,7 +689,7 @@ int nft_lex(void *, void *, void *); %type level_type log_flags log_flags_tcp log_flag_tcp %type limit_stmt quota_stmt connlimit_stmt %destructor { stmt_free($$); } limit_stmt quota_stmt connlimit_stmt -%type limit_burst_pkts limit_burst_bytes limit_mode time_unit quota_mode +%type limit_burst_pkts limit_burst_bytes limit_mode limit_bytes time_unit quota_mode %type reject_stmt reject_stmt_alloc %destructor { stmt_free($$); } reject_stmt reject_stmt_alloc %type nat_stmt nat_stmt_alloc masq_stmt masq_stmt_alloc redir_stmt redir_stmt_alloc @@ -3251,19 +3251,22 @@ limit_burst_pkts : /* empty */ { $$ = 5; } ; limit_burst_bytes : /* empty */ { $$ = 5; } - | BURST NUM BYTES { $$ = $2; } - | BURST NUM STRING + | BURST limit_bytes { $$ = $2; } + ; + +limit_bytes : NUM BYTES { $$ = $1; } + | NUM STRING { struct error_record *erec; uint64_t rate; - erec = data_unit_parse(&@$, $3, &rate); - xfree($3); + erec = data_unit_parse(&@$, $2, &rate); + xfree($2); if (erec != NULL) { erec_queue(erec, state->msgs); YYERROR; } - $$ = $2 * rate; + $$ = $1 * rate; } ; -- cgit v1.2.3