]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: rules: add a file name and line number to act_rules
authorWilly Tarreau <w@1wt.eu>
Mon, 11 Oct 2021 07:13:07 +0000 (09:13 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 12 Oct 2021 05:38:30 +0000 (07:38 +0200)
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().

include/haproxy/action-t.h
src/action.c
src/vars.c

index 08f250897c898af2f1c9543463e41d872ae475d1..45d2bd144b2b7a067f99bf97bbccba7107a422f6 100644 (file)
@@ -186,6 +186,10 @@ struct act_rule {
                        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 {
index a363dea8030ec8f5d3eff42b955b3a2f819f14df..ba465a25321b33177ef40a8fe4490445ef2be1c1 100644 (file)
@@ -297,6 +297,8 @@ struct act_rule *new_act_rule(enum act_from from, const char *file, int linenum)
        if (!rule)
                return NULL;
        rule->from = from;
+       rule->conf.file = file ? strdup(file) : NULL;
+       rule->conf.line = linenum;
        return rule;
 }
 
@@ -309,6 +311,7 @@ void free_act_rules(struct list *rules)
                free_acl_cond(rule->cond);
                if (rule->release_ptr)
                        rule->release_ptr(rule);
+               free(rule->conf.file);
                free(rule);
        }
 }
index 087bd1f5baafa8c55fda4c911d67375d8e9861d5..10f7d82d151847858758c319e29ab5f30f71459a 100644 (file)
@@ -919,6 +919,8 @@ static int vars_parse_global_set_var(char **args, int section_type, struct proxy
        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 @@ static int vars_parse_cli_set_var(char **args, char *payload, struct appctx *app
        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;