[MINOR] acl: add be_id/srv_id to match backend's and server's id
These ones can be useful in responses.
diff --git a/doc/configuration.txt b/doc/configuration.txt
index 1a6fbcf..af23d31 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -6966,6 +6966,10 @@
backend. It can be used to use a specific farm when the nominal one is full.
See also the "fe_conn", "queue" and "be_sess_rate" criteria.
+be_id <integer>
+ Applies to the backend's id. Can be used in frontends to check from which
+ backend it was called.
+
be_sess_rate <integer>
be_sess_rate(backend) <integer>
Returns true when the sessions creation rate on the backend matches the
@@ -7329,6 +7333,9 @@
tcp-request content reject if { src_update_count gt 3 }
server local 127.0.0.1:22
+srv_id <integer>
+ Applies to the server's id. Can be used in frontends or backends.
+
srv_is_up(<server>)
srv_is_up(<backend>/<server>)
Returns true when the designated server is UP, and false when it is either
diff --git a/src/backend.c b/src/backend.c
index ff06d2c..bd20749 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -1386,6 +1386,30 @@
return 1;
}
+/* set test->i to the id of the backend */
+static int
+acl_fetch_be_id(struct proxy *px, struct session *l4, void *l7, int dir,
+ struct acl_expr *expr, struct acl_test *test) {
+
+ test->flags = ACL_TEST_F_READ_ONLY;
+
+ test->i = l4->be->uuid;
+
+ return 1;
+}
+
+/* set test->i to the id of the server */
+static int
+acl_fetch_srv_id(struct proxy *px, struct session *l4, void *l7, int dir,
+ struct acl_expr *expr, struct acl_test *test) {
+
+ test->flags = ACL_TEST_F_READ_ONLY;
+
+ test->i = l4->srv->puid;
+
+ return 1;
+}
+
/* set test->i to the number of connections per second reaching the backend */
static int
acl_fetch_be_sess_rate(struct proxy *px, struct session *l4, void *l7, int dir,
@@ -1482,13 +1506,15 @@
/* Note: must not be declared <const> as its list will be overwritten */
static struct acl_kw_list acl_kws = {{ },{
- { "nbsrv", acl_parse_int, acl_fetch_nbsrv, acl_match_int, ACL_USE_NOTHING },
- { "connslots", acl_parse_int, acl_fetch_connslots, acl_match_int, ACL_USE_NOTHING },
- { "be_sess_rate", acl_parse_int, acl_fetch_be_sess_rate, acl_match_int, ACL_USE_NOTHING },
- { "be_conn", acl_parse_int, acl_fetch_be_conn, acl_match_int, ACL_USE_NOTHING },
- { "queue", acl_parse_int, acl_fetch_queue_size, acl_match_int, ACL_USE_NOTHING },
- { "avg_queue", acl_parse_int, acl_fetch_avg_queue_size, acl_match_int, ACL_USE_NOTHING },
- { "srv_is_up", acl_parse_nothing, acl_fetch_srv_is_up, acl_match_nothing, ACL_USE_NOTHING },
+ { "nbsrv", acl_parse_int, acl_fetch_nbsrv, acl_match_int, ACL_USE_NOTHING },
+ { "connslots", acl_parse_int, acl_fetch_connslots, acl_match_int, ACL_USE_NOTHING },
+ { "be_id", acl_parse_int, acl_fetch_be_id, acl_match_int, ACL_USE_NOTHING },
+ { "be_sess_rate", acl_parse_int, acl_fetch_be_sess_rate, acl_match_int, ACL_USE_NOTHING },
+ { "be_conn", acl_parse_int, acl_fetch_be_conn, acl_match_int, ACL_USE_NOTHING },
+ { "queue", acl_parse_int, acl_fetch_queue_size, acl_match_int, ACL_USE_NOTHING },
+ { "avg_queue", acl_parse_int, acl_fetch_avg_queue_size, acl_match_int, ACL_USE_NOTHING },
+ { "srv_is_up", acl_parse_nothing, acl_fetch_srv_is_up, acl_match_nothing, ACL_USE_NOTHING },
+ { "srv_id", acl_parse_int, acl_fetch_srv_id, acl_match_int, ACL_USE_NOTHING },
{ NULL, NULL, NULL, NULL },
}};