summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2019-11-14 15:45:07 +0100
committerPhil Sutter <phil@nwl.cc>2019-11-15 10:51:28 +0100
commitdf7b56c0f706eced1ad12152a208971fbe518d5b (patch)
tree9f691c23ff62a1751dc660c829dbd2edaa1aacc9 /src
parent4a8831b52b1c83322e288078120d834b78ff489a (diff)
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. Signed-off-by: Phil Sutter <phil@nwl.cc> Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/cache.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/cache.c b/src/cache.c
index a778650a..0c28a28d 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -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: