Skip to contentSkip to conversation

cache: Reduce caching for get command

PATCH In review Phil Sutter 2 participants 2 messages Nov 14, 2019 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 cache: Reduce caching for get command

Introduce a function to distinguish which command object was given and request only the necessary bits to have sets and their elements available for 'get element' command.

---
 src/cache.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
src/cache.c +17 -0
index a778650ac133a..0c28a28d3b554 100644
@@ -63,6 +63,21 @@ static unsigned int evaluate_cache_del(struct cmd *cmd, unsigned int flags)
 	return flags;
 }
 
+static unsigned int evaluate_cache_get(struct cmd *cmd, unsigned int flags)
+{
+	switch (cmd->obj) {
+	case CMD_OBJ_SETELEM:
+		flags |= NFT_CACHE_TABLE |
+			 NFT_CACHE_SET |
+			 NFT_CACHE_SETELEM;
+		break;
+	default:
+		break;
+	}
+
+	return flags;
+}
+
 static unsigned int evaluate_cache_flush(struct cmd *cmd, unsigned int flags)
 {
 	switch (cmd->obj) {
@@ -121,6 +136,8 @@ unsigned int cache_evaluate(struct nft_ctx *nft, struct list_head *cmds)
 			flags = evaluate_cache_del(cmd, flags);
 			break;
 		case CMD_GET:
+			flags = evaluate_cache_get(cmd, flags);
+			break;
 		case CMD_LIST:
 		case CMD_RESET:
 		case CMD_EXPORT:
Signature · 1 line
2.24.0