]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: track-sc: Move the track-sc configuration storage in the union
authorThierry FOURNIER <tfournier@arpalert.org>
Tue, 4 Aug 2015 07:09:48 +0000 (09:09 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 20 Aug 2015 15:13:47 +0000 (17:13 +0200)
This patch moves the track-sc configuration struct (track_ctr_prm) in the main
"arg" union. This reduce the size od the struct.

include/types/action.h
src/cfgparse.c
src/proto_http.c
src/proto_tcp.c

index 5cfcb576b2ae1572b610bc7cf25537632994967a..570710b1be38e9f17147878da95e657d8882c7b1 100644 (file)
@@ -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;
 };
 
index befecc27195f7b247046adad639729e6c9b7c10e..8e7830ef12654ac8fed22e540b0eea51c0a44859 100644 (file)
@@ -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;
                        }
 
index 5214d873d96277387859650808ac793776ee7e2d..aa01361f9b2b850168c220608b3b8adafb1d2d21 100644 (file)
@@ -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;
index 34f936ba170b85a2474b8a5abb5add6bb8085c4b..e95ca8cd5b14ae37a3d6b01d9a3365eedbcd1d49 100644 (file)
@@ -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) {