diff options
author | Phil Sutter <phil@nwl.cc> | 2022-10-14 23:19:22 +0200 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2023-01-18 14:58:48 +0100 |
commit | 1694df2de79f39c5037f82601e02226022b2e38f (patch) | |
tree | 57c6b99a1c7de8a414b5693e86cd6cf36816fd42 /src/rule.c | |
parent | ce04d25b4a116ef04f27d0b71994f61a24114d6d (diff) |
Implement 'reset rule' and 'reset rules' commands
Reset rule counters and quotas in kernel, i.e. without having to reload
them. Requires respective kernel patch to support NFT_MSG_GETRULE_RESET
message type.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'src/rule.c')
-rw-r--r-- | src/rule.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -2504,6 +2504,8 @@ static int do_command_list(struct netlink_ctx *ctx, struct cmd *cmd) case CMD_OBJ_SET: return do_list_set(ctx, cmd, table); case CMD_OBJ_RULESET: + case CMD_OBJ_RULES: + case CMD_OBJ_RULE: return do_list_ruleset(ctx, cmd); case CMD_OBJ_METERS: return do_list_sets(ctx, cmd); @@ -2611,6 +2613,14 @@ static int do_command_reset(struct netlink_ctx *ctx, struct cmd *cmd) case CMD_OBJ_QUOTA: type = NFT_OBJECT_QUOTA; break; + case CMD_OBJ_RULES: + ret = netlink_reset_rules(ctx, cmd, true); + if (ret < 0) + return ret; + + return do_command_list(ctx, cmd); + case CMD_OBJ_RULE: + return netlink_reset_rules(ctx, cmd, false); default: BUG("invalid command object type %u\n", cmd->obj); } |