From d545778d5933ab20c1d9d34a44ae93b2668c60d2 Mon Sep 17 00:00:00 2001 From: Elise Lennion Date: Thu, 26 Jan 2017 15:09:44 -0200 Subject: src: Allow reset single stateful object Currently the stateful objects can only be reseted in groups. With this patch reseting a single object is allowed: $ nft reset counter filter https-traffic table ip filter { counter https-traffic { packets 8774 bytes 542668 } } $ nft list counter filter https-traffic table ip filter { counter https-traffic { packets 0 bytes 0 } } Heavily based on work from Pablo Neira Ayuso . Signed-off-by: Elise Lennion Signed-off-by: Pablo Neira Ayuso --- src/rule.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/rule.c') diff --git a/src/rule.c b/src/rule.c index b5181a90..a9f3a496 100644 --- a/src/rule.c +++ b/src/rule.c @@ -1435,21 +1435,26 @@ static int do_command_reset(struct netlink_ctx *ctx, struct cmd *cmd) { struct obj *obj, *next; struct table *table; + bool dump = false; uint32_t type; int ret; switch (cmd->obj) { case CMD_OBJ_COUNTERS: + dump = true; + case CMD_OBJ_COUNTER: type = NFT_OBJECT_COUNTER; break; case CMD_OBJ_QUOTAS: + dump = true; + case CMD_OBJ_QUOTA: type = NFT_OBJECT_QUOTA; break; default: BUG("invalid command object type %u\n", cmd->obj); } - ret = netlink_reset_objs(ctx, &cmd->handle, &cmd->location, type); + ret = netlink_reset_objs(ctx, &cmd->handle, &cmd->location, type, dump); list_for_each_entry_safe(obj, next, &ctx->list, list) { table = table_lookup(&obj->handle); list_move(&obj->list, &table->objs); -- cgit v1.2.3