[MAJOR] session: add track-counters to track counters related to the session
This patch adds the ability to set a pointer in the session to an
entry in a stick table which holds various counters related to a
specific pattern.
Right now the syntax matches the target syntax and only the "src"
pattern can be specified, to track counters related to the session's
IPv4 source address. There is a special function to extract it and
convert it to a key. But the goal is to be able to later support as
many patterns as for the stick rules, and get rid of the specific
function.
The "track-counters" directive may only be set in a "tcp-request"
statement right now. Only the first one applies. Probably that later
we'll support multi-criteria tracking for a single session and that
we'll have to name tracking pointers.
No counter is updated right now, only the refcount is. Some subsequent
patches will have to bring that feature.
diff --git a/include/types/session.h b/include/types/session.h
index fdccc7b..222c30f 100644
--- a/include/types/session.h
+++ b/include/types/session.h
@@ -184,7 +184,8 @@
int flags;
} store[8]; /* tracked stickiness values to store */
int store_count;
- struct stksess *tracked_src_counters; /* tracked counters for this source */
+ struct stksess *tracked_counters; /* counters currently being tracked by this session */
+ struct stktable *tracked_table; /* table the counters above belong to (undefined if counters are null) */
struct {
int logwait; /* log fields waiting to be collected : LW_* */
@@ -236,6 +237,15 @@
unsigned int uniq_id; /* unique ID used for the traces */
};
+/* parameters to configure tracked counters */
+struct track_ctr_prm {
+ int type; /* type of the key */
+ union {
+ struct stktable *t; /* a pointer to the table */
+ char *n; /* or its name during parsing. */
+ } table;
+};
+
#endif /* _TYPES_SESSION_H */