From a9fb08317fd21361c9391db68a33591b41b13cf3 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 10 Jul 2009 20:53:53 +0200 Subject: [PATCH] [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... --- include/types/proxy.h | 1 + src/cfgparse.c | 5 +++++ src/proto_tcp.c | 2 ++ 3 files changed, 8 insertions(+) diff --git a/include/types/proxy.h b/include/types/proxy.h index 715f21d15..41dd3e18b 100644 --- a/include/types/proxy.h +++ b/include/types/proxy.h @@ -162,6 +162,7 @@ struct proxy { 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 5afb11e7d..a7dbe0247 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -1360,6 +1360,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) 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 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) } 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 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) } 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 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) return -1; } cond->line = linenum; + curproxy->acl_requires |= cond->requires; LIST_ADDQ(&curproxy->mon_fail_cond, &cond->list); } else { @@ -3442,6 +3446,7 @@ int check_config_validity() 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 59f76c4a6..846040ac3 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -539,6 +539,8 @@ static int tcp_parse_tcp_req(char **args, int section_type, struct proxy *curpx, // 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;