From 6615676d825e02d271fe7a9ca78a77ac3773ab93 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 3 Aug 2015 15:50:03 +0200 Subject: src: add per-bytes limit This example show how to accept packets below the ratelimit: ... limit rate 1024 mbytes/second counter accept You need a Linux kernel >= 4.3-rc1. Signed-off-by: Pablo Neira Ayuso --- src/parser_bison.y | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/parser_bison.y') diff --git a/src/parser_bison.y b/src/parser_bison.y index cfb6b707..ec44a2cd 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -1446,6 +1446,23 @@ limit_stmt : LIMIT RATE NUM SLASH time_unit $$ = limit_stmt_alloc(&@$); $$->limit.rate = $3; $$->limit.unit = $5; + $$->limit.type = NFT_LIMIT_PKTS; + } + | LIMIT RATE NUM STRING + { + struct error_record *erec; + uint64_t rate, unit; + + erec = rate_parse(&@$, $4, &rate, &unit); + if (erec != NULL) { + erec_queue(erec, state->msgs); + YYERROR; + } + + $$ = limit_stmt_alloc(&@$); + $$->limit.rate = rate * $3; + $$->limit.unit = unit; + $$->limit.type = NFT_LIMIT_PKT_BYTES; } ; -- cgit v1.2.3