summaryrefslogtreecommitdiffstats
path: root/src/rule.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2023-06-14 17:40:02 +0200
committerPhil Sutter <phil@nwl.cc>2023-07-13 16:57:54 +0200
commite2431ab955fe453b5fd25a3ab3090fbf4bf3e653 (patch)
tree6f3d7d337852271acadad28399731495b0a510ae /src/rule.c
parent5193a8970e204d1b8541c36ac2ce79f6c0f98970 (diff)
evaluate: Cache looked up set for list commands
Evaluation phase checks the given table and set exist in cache. Relieve execution phase from having to perform the lookup again by storing the set reference in cmd->set. Just have to increase the ref counter so cmd_free() does the right thing (which lacked handling of MAP and METER objects for some reason). Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'src/rule.c')
-rw-r--r--src/rule.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/rule.c b/src/rule.c
index 19d681bb..18a566f9 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -1356,6 +1356,8 @@ void cmd_free(struct cmd *cmd)
set_free(cmd->elem.set);
break;
case CMD_OBJ_SET:
+ case CMD_OBJ_MAP:
+ case CMD_OBJ_METER:
case CMD_OBJ_SETELEMS:
set_free(cmd->set);
break;
@@ -2283,11 +2285,13 @@ static void __do_list_set(struct netlink_ctx *ctx, struct cmd *cmd,
static int do_list_set(struct netlink_ctx *ctx, struct cmd *cmd,
struct table *table)
{
- struct set *set;
+ struct set *set = cmd->set;
- set = set_cache_find(table, cmd->handle.set.name);
- if (set == NULL)
- return -1;
+ if (!set) {
+ set = set_cache_find(table, cmd->handle.set.name);
+ if (set == NULL)
+ return -1;
+ }
__do_list_set(ctx, cmd, set);