]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
parser_bison: keep snat/dnat existing syntax unchanged
authorLiping Zhang <liping.zhang@spreadtrum.com>
Mon, 22 Aug 2016 15:34:15 +0000 (23:34 +0800)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 22 Aug 2016 16:27:43 +0000 (18:27 +0200)
We should keep existing syntax unchanged, and this was emphasized
in the commit 850f0a56b6ad ("src: add 'to' for snat and dnat")'s
commit log: "Existing syntax is still preserved, but the listing
shows the one including 'to'."

This problem was found by running shell test:
  # ./run-tests.sh
  [ ... ]
  W: [FAILED] ./testcases/maps/anonymous_snat_map_0
  I: [OK] ./testcases/maps/map_with_flags_0
  W: [FAILED] ./testcases/maps/named_snat_map_0
  [ ... ]

Fixes: 850f0a56b6ad ("src: add 'to' for snat and dnat")
Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/parser_bison.y

index 8025415c3e4e63c27d019f1de071c5bb40312eae..bf43608669cd1d7f49ab171caec5db539b64129e 100644 (file)
@@ -1649,15 +1649,28 @@ stmt_expr               :       map_stmt_expr
                        |       primary_rhs_expr
                        ;
 
-nat_stmt_args          :       TO      stmt_expr
+nat_stmt_args          :       stmt_expr
+                       {
+                               $<stmt>0->nat.addr = $1;
+                       }
+                       |       TO      stmt_expr
                        {
                                $<stmt>0->nat.addr = $2;
                        }
+                       |       stmt_expr       COLON   stmt_expr
+                       {
+                               $<stmt>0->nat.addr = $1;
+                               $<stmt>0->nat.proto = $3;
+                       }
                        |       TO      stmt_expr       COLON   stmt_expr
                        {
                                $<stmt>0->nat.addr = $2;
                                $<stmt>0->nat.proto = $4;
                        }
+                       |       COLON           stmt_expr
+                       {
+                               $<stmt>0->nat.proto = $2;
+                       }
                        |       TO      COLON           stmt_expr
                        {
                                $<stmt>0->nat.proto = $3;