]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: acl: set SMP_OPT_ITERATE on fetch functions
authorWilly Tarreau <w@1wt.eu>
Thu, 26 Apr 2012 09:44:02 +0000 (11:44 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 8 May 2012 18:57:18 +0000 (20:57 +0200)
This way, fetch functions will be able to tell if they're called for a single
request or as part of a loop. This is important for instance when we use
hdr(foo), because in an ACL this means that all hdr(foo) occurrences must
be checked while in a pattern it means only one of them (eg: last one).

include/types/pattern.h
src/acl.c

index 3ee18cb6bec59a85db9edec60bb46066a0bd87dd..c5b19ada1cd13fc8bb576714afce5522cad14fa1 100644 (file)
@@ -59,6 +59,7 @@ enum {
        SMP_OPT_DIR_RES = 1,    /* direction = response */
        SMP_OPT_DIR     = (SMP_OPT_DIR_REQ|SMP_OPT_DIR_RES), /* mask to get direction */
        SMP_OPT_FINAL   = 2,    /* final fetch, contents won't change anymore */
+       SMP_OPT_ITERATE = 4,    /* fetches may be iterated if supported (for ACLs) */
 };
 
 /* Flags used to describe fetched samples. MAY_CHANGE indicates that the result
index 1267ec30b288b955c17cc0b490846b955b09566c..8f76286ed09b3667ad4d9f45b1203decd5a812d6 100644 (file)
--- a/src/acl.c
+++ b/src/acl.c
@@ -1682,7 +1682,7 @@ struct acl_cond *build_acl_cond(const char *file, int line, struct proxy *px, co
 /* Execute condition <cond> and return either ACL_PAT_FAIL, ACL_PAT_MISS or
  * ACL_PAT_PASS depending on the test results. ACL_PAT_MISS may only be
  * returned if <opt> does not contain SMP_OPT_FINAL, indicating that incomplete
- * data is being examined.
+ * data is being examined. The function automatically sets SMP_OPT_ITERATE.
  * This function only computes the condition, it does not apply the polarity
  * required by IF/UNLESS, it's up to the caller to do this using something like
  * this :
@@ -1704,6 +1704,11 @@ int acl_exec_cond(struct acl_cond *cond, struct proxy *px, struct session *l4, v
        struct sample smp;
        int acl_res, suite_res, cond_res;
 
+       /* ACLs are iterated over all values, so let's always set the flag to
+        * indicate this to the fetch functions.
+        */
+       opt |= SMP_OPT_ITERATE;
+
        /* We're doing a logical OR between conditions so we initialize to FAIL.
         * The MISS status is propagated down from the suites.
         */