diff options
author | Patrick McHardy <kaber@trash.net> | 2014-09-24 13:49:05 +0200 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2014-09-24 13:49:05 +0200 |
commit | 30a7eb9eecba7d5f83d28c284948ed7448d28fc0 (patch) | |
tree | 90fce3244f1aac276c381c9d12d70865cd908057 /src/netlink_linearize.c | |
parent | d68824c96f2e8cee14b6a505c91fd379b9aa3088 (diff) |
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 <kaber@trash.net>
Diffstat (limited to 'src/netlink_linearize.c')
-rw-r--r-- | src/netlink_linearize.c | 22 |
1 files changed, 14 insertions, 8 deletions
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, |