]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: evaluate: Show error for fanout without balance
authorShivani Bhardwaj <shivanib134@gmail.com>
Thu, 7 Apr 2016 17:28:54 +0000 (22:58 +0530)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 12 Apr 2016 23:22:08 +0000 (01:22 +0200)
The idea of fanout option is to improve the performance by indexing CPU
ID to map packets to the queues. This is used for load balancing.
Fanout option is not required when there is a single queue specified.

According to iptables, queue balance should be specified in order to use
fanout. Following that, throw an error in nftables if the range of
queues for load balancing is not specified with the fanout option.

After this patch,

$ sudo nft add rule ip filter forward counter queue num 0 fanout
<cmdline>:1:46-46: Error: fanout requires a range to be specified
add rule ip filter forward counter queue num 0 fanout
                                         ^^^^^

Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/evaluate.c
src/parser_bison.y

index d9ac85421a06a777c9f9c36b747a770c363909ea..346e34fcdf83cdc3b006e2b29e258d8a2fc87e11 100644 (file)
@@ -2006,6 +2006,11 @@ static int stmt_evaluate_queue(struct eval_ctx *ctx, struct stmt *stmt)
                if (!expr_is_constant(stmt->queue.queue))
                        return expr_error(ctx->msgs, stmt->queue.queue,
                                          "queue number is not constant");
+               if (stmt->queue.queue->ops->type != EXPR_RANGE &&
+                   (stmt->queue.flags & NFT_QUEUE_FLAG_CPU_FANOUT))
+                       return expr_error(ctx->msgs, stmt->queue.queue,
+                                         "fanout requires a range to be "
+                                         "specified");
        }
        return 0;
 }
index 4b7c1f5ab115bb32e7b1a68654c8495b61b41c80..444ed4c2e85dc41e0bedb40878205abc70b79043 100644 (file)
@@ -1722,6 +1722,7 @@ queue_stmt_args           :       queue_stmt_arg
 queue_stmt_arg         :       QUEUENUM        stmt_expr
                        {
                                $<stmt>0->queue.queue = $2;
+                               $<stmt>0->queue.queue->location = @$;
                        }
                        |       queue_stmt_flags
                        {