From 27619ffbe503ed4d9e59a02e81db9a7ac49d37af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Neira=20Ayuso?= Date: Tue, 10 Jun 2014 15:26:24 +0200 Subject: queue: More compact syntax This patch allows to use a new syntax more compact and break the current syntax. This new syntax is more similar than the nftables syntax that we use usually. We can use range like we have used in other case in nftables. Here, we have some examples: Before, If we want to declare a queue, we have used a syntax like this: nft add rule test input queue num 1 total 3 options bypass,fanout If we want to use the queue number 1 and the two next (total 3), we use a range in the new syntax, for example: nft add rule test input queue num 1-3 bypass fanout Also if we want to use only one queue, the new rules are like: nft add rule test input queue num 1 # queue 1 or nft add rule test input queue # queue 0 And if we want to add a specific flags we only need to put what flags we want to use: nft add rule test input queue bypass we don't need to use options and the comma for indicating the flags. Signed-off-by: Alvaro Neira Ayuso Signed-off-by: Pablo Neira Ayuso --- src/statement.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'src/statement.c') diff --git a/src/statement.c b/src/statement.c index 3fdd9e2d..2dd3f187 100644 --- a/src/statement.c +++ b/src/statement.c @@ -174,21 +174,14 @@ struct stmt *limit_stmt_alloc(const struct location *loc) static void queue_stmt_print(const struct stmt *stmt) { - int one = 0; - - printf("queue num %u total %u", - stmt->queue.queuenum, stmt->queue.queues_total); - if (stmt->queue.flags) - printf(" options "); - if (stmt->queue.flags & NFT_QUEUE_FLAG_BYPASS) { - printf("bypass"); - one = 1; - } - if (stmt->queue.flags & NFT_QUEUE_FLAG_CPU_FANOUT) { - if (one) - printf (","); - printf("fanout"); - } + printf("queue num %u", + stmt->queue.from); + if (stmt->queue.to && stmt->queue.to != stmt->queue.from) + printf("-%u", stmt->queue.to); + if (stmt->queue.flags & NFT_QUEUE_FLAG_BYPASS) + printf(" bypass"); + if (stmt->queue.flags & NFT_QUEUE_FLAG_CPU_FANOUT) + printf(" fanout"); } -- cgit v1.2.3