MEDIUM: track-sc: Move the track-sc configuration storage in the union
This patch moves the track-sc configuration struct (track_ctr_prm) in the main
"arg" union. This reduce the size od the struct.
diff --git a/include/types/action.h b/include/types/action.h
index 5cfcb57..570710b 100644
--- a/include/types/action.h
+++ b/include/types/action.h
@@ -75,6 +75,7 @@
const char *name;
enum vars_scope scope;
} vars;
+ struct track_ctr_prm trk_ctr;
struct {
void *p[4];
} act; /* generic pointers to be used by custom actions */
@@ -82,7 +83,6 @@
union {
struct capture_prm cap;
- struct track_ctr_prm trk_ctr;
} act_prm;
};
diff --git a/src/cfgparse.c b/src/cfgparse.c
index befecc2..8e7830e 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -7539,31 +7539,31 @@
if (trule->action < TCP_ACT_TRK_SC0 || trule->action > TCP_ACT_TRK_SCMAX)
continue;
- if (trule->act_prm.trk_ctr.table.n)
- target = proxy_tbl_by_name(trule->act_prm.trk_ctr.table.n);
+ if (trule->arg.trk_ctr.table.n)
+ target = proxy_tbl_by_name(trule->arg.trk_ctr.table.n);
else
target = curproxy;
if (!target) {
Alert("Proxy '%s': unable to find table '%s' referenced by track-sc%d.\n",
- curproxy->id, trule->act_prm.trk_ctr.table.n,
+ curproxy->id, trule->arg.trk_ctr.table.n,
tcp_trk_idx(trule->action));
cfgerr++;
}
else if (target->table.size == 0) {
Alert("Proxy '%s': table '%s' used but not configured.\n",
- curproxy->id, trule->act_prm.trk_ctr.table.n ? trule->act_prm.trk_ctr.table.n : curproxy->id);
+ curproxy->id, trule->arg.trk_ctr.table.n ? trule->arg.trk_ctr.table.n : curproxy->id);
cfgerr++;
}
- else if (!stktable_compatible_sample(trule->act_prm.trk_ctr.expr, target->table.type)) {
+ else if (!stktable_compatible_sample(trule->arg.trk_ctr.expr, target->table.type)) {
Alert("Proxy '%s': stick-table '%s' uses a type incompatible with the 'track-sc%d' rule.\n",
- curproxy->id, trule->act_prm.trk_ctr.table.n ? trule->act_prm.trk_ctr.table.n : curproxy->id,
+ curproxy->id, trule->arg.trk_ctr.table.n ? trule->arg.trk_ctr.table.n : curproxy->id,
tcp_trk_idx(trule->action));
cfgerr++;
}
else {
- free(trule->act_prm.trk_ctr.table.n);
- trule->act_prm.trk_ctr.table.t = &target->table;
+ free(trule->arg.trk_ctr.table.n);
+ trule->arg.trk_ctr.table.t = &target->table;
/* Note: if we decide to enhance the track-sc syntax, we may be able
* to pass a list of counters to track and allocate them right here using
* stktable_alloc_data_type().
@@ -7578,31 +7578,31 @@
if (trule->action < TCP_ACT_TRK_SC0 || trule->action > TCP_ACT_TRK_SCMAX)
continue;
- if (trule->act_prm.trk_ctr.table.n)
- target = proxy_tbl_by_name(trule->act_prm.trk_ctr.table.n);
+ if (trule->arg.trk_ctr.table.n)
+ target = proxy_tbl_by_name(trule->arg.trk_ctr.table.n);
else
target = curproxy;
if (!target) {
Alert("Proxy '%s': unable to find table '%s' referenced by track-sc%d.\n",
- curproxy->id, trule->act_prm.trk_ctr.table.n,
+ curproxy->id, trule->arg.trk_ctr.table.n,
tcp_trk_idx(trule->action));
cfgerr++;
}
else if (target->table.size == 0) {
Alert("Proxy '%s': table '%s' used but not configured.\n",
- curproxy->id, trule->act_prm.trk_ctr.table.n ? trule->act_prm.trk_ctr.table.n : curproxy->id);
+ curproxy->id, trule->arg.trk_ctr.table.n ? trule->arg.trk_ctr.table.n : curproxy->id);
cfgerr++;
}
- else if (!stktable_compatible_sample(trule->act_prm.trk_ctr.expr, target->table.type)) {
+ else if (!stktable_compatible_sample(trule->arg.trk_ctr.expr, target->table.type)) {
Alert("Proxy '%s': stick-table '%s' uses a type incompatible with the 'track-sc%d' rule.\n",
- curproxy->id, trule->act_prm.trk_ctr.table.n ? trule->act_prm.trk_ctr.table.n : curproxy->id,
+ curproxy->id, trule->arg.trk_ctr.table.n ? trule->arg.trk_ctr.table.n : curproxy->id,
tcp_trk_idx(trule->action));
cfgerr++;
}
else {
- free(trule->act_prm.trk_ctr.table.n);
- trule->act_prm.trk_ctr.table.t = &target->table;
+ free(trule->arg.trk_ctr.table.n);
+ trule->arg.trk_ctr.table.t = &target->table;
/* Note: if we decide to enhance the track-sc syntax, we may be able
* to pass a list of counters to track and allocate them right here using
* stktable_alloc_data_type().
@@ -7617,31 +7617,31 @@
if (hrqrule->action < HTTP_REQ_ACT_TRK_SC0 || hrqrule->action > HTTP_REQ_ACT_TRK_SCMAX)
continue;
- if (hrqrule->act_prm.trk_ctr.table.n)
- target = proxy_tbl_by_name(hrqrule->act_prm.trk_ctr.table.n);
+ if (hrqrule->arg.trk_ctr.table.n)
+ target = proxy_tbl_by_name(hrqrule->arg.trk_ctr.table.n);
else
target = curproxy;
if (!target) {
Alert("Proxy '%s': unable to find table '%s' referenced by track-sc%d.\n",
- curproxy->id, hrqrule->act_prm.trk_ctr.table.n,
+ curproxy->id, hrqrule->arg.trk_ctr.table.n,
http_req_trk_idx(hrqrule->action));
cfgerr++;
}
else if (target->table.size == 0) {
Alert("Proxy '%s': table '%s' used but not configured.\n",
- curproxy->id, hrqrule->act_prm.trk_ctr.table.n ? hrqrule->act_prm.trk_ctr.table.n : curproxy->id);
+ curproxy->id, hrqrule->arg.trk_ctr.table.n ? hrqrule->arg.trk_ctr.table.n : curproxy->id);
cfgerr++;
}
- else if (!stktable_compatible_sample(hrqrule->act_prm.trk_ctr.expr, target->table.type)) {
+ else if (!stktable_compatible_sample(hrqrule->arg.trk_ctr.expr, target->table.type)) {
Alert("Proxy '%s': stick-table '%s' uses a type incompatible with the 'track-sc%d' rule.\n",
- curproxy->id, hrqrule->act_prm.trk_ctr.table.n ? hrqrule->act_prm.trk_ctr.table.n : curproxy->id,
+ curproxy->id, hrqrule->arg.trk_ctr.table.n ? hrqrule->arg.trk_ctr.table.n : curproxy->id,
http_req_trk_idx(hrqrule->action));
cfgerr++;
}
else {
- free(hrqrule->act_prm.trk_ctr.table.n);
- hrqrule->act_prm.trk_ctr.table.t = &target->table;
+ free(hrqrule->arg.trk_ctr.table.n);
+ hrqrule->arg.trk_ctr.table.t = &target->table;
/* Note: if we decide to enhance the track-sc syntax, we may be able
* to pass a list of counters to track and allocate them right here using
* stktable_alloc_data_type().
@@ -8229,7 +8229,7 @@
!(trule->act_prm.cap.expr->fetch->val & SMP_VAL_FE_SES_ACC))
break;
if ((trule->action >= TCP_ACT_TRK_SC0 && trule->action <= TCP_ACT_TRK_SCMAX) &&
- !(trule->act_prm.trk_ctr.expr->fetch->val & SMP_VAL_FE_SES_ACC))
+ !(trule->arg.trk_ctr.expr->fetch->val & SMP_VAL_FE_SES_ACC))
break;
}
diff --git a/src/proto_http.c b/src/proto_http.c
index 5214d87..aa01361 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -3652,8 +3652,8 @@
struct stktable_key *key;
void *ptr;
- t = rule->act_prm.trk_ctr.table.t;
- key = stktable_fetch_key(t, s->be, sess, s, SMP_OPT_DIR_REQ | SMP_OPT_FINAL, rule->act_prm.trk_ctr.expr, NULL);
+ t = rule->arg.trk_ctr.table.t;
+ key = stktable_fetch_key(t, s->be, sess, s, SMP_OPT_DIR_REQ | SMP_OPT_FINAL, rule->arg.trk_ctr.expr, NULL);
if (key && (ts = stktable_get_entry(t, key))) {
stream_track_stkctr(&s->stkctr[http_req_trk_idx(rule->action)], t, ts);
@@ -9173,10 +9173,10 @@
goto out_err;
}
/* we copy the table name for now, it will be resolved later */
- rule->act_prm.trk_ctr.table.n = strdup(args[cur_arg]);
+ rule->arg.trk_ctr.table.n = strdup(args[cur_arg]);
cur_arg++;
}
- rule->act_prm.trk_ctr.expr = expr;
+ rule->arg.trk_ctr.expr = expr;
rule->action = HTTP_REQ_ACT_TRK_SC0 + args[0][8] - '0';
} else if (strcmp(args[0], "redirect") == 0) {
struct redirect_rule *redir;
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 34f936b..e95ca8c 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -1190,8 +1190,8 @@
if (stkctr_entry(&s->stkctr[tcp_trk_idx(rule->action)]))
continue;
- t = rule->act_prm.trk_ctr.table.t;
- key = stktable_fetch_key(t, s->be, sess, s, SMP_OPT_DIR_REQ | partial, rule->act_prm.trk_ctr.expr, &smp);
+ t = rule->arg.trk_ctr.table.t;
+ key = stktable_fetch_key(t, s->be, sess, s, SMP_OPT_DIR_REQ | partial, rule->arg.trk_ctr.expr, &smp);
if ((smp.flags & SMP_F_MAY_CHANGE) && !(partial & SMP_OPT_FINAL))
goto missing_data; /* key might appear later */
@@ -1428,8 +1428,8 @@
if (stkctr_entry(&sess->stkctr[tcp_trk_idx(rule->action)]))
continue;
- t = rule->act_prm.trk_ctr.table.t;
- key = stktable_fetch_key(t, sess->fe, sess, NULL, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, rule->act_prm.trk_ctr.expr, NULL);
+ t = rule->arg.trk_ctr.table.t;
+ key = stktable_fetch_key(t, sess->fe, sess, NULL, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, rule->arg.trk_ctr.expr, NULL);
if (key && (ts = stktable_get_entry(t, key)))
stream_track_stkctr(&sess->stkctr[tcp_trk_idx(rule->action)], t, ts);
@@ -1657,10 +1657,10 @@
return -1;
}
/* we copy the table name for now, it will be resolved later */
- rule->act_prm.trk_ctr.table.n = strdup(args[arg]);
+ rule->arg.trk_ctr.table.n = strdup(args[arg]);
arg++;
}
- rule->act_prm.trk_ctr.expr = expr;
+ rule->arg.trk_ctr.expr = expr;
rule->action = TCP_ACT_TRK_SC0 + args[kw][8] - '0';
}
else if (strcmp(args[arg], "expect-proxy") == 0) {