mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-14 15:34:35 +00:00
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.
This commit is contained in:
parent
e209797ef0
commit
5ec63e008d
@ -75,6 +75,7 @@ struct act_rule {
|
||||
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 @@ struct act_rule {
|
||||
|
||||
union {
|
||||
struct capture_prm cap;
|
||||
struct track_ctr_prm trk_ctr;
|
||||
} act_prm;
|
||||
};
|
||||
|
||||
|
@ -7539,31 +7539,31 @@ int check_config_validity()
|
||||
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 @@ int check_config_validity()
|
||||
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 @@ int check_config_validity()
|
||||
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 @@ out_uri_auth_compat:
|
||||
!(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;
|
||||
}
|
||||
|
||||
|
@ -3652,8 +3652,8 @@ resume_execution:
|
||||
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 @@ struct act_rule *parse_http_req_cond(const char **args, const char *file, int li
|
||||
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;
|
||||
|
@ -1190,8 +1190,8 @@ resume_execution:
|
||||
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 @@ int tcp_exec_req_rules(struct session *sess)
|
||||
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 @@ static int tcp_parse_request_rule(char **args, int arg, int section_type,
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user