]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MAJOR: acl: remove fetch argument validation from the ACL struct
authorWilly Tarreau <w@1wt.eu>
Fri, 11 Jan 2013 16:06:15 +0000 (17:06 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 3 Apr 2013 00:12:59 +0000 (02:12 +0200)
ACL fetch being inherited from the sample fetch keyword, we don't need
anymore to specify what function to use to validate the fetch arguments.

Note that the job is still done in the ACL parsing code based on elements
from the sample fetch structs.

include/types/acl.h
src/acl.c
src/payload.c
src/proto_http.c

index 3e62ae2d3260530b9b31440dc169b680cd4d8d82..bb5ad0d643f29b7945de4143d2e4ac9c1326db0d 100644 (file)
@@ -237,7 +237,6 @@ struct acl_keyword {
        int (*parse)(const char **text, struct acl_pattern *pattern, int *opaque, char **err);
        int (*match)(struct sample *smp, struct acl_pattern *pattern);
        unsigned int requires;   /* bit mask of all ACL_USE_* required to evaluate this keyword */
-       int (*val_args)(struct arg *arg_p, char **err_msg);  /* argument validation function */
        /* must be after the config params */
        struct sample_fetch *smp; /* the sample fetch we depend on */
        int use_cnt;
index a996c634e61f843b3e60e7cb03f56369658c812e..2e23e30c3961cdd06f3a9cee71748a9c9f49649c 100644 (file)
--- a/src/acl.c
+++ b/src/acl.c
@@ -1052,7 +1052,7 @@ struct acl_expr *parse_acl_expr(const char **args, char **err)
                        if (!expr->args)
                                expr->args = empty_arg_list;
 
-                       if (aclkw->val_args && !aclkw->val_args(expr->args, err)) {
+                       if (aclkw->smp->val_args && !aclkw->smp->val_args(expr->args, err)) {
                                /* invalid keyword argument, error must have been
                                 * set by val_args().
                                 */
index 34b21eddddec1a16f025bc606ecde6b311a9fdcb..25145cd0af7f1ddde9efdc40f0d4febe9455b4df 100644 (file)
@@ -669,8 +669,8 @@ static struct sample_fetch_kw_list smp_kws = {{ },{
  * Please take care of keeping this list alphabetically sorted.
  */
 static struct acl_kw_list acl_kws = {{ },{
-       { "payload",            NULL,             acl_parse_str,        acl_match_str,     ACL_USE_L6REQ_VOLATILE, val_payload },
-       { "payload_lv",         NULL,             acl_parse_str,        acl_match_str,     ACL_USE_L6REQ_VOLATILE, val_payload_lv },
+       { "payload",            NULL,             acl_parse_str,        acl_match_str,     ACL_USE_L6REQ_VOLATILE },
+       { "payload_lv",         NULL,             acl_parse_str,        acl_match_str,     ACL_USE_L6REQ_VOLATILE },
        { "rep_ssl_hello_type", NULL,             acl_parse_int,        acl_match_int,     ACL_USE_L6RTR_VOLATILE },
        { "req_len",            NULL,             acl_parse_int,        acl_match_int,     ACL_USE_L6REQ_VOLATILE },
        { "req_rdp_cookie",     "rdp_cookie",     acl_parse_str,        acl_match_str,     ACL_USE_L6REQ_VOLATILE },
index a835fdceb1daac0fe95a30e921c7cfb989bfccb1..020009a70d0624b4ba30eb8770a11e0c1aeedd8f 100644 (file)
@@ -9542,17 +9542,17 @@ static struct acl_kw_list acl_kws = {{ },{
        { "cook_sub",        "cook",          acl_parse_str,     acl_match_sub,     ACL_USE_L7REQ_VOLATILE },
        { "cook_val",        "cook_val",      acl_parse_int,     acl_match_int,     ACL_USE_L7REQ_VOLATILE },
 
-       { "hdr",             "hdr",           acl_parse_str,     acl_match_str,     ACL_USE_L7REQ_VOLATILE, val_hdr },
-       { "hdr_beg",         "hdr",           acl_parse_str,     acl_match_beg,     ACL_USE_L7REQ_VOLATILE, val_hdr },
-       { "hdr_cnt",         "hdr_cnt",       acl_parse_int,     acl_match_int,     ACL_USE_L7REQ_VOLATILE          },
-       { "hdr_dir",         "hdr",           acl_parse_str,     acl_match_dir,     ACL_USE_L7REQ_VOLATILE, val_hdr },
-       { "hdr_dom",         "hdr",           acl_parse_str,     acl_match_dom,     ACL_USE_L7REQ_VOLATILE, val_hdr },
-       { "hdr_end",         "hdr",           acl_parse_str,     acl_match_end,     ACL_USE_L7REQ_VOLATILE, val_hdr },
-       { "hdr_ip",          "hdr_ip",        acl_parse_ip,      acl_match_ip,      ACL_USE_L7REQ_VOLATILE, val_hdr },
-       { "hdr_len",         "hdr",           acl_parse_int,     acl_match_len,     ACL_USE_L7REQ_VOLATILE, val_hdr },
-       { "hdr_reg",         "hdr",           acl_parse_reg,     acl_match_reg,     ACL_USE_L7REQ_VOLATILE, val_hdr },
-       { "hdr_sub",         "hdr",           acl_parse_str,     acl_match_sub,     ACL_USE_L7REQ_VOLATILE, val_hdr },
-       { "hdr_val",         "hdr_val",       acl_parse_int,     acl_match_int,     ACL_USE_L7REQ_VOLATILE, val_hdr },
+       { "hdr",             "hdr",           acl_parse_str,     acl_match_str,     ACL_USE_L7REQ_VOLATILE },
+       { "hdr_beg",         "hdr",           acl_parse_str,     acl_match_beg,     ACL_USE_L7REQ_VOLATILE },
+       { "hdr_cnt",         "hdr_cnt",       acl_parse_int,     acl_match_int,     ACL_USE_L7REQ_VOLATILE },
+       { "hdr_dir",         "hdr",           acl_parse_str,     acl_match_dir,     ACL_USE_L7REQ_VOLATILE },
+       { "hdr_dom",         "hdr",           acl_parse_str,     acl_match_dom,     ACL_USE_L7REQ_VOLATILE },
+       { "hdr_end",         "hdr",           acl_parse_str,     acl_match_end,     ACL_USE_L7REQ_VOLATILE },
+       { "hdr_ip",          "hdr_ip",        acl_parse_ip,      acl_match_ip,      ACL_USE_L7REQ_VOLATILE },
+       { "hdr_len",         "hdr",           acl_parse_int,     acl_match_len,     ACL_USE_L7REQ_VOLATILE },
+       { "hdr_reg",         "hdr",           acl_parse_reg,     acl_match_reg,     ACL_USE_L7REQ_VOLATILE },
+       { "hdr_sub",         "hdr",           acl_parse_str,     acl_match_sub,     ACL_USE_L7REQ_VOLATILE },
+       { "hdr_val",         "hdr_val",       acl_parse_int,     acl_match_int,     ACL_USE_L7REQ_VOLATILE },
 
        { "http_auth",       NULL,            acl_parse_nothing, acl_match_nothing, ACL_USE_L7REQ_VOLATILE },
        { "http_auth_group", NULL,            acl_parse_strcat,  acl_match_auth,    ACL_USE_L7REQ_VOLATILE },
@@ -9585,17 +9585,17 @@ static struct acl_kw_list acl_kws = {{ },{
        { "scook_sub",       "scook",         acl_parse_str,     acl_match_sub,     ACL_USE_L7RTR_VOLATILE },
        { "scook_val",       "scook_val",     acl_parse_int,     acl_match_int,     ACL_USE_L7RTR_VOLATILE },
 
-       { "shdr",            "shdr",          acl_parse_str,     acl_match_str,     ACL_USE_L7RTR_VOLATILE, val_hdr },
-       { "shdr_beg",        "shdr",          acl_parse_str,     acl_match_beg,     ACL_USE_L7RTR_VOLATILE, val_hdr },
-       { "shdr_cnt",        "shdr_cnt",      acl_parse_int,     acl_match_int,     ACL_USE_L7RTR_VOLATILE          },
-       { "shdr_dir",        "shdr",          acl_parse_str,     acl_match_dir,     ACL_USE_L7RTR_VOLATILE, val_hdr },
-       { "shdr_dom",        "shdr",          acl_parse_str,     acl_match_dom,     ACL_USE_L7RTR_VOLATILE, val_hdr },
-       { "shdr_end",        "shdr",          acl_parse_str,     acl_match_end,     ACL_USE_L7RTR_VOLATILE, val_hdr },
-       { "shdr_ip",         "shdr_ip",       acl_parse_ip,      acl_match_ip,      ACL_USE_L7RTR_VOLATILE, val_hdr },
-       { "shdr_len",        "shdr",          acl_parse_int,     acl_match_len,     ACL_USE_L7RTR_VOLATILE, val_hdr },
-       { "shdr_reg",        "shdr",          acl_parse_reg,     acl_match_reg,     ACL_USE_L7RTR_VOLATILE, val_hdr },
-       { "shdr_sub",        "shdr",          acl_parse_str,     acl_match_sub,     ACL_USE_L7RTR_VOLATILE, val_hdr },
-       { "shdr_val",        "shdr_val",      acl_parse_int,     acl_match_int,     ACL_USE_L7RTR_VOLATILE, val_hdr },
+       { "shdr",            "shdr",          acl_parse_str,     acl_match_str,     ACL_USE_L7RTR_VOLATILE },
+       { "shdr_beg",        "shdr",          acl_parse_str,     acl_match_beg,     ACL_USE_L7RTR_VOLATILE },
+       { "shdr_cnt",        "shdr_cnt",      acl_parse_int,     acl_match_int,     ACL_USE_L7RTR_VOLATILE },
+       { "shdr_dir",        "shdr",          acl_parse_str,     acl_match_dir,     ACL_USE_L7RTR_VOLATILE },
+       { "shdr_dom",        "shdr",          acl_parse_str,     acl_match_dom,     ACL_USE_L7RTR_VOLATILE },
+       { "shdr_end",        "shdr",          acl_parse_str,     acl_match_end,     ACL_USE_L7RTR_VOLATILE },
+       { "shdr_ip",         "shdr_ip",       acl_parse_ip,      acl_match_ip,      ACL_USE_L7RTR_VOLATILE },
+       { "shdr_len",        "shdr",          acl_parse_int,     acl_match_len,     ACL_USE_L7RTR_VOLATILE },
+       { "shdr_reg",        "shdr",          acl_parse_reg,     acl_match_reg,     ACL_USE_L7RTR_VOLATILE },
+       { "shdr_sub",        "shdr",          acl_parse_str,     acl_match_sub,     ACL_USE_L7RTR_VOLATILE },
+       { "shdr_val",        "shdr_val",      acl_parse_int,     acl_match_int,     ACL_USE_L7RTR_VOLATILE },
 
        { "status",          NULL,            acl_parse_int,     acl_match_int,     ACL_USE_L7RTR_PERMANENT },