From 4fce0d844752fbdd5e4613f99b23727f4829fdd6 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 18 Sep 2017 11:57:31 +0200 Subject: [PATCH] MINOR: action: Use trk_idx instead of tcp/http_trk_idx So tcp_trk_idx and http_trk_idx have been removed. --- include/proto/proto_http.h | 8 -------- include/proto/tcp_rules.h | 8 -------- src/cfgparse.c | 21 +++++++++++---------- src/proto_http.c | 16 ++++++++-------- src/tcp_rules.c | 16 ++++++++-------- 5 files changed, 27 insertions(+), 42 deletions(-) diff --git a/include/proto/proto_http.h b/include/proto/proto_http.h index d046f536a..c4d16ae55 100644 --- a/include/proto/proto_http.h +++ b/include/proto/proto_http.h @@ -226,14 +226,6 @@ static inline int http_body_bytes(const struct http_msg *msg) return len; } -/* for an http-request/response action ACT_ACTION_TRK_SC*, return a tracking index - * starting at zero for SC0. Unknown actions also return zero. - */ -static inline int http_trk_idx(int trk_action) -{ - return trk_action - ACT_ACTION_TRK_SC0; -} - #endif /* _PROTO_PROTO_HTTP_H */ /* diff --git a/include/proto/tcp_rules.h b/include/proto/tcp_rules.h index 3aa62ab04..bf920a104 100644 --- a/include/proto/tcp_rules.h +++ b/include/proto/tcp_rules.h @@ -37,14 +37,6 @@ void tcp_req_sess_keywords_register(struct action_kw_list *kw_list); void tcp_req_cont_keywords_register(struct action_kw_list *kw_list); void tcp_res_cont_keywords_register(struct action_kw_list *kw_list); -/* for a tcp-request action ACT_TCP_TRK_*, return a tracking index starting at - * zero for SC0. Unknown actions also return zero. - */ -static inline int tcp_trk_idx(int trk_action) -{ - return trk_action - ACT_ACTION_TRK_SC0; -} - #endif /* _PROTO_TCP_RULES_H */ /* diff --git a/src/cfgparse.c b/src/cfgparse.c index ed74960a3..77b9b08ab 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -54,6 +54,7 @@ #include #include +#include #include #include #include @@ -7879,7 +7880,7 @@ int check_config_validity() if (!target) { Alert("Proxy '%s': unable to find table '%s' referenced by track-sc%d.\n", curproxy->id, trule->arg.trk_ctr.table.n, - tcp_trk_idx(trule->action)); + trk_idx(trule->action)); cfgerr++; } else if (target->table.size == 0) { @@ -7890,7 +7891,7 @@ int check_config_validity() 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->arg.trk_ctr.table.n ? trule->arg.trk_ctr.table.n : curproxy->id, - tcp_trk_idx(trule->action)); + trk_idx(trule->action)); cfgerr++; } else { @@ -7918,7 +7919,7 @@ int check_config_validity() if (!target) { Alert("Proxy '%s': unable to find table '%s' referenced by track-sc%d.\n", curproxy->id, trule->arg.trk_ctr.table.n, - tcp_trk_idx(trule->action)); + trk_idx(trule->action)); cfgerr++; } else if (target->table.size == 0) { @@ -7929,7 +7930,7 @@ int check_config_validity() 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->arg.trk_ctr.table.n ? trule->arg.trk_ctr.table.n : curproxy->id, - tcp_trk_idx(trule->action)); + trk_idx(trule->action)); cfgerr++; } else { @@ -7957,7 +7958,7 @@ int check_config_validity() if (!target) { Alert("Proxy '%s': unable to find table '%s' referenced by track-sc%d.\n", curproxy->id, trule->arg.trk_ctr.table.n, - tcp_trk_idx(trule->action)); + trk_idx(trule->action)); cfgerr++; } else if (target->table.size == 0) { @@ -7968,7 +7969,7 @@ int check_config_validity() 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->arg.trk_ctr.table.n ? trule->arg.trk_ctr.table.n : curproxy->id, - tcp_trk_idx(trule->action)); + trk_idx(trule->action)); cfgerr++; } else { @@ -8022,7 +8023,7 @@ int check_config_validity() if (!target) { Alert("Proxy '%s': unable to find table '%s' referenced by track-sc%d.\n", curproxy->id, hrqrule->arg.trk_ctr.table.n, - http_trk_idx(hrqrule->action)); + trk_idx(hrqrule->action)); cfgerr++; } else if (target->table.size == 0) { @@ -8033,7 +8034,7 @@ int check_config_validity() 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->arg.trk_ctr.table.n ? hrqrule->arg.trk_ctr.table.n : curproxy->id, - http_trk_idx(hrqrule->action)); + trk_idx(hrqrule->action)); cfgerr++; } else { @@ -8061,7 +8062,7 @@ int check_config_validity() if (!target) { Alert("Proxy '%s': unable to find table '%s' referenced by track-sc%d.\n", curproxy->id, hrqrule->arg.trk_ctr.table.n, - http_trk_idx(hrqrule->action)); + trk_idx(hrqrule->action)); cfgerr++; } else if (target->table.size == 0) { @@ -8072,7 +8073,7 @@ int check_config_validity() 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->arg.trk_ctr.table.n ? hrqrule->arg.trk_ctr.table.n : curproxy->id, - http_trk_idx(hrqrule->action)); + trk_idx(hrqrule->action)); cfgerr++; } else { diff --git a/src/proto_http.c b/src/proto_http.c index e632ce5fe..23f683c60 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -2717,7 +2717,7 @@ resume_execution: * applies. */ - if (stkctr_entry(&s->stkctr[http_trk_idx(rule->action)]) == NULL) { + if (stkctr_entry(&s->stkctr[trk_idx(rule->action)]) == NULL) { struct stktable *t; struct stksess *ts; struct stktable_key *key; @@ -2727,7 +2727,7 @@ resume_execution: 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_trk_idx(rule->action)], t, ts); + stream_track_stkctr(&s->stkctr[trk_idx(rule->action)], t, ts); /* let's count a new HTTP request as it's the first time we do it */ ptr = stktable_data_ptr(t, ts, STKTABLE_DT_HTTP_REQ_CNT); @@ -2739,9 +2739,9 @@ resume_execution: update_freq_ctr_period(&stktable_data_cast(ptr, http_req_rate), t->data_arg[STKTABLE_DT_HTTP_REQ_RATE].u, 1); - stkctr_set_flags(&s->stkctr[http_trk_idx(rule->action)], STKCTR_TRACK_CONTENT); + stkctr_set_flags(&s->stkctr[trk_idx(rule->action)], STKCTR_TRACK_CONTENT); if (sess->fe != s->be) - stkctr_set_flags(&s->stkctr[http_trk_idx(rule->action)], STKCTR_TRACK_BACKEND); + stkctr_set_flags(&s->stkctr[trk_idx(rule->action)], STKCTR_TRACK_BACKEND); } } break; @@ -2990,7 +2990,7 @@ resume_execution: * applies. */ - if (stkctr_entry(&s->stkctr[http_trk_idx(rule->action)]) == NULL) { + if (stkctr_entry(&s->stkctr[trk_idx(rule->action)]) == NULL) { struct stktable *t; struct stksess *ts; struct stktable_key *key; @@ -3000,7 +3000,7 @@ resume_execution: key = stktable_fetch_key(t, s->be, sess, s, SMP_OPT_DIR_RES | SMP_OPT_FINAL, rule->arg.trk_ctr.expr, NULL); if (key && (ts = stktable_get_entry(t, key))) { - stream_track_stkctr(&s->stkctr[http_trk_idx(rule->action)], t, ts); + stream_track_stkctr(&s->stkctr[trk_idx(rule->action)], t, ts); /* let's count a new HTTP request as it's the first time we do it */ ptr = stktable_data_ptr(t, ts, STKTABLE_DT_HTTP_REQ_CNT); @@ -3012,9 +3012,9 @@ resume_execution: update_freq_ctr_period(&stktable_data_cast(ptr, http_req_rate), t->data_arg[STKTABLE_DT_HTTP_REQ_RATE].u, 1); - stkctr_set_flags(&s->stkctr[http_trk_idx(rule->action)], STKCTR_TRACK_CONTENT); + stkctr_set_flags(&s->stkctr[trk_idx(rule->action)], STKCTR_TRACK_CONTENT); if (sess->fe != s->be) - stkctr_set_flags(&s->stkctr[http_trk_idx(rule->action)], STKCTR_TRACK_BACKEND); + stkctr_set_flags(&s->stkctr[trk_idx(rule->action)], STKCTR_TRACK_BACKEND); /* When the client triggers a 4xx from the server, it's most often due * to a missing object or permission. These events should be tracked diff --git a/src/tcp_rules.c b/src/tcp_rules.c index b87ab4b65..d15b153a8 100644 --- a/src/tcp_rules.c +++ b/src/tcp_rules.c @@ -184,7 +184,7 @@ resume_execution: struct stktable_key *key; struct sample smp; - if (stkctr_entry(&s->stkctr[tcp_trk_idx(rule->action)])) + if (stkctr_entry(&s->stkctr[trk_idx(rule->action)])) continue; t = rule->arg.trk_ctr.table.t; @@ -194,10 +194,10 @@ resume_execution: goto missing_data; /* key might appear later */ if (key && (ts = stktable_get_entry(t, key))) { - stream_track_stkctr(&s->stkctr[tcp_trk_idx(rule->action)], t, ts); - stkctr_set_flags(&s->stkctr[tcp_trk_idx(rule->action)], STKCTR_TRACK_CONTENT); + stream_track_stkctr(&s->stkctr[trk_idx(rule->action)], t, ts); + stkctr_set_flags(&s->stkctr[trk_idx(rule->action)], STKCTR_TRACK_CONTENT); if (sess->fe != s->be) - stkctr_set_flags(&s->stkctr[tcp_trk_idx(rule->action)], STKCTR_TRACK_BACKEND); + stkctr_set_flags(&s->stkctr[trk_idx(rule->action)], STKCTR_TRACK_BACKEND); } } else if (rule->action == ACT_TCP_CAPTURE) { @@ -440,14 +440,14 @@ int tcp_exec_l4_rules(struct session *sess) */ struct stktable_key *key; - if (stkctr_entry(&sess->stkctr[tcp_trk_idx(rule->action)])) + if (stkctr_entry(&sess->stkctr[trk_idx(rule->action)])) continue; 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); + stream_track_stkctr(&sess->stkctr[trk_idx(rule->action)], t, ts); } else if (rule->action == ACT_TCP_EXPECT_PX) { conn->flags |= CO_FL_ACCEPT_PROXY; @@ -527,14 +527,14 @@ int tcp_exec_l5_rules(struct session *sess) */ struct stktable_key *key; - if (stkctr_entry(&sess->stkctr[tcp_trk_idx(rule->action)])) + if (stkctr_entry(&sess->stkctr[trk_idx(rule->action)])) continue; 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); + stream_track_stkctr(&sess->stkctr[trk_idx(rule->action)], t, ts); } else { /* Custom keywords. */