CLEANUP: session: use an array for the stick counters
The stick counters were in two distinct sets of struct members,
causing some code to be duplicated. Now we use an array, which
enables some processing to be performed in loops. This allowed
the code to be shrunk by 700 bytes.
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index de95d7f..12e92da 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -836,8 +836,8 @@
s->flags |= SN_FINST_R;
return 0;
}
- else if ((rule->action == TCP_ACT_TRK_SC1 && !s->stkctr1_entry) ||
- (rule->action == TCP_ACT_TRK_SC2 && !s->stkctr2_entry)) {
+ else if ((rule->action == TCP_ACT_TRK_SC1 && !s->stkctr[0].entry) ||
+ (rule->action == TCP_ACT_TRK_SC2 && !s->stkctr[1].entry)) {
/* Note: only the first valid tracking parameter of each
* applies.
*/
@@ -848,11 +848,11 @@
if (key && (ts = stktable_get_entry(t, key))) {
if (rule->action == TCP_ACT_TRK_SC1) {
- session_track_stkctr1(s, t, ts);
+ session_track_stkctr(&s->stkctr[0], t, ts);
if (s->fe != s->be)
s->flags |= SN_BE_TRACK_SC1;
} else {
- session_track_stkctr2(s, t, ts);
+ session_track_stkctr(&s->stkctr[1], t, ts);
if (s->fe != s->be)
s->flags |= SN_BE_TRACK_SC2;
}
@@ -996,8 +996,8 @@
result = 0;
break;
}
- else if ((rule->action == TCP_ACT_TRK_SC1 && !s->stkctr1_entry) ||
- (rule->action == TCP_ACT_TRK_SC2 && !s->stkctr2_entry)) {
+ else if ((rule->action == TCP_ACT_TRK_SC1 && !s->stkctr[0].entry) ||
+ (rule->action == TCP_ACT_TRK_SC2 && !s->stkctr[1].entry)) {
/* Note: only the first valid tracking parameter of each
* applies.
*/
@@ -1008,9 +1008,9 @@
if (key && (ts = stktable_get_entry(t, key))) {
if (rule->action == TCP_ACT_TRK_SC1)
- session_track_stkctr1(s, t, ts);
+ session_track_stkctr(&s->stkctr[0], t, ts);
else
- session_track_stkctr2(s, t, ts);
+ session_track_stkctr(&s->stkctr[1], t, ts);
}
}
else {