From e1ec60b3aa99835d3bd2982f31bb15d4b915b032 Mon Sep 17 00:00:00 2001 From: Elise Lennion Date: Thu, 26 Jan 2017 15:12:54 -0200 Subject: src: Allow list single stateful object Currently the stateful objects can only be listed in groups. With this patch listing a single object is allowed: $ nft list counter filter https-traffic table ip filter { counter https-traffic { packets 4014 bytes 228948 } } $ nft list quota filter https-quota table ip filter { quota https-quota { 25 mbytes used 278 kbytes } } Signed-off-by: Elise Lennion Signed-off-by: Pablo Neira Ayuso --- src/evaluate.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/evaluate.c') diff --git a/src/evaluate.c b/src/evaluate.c index 1d2f9258..dab7cfca 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -2882,6 +2882,7 @@ static int cmd_evaluate_list(struct eval_ctx *ctx, struct cmd *cmd) struct table *table; struct set *set; int ret; + uint32_t obj_type = NFT_OBJECT_UNSPEC; ret = cache_update(cmd->op, ctx->msgs); if (ret < 0) @@ -2936,6 +2937,19 @@ static int cmd_evaluate_list(struct eval_ctx *ctx, struct cmd *cmd) return cmd_error(ctx, "Could not process rule: Chain '%s' does not exist", cmd->handle.chain); return 0; + case CMD_OBJ_QUOTA: + obj_type = NFT_OBJECT_QUOTA; + case CMD_OBJ_COUNTER: + if (obj_type == NFT_OBJECT_UNSPEC) + obj_type = NFT_OBJECT_COUNTER; + table = table_lookup(&cmd->handle); + if (table == NULL) + return cmd_error(ctx, "Could not process rule: Table '%s' does not exist", + cmd->handle.table); + if (obj_lookup(table, cmd->handle.obj, obj_type) == NULL) + return cmd_error(ctx, "Could not process rule: Object '%s' does not exist", + cmd->handle.obj); + return 0; case CMD_OBJ_CHAINS: case CMD_OBJ_SETS: case CMD_OBJ_COUNTERS: -- cgit v1.2.3