]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
parser_bison: simplify reset syntax
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 14 Mar 2023 13:56:18 +0000 (14:56 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 15 Mar 2023 11:07:57 +0000 (12:07 +0100)
Simplify:

*reset rules* *chain* ['family'] 'table' ['chain]'
to
*reset rules* ['family'] 'table' 'chain'

*reset rules* *table* ['family'] 'table'
to
*reset rules* ['family'] 'table'

*reset counters* ['family'] *table* 'table'
to
*reset counters* ['family'] 'table'

*reset quotas* ['family'] *table* 'table'
to
*reset quotas* ['family'] 'table'

Previous syntax remains in place for backward compatibility.

Acked-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
doc/nft.txt
src/parser_bison.y

index 0d60c7520d31e810e1dd091a9e6ceaa314336a88..83f0f8bb155a2c9339edec0b7a77848e0459cf2a 100644 (file)
@@ -490,9 +490,7 @@ RULES
 *replace rule* ['family'] 'table' 'chain' *handle* 'handle' 'statement' ... [*comment* 'comment']
 {*delete* | *reset*} *rule* ['family'] 'table' 'chain' *handle* 'handle'
 *destroy rule* ['family'] 'table' 'chain' *handle* 'handle'
-*reset rules* ['family']
-*reset rules* *table* ['family'] 'table'
-*reset rules* *chain* ['family'] 'table' ['chain']
+*reset rules* ['family'] ['table' ['chain']]
 
 Rules are added to chains in the given table. If the family is not specified, the
 ip family is used. Rules are constructed from two kinds of components according
@@ -762,8 +760,8 @@ STATEFUL OBJECTS
 *list limits* ['family']
 *reset counters* ['family']
 *reset quotas* ['family']
-*reset counters* ['family'] *table* 'table'
-*reset quotas* ['family'] *table* 'table'
+*reset counters* ['family'] 'table'
+*reset quotas* ['family'] 'table'
 
 Stateful objects are attached to tables and are identified by a unique name.
 They group stateful information from rules, to reference them in rules the
index ccedfafe1bfaec6c5e4a2acc87824d2b122e8514..e4f21ca1a722358b653586ec3c1f7eed3e6e262f 100644 (file)
@@ -1650,11 +1650,16 @@ basehook_spec           :       ruleset_spec
                        ;
 
 reset_cmd              :       COUNTERS        ruleset_spec
+                       {
+                               $$ = cmd_alloc(CMD_RESET, CMD_OBJ_COUNTERS, &$2, &@$, NULL);
+                       }
+                       |       COUNTERS        table_spec
                        {
                                $$ = cmd_alloc(CMD_RESET, CMD_OBJ_COUNTERS, &$2, &@$, NULL);
                        }
                        |       COUNTERS        TABLE   table_spec
                        {
+                               /* alias of previous rule. */
                                $$ = cmd_alloc(CMD_RESET, CMD_OBJ_COUNTERS, &$3, &@$, NULL);
                        }
                        |       COUNTER         obj_spec        close_scope_counter
@@ -1669,6 +1674,11 @@ reset_cmd                :       COUNTERS        ruleset_spec
                        {
                                $$ = cmd_alloc(CMD_RESET, CMD_OBJ_QUOTAS, &$3, &@$, NULL);
                        }
+                       |       QUOTAS          table_spec
+                       {
+                               /* alias of previous rule. */
+                               $$ = cmd_alloc(CMD_RESET, CMD_OBJ_QUOTAS, &$2, &@$, NULL);
+                       }
                        |       QUOTA           obj_spec        close_scope_quota
                        {
                                $$ = cmd_alloc(CMD_RESET, CMD_OBJ_QUOTA, &$2, &@$, NULL);
@@ -1677,12 +1687,22 @@ reset_cmd               :       COUNTERS        ruleset_spec
                        {
                                $$ = cmd_alloc(CMD_RESET, CMD_OBJ_RULES, &$2, &@$, NULL);
                        }
+                       |       RULES           table_spec
+                       {
+                               $$ = cmd_alloc(CMD_RESET, CMD_OBJ_RULES, &$2, &@$, NULL);
+                       }
                        |       RULES           TABLE   table_spec
                        {
+                               /* alias of previous rule. */
                                $$ = cmd_alloc(CMD_RESET, CMD_OBJ_RULES, &$3, &@$, NULL);
                        }
+                       |       RULES           chain_spec
+                       {
+                               $$ = cmd_alloc(CMD_RESET, CMD_OBJ_RULES, &$2, &@$, NULL);
+                       }
                        |       RULES           CHAIN   chain_spec
                        {
+                               /* alias of previous rule. */
                                $$ = cmd_alloc(CMD_RESET, CMD_OBJ_RULES, &$3, &@$, NULL);
                        }
                        |       RULE            ruleid_spec