]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] report in the proxies the requirements for ACLs
authorWilly Tarreau <w@1wt.eu>
Fri, 10 Jul 2009 18:53:53 +0000 (20:53 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 10 Jul 2009 21:09:39 +0000 (23:09 +0200)
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
src/cfgparse.c
src/proto_tcp.c

index 715f21d1525c3259594344a31279738be3f7b565..41dd3e18baa46478a07009f29a6076478b04dca8 100644 (file)
@@ -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) */
 
index 5afb11e7d99dae7f62c8750aafb6cac6ec7e6efa..a7dbe02478c020357734bd65d9d04975c46779d5 100644 (file)
@@ -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);
index 59f76c4a6c0f051228eae4a532e44a88ef5be78e..846040ac32f29561e0a392677d4e5aef46a99aca 100644 (file)
@@ -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;