#define MAX_HDR_HISTORY 10
#endif
+// max # of stick counters per session (at least 3 for sc0..sc2)
+// Some changes are needed in TCP_ACT_TRK_SC* and SN_BE_TRACK_SC* if more
+// values are required.
+#ifndef MAX_SESS_STKCTR
+#define MAX_SESS_STKCTR 3
+#endif
+
// max # of loops we can perform around a read() which succeeds.
// It's very frequent that the system returns a few TCP segments at a time.
#ifndef MAX_READ_POLL_LOOPS
void *ptr;
int i;
- for (i = 0; i < sizeof(s->stkctr) / sizeof(s->stkctr[0]); i++) {
+ for (i = 0; i < MAX_SESS_STKCTR; i++) {
if (!s->stkctr[i].entry)
continue;
ptr = stktable_data_ptr(s->stkctr[i].table, s->stkctr[i].entry, STKTABLE_DT_CONN_CUR);
if (likely(!(s->flags & SN_BE_TRACK_ANY)))
return;
- for (i = 0; i < sizeof(s->stkctr) / sizeof(s->stkctr[0]); i++) {
+ for (i = 0; i < MAX_SESS_STKCTR; i++) {
if (!s->stkctr[i].entry)
continue;
void *ptr;
int i;
- for (i = 0; i < sizeof(s->stkctr) / sizeof(s->stkctr[0]); i++) {
+ for (i = 0; i < MAX_SESS_STKCTR; i++) {
if (!s->stkctr[i].entry)
continue;
if (likely(!(s->flags & SN_BE_TRACK_ANY)))
return;
- for (i = 0; i < sizeof(s->stkctr) / sizeof(s->stkctr[0]); i++) {
+ for (i = 0; i < MAX_SESS_STKCTR; i++) {
if (!s->stkctr[i].entry)
continue;
void *ptr;
int i;
- for (i = 0; i < sizeof(s->stkctr) / sizeof(s->stkctr[0]); i++) {
+ for (i = 0; i < MAX_SESS_STKCTR; i++) {
if (!s->stkctr[i].entry)
continue;
TCP_ACT_ACCEPT = 1,
TCP_ACT_REJECT = 2,
TCP_ACT_EXPECT_PX = 3,
- TCP_ACT_TRK_SC0 = 4, /* TCP request tracking : must be contiguous */
+ TCP_ACT_TRK_SC0 = 4, /* TCP request tracking : must be contiguous and cover up to MAX_SESS_STKCTR values */
TCP_ACT_TRK_SC1 = 5,
TCP_ACT_TRK_SC2 = 6,
+ TCP_ACT_TRK_SCMAX = TCP_ACT_TRK_SC0 + MAX_SESS_STKCTR - 1,
};
struct tcp_rule {
#define SN_COMP_READY 0x00100000 /* the compression is initialized */
-/* session tracking flags: these ones must absolutely be contiguous. See also s->stkctr */
+/* session tracking flags: these ones must absolutely be contiguous and cover
+ * at least MAX_SESS_STKCTR flags.
+ */
#define SN_BE_TRACK_SC0 0x00200000 /* backend tracks stick-counter 0 */
#define SN_BE_TRACK_SC1 0x00400000 /* backend tracks stick-counter 1 */
#define SN_BE_TRACK_SC2 0x00800000 /* backend tracks stick-counter 2 */
} store[8]; /* tracked stickiness values to store */
int store_count;
- struct stkctr stkctr[3]; /* stick counters */
+ struct stkctr stkctr[MAX_SESS_STKCTR]; /* stick counters */
struct stream_interface si[2]; /* client and server stream interfaces */
struct {
list_for_each_entry(trule, &curproxy->tcp_req.l4_rules, list) {
struct proxy *target;
- if (trule->action < TCP_ACT_TRK_SC0 || trule->action > TCP_ACT_TRK_SC2)
+ if (trule->action < TCP_ACT_TRK_SC0 || trule->action > TCP_ACT_TRK_SCMAX)
continue;
if (trule->act_prm.trk_ctr.table.n)
list_for_each_entry(trule, &curproxy->tcp_req.inspect_rules, list) {
struct proxy *target;
- if (trule->action < TCP_ACT_TRK_SC0 || trule->action > TCP_ACT_TRK_SC2)
+ if (trule->action < TCP_ACT_TRK_SC0 || trule->action > TCP_ACT_TRK_SCMAX)
continue;
if (trule->act_prm.trk_ctr.table.n)
s->flags |= SN_FINST_R;
return 0;
}
- else if ((rule->action >= TCP_ACT_TRK_SC0 && rule->action <= TCP_ACT_TRK_SC2) &&
+ else if ((rule->action >= TCP_ACT_TRK_SC0 && rule->action <= TCP_ACT_TRK_SCMAX) &&
!s->stkctr[tcp_trk_idx(rule->action)].entry) {
/* Note: only the first valid tracking parameter of each
* applies.
result = 0;
break;
}
- else if ((rule->action >= TCP_ACT_TRK_SC0 && rule->action <= TCP_ACT_TRK_SC2) &&
+ else if ((rule->action >= TCP_ACT_TRK_SC0 && rule->action <= TCP_ACT_TRK_SCMAX) &&
!s->stkctr[tcp_trk_idx(rule->action)].entry) {
/* Note: only the first valid tracking parameter of each
* applies.
arg++;
rule->action = TCP_ACT_REJECT;
}
- else if (strcmp(args[arg], "track-sc0") == 0 || strcmp(args[arg], "track-sc1") == 0 || strcmp(args[arg], "track-sc2") == 0) {
+ else if (strncmp(args[arg], "track-sc", 8) == 0 &&
+ args[arg][9] == '\0' && args[arg][8] >= '0' &&
+ args[arg][8] <= '0' + MAX_SESS_STKCTR) { /* track-sc 0..9 */
struct sample_expr *expr;
int kw = arg;
}
else {
memprintf(err,
- "'%s %s' expects 'accept', 'reject', 'track-sc0', 'track-sc1' "
- " or 'track-sc2' in %s '%s' (got '%s')",
- args[0], args[1], proxy_type_str(curpx), curpx->id, args[arg]);
+ "'%s %s' expects 'accept', 'reject', 'track-sc0' ... 'track-sc%d' "
+ " in %s '%s' (got '%s')",
+ args[0], args[1], MAX_SESS_STKCTR, proxy_type_str(curpx), curpx->id, args[arg]);
return -1;
}
/* Let's count a session now */
proxy_inc_fe_sess_ctr(l, p);
- for (i = 0; i < sizeof(s->stkctr) / sizeof(s->stkctr[0]); i++) {
+ for (i = 0; i < MAX_SESS_STKCTR; i++) {
void *ptr;
if (!s->stkctr[i].entry)
if (s->listener->counters)
s->listener->counters->bytes_in += bytes;
- for (i = 0; i < sizeof(s->stkctr) / sizeof(s->stkctr[0]); i++) {
+ for (i = 0; i < MAX_SESS_STKCTR; i++) {
if (!s->stkctr[i].entry)
continue;
if (s->listener->counters)
s->listener->counters->bytes_out += bytes;
- for (i = 0; i < sizeof(s->stkctr) / sizeof(s->stkctr[0]); i++) {
+ for (i = 0; i < MAX_SESS_STKCTR; i++) {
if (!s->stkctr[i].entry)
continue;