mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-23 06:41:32 +02:00
MINOR: vars: store flags into variables and add VF_PERMANENT
In order to continue to honor the ifexist Lua option and prevent rogue SPOA agents from creating too many variables, we'll need to keep the ability to mark certain proc.* variables as permanent when they're known from the config file. Let's add a flag there for this. It's added to the variable when the variable is created with this flag set by the caller. Another approach could have been to use a distinct list or distinct scope but that sounds complicated and bug-prone.
This commit is contained in:
parent
63c30667d7
commit
3dc6dc3178
@ -28,6 +28,7 @@
|
|||||||
/* flags used when setting/clearing variables */
|
/* flags used when setting/clearing variables */
|
||||||
#define VF_UPDATEONLY 0x00000001 // SCOPE_PROC variables are only updated
|
#define VF_UPDATEONLY 0x00000001 // SCOPE_PROC variables are only updated
|
||||||
#define VF_CREATEONLY 0x00000002 // do nothing if the variable already exists
|
#define VF_CREATEONLY 0x00000002 // do nothing if the variable already exists
|
||||||
|
#define VF_PERMANENT 0x00000004 // variables known to the config parser
|
||||||
|
|
||||||
enum vars_scope {
|
enum vars_scope {
|
||||||
SCOPE_SESS = 0,
|
SCOPE_SESS = 0,
|
||||||
@ -54,6 +55,8 @@ struct var_desc {
|
|||||||
struct var {
|
struct var {
|
||||||
struct list l; /* Used for chaining vars. */
|
struct list l; /* Used for chaining vars. */
|
||||||
const char *name; /* Contains the variable name. */
|
const char *name; /* Contains the variable name. */
|
||||||
|
uint flags; // VF_*
|
||||||
|
/* 32-bit hole here */
|
||||||
struct sample_data data; /* data storage. */
|
struct sample_data data; /* data storage. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -357,6 +357,7 @@ static int smp_fetch_var(const struct arg *args, struct sample *smp, const char
|
|||||||
* - VF_UPDATEONLY: if the scope is SCOPE_PROC, the variable may only be
|
* - VF_UPDATEONLY: if the scope is SCOPE_PROC, the variable may only be
|
||||||
* updated but not created.
|
* updated but not created.
|
||||||
* - VF_CREATEONLY: do nothing if the variable already exists (success).
|
* - VF_CREATEONLY: do nothing if the variable already exists (success).
|
||||||
|
* - VF_PERMANENT: this flag will be passed to the variable upon creation
|
||||||
*
|
*
|
||||||
* It returns 0 on failure, non-zero on success.
|
* It returns 0 on failure, non-zero on success.
|
||||||
*/
|
*/
|
||||||
@ -408,6 +409,7 @@ static int var_set(const char *name, enum vars_scope scope, struct sample *smp,
|
|||||||
goto unlock;
|
goto unlock;
|
||||||
LIST_APPEND(&vars->head, &var->l);
|
LIST_APPEND(&vars->head, &var->l);
|
||||||
var->name = name;
|
var->name = name;
|
||||||
|
var->flags = flags & VF_PERMANENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set type. */
|
/* Set type. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user