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_delinearize.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/netlink_delinearize.c') diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c index 195d4329..796b6327 100644 --- a/src/netlink_delinearize.c +++ b/src/netlink_delinearize.c @@ -558,15 +558,24 @@ static void netlink_parse_queue(struct netlink_parse_ctx *ctx, const struct location *loc, const struct nft_rule_expr *nle) { + struct expr *expr, *high; struct stmt *stmt; - uint16_t range_to; + uint16_t num, total; + + num = nft_rule_expr_get_u16(nle, NFT_EXPR_QUEUE_NUM); + total = nft_rule_expr_get_u16(nle, NFT_EXPR_QUEUE_TOTAL); + + expr = constant_expr_alloc(loc, &integer_type, + BYTEORDER_HOST_ENDIAN, 16, &num); + if (total > 1) { + total += num - 1; + high = constant_expr_alloc(loc, &integer_type, + BYTEORDER_HOST_ENDIAN, 16, &total); + expr = range_expr_alloc(loc, expr, high); + } stmt = queue_stmt_alloc(loc); - stmt->queue.from = nft_rule_expr_get_u16(nle, NFT_EXPR_QUEUE_NUM); - range_to = nft_rule_expr_get_u16(nle, NFT_EXPR_QUEUE_TOTAL); - range_to += stmt->queue.from - 1; - stmt->queue.to = range_to; - + stmt->queue.queue = expr; stmt->queue.flags = nft_rule_expr_get_u16(nle, NFT_EXPR_QUEUE_FLAGS); list_add_tail(&stmt->list, &ctx->rule->stmts); } -- cgit v1.2.3