From d1169e46f3f45b9a3bb8e164717f91cd6917ad3e Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 3 Jul 2015 19:35:35 +0200 Subject: evaluate: add cmd_evaluate_rename() Make sure the table that we want to rename already exist. This is required by the follow up patch that that adds chains to the cache. Signed-off-by: Pablo Neira Ayuso --- src/evaluate.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/evaluate.c b/src/evaluate.c index 8c161953..511b71b5 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -1962,6 +1962,26 @@ static int cmd_evaluate_list(struct eval_ctx *ctx, struct cmd *cmd) } } +static int cmd_evaluate_rename(struct eval_ctx *ctx, struct cmd *cmd) +{ + struct table *table; + + switch (cmd->obj) { + case CMD_OBJ_CHAIN: + table = table_lookup(&ctx->cmd->handle); + if (table == NULL) + return cmd_error(ctx, "Could not process rule: Table '%s' does not exist", + ctx->cmd->handle.table); + if (chain_lookup(table, &ctx->cmd->handle) == NULL) + return cmd_error(ctx, "Could not process rule: Chain '%s' does not exist", + ctx->cmd->handle.chain); + break; + default: + BUG("invalid command object type %u\n", cmd->obj); + } + return 0; +} + enum { CMD_MONITOR_EVENT_ANY, CMD_MONITOR_EVENT_NEW, @@ -2055,7 +2075,9 @@ int cmd_evaluate(struct eval_ctx *ctx, struct cmd *cmd) case CMD_LIST: return cmd_evaluate_list(ctx, cmd); case CMD_FLUSH: + return 0; case CMD_RENAME: + return cmd_evaluate_rename(ctx, cmd); case CMD_EXPORT: case CMD_DESCRIBE: return 0; -- cgit v1.2.3