summaryrefslogtreecommitdiffstats
path: root/src/evaluate.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2016-08-31 18:27:13 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2016-09-05 19:15:30 +0200
commitbc4908b79a80fba8ce5c02aac52e40d16ec95aad (patch)
tree4ffb17151f4f05e8e6f150f0a5f83dc7fba2d98c /src/evaluate.c
parent83e52f7a7f5eaa893e146d23ff2e9292179f9485 (diff)
evaluate: display expression, statement and command name on debug
Extend debugging knob for evaluation to display the command, the expression and statement names. # nft --debug=eval add rule x y ip saddr 1.1.1.1 counter <cmdline>:1:1-37: Evaluate add add rule x y ip saddr 1.1.1.1 counter ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <cmdline>:1:14-29: Evaluate expression add rule x y ip saddr 1.1.1.1 counter ^^^^^^^^^^^^^^^^ ip saddr $1.1.1.1 <cmdline>:1:14-29: Evaluate relational add rule x y ip saddr 1.1.1.1 counter ^^^^^^^^^^^^^^^^ ip saddr $1.1.1.1 <cmdline>:1:14-21: Evaluate payload add rule x y ip saddr 1.1.1.1 counter ^^^^^^^^ ip saddr <cmdline>:1:23-29: Evaluate symbol add rule x y ip saddr 1.1.1.1 counter ^^^^^^^ <cmdline>:1:23-29: Evaluate value add rule x y ip saddr 1.1.1.1 counter ^^^^^^^ 1.1.1.1 <cmdline>:1:31-37: Evaluate counter add rule x y ip saddr 1.1.1.1 counter ^^^^^^^ counter packets 0 bytes 0 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/evaluate.c')
-rw-r--r--src/evaluate.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/evaluate.c b/src/evaluate.c
index c1ee6b19..45af3298 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -1589,7 +1589,8 @@ static int expr_evaluate(struct eval_ctx *ctx, struct expr **expr)
#ifdef DEBUG
if (debug_level & DEBUG_EVALUATION) {
struct error_record *erec;
- erec = erec_create(EREC_INFORMATIONAL, &(*expr)->location, "Evaluate");
+ erec = erec_create(EREC_INFORMATIONAL, &(*expr)->location,
+ "Evaluate %s", (*expr)->ops->name);
erec_print(stdout, erec); expr_print(*expr); printf("\n\n");
}
#endif
@@ -2432,7 +2433,8 @@ int stmt_evaluate(struct eval_ctx *ctx, struct stmt *stmt)
#ifdef DEBUG
if (debug_level & DEBUG_EVALUATION) {
struct error_record *erec;
- erec = erec_create(EREC_INFORMATIONAL, &stmt->location, "Evaluate");
+ erec = erec_create(EREC_INFORMATIONAL, &stmt->location,
+ "Evaluate %s", stmt->ops->name);
erec_print(stdout, erec); stmt_print(stmt); printf("\n\n");
}
#endif
@@ -2934,12 +2936,38 @@ static int cmd_evaluate_export(struct eval_ctx *ctx, struct cmd *cmd)
return cache_update(cmd->op, ctx->msgs);
}
+#ifdef DEBUG
+static const char *cmd_op_name[] = {
+ [CMD_INVALID] = "invalid",
+ [CMD_ADD] = "add",
+ [CMD_REPLACE] = "replace",
+ [CMD_CREATE] = "create",
+ [CMD_INSERT] = "insert",
+ [CMD_DELETE] = "delete",
+ [CMD_LIST] = "list",
+ [CMD_FLUSH] = "flush",
+ [CMD_RENAME] = "rename",
+ [CMD_EXPORT] = "export",
+ [CMD_MONITOR] = "monitor",
+ [CMD_DESCRIBE] = "describe",
+};
+
+static const char *cmd_op_to_name(enum cmd_ops op)
+{
+ if (op > CMD_DESCRIBE)
+ return "unknown";
+
+ return cmd_op_name[op];
+}
+#endif
+
int cmd_evaluate(struct eval_ctx *ctx, struct cmd *cmd)
{
#ifdef DEBUG
if (debug_level & DEBUG_EVALUATION) {
struct error_record *erec;
- erec = erec_create(EREC_INFORMATIONAL, &cmd->location, "Evaluate");
+ erec = erec_create(EREC_INFORMATIONAL, &cmd->location,
+ "Evaluate %s", cmd_op_to_name(cmd->op));
erec_print(stdout, erec); printf("\n\n");
}
#endif