summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2020-07-21 01:50:06 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2020-07-21 14:20:18 +0200
commit40ef308e19b6db02017a8a650406b0c6d37be750 (patch)
tree1454397990893d59b6d4a9e90a0424202eaa8817 /src
parent6c3fbd20c9aeeefd75543d759370af11787873c9 (diff)
rule: flush set cache before flush command
Flush the set cache before adding the flush command to the netlink batch. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/rule.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/rule.c b/src/rule.c
index fa186140..6b71dfee 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -2692,6 +2692,21 @@ static int do_command_reset(struct netlink_ctx *ctx, struct cmd *cmd)
return do_list_obj(ctx, cmd, type);
}
+static void flush_set_cache(struct netlink_ctx *ctx, struct cmd *cmd)
+{
+ struct table *table;
+ struct set *set;
+
+ table = table_lookup(&cmd->handle, &ctx->nft->cache);
+ assert(table);
+ set = set_lookup(table, cmd->handle.set.name);
+ assert(set);
+ if (set->init != NULL) {
+ expr_free(set->init);
+ set->init = NULL;
+ }
+}
+
static int do_command_flush(struct netlink_ctx *ctx, struct cmd *cmd)
{
switch (cmd->obj) {
@@ -2701,6 +2716,7 @@ static int do_command_flush(struct netlink_ctx *ctx, struct cmd *cmd)
case CMD_OBJ_SET:
case CMD_OBJ_MAP:
case CMD_OBJ_METER:
+ flush_set_cache(ctx, cmd);
return mnl_nft_setelem_flush(ctx, cmd);
case CMD_OBJ_RULESET:
return mnl_nft_table_del(ctx, cmd);