summaryrefslogtreecommitdiffstats
path: root/src/json.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/json.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/json.c')
-rw-r--r--src/json.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/json.c b/src/json.c
index 21199ca4..a119dfc4 100644
--- a/src/json.c
+++ b/src/json.c
@@ -1799,10 +1799,13 @@ static json_t *do_list_chains_json(struct netlink_ctx *ctx, struct cmd *cmd)
static json_t *do_list_set_json(struct netlink_ctx *ctx,
struct cmd *cmd, struct table *table)
{
- struct set *set = set_cache_find(table, cmd->handle.set.name);
+ struct set *set = cmd->set;
- if (set == NULL)
- return json_null();
+ if (!set) {
+ set = set_cache_find(table, cmd->handle.set.name);
+ if (set == NULL)
+ return json_null();
+ }
return json_pack("[o]", set_print_json(&ctx->nft->output, set));
}