diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-11-27 23:24:21 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2017-01-03 14:21:52 +0100 |
commit | d156fd17ee7ff9a2822d7714e1c8dfe7b6b18f55 (patch) | |
tree | 7f14b719a9459ee21dd75469f94b02e62577a2ea /src/parser_bison.y | |
parent | da3f503dc3609a66d84782aa200c1aafaecdc1f7 (diff) |
src: add used quota support
table ip x {
chain y {
type filter hook forward priority 0; policy accept;
quota over 200 mbytes used 1143 kbytes drop
}
}
This patch allows us to list and to restore used quota.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/parser_bison.y')
-rw-r--r-- | src/parser_bison.y | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/parser_bison.y b/src/parser_bison.y index 0f3ad915..aea6e47d 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -378,6 +378,7 @@ static void location_update(struct location *loc, struct location *rhs, int n) %token UNTIL "until" %token QUOTA "quota" +%token USED "used" %token NANOSECOND "nanosecond" %token MICROSECOND "microsecond" @@ -427,7 +428,7 @@ static void location_update(struct location *loc, struct location *rhs, int n) %type <string> identifier type_identifier string comment_spec %destructor { xfree($$); } identifier type_identifier string comment_spec -%type <val> time_spec +%type <val> time_spec quota_used %type <val> type_identifier_list %type <datatype> data_type @@ -1636,7 +1637,22 @@ quota_unit : BYTES { $$ = xstrdup("bytes"); } | STRING { $$ = $1; } ; -quota_stmt : QUOTA quota_mode NUM quota_unit +quota_used : /* empty */ { $$ = 0; } + | USED NUM quota_unit + { + struct error_record *erec; + uint64_t rate; + + erec = data_unit_parse(&@$, $3, &rate); + if (erec != NULL) { + erec_queue(erec, state->msgs); + YYERROR; + } + $$ = $2 * rate; + } + ; + +quota_stmt : QUOTA quota_mode NUM quota_unit quota_used { struct error_record *erec; uint64_t rate; @@ -1648,6 +1664,7 @@ quota_stmt : QUOTA quota_mode NUM quota_unit } $$ = quota_stmt_alloc(&@$); $$->quota.bytes = $3 * rate; + $$->quota.used = $5; $$->quota.flags = $2; } ; |