From: Willy Tarreau Date: Mon, 23 Apr 2012 17:18:42 +0000 (+0200) Subject: MEDIUM: acl: get rid of the SET_RES flags X-Git-Tag: v1.5-dev9~48 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=197e10aaae6194bb37d3c128fd8ea60964994ece;p=thirdparty%2Fhaproxy.git MEDIUM: acl: get rid of the SET_RES flags We now simply rely on a boolean result from a fetch to declare a match. Booleans are not compared against patterns, they fix the result. --- diff --git a/include/types/pattern.h b/include/types/pattern.h index c37959564b..8fcc5d89c3 100644 --- a/include/types/pattern.h +++ b/include/types/pattern.h @@ -56,11 +56,6 @@ enum { SMP_F_VOLATILE = (1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6), /* any volatility condition */ SMP_F_READ_ONLY = 1 << 7, /* returned data must not be altered */ - SMP_F_RES_SET = 1 << 8, /* migration: ACL match must reflect the RES_PASS flag */ - SMP_F_RES_PASS = 1 << 9, /* migration: returned data is a TRUE boolean */ - SMP_F_SET_RES_PASS = (SMP_F_RES_SET|SMP_F_RES_PASS), /* migration: force ACLs to PASS */ - SMP_F_SET_RES_FAIL = (SMP_F_RES_SET), /* migration: force ACLs to FAIL */ - SMP_F_MUST_FREE = 1 << 10, /* migration: this sample must be freed ASAP */ }; diff --git a/src/acl.c b/src/acl.c index 91a9754c46..9c4ce0ca53 100644 --- a/src/acl.c +++ b/src/acl.c @@ -69,7 +69,7 @@ acl_fetch_true(struct proxy *px, struct session *l4, void *l7, int dir, struct acl_expr *expr, struct sample *smp) { smp->type = SMP_T_BOOL; - smp->flags |= SMP_F_SET_RES_PASS; + smp->data.uint = 1; return 1; } @@ -85,7 +85,7 @@ acl_fetch_wait_end(struct proxy *px, struct session *l4, void *l7, int dir, return 0; } smp->type = SMP_T_BOOL; - smp->flags |= SMP_F_SET_RES_PASS; + smp->data.uint = 1; return 1; } @@ -95,7 +95,7 @@ acl_fetch_false(struct proxy *px, struct session *l4, void *l7, int dir, struct acl_expr *expr, struct sample *smp) { smp->type = SMP_T_BOOL; - smp->flags |= SMP_F_SET_RES_FAIL; + smp->data.uint = 0; return 1; } @@ -1870,8 +1870,8 @@ int acl_exec_cond(struct acl_cond *cond, struct proxy *px, struct session *l4, v continue; } - if (smp.flags & SMP_F_RES_SET) { - if (smp.flags & SMP_F_RES_PASS) + if (smp.type == SMP_T_BOOL) { + if (smp.data.uint) acl_res |= ACL_PAT_PASS; else acl_res |= ACL_PAT_FAIL; diff --git a/src/backend.c b/src/backend.c index c60f3a3e1b..4d0d86f14c 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1414,9 +1414,9 @@ acl_fetch_srv_is_up(struct proxy *px, struct session *l4, void *l7, int dir, smp->type = SMP_T_BOOL; if (!(srv->state & SRV_MAINTAIN) && (!(srv->state & SRV_CHECKED) || (srv->state & SRV_RUNNING))) - smp->flags |= SMP_F_SET_RES_PASS; + smp->data.uint = 1; else - smp->flags |= SMP_F_SET_RES_FAIL; + smp->data.uint = 0; return 1; } diff --git a/src/proto_http.c b/src/proto_http.c index e9ae1b4446..b6036d56bb 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -7562,7 +7562,7 @@ acl_prefetch_http(struct proxy *px, struct session *s, void *l7, int dir, if (unlikely(txn->req.msg_state < HTTP_MSG_BODY)) { if ((msg->msg_state == HTTP_MSG_ERROR) || (s->req->flags & BF_FULL)) { - smp->flags |= SMP_F_SET_RES_FAIL; + smp->data.uint = 0; return -1; } @@ -7573,7 +7573,7 @@ acl_prefetch_http(struct proxy *px, struct session *s, void *l7, int dir, /* Still no valid request ? */ if (unlikely(msg->msg_state < HTTP_MSG_BODY)) { if ((msg->msg_state == HTTP_MSG_ERROR) || (s->req->flags & BF_FULL)) { - smp->flags |= SMP_F_SET_RES_FAIL; + smp->data.uint = 0; return -1; } /* wait for final state */ @@ -7590,7 +7590,7 @@ acl_prefetch_http(struct proxy *px, struct session *s, void *l7, int dir, s->flags |= SN_REDIRECTABLE; if (unlikely(msg->sl.rq.v_l == 0) && !http_upgrade_v09_to_v10(txn)) { - smp->flags |= SMP_F_SET_RES_FAIL; + smp->data.uint = 0; return -1; } } @@ -7982,7 +7982,7 @@ acl_fetch_proto_http(struct proxy *px, struct session *l4, void *l7, int dir, CHECK_HTTP_MESSAGE_FIRST(); smp->type = SMP_T_BOOL; - smp->flags |= SMP_F_SET_RES_PASS; + smp->data.uint = 1; return 1; } @@ -7995,11 +7995,7 @@ acl_fetch_http_first_req(struct proxy *px, struct session *s, void *l7, int dir, return 0; smp->type = SMP_T_BOOL; - if (s->txn.flags & TX_NOT_FIRST) - smp->flags |= SMP_F_SET_RES_FAIL; - else - smp->flags |= SMP_F_SET_RES_PASS; - + smp->data.uint = !(s->txn.flags & TX_NOT_FIRST); return 1; } @@ -8018,11 +8014,7 @@ acl_fetch_http_auth(struct proxy *px, struct session *l4, void *l7, int dir, return 0; smp->type = SMP_T_BOOL; - if (check_user(expr->args->data.usr, 0, l4->txn.auth.user, l4->txn.auth.pass)) - smp->flags |= SMP_F_SET_RES_PASS; - else - smp->flags |= SMP_F_SET_RES_FAIL; - + smp->data.uint = check_user(expr->args->data.usr, 0, l4->txn.auth.user, l4->txn.auth.pass); return 1; }