Make sure the table and the original chain that we want to rename already exist. Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> --- src/evaluate.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/evaluate.c b/src/evaluate.c index 91c4989..022e1ff 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -1956,6 +1956,28 @@ 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; + struct chain *chain; + + switch (cmd->obj) { + case CMD_OBJ_CHAIN: + table = table_lookup(&ctx->cmd->handle); + if (table == NULL) { + return cmd_error(ctx, "Table '%s' does not exist", + ctx->cmd->handle.table); + } + chain = chain_lookup(table, &ctx->cmd->handle); + if (chain == NULL) + return cmd_error(ctx, "Chain '%s' does not exist", + ctx->cmd->handle.chain); + return 0; + default: + BUG("invalid command object type %u\n", cmd->obj); + } +} + enum { CMD_MONITOR_EVENT_ANY, CMD_MONITOR_EVENT_NEW, @@ -2043,7 +2065,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; -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html