summaryrefslogtreecommitdiffstats
path: root/src/parser.y
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2014-02-26 01:51:31 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2014-02-27 17:10:26 +0100
commitb2c827223395682ee231504385f692267d1a3bfb (patch)
tree6489771dd4cd450799c9d59b9ecde6bedbd45df0 /src/parser.y
parente61e363e5603352322b59f7c09c968392ba1cef6 (diff)
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 <pablo@netfilter.org>
Diffstat (limited to 'src/parser.y')
-rw-r--r--src/parser.y18
1 files changed, 15 insertions, 3 deletions
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 <string> identifier string
-%destructor { xfree($$); } identifier string
+%type <string> identifier string comment_spec
+%destructor { xfree($$); } identifier string comment_spec
%type <cmd> 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);