]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: add comment support for map too
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 17 Aug 2020 10:12:23 +0000 (12:12 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 17 Aug 2020 11:03:49 +0000 (13:03 +0200)
Extend and slightly rework tests/shell to cover this case too.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/parser_bison.y
tests/shell/testcases/sets/0054comments_set_0
tests/shell/testcases/sets/dumps/0054comments_set_0.nft

index 7e094ff60eac805dd4effbf7e686f8583b7f8e66..d4e994175fea69cf0cbe075c9bb8db581b85f33e 100644 (file)
@@ -1896,6 +1896,11 @@ map_block                :       /* empty */     { $$ = $<set>-1; }
                                $1->init = $4;
                                $$ = $1;
                        }
+                       |       map_block       comment_spec    stmt_separator
+                       {
+                               $1->comment = $2;
+                               $$ = $1;
+                       }
                        |       map_block       set_mechanism   stmt_separator
                        ;
 
index 93a73f0d2fa2cb742eade4d66f87d253eeb933b0..9c8f7875fc83ae293f63891eff37a07105616719 100755 (executable)
@@ -1,11 +1,9 @@
 #!/bin/bash
 
+set -e
+
 # Test that comments are added to sets
 
 $NFT add table t
 $NFT add set t s {type ipv4_addr \; flags interval \; comment "test" \;}
-if ! $NFT list ruleset | grep test >/dev/null ; then
-       echo "E: missing comment in set" >&2
-       exit 1
-fi
-
+$NFT add map t m {type ipv4_addr : ipv4_addr \; flags interval \; comment \"another test\" \;}
index 2ad840039350648f67440cc8678de152c97fd118..79299241f8e65673c2a6789bfc67b32eb51c7858 100644 (file)
@@ -4,4 +4,10 @@ table ip t {
                flags interval
                comment "test"
        }
+
+       map m {
+               type ipv4_addr : ipv4_addr
+               flags interval
+               comment "another test"
+       }
 }