summaryrefslogtreecommitdiffstats
path: root/src/rule.c
diff options
context:
space:
mode:
authorElise Lennion <elise.lennion@gmail.com>2017-01-26 15:12:54 -0200
committerPablo Neira Ayuso <pablo@netfilter.org>2017-01-27 13:33:20 +0100
commite1ec60b3aa99835d3bd2982f31bb15d4b915b032 (patch)
tree04bf72f589a5332411a46b0f35085d7d659982d4 /src/rule.c
parentd545778d5933ab20c1d9d34a44ae93b2668c60d2 (diff)
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 <elise.lennion@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/rule.c')
-rw-r--r--src/rule.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/rule.c b/src/rule.c
index a9f3a496..0d58073f 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -1276,8 +1276,16 @@ static int do_list_obj(struct netlink_ctx *ctx, struct cmd *cmd, uint32_t type)
family2str(table->handle.family),
table->handle.table);
+ if (cmd->handle.table != NULL &&
+ strcmp(cmd->handle.table, table->handle.table)) {
+ printf("}\n");
+ continue;
+ }
+
list_for_each_entry(obj, &table->objs, list) {
- if (obj->type != type)
+ if (obj->type != type ||
+ (cmd->handle.obj != NULL &&
+ strcmp(cmd->handle.obj, obj->handle.obj)))
continue;
obj_print_declaration(obj, &opts);
@@ -1420,8 +1428,10 @@ static int do_command_list(struct netlink_ctx *ctx, struct cmd *cmd)
return do_list_sets(ctx, cmd);
case CMD_OBJ_MAP:
return do_list_set(ctx, cmd, table);
+ case CMD_OBJ_COUNTER:
case CMD_OBJ_COUNTERS:
return do_list_obj(ctx, cmd, NFT_OBJECT_COUNTER);
+ case CMD_OBJ_QUOTA:
case CMD_OBJ_QUOTAS:
return do_list_obj(ctx, cmd, NFT_OBJECT_QUOTA);
default: