summaryrefslogtreecommitdiffstats
path: root/src/parser.y
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2014-09-24 13:49:05 +0200
committerPatrick McHardy <kaber@trash.net>2014-09-24 13:49:05 +0200
commit30a7eb9eecba7d5f83d28c284948ed7448d28fc0 (patch)
tree90fce3244f1aac276c381c9d12d70865cd908057 /src/parser.y
parentd68824c96f2e8cee14b6a505c91fd379b9aa3088 (diff)
queue: clean up queue statement
- Rename keyword tokens to their actual keyword - Change the grammar to follow the standard schema for statements and arguments - Use actual expression for the queue numbers to support using normal range expressions, symbolic expression and so on. - restore comma seperation of flag keywords The result is that its possible to use standard ranges, prefix expressions, symbolic expressions etc for the queue number. We get checks for overflow, negative ranges and so on automatically. The comma seperation of flags is more similar to what we have for other flag values. It is still possible to use spaces, however this could be removed since we never had a release supporting that. Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'src/parser.y')
-rw-r--r--src/parser.y63
1 files changed, 17 insertions, 46 deletions
diff --git a/src/parser.y b/src/parser.y
index c9b22f06..cf1f42b5 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -368,8 +368,8 @@ static void location_update(struct location *loc, struct location *rhs, int n)
%token QUEUE "queue"
%token QUEUENUM "num"
-%token QUEUEBYPASS "bypass"
-%token QUEUECPUFANOUT "fanout"
+%token BYPASS "bypass"
+%token FANOUT "fanout"
%token POSITION "position"
%token COMMENT "comment"
@@ -427,9 +427,9 @@ static void location_update(struct location *loc, struct location *rhs, int n)
%destructor { stmt_free($$); } reject_stmt
%type <stmt> nat_stmt nat_stmt_alloc
%destructor { stmt_free($$); } nat_stmt nat_stmt_alloc
-%type <stmt> queue_stmt queue_stmt_alloc queue_range
+%type <stmt> queue_stmt queue_stmt_alloc
%destructor { stmt_free($$); } queue_stmt queue_stmt_alloc
-%type <val> queue_flags queue_flag
+%type <val> queue_stmt_flags queue_stmt_flag
%type <expr> symbol_expr verdict_expr integer_expr
%destructor { expr_free($$); } symbol_expr verdict_expr integer_expr
@@ -1381,7 +1381,7 @@ nat_stmt_args : expr
;
queue_stmt : queue_stmt_alloc
- | queue_stmt_alloc queue_args
+ | queue_stmt_alloc queue_stmt_args
;
queue_stmt_alloc : QUEUE
@@ -1390,61 +1390,32 @@ queue_stmt_alloc : QUEUE
}
;
-queue_args : QUEUENUM queue_range queue_flags
+queue_stmt_args : queue_stmt_arg
{
- $<stmt>0->queue.from = $2->queue.from;
- $<stmt>0->queue.to = $2->queue.to;
- $<stmt>0->queue.flags = $3;
- }
- | QUEUENUM queue_range
- {
- $<stmt>0->queue.from = $2->queue.from;
- $<stmt>0->queue.to = $2->queue.to;
- }
- | queue_flags
- {
- $<stmt>0->queue.flags = $1;
+ $<stmt>$ = $<stmt>0;
}
+ | queue_stmt_args queue_stmt_arg
;
-queue_range : NUM
+queue_stmt_arg : QUEUENUM expr
{
- $<stmt>0->queue.from = $1;
- $<stmt>0->queue.to = $1;
- $$ = $<stmt>0;
+ $<stmt>0->queue.queue = $2;
}
- | NUM DASH NUM
+ | queue_stmt_flags
{
- if ($3 < $1) {
- erec_queue(error(&@1,
- "invalid range %d-%d",
- $1, $3), state->msgs);
- YYERROR;
- }
- $<stmt>0->queue.from = $1;
- $<stmt>0->queue.to = $3;
- $$ = $<stmt>0;
+ $<stmt>0->queue.flags |= $1;
}
;
-queue_flags : queue_flag
+queue_stmt_flags : queue_stmt_flag
+ | queue_stmt_flags COMMA queue_stmt_flag
{
- $$ = $1;
- }
- | queue_flags queue_flag
- {
- $$ |= $1 | $2;
+ $$ = $1 | $3;
}
;
-queue_flag : QUEUEBYPASS
- {
- $$ = NFT_QUEUE_FLAG_BYPASS;
- }
- | QUEUECPUFANOUT
- {
- $$ = NFT_QUEUE_FLAG_CPU_FANOUT;
- }
+queue_stmt_flag : BYPASS { $$ = NFT_QUEUE_FLAG_BYPASS; }
+ | FANOUT { $$ = NFT_QUEUE_FLAG_CPU_FANOUT; }
;
match_stmt : relational_expr