]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
parser_bison: keep map flag around when flags are specified
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 27 Jul 2016 11:36:01 +0000 (13:36 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 27 Jul 2016 11:50:01 +0000 (13:50 +0200)
If you add a map with timeouts, eg.

  # nft add table x
  # nft add map x y { type ipv4_addr : ipv4_addr\; flags timeout\; }

The listing shows a set instead of a map:

  # nft list ruleset
  table ip x {
          set y {
                  type ipv4_addr
                  flags timeout
          }
  }

This patch fixes the parser to keep the map flag around when timeout
flag (or any other flags) are specified.

This patch also comes with a regression test.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/parser_bison.y
tests/shell/testcases/maps/map_with_flags_0 [new file with mode: 0755]

index 119fd09cc70810ff9eafac42fbb7845a1edb3216..e16b8a326d4b5fdef524f491bcf88ff8e1eceb6d 100644 (file)
@@ -1071,7 +1071,7 @@ map_block         :       /* empty */     { $$ = $<set>-1; }
                        }
                        |       map_block       FLAGS           set_flag_list   stmt_seperator
                        {
-                               $1->flags = $3;
+                               $1->flags |= $3;
                                $$ = $1;
                        }
                        |       map_block       ELEMENTS        '='             set_expr
diff --git a/tests/shell/testcases/maps/map_with_flags_0 b/tests/shell/testcases/maps/map_with_flags_0
new file mode 100755 (executable)
index 0000000..8774eb5
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+set -e
+
+$NFT add table x
+$NFT add map x y { type ipv4_addr : ipv4_addr\; flags timeout\; }
+
+EXPECTED="table ip x {
+       map y {
+               type ipv4_addr : ipv4_addr
+               flags timeout
+       }
+}"
+
+GET="$($NFT list ruleset)"
+
+if [ "$EXPECTED" != "$GET" ] ; then
+       DIFF="$(which diff)"
+       [ -x $DIFF ] && $DIFF -u <(echo "$EXPECTED") <(echo "$GET")
+       exit 1
+fi