]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
parser_bison: no need for 'name' token for meters
authorPablo Neira Ayuso <pablo@netfilter.org>
Fri, 24 Nov 2017 12:33:47 +0000 (13:33 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 24 Nov 2017 14:53:44 +0000 (15:53 +0100)
Rework grammar to skip the 'name' token after 'meter' for named meters.
For consistency with sets and maps in terms of syntax.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/parser_bison.y
tests/py/ip/flowtable.t
tests/py/ip/flowtable.t.payload
tests/py/ip6/flowtable.t
tests/py/ip6/flowtable.t.payload
tests/shell/testcases/sets/0022type_selective_flush_0

index d2673173bd2747facb47c4aae328dfa297a5aaab..6e85a62804d4e99f4f2797419932fe83f954b79c 100644 (file)
@@ -557,8 +557,8 @@ int nft_lex(void *, void *, void *);
 %type <stmt>                   set_stmt
 %destructor { stmt_free($$); } set_stmt
 %type <val>                    set_stmt_op
-%type <stmt>                   meter_stmt meter_stmt_alloc
-%destructor { stmt_free($$); } meter_stmt meter_stmt_alloc
+%type <stmt>                   meter_stmt meter_stmt_alloc flow_stmt_legacy_alloc
+%destructor { stmt_free($$); } meter_stmt meter_stmt_alloc flow_stmt_legacy_alloc
 
 %type <expr>                   symbol_expr verdict_expr integer_expr variable_expr
 %destructor { expr_free($$); } symbol_expr verdict_expr integer_expr variable_expr
@@ -2482,39 +2482,42 @@ set_stmt_op             :       ADD     { $$ = NFT_DYNSET_OP_ADD; }
                        |       UPDATE  { $$ = NFT_DYNSET_OP_UPDATE; }
                        ;
 
-meter_stmt             :       meter_stmt_alloc                meter_stmt_opts '{' meter_key_expr stmt '}'
+meter_stmt             :       flow_stmt_legacy_alloc          flow_stmt_opts  '{' meter_key_expr stmt '}'
                        {
                                $1->meter.key  = $4;
                                $1->meter.stmt = $5;
                                $$->location  = @$;
                                $$ = $1;
                        }
+                       |       meter_stmt_alloc                { $$ = $1; }
                        ;
 
-meter_stmt_alloc       :       FLOW
-                       {
-                               $$ = meter_stmt_alloc(&@$);
-                       }
-                       |       METER
+flow_stmt_legacy_alloc :       FLOW
                        {
                                $$ = meter_stmt_alloc(&@$);
                        }
                        ;
 
-meter_stmt_opts                :       meter_stmt_opt
+flow_stmt_opts         :       flow_stmt_opt
                        {
                                $<stmt>$        = $<stmt>0;
                        }
-                       |       meter_stmt_opts         meter_stmt_opt
+                       |       flow_stmt_opts          flow_stmt_opt
                        ;
 
-meter_stmt_opt         :       TABLE                   identifier
+flow_stmt_opt          :       TABLE                   identifier
                        {
                                $<stmt>0->meter.name = $2;
                        }
-                       |       NAME                    identifier
+                       ;
+
+meter_stmt_alloc       :       METER   identifier              '{' meter_key_expr stmt '}'
                        {
-                               $<stmt>0->meter.name = $2;
+                               $$ = meter_stmt_alloc(&@$);
+                               $$->meter.name = $2;
+                               $$->meter.key  = $4;
+                               $$->meter.stmt = $5;
+                               $$->location  = @$;
                        }
                        ;
 
index 7eaf5731ea221a5102a8845ab48ed4efdfcc6953..4427fab88eb835682e004ced041fe599b717cc8c 100644 (file)
@@ -2,4 +2,4 @@
 
 *ip;test-ip;input
 
-meter name xyz { ip saddr timeout 30s counter};ok
+meter xyz { ip saddr timeout 30s counter};ok
index 4dbd03d019262d396b0bc5012755485c52f1f43e..34a584994b64bf1d7b06e3189f2f41f2a99e2ce4 100644 (file)
@@ -1,4 +1,4 @@
-# meter name xyz { ip saddr timeout 30s counter}
+# meter xyz { ip saddr timeout 30s counter}
 xyz test-ip 31
 xyz test-ip 0
 ip test-ip input 
index 7a53f31aa67ea086b9be235f01336659fe705fe5..5c048935d726c1ac5ff1334eba53b832d41f7605 100644 (file)
@@ -2,5 +2,5 @@
 
 *ip6;test-ip6;input
 
-meter name acct_out { meta iif . ip6 saddr timeout 600s counter };ok;meter name acct_out { iif . ip6 saddr timeout 10m counter}
-meter name acct_out { ip6 saddr . meta iif timeout 600s counter };ok;meter name acct_out { ip6 saddr . iif timeout 10m counter}
+meter acct_out { meta iif . ip6 saddr timeout 600s counter };ok;meter acct_out { iif . ip6 saddr timeout 10m counter}
+meter acct_out { ip6 saddr . meta iif timeout 600s counter };ok;meter acct_out { ip6 saddr . iif timeout 10m counter}
index cf2de733ca42e563993279d362533a2ede442906..a3f71b1304dc16f699c92871e2f59a1bd8c95bc9 100644 (file)
@@ -1,4 +1,4 @@
-# meter name acct_out { meta iif . ip6 saddr timeout 600s counter }
+# meter acct_out { meta iif . ip6 saddr timeout 600s counter }
 acct_out test-ip6 31
 acct_out test-ip6 0
 ip6 test-ip6 input
@@ -6,7 +6,7 @@ ip6 test-ip6 input
   [ payload load 16b @ network header + 8 => reg 9 ]
   [ dynset update reg_key 1 set acct_out timeout 600000ms expr [ counter pkts 0 bytes 0 ] ]
 
-# meter name acct_out { ip6 saddr . meta iif timeout 600s counter }
+# meter acct_out { ip6 saddr . meta iif timeout 600s counter }
 acct_out test-ip6 31
 acct_out test-ip6 0
 ip6 test-ip6 input
index 87a4c7bc4393d0e982c3093aba570839c5a1f59a..659bf70c05bfc3f67a39417eb79db25c66a58d0f 100755 (executable)
@@ -16,7 +16,7 @@ add table t
 add chain t c
 add set t s {type ipv4_addr;}
 add map t m {type ipv4_addr : inet_service;}
-add rule t c tcp dport 80 meter name f {ip saddr limit rate 10/second}
+add rule t c tcp dport 80 meter f {ip saddr limit rate 10/second}
 " >$tmpfile
 
 $NFT -f $tmpfile
@@ -26,7 +26,7 @@ $NFT -f $tmpfile
 declare -a cmds=(
                "flush set t m" "flush set t f"
                "flush map t s" "flush map t f"
-               "flush meter name t s" "flush meter name t m"
+               "flush meter t s" "flush meter t m"
                )
 
 for i in "${cmds[@]}"