diff --git a/doc/configuration.txt b/doc/configuration.txt index 1a6fbcf92..af23d312c 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -6966,6 +6966,10 @@ be_conn(backend) 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 + Applies to the backend's id. Can be used in frontends to check from which + backend it was called. + be_sess_rate be_sess_rate(backend) Returns true when the sessions creation rate on the backend matches the @@ -7329,6 +7333,9 @@ src_updt_conn_cnt(table) tcp-request content reject if { src_update_count gt 3 } server local 127.0.0.1:22 +srv_id + Applies to the server's id. Can be used in frontends or backends. + srv_is_up() srv_is_up(/) 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 ff06d2c27..bd207496b 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1386,6 +1386,30 @@ acl_fetch_connslots(struct proxy *px, struct session *l4, void *l7, int dir, 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 @@ acl_fetch_avg_queue_size(struct proxy *px, struct session *l4, void *l7, int dir /* Note: must not be declared 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 }, }};