summaryrefslogtreecommitdiffstats
path: root/src/statement.c
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2021-06-15 14:57:08 +0200
committerFlorian Westphal <fw@strlen.de>2021-06-21 14:44:58 +0200
commit6cf0f2c17bfb96c05dd0c03e0b91a75d732917cf (patch)
treeabb34028a9da0d2de41f26f1d40a61657022233c /src/statement.c
parent3486127e52426d1861a78b44f10e5997c3a69ff2 (diff)
src: queue: allow use of arbitrary queue expressions
back in 2016 Liping Zhang added support to kernel and libnftnl to specify a source register containing the queue number to use. This was never added to nft itself, so allow this. On linearization side, check if attached expression is a range. If its not, allocate a new register and set NFTNL_EXPR_QUEUE_SREG_QNUM attribute after generating the lowlevel expressions for the kernel. On delinarization we need to check for presence of NFTNL_EXPR_QUEUE_SREG_QNUM and decode the expression(s) when present. Also need to do postprocessing for STMT_QUEUE so that the protocol context is set correctly, without this only raw payload expressions will be shown (@nh,32,...) instead of 'ip ...'. Next patch adds test cases. Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'src/statement.c')
-rw-r--r--src/statement.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/statement.c b/src/statement.c
index 9eb49339..dfd27510 100644
--- a/src/statement.c
+++ b/src/statement.c
@@ -507,8 +507,13 @@ static void queue_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
nft_print(octx, "%sfanout", delim);
if (e) {
- nft_print(octx, " num ");
- expr_print(stmt->queue.queue, octx);
+ if (e->etype == EXPR_VALUE || e->etype == EXPR_RANGE) {
+ nft_print(octx, " num ");
+ expr_print(stmt->queue.queue, octx);
+ } else {
+ nft_print(octx, " to ");
+ expr_print(stmt->queue.queue, octx);
+ }
} else {
nft_print(octx, " num 0");
}