MEDIUM: acl/pattern: use the same direction scheme
Patterns were using a bitmask to indicate if request or response was desired
in fetch functions and keywords. ACLs were using a bitmask in fetch keywords
and a single bit in fetch functions. ACLs were also using an ACL_PARTIAL bit
in fetch functions indicating that a non-final fetch was performed, which was
an abuse of the existing direction flag.
The change now consists in using :
- a capabilities field for fetch keywords => SMP_CAP_REQ/RES to indicate
if a keyword supports requests, responses, both, etc...
- an option field for fetch functions to indicate what the caller expects
(request/response, final/non-final)
The ACL_PARTIAL bit was reversed to get SMP_OPT_FINAL as it's more explicit
to know we're working on a final buffer than on a non-final one.
ACL_DIR_* were removed, as well as PATTERN_FETCH_*. L4 fetches were improved
to support being called on responses too since they're still available.
The <dir> field of all fetch functions was changed to <opt> which is now
unsigned.
The patch is large but mostly made of cosmetic changes to accomodate this, as
almost no logic change happened.
diff --git a/src/backend.c b/src/backend.c
index a956707..5bec608 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -416,7 +416,7 @@
args[0].data.str.len = px->hh_len;
args[1].type = ARGT_STOP;
- ret = smp_fetch_rdp_cookie(px, s, NULL, ACL_DIR_REQ, args, &smp);
+ ret = smp_fetch_rdp_cookie(px, s, NULL, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, args, &smp);
len = smp.data.str.len;
if (ret == 0 || (smp.flags & SMP_F_MAY_CHANGE) || len == 0)
@@ -1134,7 +1134,7 @@
args[0].data.str.len = s->be->rdp_cookie_len;
args[1].type = ARGT_STOP;
- ret = smp_fetch_rdp_cookie(px, s, NULL, ACL_DIR_REQ, args, &smp);
+ ret = smp_fetch_rdp_cookie(px, s, NULL, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, args, &smp);
if (ret == 0 || (smp.flags & SMP_F_MAY_CHANGE) || smp.data.str.len == 0)
goto no_cookie;
@@ -1374,7 +1374,7 @@
* undefined behaviour.
*/
static int
-acl_fetch_nbsrv(struct proxy *px, struct session *l4, void *l7, int dir,
+acl_fetch_nbsrv(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp)
{
smp->flags = SMP_F_VOL_TEST;
@@ -1397,7 +1397,7 @@
* undefined behaviour.
*/
static int
-acl_fetch_srv_is_up(struct proxy *px, struct session *l4, void *l7, int dir,
+acl_fetch_srv_is_up(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp)
{
struct server *srv = args->data.srv;
@@ -1417,7 +1417,7 @@
* undefined behaviour.
*/
static int
-acl_fetch_connslots(struct proxy *px, struct session *l4, void *l7, int dir,
+acl_fetch_connslots(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp)
{
struct server *iterator;
@@ -1445,7 +1445,7 @@
/* set temp integer to the id of the backend */
static int
-acl_fetch_be_id(struct proxy *px, struct session *l4, void *l7, int dir,
+acl_fetch_be_id(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp)
{
smp->flags = SMP_F_VOL_TXN;
@@ -1456,7 +1456,7 @@
/* set temp integer to the id of the server */
static int
-acl_fetch_srv_id(struct proxy *px, struct session *l4, void *l7, int dir,
+acl_fetch_srv_id(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp)
{
if (!target_srv(&l4->target))
@@ -1473,7 +1473,7 @@
* undefined behaviour.
*/
static int
-acl_fetch_be_sess_rate(struct proxy *px, struct session *l4, void *l7, int dir,
+acl_fetch_be_sess_rate(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp)
{
smp->flags = SMP_F_VOL_TEST;
@@ -1487,7 +1487,7 @@
* undefined behaviour.
*/
static int
-acl_fetch_be_conn(struct proxy *px, struct session *l4, void *l7, int dir,
+acl_fetch_be_conn(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp)
{
smp->flags = SMP_F_VOL_TEST;
@@ -1501,7 +1501,7 @@
* undefined behaviour.
*/
static int
-acl_fetch_queue_size(struct proxy *px, struct session *l4, void *l7, int dir,
+acl_fetch_queue_size(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp)
{
smp->flags = SMP_F_VOL_TEST;
@@ -1519,7 +1519,7 @@
* undefined behaviour.
*/
static int
-acl_fetch_avg_queue_size(struct proxy *px, struct session *l4, void *l7, int dir,
+acl_fetch_avg_queue_size(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp)
{
int nbsrv;
@@ -1548,7 +1548,7 @@
* undefined behaviour.
*/
static int
-acl_fetch_srv_conn(struct proxy *px, struct session *l4, void *l7, int dir,
+acl_fetch_srv_conn(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp)
{
smp->flags = SMP_F_VOL_TEST;