]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: proxy: remove acl_requires and just keep a flag "http_needed"
authorWilly Tarreau <w@1wt.eu>
Sun, 24 Mar 2013 06:22:08 +0000 (07:22 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 3 Apr 2013 00:13:00 +0000 (02:13 +0200)
Proxy's acl_requires was a copy of all bits taken from ACLs, but we'll
get rid of ACL flags and only rely on sample fetches soon. The proxy's
acl_requires was only used to allocate an HTTP context when needed, and
was even forced in HTTP mode. So better have a flag which exactly says
what it's supposed to be used for.

include/proto/acl.h
include/types/proxy.h
src/acl.c
src/cfgparse.c
src/frontend.c
src/log.c
src/proto_tcp.c
src/proxy.c

index 58591ab9dd28d0d92f07ef130bb45336ff963a47..1471dae42a6aecc3f7bc57ad5feae44acb5e9c38 100644 (file)
@@ -84,8 +84,8 @@ struct acl_cond *parse_acl_cond(const char **args, struct list *known_acl, int p
 /* Builds an ACL condition starting at the if/unless keyword. The complete
  * condition is returned. NULL is returned in case of error or if the first
  * word is neither "if" nor "unless". It automatically sets the file name and
- * the line number in the condition for better error reporting, and adds the
- * ACL requirements to the proxy's acl_requires. If <err> is not NULL, it will
+ * the line number in the condition for better error reporting, and sets the
+ * HTTP initialization requirements in the proxy. If <err> is not NULL, it will
  * be set to an error message upon errors, that the caller will have to free.
  */
 struct acl_cond *build_acl_cond(const char *file, int line, struct proxy *px, const char **args, char **err);
index 87e90ee90ea09ea27cd629fe043af007eb2636e5..5abf35e344b9ee051881b104028011321fd5dffc 100644 (file)
@@ -205,6 +205,7 @@ struct proxy {
        unsigned int fe_req_ana, be_req_ana;    /* bitmap of common request protocol analysers for the frontend and backend */
        unsigned int fe_rsp_ana, be_rsp_ana;    /* bitmap of common response protocol analysers for the frontend and backend */
        int mode;                               /* mode = PR_MODE_TCP, PR_MODE_HTTP or PR_MODE_HEALTH */
+       unsigned int http_needed;               /* non-null if HTTP analyser may be used */
        union {
                struct proxy *be;               /* default backend, or NULL if none set */
                char *name;                     /* default backend name during config parse */
@@ -227,7 +228,6 @@ struct proxy {
                unsigned int inspect_delay;     /* inspection delay */
                struct list inspect_rules;      /* inspection rules */
        } tcp_rep;
-       int acl_requires;                       /* Elements required to satisfy all ACLs (ACL_USE_*) */
        struct server *srv, defsrv;             /* known servers; default server configuration */
        int srv_act, srv_bck;                   /* # of servers eligible for LB (UP|!checked) AND (enabled+weight!=0) */
        struct lbprm lbprm;                     /* load-balancing parameters */
index 2b3bbd5474a3c230570b74be78de78eed80a5bd8..58363fa16b5ac3aa6ea41b2b730cb1070a6515da 100644 (file)
--- a/src/acl.c
+++ b/src/acl.c
@@ -1463,8 +1463,8 @@ struct acl_cond *parse_acl_cond(const char **args, struct list *known_acl, int p
 /* Builds an ACL condition starting at the if/unless keyword. The complete
  * condition is returned. NULL is returned in case of error or if the first
  * word is neither "if" nor "unless". It automatically sets the file name and
- * the line number in the condition for better error reporting, and adds the
- * ACL requirements to the proxy's acl_requires. If <err> is not NULL, it will
+ * the line number in the condition for better error reporting, and sets the
+ * HTTP intiailization requirements in the proxy. If <err> is not NULL, it will
  * be filled with a pointer to an error message in case of error, that the
  * caller is responsible for freeing. The initial location must either be
  * freeable or NULL.
@@ -1498,8 +1498,7 @@ struct acl_cond *build_acl_cond(const char *file, int line, struct proxy *px, co
 
        cond->file = file;
        cond->line = line;
-       px->acl_requires |= cond->requires;
-
+       px->http_needed |= !!(cond->requires & ACL_USE_L7_ANY);
        return cond;
 }
 
index 6b27c24d84b067fb47a635bddd3fdd3e10f06430..e277b12b4008b8604ee6e17f184160a2ffde40fd 100644 (file)
@@ -3040,8 +3040,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                }
 
                /* check if we need to allocate an hdr_idx struct for HTTP parsing */
-               if (expr->fetch->use & SMP_USE_HTTP_ANY)
-                       curproxy->acl_requires |= ACL_USE_L7_ANY;
+               curproxy->http_needed |= !!(expr->fetch->use & SMP_USE_HTTP_ANY);
 
                if (strcmp(args[myidx], "table") == 0) {
                        myidx++;
@@ -6044,7 +6043,7 @@ int check_config_validity()
                        break;
 
                case PR_MODE_HTTP:
-                       curproxy->acl_requires |= ACL_USE_L7_ANY;
+                       curproxy->http_needed = 1;
                        break;
                }
 
index f259adeddd263d623186f54dae399b5b227a5e04..b0bab37e7055e11e8a43505fe7bcd521dbd69a57 100644 (file)
@@ -115,7 +115,7 @@ int frontend_accept(struct session *s)
                        goto out_free_reqcap;   /* no memory */
        }
 
-       if (s->fe->acl_requires & ACL_USE_L7_ANY) {
+       if (s->fe->http_needed) {
                /* we have to allocate header indexes only if we know
                 * that we may make use of them. This of course includes
                 * (mode == PR_MODE_HTTP).
index 25dda04b068c51a9f4fa224d8f4153c87af6750f..165fd724e43d8ed801af40dad86085304bd87927 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -347,8 +347,7 @@ void add_sample_to_logformat_list(char *text, char *arg, int arg_len, struct pro
 
        /* check if we need to allocate an hdr_idx struct for HTTP parsing */
        /* Note, we may also need to set curpx->to_log with certain fetches */
-       if (expr->fetch->use & SMP_USE_HTTP_ANY)
-               curpx->acl_requires |= ACL_USE_L7_ANY;
+       curpx->http_needed |= !!(expr->fetch->use & SMP_USE_HTTP_ANY);
 
        /* FIXME: temporary workaround for missing LW_XPRT flag needed with some
         * sample fetches (eg: ssl*). We always set it for now on, but this will
index 8f631f88858ea30d6fb04283aea4f62f767de4a8..3cf0d81ad49d6404cde56051e09ac7a0321bee56 100644 (file)
@@ -1129,8 +1129,7 @@ static int tcp_parse_request_rule(char **args, int arg, int section_type,
                }
 
                /* check if we need to allocate an hdr_idx struct for HTTP parsing */
-               if (expr->fetch->use & SMP_USE_HTTP_ANY)
-                       curpx->acl_requires |= ACL_USE_L7_ANY;
+               curpx->http_needed |= !!(expr->fetch->use & SMP_USE_HTTP_ANY);
 
                if (strcmp(args[arg], "table") == 0) {
                        arg++;
index 9ccd25ad83d6702edebfcedfcb353614492e8b0e..1986a7c2ba275c9b0e3f1eea7ee18d268835258d 100644 (file)
@@ -828,7 +828,7 @@ int session_set_backend(struct session *s, struct proxy *be)
        /* If the target backend requires HTTP processing, we have to allocate
         * a struct hdr_idx for it if we did not have one.
         */
-       if (unlikely(!s->txn.hdr_idx.v && (be->acl_requires & ACL_USE_L7_ANY))) {
+       if (unlikely(!s->txn.hdr_idx.v && be->http_needed)) {
                if ((s->txn.hdr_idx.v = pool_alloc2(pool2_hdr_idx)) == NULL)
                        return 0; /* not enough memory */