diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-11-27 23:35:25 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2017-01-03 14:21:53 +0100 |
commit | 4756d92e517ae1f7d662c0ed083b54d8dc822e4a (patch) | |
tree | 5130faa44f2f3e72b257f4d30fd1752749109049 /src/parser_bison.y | |
parent | d156fd17ee7ff9a2822d7714e1c8dfe7b6b18f55 (diff) |
src: listing of stateful objects
This patch allows you to dump existing stateful objects, eg.
# nft list ruleset
table ip filter {
counter test {
packets 64 bytes 1268
}
quota test {
over 1 mbytes used 1268 bytes
}
chain input {
type filter hook input priority 0; policy accept;
quota name test drop
counter name test
}
}
# nft list quotas
table ip filter {
quota test {
over 1 mbytes used 1268 bytes
}
}
# nft list counters
table ip filter {
counter test {
packets 64 bytes 1268
}
}
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/parser_bison.y')
-rw-r--r-- | src/parser_bison.y | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/parser_bison.y b/src/parser_bison.y index aea6e47d..2213f380 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -364,6 +364,9 @@ static void location_update(struct location *loc, struct location *rhs, int n) %token PACKETS "packets" %token BYTES "bytes" +%token COUNTERS "counters" +%token QUOTAS "quotas" + %token LOG "log" %token PREFIX "prefix" %token GROUP "group" @@ -441,8 +444,8 @@ static void location_update(struct location *loc, struct location *rhs, int n) %type <handle> table_spec chain_spec chain_identifier ruleid_spec handle_spec position_spec rule_position ruleset_spec %destructor { handle_free(&$$); } table_spec chain_spec chain_identifier ruleid_spec handle_spec position_spec rule_position ruleset_spec -%type <handle> set_spec set_identifier -%destructor { handle_free(&$$); } set_spec set_identifier +%type <handle> set_spec set_identifier obj_spec +%destructor { handle_free(&$$); } set_spec set_identifier obj_spec %type <val> family_spec family_spec_explicit chain_policy prio_spec %type <string> dev_spec quota_unit @@ -872,6 +875,22 @@ list_cmd : TABLE table_spec { $$ = cmd_alloc(CMD_LIST, CMD_OBJ_SET, &$2, &@$, NULL); } + | COUNTERS ruleset_spec + { + $$ = cmd_alloc(CMD_LIST, CMD_OBJ_COUNTERS, &$2, &@$, NULL); + } + | COUNTER obj_spec + { + $$ = cmd_alloc(CMD_LIST, CMD_OBJ_COUNTER, &$2, &@$, NULL); + } + | QUOTAS ruleset_spec + { + $$ = cmd_alloc(CMD_LIST, CMD_OBJ_QUOTAS, &$2, &@$, NULL); + } + | QUOTA obj_spec + { + $$ = cmd_alloc(CMD_LIST, CMD_OBJ_QUOTA, &$2, &@$, NULL); + } | RULESET ruleset_spec { $$ = cmd_alloc(CMD_LIST, CMD_OBJ_RULESET, &$2, &@$, NULL); @@ -1299,6 +1318,13 @@ set_identifier : identifier } ; +obj_spec : table_spec identifier + { + $$ = $1; + $$.obj = $2; + } + ; + handle_spec : HANDLE NUM { memset(&$$, 0, sizeof($$)); |