Skip to contentSkip to conversation

cache: revisit reset command flags

PATCH New Pablo Neira Ayuso 1 participant 1 message Aug 15, 2024 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 cache: revisit reset command flags

- reset rules => fetch full cache, rules can refer to objects
- reset counter,quota => fetch only table and objects

... otherwise, default to cache full fetch, which is slow but safe.

Fixes 1694df2de79f ("Implement 'reset rule' and 'reset rules' commands")

---
I plan to send v2 to extend tests.

A few more comments:

- nft reset ruleset seems to be missing?
- nft reset rules lists the entire ruleset, i guess this expected nft reset counters comes with memleak, ASAN reports

 src/cache.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
src/cache.c +9 -4
index 233147649263..d91e4b682e1f 100644
@@ -278,16 +278,21 @@ static unsigned int evaluate_cache_reset(struct cmd *cmd, unsigned int flags,
 			if (cmd->handle.chain.name)
 				filter->list.chain = cmd->handle.chain.name;
 		}
-		flags |= NFT_CACHE_SET | NFT_CACHE_FLOWTABLE |
-			 NFT_CACHE_OBJECT | NFT_CACHE_CHAIN;
+		flags |= NFT_CACHE_FULL;
+		break;
+	case CMD_OBJ_COUNTER:
+	case CMD_OBJ_COUNTERS:
+	case CMD_OBJ_QUOTA:
+	case CMD_OBJ_QUOTAS:
+		flags |= NFT_CACHE_TABLE | NFT_CACHE_OBJECT;
 		break;
 	case CMD_OBJ_ELEMENTS:
 	case CMD_OBJ_SET:
 	case CMD_OBJ_MAP:
-		flags |= NFT_CACHE_SET;
+		flags |= NFT_CACHE_SETELEM | NFT_CACHE_CHAIN | NFT_CACHE_OBJECT;
 		break;
 	default:
-		flags |= NFT_CACHE_TABLE;
+		flags |= NFT_CACHE_FULL;
 		break;
 	}
 	flags |= NFT_CACHE_REFRESH;
Signature · 1 line
2.30.2