diff options
author | Patrick McHardy <kaber@trash.net> | 2014-01-16 20:01:56 +0000 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2014-01-16 20:01:56 +0000 |
commit | 11884cfb1c0432cc455ff8e3269500e819e0c434 (patch) | |
tree | 90678c8cf7a3193a1356069a238e7bd1428bb251 /src/parser.y | |
parent | 21cfa9a7405f78f424c869e592d21ebdaf379803 (diff) |
set: make set flags output parsable
This patch fixes two problems:
- the output of "nft list table ..." is not parsable if sets are included
because the parser can't parse the flags.
- set flags can't be specified during set creation.
To fix this, the set output is changed to:
- not print each flag on a single line
- prefix the flags with "flags "
- only show the interval flag since all others are for internal use only
The parser is changed to parse the flags specified in a set declaration.
This allows to parse empty sets. The following patch will take care of
parsing sets that are already populated.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'src/parser.y')
-rw-r--r-- | src/parser.y | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/parser.y b/src/parser.y index 5cd8ef67..1b09e616 100644 --- a/src/parser.y +++ b/src/parser.y @@ -182,6 +182,8 @@ static void location_update(struct location *loc, struct location *rhs, int n) %token RETURN "return" %token QUEUE "queue" +%token INTERVAL "interval" + %token <val> NUM "number" %token <string> STRING "string" %token <string> QUOTED_STRING @@ -353,6 +355,8 @@ static void location_update(struct location *loc, struct location *rhs, int n) %type <rule> rule %destructor { rule_free($$); } rule +%type <val> set_flag_list set_flag + %type <set> set_block_alloc set_block %destructor { set_free($$); } set_block_alloc @@ -737,6 +741,21 @@ set_block : /* empty */ { $$ = $<set>-1; } } $$ = $1; } + | set_block FLAGS set_flag_list stmt_seperator + { + $1->flags = $3; + $$ = $1; + } + ; + +set_flag_list : set_flag_list COMMA set_flag + { + $$ = $1 | $3; + } + | set_flag + ; + +set_flag : INTERVAL { $$ = SET_F_INTERVAL; } ; map_block_alloc : /* empty */ @@ -769,6 +788,11 @@ map_block : /* empty */ { $$ = $<set>-1; } $$ = $1; } + | map_block FLAGS set_flag_list stmt_seperator + { + $1->flags = $3; + $$ = $1; + } ; hook_spec : TYPE STRING HOOK STRING PRIORITY NUM |