From b2c827223395682ee231504385f692267d1a3bfb Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Wed, 26 Feb 2014 01:51:31 +0100 Subject: src: add support for rule human-readable comments This patch adds support for human-readable comments: nft add rule filter input accept comment \"accept all traffic\" Note that comments *always* come at the end of the rule. This uses the new data area that allows you to attach information to the rule via netlink. Signed-off-by: Pablo Neira Ayuso --- src/parser.y | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/parser.y') diff --git a/src/parser.y b/src/parser.y index b3acc748..dd09fb44 100644 --- a/src/parser.y +++ b/src/parser.y @@ -351,12 +351,13 @@ static void location_update(struct location *loc, struct location *rhs, int n) %token OPTIONS "options" %token POSITION "position" +%token COMMENT "comment" %token XML "xml" %token JSON "json" -%type identifier string -%destructor { xfree($$); } identifier string +%type identifier string comment_spec +%destructor { xfree($$); } identifier string comment_spec %type line %destructor { cmd_free($$); } line @@ -1020,11 +1021,22 @@ ruleid_spec : chain_spec handle_spec position_spec } ; -rule : stmt_list +comment_spec : /* empty */ + { + $$ = NULL; + } + | COMMENT string + { + $$ = $2; + } + ; + +rule : stmt_list comment_spec { struct stmt *i; $$ = rule_alloc(&@$, NULL); + $$->handle.comment = $2; list_for_each_entry(i, $1, list) $$->num_stmts++; list_splice_tail($1, &$$->stmts); -- cgit v1.2.3