summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2015-07-03 19:35:35 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2015-08-18 01:35:56 +0200
commitd1169e46f3f45b9a3bb8e164717f91cd6917ad3e (patch)
tree660ed05d5cf9d7719035a01d1de5a31dc54fd43e
parent6044595f9bc4ec1998fa48ebae8ecbdb6d0be500 (diff)
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 <pablo@netfilter.org>
-rw-r--r--src/evaluate.c22
1 files changed, 22 insertions, 0 deletions
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;