/************************************************************************/
/* set temp integer to the number of enabled servers on the proxy.
- * Accepts either 0 or 1 argument. Argument is a string, other types will lead to
+ * Accepts either 0 or 1 argument. Argument is a backend, other types will lead to
* undefined behaviour.
*/
static int
struct acl_expr *expr, struct acl_test *test)
{
test->flags = ACL_TEST_F_VOL_TEST;
- if (expr->args) {
- /* another proxy was designated, we must look for it */
- for (px = proxy; px; px = px->next)
- if ((px->cap & PR_CAP_BE) && !strcmp(px->id, expr->args->data.str.str))
- break;
- }
- if (!px)
- return 0;
+ if (expr->args)
+ px = expr->args->data.prx;
if (px->srv_act)
temp_pattern.data.integer = px->srv_act;
}
/* set temp integer to the number of enabled servers on the proxy.
- * Accepts either 0 or 1 argument. Argument is a string, other types will lead to
+ * Accepts either 0 or 1 argument. Argument is a backend, other types will lead to
* undefined behaviour.
*/
static int
struct acl_expr *expr, struct acl_test *test)
{
struct server *iterator;
+
test->flags = ACL_TEST_F_VOL_TEST;
- if (expr->args) {
- /* another proxy was designated, we must look for it */
- for (px = proxy; px; px = px->next)
- if ((px->cap & PR_CAP_BE) && !strcmp(px->id, expr->args->data.str.str))
- break;
- }
- if (!px)
- return 0;
+ if (expr->args)
+ px = expr->args->data.prx;
temp_pattern.data.integer = 0;
iterator = px->srv;
}
/* set temp integer to the number of connections per second reaching the backend.
- * Accepts either 0 or 1 argument. Argument is a string, other types will lead to
+ * Accepts either 0 or 1 argument. Argument is a backend, other types will lead to
* undefined behaviour.
*/
static int
struct acl_expr *expr, struct acl_test *test)
{
test->flags = ACL_TEST_F_VOL_TEST;
- if (expr->args) {
- /* another proxy was designated, we must look for it */
- for (px = proxy; px; px = px->next)
- if ((px->cap & PR_CAP_BE) && !strcmp(px->id, expr->args->data.str.str))
- break;
- }
- if (!px)
- return 0;
+ if (expr->args)
+ px = expr->args->data.prx;
temp_pattern.data.integer = read_freq_ctr(&px->be_sess_per_sec);
return 1;
}
/* set temp integer to the number of concurrent connections on the backend.
- * Accepts either 0 or 1 argument. Argument is a string, other types will lead to
+ * Accepts either 0 or 1 argument. Argument is a backend, other types will lead to
* undefined behaviour.
*/
static int
struct acl_expr *expr, struct acl_test *test)
{
test->flags = ACL_TEST_F_VOL_TEST;
- if (expr->args) {
- /* another proxy was designated, we must look for it */
- for (px = proxy; px; px = px->next)
- if ((px->cap & PR_CAP_BE) && !strcmp(px->id, expr->args->data.str.str))
- break;
- }
- if (!px)
- return 0;
+ if (expr->args)
+ px = expr->args->data.prx;
temp_pattern.data.integer = px->beconn;
return 1;
}
/* set temp integer to the total number of queued connections on the backend.
- * Accepts either 0 or 1 argument. Argument is a string, other types will lead to
+ * Accepts either 0 or 1 argument. Argument is a backend, other types will lead to
* undefined behaviour.
*/
static int
struct acl_expr *expr, struct acl_test *test)
{
test->flags = ACL_TEST_F_VOL_TEST;
- if (expr->args) {
- /* another proxy was designated, we must look for it */
- for (px = proxy; px; px = px->next)
- if ((px->cap & PR_CAP_BE) && !strcmp(px->id, expr->args->data.str.str))
- break;
- }
- if (!px)
- return 0;
+ if (expr->args)
+ px = expr->args->data.prx;
temp_pattern.data.integer = px->totpend;
return 1;
* server, we return twice the total, just as if we had half a running server.
* This is more or less correct anyway, since we expect the last server to come
* back soon.
- * Accepts either 0 or 1 argument. Argument is a string, other types will lead to
+ * Accepts either 0 or 1 argument. Argument is a backend, other types will lead to
* undefined behaviour.
*/
static int
int nbsrv;
test->flags = ACL_TEST_F_VOL_TEST;
- if (expr->args) {
- /* another proxy was designated, we must look for it */
- for (px = proxy; px; px = px->next)
- if ((px->cap & PR_CAP_BE) && !strcmp(px->id, expr->args->data.str.str))
- break;
- }
- if (!px)
- return 0;
+ if (expr->args)
+ px = expr->args->data.prx;
if (px->srv_act)
nbsrv = px->srv_act;
/*
* Session management functions.
*
- * Copyright 2000-2010 Willy Tarreau <w@1wt.eu>
+ * Copyright 2000-2012 Willy Tarreau <w@1wt.eu>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
/* set temp integer to the General Purpose Counter 0 value from the session's source
* address in the table pointed to by expr.
- * Accepts 0 or 1 argument of type string.
+ * Accepts 0 or 1 argument of type table.
*/
static int
acl_fetch_src_get_gpc0(struct proxy *px, struct session *l4, void *l7, int dir,
return 0;
if (expr->args)
- px = find_stktable(expr->args->data.str.str);
-
- if (!px)
- return 0; /* table not found */
+ px = expr->args->data.prx;
return acl_fetch_get_gpc0(&px->table, test, stktable_lookup_key(&px->table, key));
}
/* Increment the General Purpose Counter 0 value from the session's source
* address in the table pointed to by expr, and return it into temp integer.
- * Accepts 0 or 1 argument of type string.
+ * Accepts 0 or 1 argument of type table.
*/
static int
acl_fetch_src_inc_gpc0(struct proxy *px, struct session *l4, void *l7, int dir,
return 0;
if (expr->args)
- px = find_stktable(expr->args->data.str.str);
-
- if (!px)
- return 0; /* table not found */
+ px = expr->args->data.prx;
return acl_fetch_inc_gpc0(&px->table, test, stktable_update_key(&px->table, key));
}
/* Clear the General Purpose Counter 0 value from the session's source address
* in the table pointed to by expr, and return its previous value into temp integer.
- * Accepts 0 or 1 argument of type string.
+ * Accepts 0 or 1 argument of type table.
*/
static int
acl_fetch_src_clr_gpc0(struct proxy *px, struct session *l4, void *l7, int dir,
return 0;
if (expr->args)
- px = find_stktable(expr->args->data.str.str);
-
- if (!px)
- return 0; /* table not found */
+ px = expr->args->data.prx;
return acl_fetch_clr_gpc0(&px->table, test, stktable_update_key(&px->table, key));
}
/* set temp integer to the cumulated number of connections from the session's source
* address in the table pointed to by expr.
- * Accepts 0 or 1 argument of type string.
+ * Accepts 0 or 1 argument of type table.
*/
static int
acl_fetch_src_conn_cnt(struct proxy *px, struct session *l4, void *l7, int dir,
return 0;
if (expr->args)
- px = find_stktable(expr->args->data.str.str);
-
- if (!px)
- return 0; /* table not found */
+ px = expr->args->data.prx;
return acl_fetch_conn_cnt(&px->table, test, stktable_lookup_key(&px->table, key));
}
/* set temp integer to the connection rate from the session's source address in the
* table pointed to by expr, over the configured period.
- * Accepts 0 or 1 argument of type string.
+ * Accepts 0 or 1 argument of type table.
*/
static int
acl_fetch_src_conn_rate(struct proxy *px, struct session *l4, void *l7, int dir,
return 0;
if (expr->args)
- px = find_stktable(expr->args->data.str.str);
-
- if (!px)
- return 0; /* table not found */
+ px = expr->args->data.prx;
return acl_fetch_conn_rate(&px->table, test, stktable_lookup_key(&px->table, key));
}
/* set temp integer to the number of connections from the session's source address
* in the table pointed to by expr, after updating it.
- * Accepts 0 or 1 argument of type string.
+ * Accepts 0 or 1 argument of type table.
*/
static int
acl_fetch_src_updt_conn_cnt(struct proxy *px, struct session *l4, void *l7, int dir,
return 0;
if (expr->args)
- px = find_stktable(expr->args->data.str.str);
-
- if (!px)
- return 0; /* table not found */
+ px = expr->args->data.prx;
if ((ts = stktable_update_key(&px->table, key)) == NULL)
/* entry does not exist and could not be created */
/* set temp integer to the number of concurrent connections from the session's source
* address in the table pointed to by expr.
- * Accepts 0 or 1 argument of type string.
+ * Accepts 0 or 1 argument of type table.
*/
static int
acl_fetch_src_conn_cur(struct proxy *px, struct session *l4, void *l7, int dir,
return 0;
if (expr->args)
- px = find_stktable(expr->args->data.str.str);
-
- if (!px)
- return 0; /* table not found */
+ px = expr->args->data.prx;
return acl_fetch_conn_cur(&px->table, test, stktable_lookup_key(&px->table, key));
}
/* set temp integer to the cumulated number of session from the session's source
* address in the table pointed to by expr.
- * Accepts 0 or 1 argument of type string.
+ * Accepts 0 or 1 argument of type table.
*/
static int
acl_fetch_src_sess_cnt(struct proxy *px, struct session *l4, void *l7, int dir,
return 0;
if (expr->args)
- px = find_stktable(expr->args->data.str.str);
-
- if (!px)
- return 0; /* table not found */
+ px = expr->args->data.prx;
return acl_fetch_sess_cnt(&px->table, test, stktable_lookup_key(&px->table, key));
}
/* set temp integer to the session rate from the session's source address in the
* table pointed to by expr, over the configured period.
- * Accepts 0 or 1 argument of type string.
+ * Accepts 0 or 1 argument of type table.
*/
static int
acl_fetch_src_sess_rate(struct proxy *px, struct session *l4, void *l7, int dir,
return 0;
if (expr->args)
- px = find_stktable(expr->args->data.str.str);
-
- if (!px)
- return 0; /* table not found */
+ px = expr->args->data.prx;
return acl_fetch_sess_rate(&px->table, test, stktable_lookup_key(&px->table, key));
}
/* set temp integer to the cumulated number of session from the session's source
* address in the table pointed to by expr.
- * Accepts 0 or 1 argument of type string.
+ * Accepts 0 or 1 argument of type table.
*/
static int
acl_fetch_src_http_req_cnt(struct proxy *px, struct session *l4, void *l7, int dir,
return 0;
if (expr->args)
- px = find_stktable(expr->args->data.str.str);
-
- if (!px)
- return 0; /* table not found */
+ px = expr->args->data.prx;
return acl_fetch_http_req_cnt(&px->table, test, stktable_lookup_key(&px->table, key));
}
/* set temp integer to the session rate from the session's source address in the
* table pointed to by expr, over the configured period.
- * Accepts 0 or 1 argument of type string.
+ * Accepts 0 or 1 argument of type table.
*/
static int
acl_fetch_src_http_req_rate(struct proxy *px, struct session *l4, void *l7, int dir,
return 0;
if (expr->args)
- px = find_stktable(expr->args->data.str.str);
-
- if (!px)
- return 0; /* table not found */
+ px = expr->args->data.prx;
return acl_fetch_http_req_rate(&px->table, test, stktable_lookup_key(&px->table, key));
}
/* set temp integer to the cumulated number of session from the session's source
* address in the table pointed to by expr.
- * Accepts 0 or 1 argument of type string.
+ * Accepts 0 or 1 argument of type table.
*/
static int
acl_fetch_src_http_err_cnt(struct proxy *px, struct session *l4, void *l7, int dir,
return 0;
if (expr->args)
- px = find_stktable(expr->args->data.str.str);
-
- if (!px)
- return 0; /* table not found */
+ px = expr->args->data.prx;
return acl_fetch_http_err_cnt(&px->table, test, stktable_lookup_key(&px->table, key));
}
/* set temp integer to the session rate from the session's source address in the
* table pointed to by expr, over the configured period.
- * Accepts 0 or 1 argument of type string.
+ * Accepts 0 or 1 argument of type table.
*/
static int
acl_fetch_src_http_err_rate(struct proxy *px, struct session *l4, void *l7, int dir,
return 0;
if (expr->args)
- px = find_stktable(expr->args->data.str.str);
-
- if (!px)
- return 0; /* table not found */
+ px = expr->args->data.prx;
return acl_fetch_http_err_rate(&px->table, test, stktable_lookup_key(&px->table, key));
}
/* set temp integer to the number of kbytes received from the session's source
* address in the table pointed to by expr.
- * Accepts 0 or 1 argument of type string.
+ * Accepts 0 or 1 argument of type table.
*/
static int
acl_fetch_src_kbytes_in(struct proxy *px, struct session *l4, void *l7, int dir,
return 0;
if (expr->args)
- px = find_stktable(expr->args->data.str.str);
-
- if (!px)
- return 0; /* table not found */
+ px = expr->args->data.prx;
return acl_fetch_kbytes_in(&px->table, test, stktable_lookup_key(&px->table, key));
}
/* set temp integer to the bytes rate from clients from the session's source address
* in the table pointed to by expr, over the configured period.
- * Accepts 0 or 1 argument of type string.
+ * Accepts 0 or 1 argument of type table.
*/
static int
acl_fetch_src_bytes_in_rate(struct proxy *px, struct session *l4, void *l7, int dir,
return 0;
if (expr->args)
- px = find_stktable(expr->args->data.str.str);
-
- if (!px)
- return 0; /* table not found */
+ px = expr->args->data.prx;
return acl_fetch_bytes_in_rate(&px->table, test, stktable_lookup_key(&px->table, key));
}
/* set temp integer to the number of kbytes sent to the session's source address in
* the table pointed to by expr.
- * Accepts 0 or 1 argument of type string.
+ * Accepts 0 or 1 argument of type table.
*/
static int
acl_fetch_src_kbytes_out(struct proxy *px, struct session *l4, void *l7, int dir,
return 0;
if (expr->args)
- px = find_stktable(expr->args->data.str.str);
-
- if (!px)
- return 0; /* table not found */
+ px = expr->args->data.prx;
return acl_fetch_kbytes_out(&px->table, test, stktable_lookup_key(&px->table, key));
}
/* set temp integer to the bytes rate to client from the session's source address in
* the table pointed to by expr, over the configured period.
- * Accepts 0 or 1 argument of type string.
+ * Accepts 0 or 1 argument of type table.
*/
static int
acl_fetch_src_bytes_out_rate(struct proxy *px, struct session *l4, void *l7, int dir,
return 0;
if (expr->args)
- px = find_stktable(expr->args->data.str.str);
-
- if (!px)
- return 0; /* table not found */
+ px = expr->args->data.prx;
return acl_fetch_bytes_out_rate(&px->table, test, stktable_lookup_key(&px->table, key));
}
/* set temp integer to the number of used entries in the table pointed to by expr.
- * Accepts 0 or 1 argument of type string.
+ * Accepts 0 or 1 argument of type table.
*/
static int
acl_fetch_table_cnt(struct proxy *px, struct session *l4, void *l7, int dir,
struct acl_expr *expr, struct acl_test *test)
{
if (expr->args)
- px = find_stktable(expr->args->data.str.str);
-
- if (!px)
- return 0; /* table not found */
+ px = expr->args->data.prx;
test->flags = ACL_TEST_F_VOL_TEST;
temp_pattern.data.integer = px->table.current;
}
/* set temp integer to the number of free entries in the table pointed to by expr.
- * Accepts 0 or 1 argument of type string.
+ * Accepts 0 or 1 argument of type table.
*/
static int
acl_fetch_table_avl(struct proxy *px, struct session *l4, void *l7, int dir,
struct acl_expr *expr, struct acl_test *test)
{
if (expr->args)
- px = find_stktable(expr->args->data.str.str);
-
- if (!px)
- return 0; /* table not found */
+ px = expr->args->data.prx;
test->flags = ACL_TEST_F_VOL_TEST;
temp_pattern.data.integer = px->table.size - px->table.current;