Skip to contentSkip to conversation

src: add comment support for map too

PATCH New Pablo Neira Ayuso 1 participant 1 message Aug 17, 2020 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 src: add comment support for map too

Extend and slightly rework tests/shell to cover this case too.

---
 src/parser_bison.y                                      | 5 +++++
 tests/shell/testcases/sets/0054comments_set_0           | 8 +++-----
 tests/shell/testcases/sets/dumps/0054comments_set_0.nft | 6 ++++++
 3 files changed, 14 insertions(+), 5 deletions(-)
src/parser_bison.y +5 -0
index 7e094ff60eac..d4e994175fea 100644
@@ -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
 			;
 
tests/shell/testcases/sets/0054comments_set_0 +3 -5
index 93a73f0d2fa2..9c8f7875fc83 100755
@@ -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\" \;}
tests/shell/testcases/sets/dumps/0054comments_set_0.nft +6 -0
index 2ad840039350..79299241f8e6 100644
@@ -4,4 +4,10 @@ table ip t {
 		flags interval
 		comment "test"
 	}
+
+	map m {
+		type ipv4_addr : ipv4_addr
+		flags interval
+		comment "another test"
+	}
 }
Signature · 1 line
2.20.1