Skip to contentSkip to conversation

cache: do not populate the cache in case of flush ruleset command

PATCH Superseded Pablo Neira Ayuso 1 participant 1 message Jun 14, 2019 netfilter

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 cache: do not populate the cache in case of flush ruleset command

__CMD_FLUSH_RULESET is a dummy definition that used to skip the netlink dump to populate the cache. This patch is a workaround until we have a better infrastructure to track the state of the cache objects.

---
 include/rule.h | 1 +
 src/cache.c    | 3 +++
 src/rule.c     | 3 +++
 3 files changed, 7 insertions(+)
include/rule.h +1 -0
index dd9df9ec6dd8..b41825d000d6 100644
@@ -462,6 +462,7 @@ enum cmd_ops {
 	CMD_EXPORT,
 	CMD_MONITOR,
 	CMD_DESCRIBE,
+	__CMD_FLUSH_RULESET,
 };
 
 /**
src/cache.c +3 -0
index 532ef425906a..d7153f6f6b8f 100644
@@ -54,6 +54,9 @@ static unsigned int evaluate_cache_flush(struct cmd *cmd)
 	unsigned int completeness = CMD_INVALID;
 
 	switch (cmd->obj) {
+	case CMD_OBJ_RULESET:
+		completeness = __CMD_FLUSH_RULESET;
+		break;
 	case CMD_OBJ_SET:
 	case CMD_OBJ_MAP:
 	case CMD_OBJ_METER:
src/rule.c +3 -0
index 8de5aa62b94f..3dba8b991e12 100644
@@ -155,6 +155,9 @@ static int cache_init_objects(struct netlink_ctx *ctx, enum cmd_ops cmd)
 	struct set *set;
 	int ret;
 
+	if (cmd == __CMD_FLUSH_RULESET)
+		return 0;
+
 	list_for_each_entry(table, &ctx->nft->cache.list, list) {
 		ret = netlink_list_sets(ctx, &table->handle);
 		list_splice_tail_init(&ctx->list, &table->sets);
Signature · 1 line
2.11.0