[MINOR] report in the proxies the requirements for ACLs
This patch propagates the ACL conditions' "requires" bitfield
to the proxies. This makes it possible to know exactly what a
proxy might have to support for any request, which helps knowing
whether we have to allocate some space for certain types of
structures or not (eg: the hdr_idx struct).
The concept might be extended to a lot more types of information,
such as detecting whether we need to allocate some space for some
request ACLs which need a result in the response, etc...
diff --git a/include/types/proxy.h b/include/types/proxy.h
index 715f21d..41dd3e1 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -162,6 +162,7 @@
unsigned int inspect_delay; /* inspection delay */
struct list inspect_rules; /* inspection rules */
} tcp_req;
+ int acl_requires; /* Elements required to satisfy all ACLs (ACL_USE_*) */
struct server *srv; /* known servers */
int srv_act, srv_bck; /* # of servers eligible for LB (UP|!checked) AND (enabled+weight!=0) */
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 5afb11e..a7dbe02 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -1360,6 +1360,7 @@
return -1;
}
cond->line = linenum;
+ curproxy->acl_requires |= cond->requires;
LIST_ADDQ(&curproxy->block_cond, &cond->list);
warnif_misplaced_block(curproxy, file, linenum, args[0]);
}
@@ -1475,6 +1476,7 @@
}
cond->line = linenum;
+ curproxy->acl_requires |= cond->requires;
rule = (struct redirect_rule *)calloc(1, sizeof(*rule));
rule->cond = cond;
rule->rdr_str = strdup(destination);
@@ -1536,6 +1538,7 @@
}
cond->line = linenum;
+ curproxy->acl_requires |= cond->requires;
if (cond->requires & ACL_USE_RTR_ANY) {
struct acl *acl;
const char *name;
@@ -1921,6 +1924,7 @@
return -1;
}
cond->line = linenum;
+ curproxy->acl_requires |= cond->requires;
LIST_ADDQ(&curproxy->mon_fail_cond, &cond->list);
}
else {
@@ -3442,6 +3446,7 @@
break;
case PR_MODE_HTTP:
+ curproxy->acl_requires |= ACL_USE_L7_ANY;
if ((curproxy->cookie_name != NULL) && (curproxy->srv == NULL)) {
Alert("config : HTTP proxy %s has a cookie but no server list !\n",
curproxy->id);
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 59f76c4..846040a 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -539,6 +539,8 @@
// FIXME: how to set this ?
// cond->line = linenum;
+ if (cond)
+ curpx->acl_requires |= cond->requires;
if (cond && cond->requires & (ACL_USE_RTR_ANY | ACL_USE_L7_ANY)) {
struct acl *acl;
const char *name;