From a8dc9e2a2b40d5d29b12920873bbe1f2cfeda8f6 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Wed, 2 Dec 2020 18:31:00 +0100 Subject: parser_bison: allow to restore limit from dynamic set Update parser to allow to restore limit per set element in dynamic set. Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1477 Signed-off-by: Pablo Neira Ayuso --- src/parser_bison.y | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/parser_bison.y') diff --git a/src/parser_bison.y b/src/parser_bison.y index a8884466..fb329919 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -4097,6 +4097,38 @@ set_elem_expr_option : TIMEOUT time_spec stmt->counter.bytes = $5; $0->stmt = stmt; } + | LIMIT RATE limit_mode NUM SLASH time_unit limit_burst_pkts + { + struct stmt *stmt; + + stmt = limit_stmt_alloc(&@$); + stmt->limit.rate = $4; + stmt->limit.unit = $6; + stmt->limit.burst = $7; + stmt->limit.type = NFT_LIMIT_PKTS; + stmt->limit.flags = $3; + $0->stmt = stmt; + } + | LIMIT RATE limit_mode NUM STRING limit_burst_bytes + { + struct error_record *erec; + uint64_t rate, unit; + struct stmt *stmt; + + erec = rate_parse(&@$, $5, &rate, &unit); + xfree($5); + if (erec != NULL) { + erec_queue(erec, state->msgs); + YYERROR; + } + + stmt = limit_stmt_alloc(&@$); + stmt->limit.rate = rate * $4; + stmt->limit.unit = unit; + stmt->limit.burst = $6; + stmt->limit.type = NFT_LIMIT_PKT_BYTES; + stmt->limit.flags = $3; + } | comment_spec { if (already_set($0->comment, &@1, state)) { -- cgit v1.2.3