From 30a7eb9eecba7d5f83d28c284948ed7448d28fc0 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Wed, 24 Sep 2014 13:49:05 +0200 Subject: 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 --- src/netlink_linearize.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/netlink_linearize.c') diff --git a/src/netlink_linearize.c b/src/netlink_linearize.c index 17375a5b..c46b6d47 100644 --- a/src/netlink_linearize.c +++ b/src/netlink_linearize.c @@ -687,21 +687,27 @@ static void netlink_gen_queue_stmt(struct netlink_linearize_ctx *ctx, { struct nft_rule_expr *nle; uint16_t total_queues; + mpz_t low, high; - nle = alloc_nft_expr("queue"); - - nft_rule_expr_set_u16(nle, NFT_EXPR_QUEUE_NUM, - stmt->queue.from); - - total_queues = stmt->queue.to - stmt->queue.from; - nft_rule_expr_set_u16(nle, NFT_EXPR_QUEUE_TOTAL, - total_queues + 1); + mpz_init2(low, 16); + mpz_init2(high, 16); + if (stmt->queue.queue != NULL) { + range_expr_value_low(low, stmt->queue.queue); + range_expr_value_high(high, stmt->queue.queue); + } + total_queues = mpz_get_uint16(high) - mpz_get_uint16(low) + 1; + nle = alloc_nft_expr("queue"); + nft_rule_expr_set_u16(nle, NFT_EXPR_QUEUE_NUM, mpz_get_uint16(low)); + nft_rule_expr_set_u16(nle, NFT_EXPR_QUEUE_TOTAL, total_queues); if (stmt->queue.flags) { nft_rule_expr_set_u16(nle, NFT_EXPR_QUEUE_FLAGS, stmt->queue.flags); } nft_rule_add_expr(ctx->nlr, nle); + + mpz_clear(low); + mpz_clear(high); } static void netlink_gen_ct_stmt(struct netlink_linearize_ctx *ctx, -- cgit v1.2.3