MINOR: rules: add a file name and line number to act_rules
These ones are passed on rule creation for the sole purpose of being
reported in "show sess", which is not done yet. For now the entries
are allocated upon rule creation and freed in free_act_rules().
diff --git a/include/haproxy/action-t.h b/include/haproxy/action-t.h
index 08f2508..45d2bd1 100644
--- a/include/haproxy/action-t.h
+++ b/include/haproxy/action-t.h
@@ -186,6 +186,10 @@
void *p[4];
} act; /* generic pointers to be used by custom actions */
} arg; /* arguments used by some actions */
+ struct {
+ char *file; /* file name where the rule appears (or NULL) */
+ int line; /* line number where the rule appears */
+ } conf;
};
struct action_kw {
diff --git a/src/action.c b/src/action.c
index a363dea..ba465a2 100644
--- a/src/action.c
+++ b/src/action.c
@@ -297,6 +297,8 @@
if (!rule)
return NULL;
rule->from = from;
+ rule->conf.file = file ? strdup(file) : NULL;
+ rule->conf.line = linenum;
return rule;
}
@@ -309,6 +311,7 @@
free_acl_cond(rule->cond);
if (rule->release_ptr)
rule->release_ptr(rule);
+ free(rule->conf.file);
free(rule);
}
}
diff --git a/src/vars.c b/src/vars.c
index 087bd1f..10f7d82 100644
--- a/src/vars.c
+++ b/src/vars.c
@@ -919,6 +919,8 @@
struct act_rule rule = {
.arg.vars.scope = SCOPE_PROC,
.from = ACT_F_CFG_PARSER,
+ .conf.file = (char *)file,
+ .conf.line = line,
};
enum obj_type objt = OBJ_TYPE_NONE;
struct session *sess = NULL;
@@ -1038,6 +1040,8 @@
struct act_rule rule = {
.arg.vars.scope = SCOPE_PROC,
.from = ACT_F_CLI_PARSER,
+ .conf.file = "CLI",
+ .conf.line = 0,
};
enum obj_type objt = OBJ_TYPE_NONE;
struct session *sess = NULL;