[MINOR] session: add the trk_conn_cur ACL keyword to track concurrent connection
This one applies to the entry being tracked by current session.
diff --git a/src/session.c b/src/session.c
index 55a8066..b09caae 100644
--- a/src/session.c
+++ b/src/session.c
@@ -2083,7 +2083,6 @@
return 0; /* parameter not stored */
test->i = stktable_data_cast(ptr, conn_cnt);
}
-
return 1;
}
@@ -2160,6 +2159,33 @@
return 1;
}
+/* set test->i to the number of concurrent connections in the stksess entry <ts> */
+static int
+acl_fetch_conn_cur(struct stktable *table, struct acl_test *test, struct stksess *ts)
+{
+ test->flags = ACL_TEST_F_VOL_TEST;
+ test->i = 0;
+
+ if (ts != NULL) {
+ void *ptr = stktable_data_ptr(table, ts, STKTABLE_DT_CONN_CUR);
+ if (!ptr)
+ return 0; /* parameter not stored */
+ test->i = stktable_data_cast(ptr, conn_cur);
+ }
+ return 1;
+}
+
+/* set test->i to the number of concurrent connections from the session's tracked counters */
+static int
+acl_fetch_trk_conn_cur(struct proxy *px, struct session *l4, void *l7, int dir,
+ struct acl_expr *expr, struct acl_test *test)
+{
+ if (!l4->tracked_counters)
+ return 0;
+
+ return acl_fetch_conn_cur(l4->tracked_table, test, l4->tracked_counters);
+}
+
/* set test->i to the number of concurrent connections from the session's source
* address in the table pointed to by expr.
*/
@@ -2167,7 +2193,6 @@
acl_fetch_src_conn_cur(struct proxy *px, struct session *l4, void *l7, int dir,
struct acl_expr *expr, struct acl_test *test)
{
- struct stksess *ts;
struct stktable_key *key;
key = tcpv4_src_to_stktable_key(l4);
@@ -2180,17 +2205,7 @@
if (!px)
return 0; /* table not found */
- test->flags = ACL_TEST_F_VOL_TEST;
- test->i = 0;
-
- if ((ts = stktable_lookup_key(&px->table, key)) != NULL) {
- void *ptr = stktable_data_ptr(&px->table, ts, STKTABLE_DT_CONN_CUR);
- if (!ptr)
- return 0; /* parameter not stored */
- test->i = stktable_data_cast(ptr, conn_cur);
- }
-
- return 1;
+ return acl_fetch_conn_cnt(&px->table, test, stktable_lookup_key(&px->table, key));
}
/* set test->i to the number of kbytes received from the session's source
@@ -2265,6 +2280,7 @@
{ "trk_conn_cnt", acl_parse_int, acl_fetch_trk_conn_cnt, acl_match_int, ACL_USE_NOTHING },
{ "src_conn_cnt", acl_parse_int, acl_fetch_src_conn_cnt, acl_match_int, ACL_USE_TCP4_VOLATILE },
{ "src_updt_conn_cnt", acl_parse_int, acl_fetch_src_updt_conn_cnt, acl_match_int, ACL_USE_TCP4_VOLATILE },
+ { "trk_conn_cur", acl_parse_int, acl_fetch_trk_conn_cur, acl_match_int, ACL_USE_NOTHING },
{ "src_conn_cur", acl_parse_int, acl_fetch_src_conn_cur, acl_match_int, ACL_USE_TCP4_VOLATILE },
{ "src_kbytes_in", acl_parse_int, acl_fetch_src_kbytes_in, acl_match_int, ACL_USE_TCP4_VOLATILE },
{ "src_kbytes_out", acl_parse_int, acl_fetch_src_kbytes_out, acl_match_int, ACL_USE_TCP4_VOLATILE },