mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-20 21:31:28 +02:00
MEDIUM: stats: consider that shared stats pointers may be NULL
This patch looks huge, but it has a very simple goal: protect all accessed to shared stats pointers (either read or writes), because we know consider that these pointers may be NULL. The reason behind this is despite all precautions taken to ensure the pointers shouldn't be NULL when not expected, there are still corner cases (ie: frontends stats used on a backend which no FE cap and vice versa) where we could try to access a memory area which is not allocated. Willy stumbled on such cases while playing with the rings servers upon connection error, which eventually led to process crashes (since 3.3 when shared stats were implemented) Also, we may decide later that shared stats are optional and should be disabled on the proxy to save memory and CPU, and this patch is a step further towards that goal. So in essence, this patch ensures shared stats pointers are always initialized (including NULL), and adds necessary guards before shared stats pointers are de-referenced. Since we already had some checks for backends and listeners stats, and the pointer address retrieval should stay in cpu cache, let's hope that this patch doesn't impact stats performance much.
This commit is contained in:
parent
40eb1dd135
commit
5c299dee5a
@ -86,7 +86,8 @@ static inline int be_usable_srv(struct proxy *be)
|
||||
/* set the time of last session on the backend */
|
||||
static inline void be_set_sess_last(struct proxy *be)
|
||||
{
|
||||
HA_ATOMIC_STORE(&be->be_counters.shared.tg[tgid - 1]->last_sess, ns_to_sec(now_ns));
|
||||
if (be->be_counters.shared.tg[tgid - 1])
|
||||
HA_ATOMIC_STORE(&be->be_counters.shared.tg[tgid - 1]->last_sess, ns_to_sec(now_ns));
|
||||
}
|
||||
|
||||
/* This function returns non-zero if the designated server will be
|
||||
|
@ -47,7 +47,7 @@ void counters_be_shared_drop(struct be_counters_shared *counters);
|
||||
unsigned long now_seconds = ns_to_sec(now_ns); \
|
||||
int it; \
|
||||
\
|
||||
for (it = 1; it < global.nbtgroups; it++) { \
|
||||
for (it = 1; (it < global.nbtgroups && scounters[it]); it++) { \
|
||||
unsigned long cur = HA_ATOMIC_LOAD((type *)((char *)scounters[it] + offset));\
|
||||
if ((now_seconds - cur) < (now_seconds - last)) \
|
||||
last = cur; \
|
||||
@ -74,7 +74,7 @@ void counters_be_shared_drop(struct be_counters_shared *counters);
|
||||
uint64_t __ret = 0; \
|
||||
int it; \
|
||||
\
|
||||
for (it = 0; it < global.nbtgroups; it++) \
|
||||
for (it = 0; (it < global.nbtgroups && scounters[it]); it++) \
|
||||
__ret += rfunc((type *)((char *)scounters[it] + offset)); \
|
||||
__ret; \
|
||||
})
|
||||
@ -94,7 +94,7 @@ void counters_be_shared_drop(struct be_counters_shared *counters);
|
||||
uint64_t __ret = 0; \
|
||||
int it; \
|
||||
\
|
||||
for (it = 0; it < global.nbtgroups; it++) \
|
||||
for (it = 0; (it < global.nbtgroups && scounters[it]); it++) \
|
||||
__ret += rfunc(&scounters[it]->elem, arg1, arg2); \
|
||||
__ret; \
|
||||
})
|
||||
|
@ -144,10 +144,12 @@ static inline void proxy_reset_timeouts(struct proxy *proxy)
|
||||
/* increase the number of cumulated connections received on the designated frontend */
|
||||
static inline void proxy_inc_fe_conn_ctr(struct listener *l, struct proxy *fe)
|
||||
{
|
||||
_HA_ATOMIC_INC(&fe->fe_counters.shared.tg[tgid - 1]->cum_conn);
|
||||
if (l && l->counters)
|
||||
if (fe->fe_counters.shared.tg[tgid - 1])
|
||||
_HA_ATOMIC_INC(&fe->fe_counters.shared.tg[tgid - 1]->cum_conn);
|
||||
if (l && l->counters && l->counters->shared.tg[tgid - 1])
|
||||
_HA_ATOMIC_INC(&l->counters->shared.tg[tgid - 1]->cum_conn);
|
||||
update_freq_ctr(&fe->fe_counters.shared.tg[tgid - 1]->conn_per_sec, 1);
|
||||
if (fe->fe_counters.shared.tg[tgid - 1])
|
||||
update_freq_ctr(&fe->fe_counters.shared.tg[tgid - 1]->conn_per_sec, 1);
|
||||
HA_ATOMIC_UPDATE_MAX(&fe->fe_counters.cps_max,
|
||||
update_freq_ctr(&fe->fe_counters._conn_per_sec, 1));
|
||||
}
|
||||
@ -155,11 +157,12 @@ static inline void proxy_inc_fe_conn_ctr(struct listener *l, struct proxy *fe)
|
||||
/* increase the number of cumulated connections accepted by the designated frontend */
|
||||
static inline void proxy_inc_fe_sess_ctr(struct listener *l, struct proxy *fe)
|
||||
{
|
||||
|
||||
_HA_ATOMIC_INC(&fe->fe_counters.shared.tg[tgid - 1]->cum_sess);
|
||||
if (l && l->counters)
|
||||
if (fe->fe_counters.shared.tg[tgid - 1])
|
||||
_HA_ATOMIC_INC(&fe->fe_counters.shared.tg[tgid - 1]->cum_sess);
|
||||
if (l && l->counters && l->counters->shared.tg[tgid - 1])
|
||||
_HA_ATOMIC_INC(&l->counters->shared.tg[tgid - 1]->cum_sess);
|
||||
update_freq_ctr(&fe->fe_counters.shared.tg[tgid - 1]->sess_per_sec, 1);
|
||||
if (fe->fe_counters.shared.tg[tgid - 1])
|
||||
update_freq_ctr(&fe->fe_counters.shared.tg[tgid - 1]->sess_per_sec, 1);
|
||||
HA_ATOMIC_UPDATE_MAX(&fe->fe_counters.sps_max,
|
||||
update_freq_ctr(&fe->fe_counters._sess_per_sec, 1));
|
||||
}
|
||||
@ -174,16 +177,19 @@ static inline void proxy_inc_fe_cum_sess_ver_ctr(struct listener *l, struct prox
|
||||
http_ver > sizeof(fe->fe_counters.shared.tg[tgid - 1]->cum_sess_ver) / sizeof(*fe->fe_counters.shared.tg[tgid - 1]->cum_sess_ver))
|
||||
return;
|
||||
|
||||
_HA_ATOMIC_INC(&fe->fe_counters.shared.tg[tgid - 1]->cum_sess_ver[http_ver - 1]);
|
||||
if (l && l->counters)
|
||||
if (fe->fe_counters.shared.tg[tgid - 1])
|
||||
_HA_ATOMIC_INC(&fe->fe_counters.shared.tg[tgid - 1]->cum_sess_ver[http_ver - 1]);
|
||||
if (l && l->counters && l->counters->shared.tg[tgid - 1])
|
||||
_HA_ATOMIC_INC(&l->counters->shared.tg[tgid - 1]->cum_sess_ver[http_ver - 1]);
|
||||
}
|
||||
|
||||
/* increase the number of cumulated streams on the designated backend */
|
||||
static inline void proxy_inc_be_ctr(struct proxy *be)
|
||||
{
|
||||
_HA_ATOMIC_INC(&be->be_counters.shared.tg[tgid - 1]->cum_sess);
|
||||
update_freq_ctr(&be->be_counters.shared.tg[tgid - 1]->sess_per_sec, 1);
|
||||
if (be->be_counters.shared.tg[tgid - 1])
|
||||
_HA_ATOMIC_INC(&be->be_counters.shared.tg[tgid - 1]->cum_sess);
|
||||
if (be->be_counters.shared.tg[tgid - 1])
|
||||
update_freq_ctr(&be->be_counters.shared.tg[tgid - 1]->sess_per_sec, 1);
|
||||
HA_ATOMIC_UPDATE_MAX(&be->be_counters.sps_max,
|
||||
update_freq_ctr(&be->be_counters._sess_per_sec, 1));
|
||||
}
|
||||
@ -198,10 +204,12 @@ static inline void proxy_inc_fe_req_ctr(struct listener *l, struct proxy *fe,
|
||||
if (http_ver >= sizeof(fe->fe_counters.shared.tg[tgid - 1]->p.http.cum_req) / sizeof(*fe->fe_counters.shared.tg[tgid - 1]->p.http.cum_req))
|
||||
return;
|
||||
|
||||
_HA_ATOMIC_INC(&fe->fe_counters.shared.tg[tgid - 1]->p.http.cum_req[http_ver]);
|
||||
if (l && l->counters)
|
||||
if (fe->fe_counters.shared.tg[tgid - 1])
|
||||
_HA_ATOMIC_INC(&fe->fe_counters.shared.tg[tgid - 1]->p.http.cum_req[http_ver]);
|
||||
if (l && l->counters && l->counters->shared.tg[tgid - 1])
|
||||
_HA_ATOMIC_INC(&l->counters->shared.tg[tgid - 1]->p.http.cum_req[http_ver]);
|
||||
update_freq_ctr(&fe->fe_counters.shared.tg[tgid - 1]->req_per_sec, 1);
|
||||
if (fe->fe_counters.shared.tg[tgid - 1])
|
||||
update_freq_ctr(&fe->fe_counters.shared.tg[tgid - 1]->req_per_sec, 1);
|
||||
HA_ATOMIC_UPDATE_MAX(&fe->fe_counters.p.http.rps_max,
|
||||
update_freq_ctr(&fe->fe_counters.p.http._req_per_sec, 1));
|
||||
}
|
||||
|
@ -207,8 +207,10 @@ static inline void server_index_id(struct proxy *px, struct server *srv)
|
||||
/* increase the number of cumulated streams on the designated server */
|
||||
static inline void srv_inc_sess_ctr(struct server *s)
|
||||
{
|
||||
_HA_ATOMIC_INC(&s->counters.shared.tg[tgid - 1]->cum_sess);
|
||||
update_freq_ctr(&s->counters.shared.tg[tgid - 1]->sess_per_sec, 1);
|
||||
if (s->counters.shared.tg[tgid - 1]) {
|
||||
_HA_ATOMIC_INC(&s->counters.shared.tg[tgid - 1]->cum_sess);
|
||||
update_freq_ctr(&s->counters.shared.tg[tgid - 1]->sess_per_sec, 1);
|
||||
}
|
||||
HA_ATOMIC_UPDATE_MAX(&s->counters.sps_max,
|
||||
update_freq_ctr(&s->counters._sess_per_sec, 1));
|
||||
}
|
||||
@ -216,7 +218,8 @@ static inline void srv_inc_sess_ctr(struct server *s)
|
||||
/* set the time of last session on the designated server */
|
||||
static inline void srv_set_sess_last(struct server *s)
|
||||
{
|
||||
HA_ATOMIC_STORE(&s->counters.shared.tg[tgid - 1]->last_sess, ns_to_sec(now_ns));
|
||||
if (s->counters.shared.tg[tgid - 1])
|
||||
HA_ATOMIC_STORE(&s->counters.shared.tg[tgid - 1]->last_sess, ns_to_sec(now_ns));
|
||||
}
|
||||
|
||||
/* returns the current server throttle rate between 0 and 100% */
|
||||
|
@ -361,9 +361,10 @@ static inline void stream_choose_redispatch(struct stream *s)
|
||||
s->flags &= ~(SF_DIRECT | SF_ASSIGNED);
|
||||
s->scb->state = SC_ST_REQ;
|
||||
} else {
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->retries);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->retries);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->retries);
|
||||
s->scb->state = SC_ST_ASS;
|
||||
}
|
||||
|
||||
|
@ -825,8 +825,10 @@ int assign_server(struct stream *s)
|
||||
goto out;
|
||||
}
|
||||
else if (srv != prev_srv) {
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->cum_lbconn);
|
||||
_HA_ATOMIC_INC(&srv->counters.shared.tg[tgid - 1]->cum_lbconn);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->cum_lbconn);
|
||||
if (srv->counters.shared.tg[tgid - 1])
|
||||
_HA_ATOMIC_INC(&srv->counters.shared.tg[tgid - 1]->cum_lbconn);
|
||||
}
|
||||
stream_set_srv_target(s, srv);
|
||||
}
|
||||
@ -1000,11 +1002,15 @@ int assign_server_and_queue(struct stream *s)
|
||||
s->txn->flags |= TX_CK_DOWN;
|
||||
}
|
||||
s->flags |= SF_REDISP;
|
||||
_HA_ATOMIC_INC(&prev_srv->counters.shared.tg[tgid - 1]->redispatches);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->redispatches);
|
||||
if (prev_srv->counters.shared.tg[tgid - 1])
|
||||
_HA_ATOMIC_INC(&prev_srv->counters.shared.tg[tgid - 1]->redispatches);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->redispatches);
|
||||
} else {
|
||||
_HA_ATOMIC_INC(&prev_srv->counters.shared.tg[tgid - 1]->retries);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->retries);
|
||||
if (prev_srv->counters.shared.tg[tgid - 1])
|
||||
_HA_ATOMIC_INC(&prev_srv->counters.shared.tg[tgid - 1]->retries);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->retries);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2119,12 +2125,14 @@ int connect_server(struct stream *s)
|
||||
s->scb->flags |= SC_FL_NOLINGER;
|
||||
|
||||
if (s->flags & SF_SRV_REUSED) {
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->reuse);
|
||||
if (srv)
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->reuse);
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->reuse);
|
||||
} else {
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->connect);
|
||||
if (srv)
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->connect);
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->connect);
|
||||
}
|
||||
|
||||
@ -2316,8 +2324,10 @@ int srv_redispatch_connect(struct stream *s)
|
||||
s->conn_err_type = STRM_ET_QUEUE_ERR;
|
||||
}
|
||||
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_conns);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_conns);
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_conns);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_conns);
|
||||
return 1;
|
||||
|
||||
case SRV_STATUS_NOSRV:
|
||||
@ -2326,7 +2336,8 @@ int srv_redispatch_connect(struct stream *s)
|
||||
s->conn_err_type = STRM_ET_CONN_ERR;
|
||||
}
|
||||
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_conns);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_conns);
|
||||
return 1;
|
||||
|
||||
case SRV_STATUS_QUEUED:
|
||||
@ -2354,9 +2365,10 @@ int srv_redispatch_connect(struct stream *s)
|
||||
srv_inc_sess_ctr(srv);
|
||||
if (srv)
|
||||
srv_set_sess_last(srv);
|
||||
if (srv)
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_conns);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_conns);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_conns);
|
||||
|
||||
/* release other streams waiting for this server */
|
||||
if (may_dequeue_tasks(srv, s->be))
|
||||
@ -2429,9 +2441,10 @@ void back_try_conn_req(struct stream *s)
|
||||
srv_inc_sess_ctr(srv);
|
||||
if (srv)
|
||||
srv_set_sess_last(srv);
|
||||
if (srv)
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_conns);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_conns);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_conns);
|
||||
|
||||
/* release other streams waiting for this server */
|
||||
sess_change_server(s, NULL);
|
||||
@ -2496,9 +2509,10 @@ void back_try_conn_req(struct stream *s)
|
||||
/* we may need to know the position in the queue for logging */
|
||||
pendconn_cond_unlink(s->pend_pos);
|
||||
|
||||
if (srv)
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_conns);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_conns);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_conns);
|
||||
sc_abort(sc);
|
||||
sc_shutdown(sc);
|
||||
req->flags |= CF_WRITE_TIMEOUT;
|
||||
@ -2752,9 +2766,10 @@ void back_handle_st_cer(struct stream *s)
|
||||
s->conn_err_type = STRM_ET_CONN_ERR;
|
||||
}
|
||||
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_conns);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_conns);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_conns);
|
||||
sess_change_server(s, NULL);
|
||||
if (may_dequeue_tasks(objt_server(s->target), s->be))
|
||||
process_srv_queue(objt_server(s->target));
|
||||
@ -2785,9 +2800,10 @@ void back_handle_st_cer(struct stream *s)
|
||||
if (!s->conn_err_type)
|
||||
s->conn_err_type = STRM_ET_CONN_OTHER;
|
||||
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->internal_errors);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->internal_errors);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->internal_errors);
|
||||
sess_change_server(s, NULL);
|
||||
if (may_dequeue_tasks(objt_server(s->target), s->be))
|
||||
process_srv_queue(objt_server(s->target));
|
||||
|
24
src/cache.c
24
src/cache.c
@ -2132,10 +2132,14 @@ enum act_return http_action_req_cache_use(struct act_rule *rule, struct proxy *p
|
||||
if (s->txn->flags & TX_CACHE_IGNORE)
|
||||
return ACT_RET_CONT;
|
||||
|
||||
if (px == strm_fe(s))
|
||||
_HA_ATOMIC_INC(&px->fe_counters.shared.tg[tgid - 1]->p.http.cache_lookups);
|
||||
else
|
||||
_HA_ATOMIC_INC(&px->be_counters.shared.tg[tgid - 1]->p.http.cache_lookups);
|
||||
if (px == strm_fe(s)) {
|
||||
if (px->fe_counters.shared.tg[tgid - 1])
|
||||
_HA_ATOMIC_INC(&px->fe_counters.shared.tg[tgid - 1]->p.http.cache_lookups);
|
||||
}
|
||||
else {
|
||||
if (px->be_counters.shared.tg[tgid - 1])
|
||||
_HA_ATOMIC_INC(&px->be_counters.shared.tg[tgid - 1]->p.http.cache_lookups);
|
||||
}
|
||||
|
||||
cache_tree = get_cache_tree_from_hash(cache, read_u32(s->txn->cache_hash));
|
||||
|
||||
@ -2221,10 +2225,14 @@ enum act_return http_action_req_cache_use(struct act_rule *rule, struct proxy *p
|
||||
ctx->send_notmodified =
|
||||
should_send_notmodified_response(cache, htxbuf(&s->req.buf), res);
|
||||
|
||||
if (px == strm_fe(s))
|
||||
_HA_ATOMIC_INC(&px->fe_counters.shared.tg[tgid - 1]->p.http.cache_hits);
|
||||
else
|
||||
_HA_ATOMIC_INC(&px->be_counters.shared.tg[tgid - 1]->p.http.cache_hits);
|
||||
if (px == strm_fe(s)) {
|
||||
if (px->fe_counters.shared.tg[tgid - 1])
|
||||
_HA_ATOMIC_INC(&px->fe_counters.shared.tg[tgid - 1]->p.http.cache_hits);
|
||||
}
|
||||
else {
|
||||
if (px->be_counters.shared.tg[tgid - 1])
|
||||
_HA_ATOMIC_INC(&px->be_counters.shared.tg[tgid - 1]->p.http.cache_hits);
|
||||
}
|
||||
return ACT_RET_CONT;
|
||||
} else {
|
||||
s->target = NULL;
|
||||
|
@ -513,7 +513,8 @@ void set_server_check_status(struct check *check, short status, const char *desc
|
||||
if ((!(check->state & CHK_ST_AGENT) ||
|
||||
(check->status >= HCHK_STATUS_L57DATA)) &&
|
||||
(check->health > 0)) {
|
||||
_HA_ATOMIC_INC(&s->counters.shared.tg[tgid - 1]->failed_checks);
|
||||
if (s->counters.shared.tg[tgid - 1])
|
||||
_HA_ATOMIC_INC(&s->counters.shared.tg[tgid - 1]->failed_checks);
|
||||
report = 1;
|
||||
check->health--;
|
||||
if (check->health < check->rise)
|
||||
@ -740,7 +741,8 @@ void __health_adjust(struct server *s, short status)
|
||||
HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
|
||||
|
||||
HA_ATOMIC_STORE(&s->consecutive_errors, 0);
|
||||
_HA_ATOMIC_INC(&s->counters.shared.tg[tgid - 1]->failed_hana);
|
||||
if (s->counters.shared.tg[tgid - 1])
|
||||
_HA_ATOMIC_INC(&s->counters.shared.tg[tgid - 1]->failed_hana);
|
||||
|
||||
if (s->check.fastinter) {
|
||||
/* timer might need to be advanced, it might also already be
|
||||
|
@ -446,11 +446,13 @@ static int fcgi_flt_http_headers(struct stream *s, struct filter *filter, struct
|
||||
goto end;
|
||||
|
||||
rewrite_err:
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_rewrites);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_rewrites);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_rewrites);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_rewrites);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->failed_rewrites);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_rewrites);
|
||||
hdr_rule_err:
|
||||
node = ebpt_first(&hdr_rules);
|
||||
|
@ -393,14 +393,20 @@ comp_http_payload(struct stream *s, struct filter *filter, struct http_msg *msg,
|
||||
|
||||
if (st->comp_ctx[dir] && st->comp_ctx[dir]->cur_lvl > 0) {
|
||||
update_freq_ctr(&global.comp_bps_in, consumed);
|
||||
_HA_ATOMIC_ADD(&s->sess->fe_tgcounters->comp_in[dir], consumed);
|
||||
_HA_ATOMIC_ADD(&s->be_tgcounters->comp_in[dir], consumed);
|
||||
if (s->sess->fe_tgcounters) {
|
||||
_HA_ATOMIC_ADD(&s->sess->fe_tgcounters->comp_in[dir], consumed);
|
||||
_HA_ATOMIC_ADD(&s->sess->fe_tgcounters->comp_out[dir], to_forward);
|
||||
}
|
||||
if (s->be_tgcounters) {
|
||||
_HA_ATOMIC_ADD(&s->be_tgcounters->comp_in[dir], consumed);
|
||||
_HA_ATOMIC_ADD(&s->be_tgcounters->comp_out[dir], to_forward);
|
||||
}
|
||||
update_freq_ctr(&global.comp_bps_out, to_forward);
|
||||
_HA_ATOMIC_ADD(&s->sess->fe_tgcounters->comp_out[dir], to_forward);
|
||||
_HA_ATOMIC_ADD(&s->be_tgcounters->comp_out[dir], to_forward);
|
||||
} else {
|
||||
_HA_ATOMIC_ADD(&s->sess->fe_tgcounters->comp_byp[dir], consumed);
|
||||
_HA_ATOMIC_ADD(&s->be_tgcounters->comp_byp[dir], consumed);
|
||||
if (s->sess->fe_tgcounters)
|
||||
_HA_ATOMIC_ADD(&s->sess->fe_tgcounters->comp_byp[dir], consumed);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_ADD(&s->be_tgcounters->comp_byp[dir], consumed);
|
||||
}
|
||||
return to_forward;
|
||||
|
||||
@ -418,9 +424,10 @@ comp_http_end(struct stream *s, struct filter *filter,
|
||||
if (!(msg->chn->flags & CF_ISRESP) || !st || !st->comp_algo[COMP_DIR_RES])
|
||||
goto end;
|
||||
|
||||
if (strm_fe(s)->mode == PR_MODE_HTTP)
|
||||
if (strm_fe(s)->mode == PR_MODE_HTTP && s->sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sess->fe_tgcounters->p.http.comp_rsp);
|
||||
if ((s->flags & SF_BE_ASSIGNED) && (s->be->mode == PR_MODE_HTTP))
|
||||
if ((s->flags & SF_BE_ASSIGNED) && (s->be->mode == PR_MODE_HTTP) &&
|
||||
s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->p.http.comp_rsp);
|
||||
end:
|
||||
return 1;
|
||||
|
@ -8921,7 +8921,8 @@ __LJMP static int hlua_txn_done(lua_State *L)
|
||||
if (htxn->dir == SMP_OPT_DIR_REQ) {
|
||||
/* let's log the request time */
|
||||
s->logs.request_ts = now_ns;
|
||||
if (s->sess->fe == s->be) /* report it if the request was intercepted by the frontend */
|
||||
/* report it if the request was intercepted by the frontend */
|
||||
if (s->sess->fe == s->be && s->sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sess->fe_tgcounters->intercepted_req);
|
||||
}
|
||||
|
||||
|
@ -116,12 +116,13 @@ static enum act_return http_action_set_req_line(struct act_rule *rule, struct pr
|
||||
goto leave;
|
||||
|
||||
fail_rewrite:
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_rewrites);
|
||||
if (s->flags & SF_BE_ASSIGNED)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_rewrites);
|
||||
if ((s->flags & SF_BE_ASSIGNED) && s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_rewrites);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->failed_rewrites);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_rewrites);
|
||||
|
||||
if (!(s->txn->req.flags & HTTP_MSGF_SOFT_RW)) {
|
||||
@ -386,12 +387,13 @@ static enum act_return http_action_normalize_uri(struct act_rule *rule, struct p
|
||||
goto leave;
|
||||
|
||||
fail_rewrite:
|
||||
_HA_ATOMIC_ADD(&sess->fe_tgcounters->failed_rewrites, 1);
|
||||
if (s->flags & SF_BE_ASSIGNED)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_ADD(&sess->fe_tgcounters->failed_rewrites, 1);
|
||||
if ((s->flags & SF_BE_ASSIGNED) && s->be_tgcounters)
|
||||
_HA_ATOMIC_ADD(&s->be_tgcounters->failed_rewrites, 1);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_ADD(&sess->li_tgcounters->failed_rewrites, 1);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_ADD(&s->sv_tgcounters->failed_rewrites, 1);
|
||||
|
||||
if (!(s->txn->req.flags & HTTP_MSGF_SOFT_RW)) {
|
||||
@ -562,12 +564,13 @@ static enum act_return http_action_replace_uri(struct act_rule *rule, struct pro
|
||||
goto leave;
|
||||
|
||||
fail_rewrite:
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_rewrites);
|
||||
if (s->flags & SF_BE_ASSIGNED)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_rewrites);
|
||||
if ((s->flags & SF_BE_ASSIGNED) && s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_rewrites);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->failed_rewrites);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_rewrites);
|
||||
|
||||
if (!(s->txn->req.flags & HTTP_MSGF_SOFT_RW)) {
|
||||
@ -642,12 +645,13 @@ static enum act_return action_http_set_status(struct act_rule *rule, struct prox
|
||||
struct session *sess, struct stream *s, int flags)
|
||||
{
|
||||
if (http_res_set_status(rule->arg.http.i, rule->arg.http.str, s) == -1) {
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_rewrites);
|
||||
if (s->flags & SF_BE_ASSIGNED)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_rewrites);
|
||||
if ((s->flags & SF_BE_ASSIGNED) && s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_rewrites);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->failed_rewrites);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_rewrites);
|
||||
|
||||
if (!(s->txn->req.flags & HTTP_MSGF_SOFT_RW)) {
|
||||
@ -717,9 +721,11 @@ static enum act_return http_action_reject(struct act_rule *rule, struct proxy *p
|
||||
s->req.analysers &= AN_REQ_FLT_END;
|
||||
s->res.analysers &= AN_RES_FLT_END;
|
||||
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->denied_req);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->denied_req);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->denied_req);
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->denied_req);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->denied_req);
|
||||
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
@ -1280,7 +1286,8 @@ static enum act_return http_action_auth(struct act_rule *rule, struct proxy *px,
|
||||
s->logs.request_ts = now_ns;
|
||||
req->analysers &= AN_REQ_FLT_END;
|
||||
|
||||
if (s->sess->fe == s->be) /* report it if the request was intercepted by the frontend */
|
||||
/* report it if the request was intercepted by the frontend */
|
||||
if (s->sess->fe == s->be && s->sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sess->fe_tgcounters->intercepted_req);
|
||||
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
@ -1449,12 +1456,13 @@ static enum act_return http_action_set_header(struct act_rule *rule, struct prox
|
||||
goto leave;
|
||||
|
||||
fail_rewrite:
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_rewrites);
|
||||
if (s->flags & SF_BE_ASSIGNED)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_rewrites);
|
||||
if ((s->flags & SF_BE_ASSIGNED) && s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_rewrites);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->failed_rewrites);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_rewrites);
|
||||
|
||||
if (!(msg->flags & HTTP_MSGF_SOFT_RW)) {
|
||||
@ -1581,12 +1589,13 @@ static enum act_return http_action_replace_header(struct act_rule *rule, struct
|
||||
goto leave;
|
||||
|
||||
fail_rewrite:
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_rewrites);
|
||||
if (s->flags & SF_BE_ASSIGNED)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_rewrites);
|
||||
if ((s->flags & SF_BE_ASSIGNED) && s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_rewrites);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->failed_rewrites);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_rewrites);
|
||||
|
||||
if (!(msg->flags & HTTP_MSGF_SOFT_RW)) {
|
||||
@ -2318,7 +2327,8 @@ static enum act_return http_action_return(struct act_rule *rule, struct proxy *p
|
||||
s->logs.request_ts = now_ns;
|
||||
req->analysers &= AN_REQ_FLT_END;
|
||||
|
||||
if (s->sess->fe == s->be) /* report it if the request was intercepted by the frontend */
|
||||
/* report it if the request was intercepted by the frontend */
|
||||
if (s->sess->fe == s->be && s->sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sess->fe_tgcounters->intercepted_req);
|
||||
}
|
||||
|
||||
|
247
src/http_ana.c
247
src/http_ana.c
@ -233,7 +233,8 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
||||
struct acl_cond *cond;
|
||||
|
||||
s->flags |= SF_MONITOR;
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->intercepted_req);
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->intercepted_req);
|
||||
|
||||
/* Check if we want to fail this monitor request or not */
|
||||
list_for_each_entry(cond, &sess->fe->mon_fail_cond, list) {
|
||||
@ -342,16 +343,18 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
||||
txn->status = 500;
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
s->flags |= SF_ERR_INTERNAL;
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->internal_errors);
|
||||
stream_report_term_evt(s->scb, strm_tevt_type_internal_err);
|
||||
goto return_prx_cond;
|
||||
|
||||
return_bad_req:
|
||||
txn->status = 400;
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_req);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_req);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->failed_req);
|
||||
stream_report_term_evt(s->scb, strm_tevt_type_proto_err);
|
||||
/* fall through */
|
||||
@ -487,7 +490,8 @@ int http_process_req_common(struct stream *s, struct channel *req, int an_bit, s
|
||||
|
||||
/* Proceed with the applets now. */
|
||||
if (unlikely(objt_applet(s->target))) {
|
||||
if (sess->fe == s->be) /* report it if the request was intercepted by the frontend */
|
||||
/* report it if the request was intercepted by the frontend */
|
||||
if (sess->fe == s->be && sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->intercepted_req);
|
||||
|
||||
if (http_handle_expect_hdr(s, htx, msg) == -1)
|
||||
@ -564,10 +568,11 @@ int http_process_req_common(struct stream *s, struct channel *req, int an_bit, s
|
||||
if (!req->analyse_exp)
|
||||
req->analyse_exp = tick_add(now_ms, 0);
|
||||
stream_inc_http_err_ctr(s);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->denied_req);
|
||||
if (s->flags & SF_BE_ASSIGNED)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->denied_req);
|
||||
if ((s->flags & SF_BE_ASSIGNED) && s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->denied_req);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->denied_req);
|
||||
stream_report_term_evt(s->scf, strm_tevt_type_intercepted);
|
||||
goto done_without_exp;
|
||||
@ -581,10 +586,11 @@ int http_process_req_common(struct stream *s, struct channel *req, int an_bit, s
|
||||
|
||||
s->logs.request_ts = now_ns;
|
||||
stream_inc_http_err_ctr(s);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->denied_req);
|
||||
if (s->flags & SF_BE_ASSIGNED)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->denied_req);
|
||||
if ((s->flags & SF_BE_ASSIGNED) && s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->denied_req);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->denied_req);
|
||||
stream_report_term_evt(s->scf, strm_tevt_type_intercepted);
|
||||
goto return_prx_err;
|
||||
@ -592,12 +598,13 @@ int http_process_req_common(struct stream *s, struct channel *req, int an_bit, s
|
||||
return_fail_rewrite:
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
s->flags |= SF_ERR_PRXCOND;
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_rewrites);
|
||||
if (s->flags & SF_BE_ASSIGNED)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_rewrites);
|
||||
if ((s->flags & SF_BE_ASSIGNED) && s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_rewrites);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->failed_rewrites);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_rewrites);
|
||||
/* fall through */
|
||||
|
||||
@ -605,18 +612,20 @@ int http_process_req_common(struct stream *s, struct channel *req, int an_bit, s
|
||||
txn->status = 500;
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
s->flags |= SF_ERR_INTERNAL;
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
if (s->flags & SF_BE_ASSIGNED)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
if ((s->flags & SF_BE_ASSIGNED) && s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->internal_errors);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->internal_errors);
|
||||
stream_report_term_evt(s->scf, strm_tevt_type_internal_err);
|
||||
goto return_prx_err;
|
||||
|
||||
return_bad_req:
|
||||
txn->status = 400;
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_req);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_req);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->failed_req);
|
||||
stream_report_term_evt(s->scf, strm_tevt_type_proto_err);
|
||||
/* fall through */
|
||||
@ -750,12 +759,13 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
|
||||
return_fail_rewrite:
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
s->flags |= SF_ERR_PRXCOND;
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_rewrites);
|
||||
if (s->flags & SF_BE_ASSIGNED)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_rewrites);
|
||||
if ((s->flags & SF_BE_ASSIGNED) && s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_rewrites);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->failed_rewrites);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_rewrites);
|
||||
/* fall through */
|
||||
|
||||
@ -763,10 +773,11 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit)
|
||||
txn->status = 500;
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
s->flags |= SF_ERR_INTERNAL;
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
if (s->flags & SF_BE_ASSIGNED)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
if ((s->flags & SF_BE_ASSIGNED) && s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->internal_errors);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->internal_errors);
|
||||
stream_report_term_evt(s->scf, strm_tevt_type_internal_err);
|
||||
|
||||
@ -873,18 +884,20 @@ int http_wait_for_request_body(struct stream *s, struct channel *req, int an_bit
|
||||
txn->status = 500;
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
s->flags |= SF_ERR_INTERNAL;
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
if (s->flags & SF_BE_ASSIGNED)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
if ((s->flags & SF_BE_ASSIGNED) && s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->internal_errors);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->internal_errors);
|
||||
stream_report_term_evt(s->scf, strm_tevt_type_internal_err);
|
||||
goto return_prx_err;
|
||||
|
||||
return_bad_req: /* let's centralize all bad requests */
|
||||
txn->status = 400;
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_req);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_req);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->failed_req);
|
||||
stream_report_term_evt(s->scf, strm_tevt_type_proto_err);
|
||||
/* fall through */
|
||||
@ -1102,11 +1115,13 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
|
||||
return 0;
|
||||
|
||||
return_cli_abort:
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->cli_aborts);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->cli_aborts);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->cli_aborts);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->cli_aborts);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->cli_aborts);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->cli_aborts);
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
s->flags |= ((req->flags & CF_READ_TIMEOUT) ? SF_ERR_CLITO : SF_ERR_CLICL);
|
||||
@ -1114,11 +1129,13 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
|
||||
goto return_prx_cond;
|
||||
|
||||
return_srv_abort:
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->srv_aborts);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->srv_aborts);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->srv_aborts);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->srv_aborts);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->srv_aborts);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->srv_aborts);
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
s->flags |= ((req->flags & CF_WRITE_TIMEOUT) ? SF_ERR_SRVTO : SF_ERR_SRVCL);
|
||||
@ -1128,19 +1145,22 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
|
||||
return_int_err:
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
s->flags |= SF_ERR_INTERNAL;
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->internal_errors);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->internal_errors);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->internal_errors);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->internal_errors);
|
||||
stream_report_term_evt(s->scf, strm_tevt_type_internal_err);
|
||||
status = 500;
|
||||
goto return_prx_cond;
|
||||
|
||||
return_bad_req:
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_req);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_req);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->failed_req);
|
||||
stream_report_term_evt(s->scf, strm_tevt_type_proto_err);
|
||||
status = 400;
|
||||
@ -1175,9 +1195,11 @@ static __inline int do_l7_retry(struct stream *s, struct stconn *sc)
|
||||
s->flags &= ~SF_CURR_SESS;
|
||||
_HA_ATOMIC_DEC(&__objt_server(s->target)->cur_sess);
|
||||
}
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->retries);
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->retries);
|
||||
}
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->retries);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->retries);
|
||||
|
||||
req = &s->req;
|
||||
res = &s->res;
|
||||
@ -1294,8 +1316,9 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
if (s->flags & SF_SRV_REUSED)
|
||||
goto abort_keep_alive;
|
||||
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_resp);
|
||||
if (objt_server(s->target))
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_resp);
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_resp);
|
||||
|
||||
/* if the server refused the early data, just send a 425 */
|
||||
@ -1331,8 +1354,9 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_resp);
|
||||
if (objt_server(s->target))
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_resp);
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_resp);
|
||||
|
||||
txn->status = 504;
|
||||
@ -1352,11 +1376,13 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
/* 3: client abort with an abortonclose */
|
||||
else if ((s->scb->flags & (SC_FL_EOS|SC_FL_ABRT_DONE)) && (s->scb->flags & SC_FL_SHUT_DONE) &&
|
||||
(s->scf->flags & (SC_FL_EOS|SC_FL_ABRT_DONE))) {
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->cli_aborts);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->cli_aborts);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->cli_aborts);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->cli_aborts);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->cli_aborts);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->cli_aborts);
|
||||
|
||||
txn->status = 400;
|
||||
@ -1390,8 +1416,9 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
if (s->flags & SF_SRV_REUSED)
|
||||
goto abort_keep_alive;
|
||||
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_resp);
|
||||
if (objt_server(s->target))
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_resp);
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_resp);
|
||||
|
||||
txn->status = 502;
|
||||
@ -1413,8 +1440,9 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
if (s->flags & SF_SRV_REUSED)
|
||||
goto abort_keep_alive;
|
||||
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_resp);
|
||||
if (objt_server(s->target))
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_resp);
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_resp);
|
||||
rep->analysers &= AN_RES_FLT_END;
|
||||
|
||||
@ -1514,7 +1542,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
if (http_status_matches(http_fail_status_codes, txn->status))
|
||||
stream_inc_http_fail_ctr(s);
|
||||
|
||||
if (objt_server(s->target)) {
|
||||
if (s->sv_tgcounters) {
|
||||
n = txn->status / 100;
|
||||
if (n < 1 || n > 5)
|
||||
n = 0;
|
||||
@ -1664,11 +1692,13 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
return 1;
|
||||
|
||||
return_int_err:
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->internal_errors);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->internal_errors);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->internal_errors);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->internal_errors);
|
||||
txn->status = 500;
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
@ -1685,8 +1715,9 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
|
||||
return 0;
|
||||
}
|
||||
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_resp);
|
||||
if (objt_server(s->target))
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_resp);
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_resp);
|
||||
|
||||
txn->status = 502;
|
||||
@ -1984,11 +2015,13 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s
|
||||
return 1;
|
||||
|
||||
deny:
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->denied_resp);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->denied_resp);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->denied_resp);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->denied_resp);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->denied_resp);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->denied_resp);
|
||||
stream_report_term_evt(s->scb, strm_tevt_type_intercepted);
|
||||
goto return_prx_err;
|
||||
@ -1996,11 +2029,13 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s
|
||||
return_fail_rewrite:
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
s->flags |= SF_ERR_PRXCOND;
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_rewrites);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_rewrites);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_rewrites);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_rewrites);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->failed_rewrites);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_rewrites);
|
||||
/* fall through */
|
||||
|
||||
@ -2008,11 +2043,13 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s
|
||||
txn->status = 500;
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
s->flags |= SF_ERR_INTERNAL;
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->internal_errors);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->internal_errors);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->internal_errors);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->internal_errors);
|
||||
stream_report_term_evt(s->scb, strm_tevt_type_internal_err);
|
||||
goto return_prx_err;
|
||||
@ -2021,9 +2058,11 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s
|
||||
s->logs.t_data = -1; /* was not a valid response */
|
||||
txn->status = 502;
|
||||
stream_inc_http_fail_ctr(s);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_resp);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_resp);
|
||||
if (objt_server(s->target)) {
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_resp);
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_resp);
|
||||
health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_RSP);
|
||||
}
|
||||
stream_report_term_evt(s->scb, strm_tevt_type_proto_err);
|
||||
@ -2253,11 +2292,13 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit
|
||||
return 0;
|
||||
|
||||
return_srv_abort:
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->srv_aborts);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->srv_aborts);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->srv_aborts);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->srv_aborts);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->srv_aborts);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->srv_aborts);
|
||||
stream_inc_http_fail_ctr(s);
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
@ -2265,22 +2306,26 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit
|
||||
goto return_error;
|
||||
|
||||
return_cli_abort:
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->cli_aborts);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->cli_aborts);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->cli_aborts);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->cli_aborts);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->cli_aborts);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->cli_aborts);
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
s->flags |= ((res->flags & CF_WRITE_TIMEOUT) ? SF_ERR_CLITO : SF_ERR_CLICL);
|
||||
goto return_error;
|
||||
|
||||
return_int_err:
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->internal_errors);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->internal_errors);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->internal_errors);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->internal_errors);
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
s->flags |= SF_ERR_INTERNAL;
|
||||
@ -2288,9 +2333,11 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit
|
||||
goto return_error;
|
||||
|
||||
return_bad_res:
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_resp);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_resp);
|
||||
if (objt_server(s->target)) {
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_resp);
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_resp);
|
||||
health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_RSP);
|
||||
}
|
||||
stream_inc_http_fail_ctr(s);
|
||||
@ -2572,7 +2619,8 @@ int http_apply_redirect_rule(struct redirect_rule *rule, struct stream *s, struc
|
||||
s->logs.request_ts = now_ns;
|
||||
req->analysers &= AN_REQ_FLT_END;
|
||||
|
||||
if (s->sess->fe == s->be) /* report it if the request was intercepted by the frontend */
|
||||
/* report it if the request was intercepted by the frontend */
|
||||
if (s->sess->fe == s->be && s->sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sess->fe_tgcounters->intercepted_req);
|
||||
}
|
||||
|
||||
@ -4284,8 +4332,9 @@ enum rule_result http_wait_for_msg_body(struct stream *s, struct channel *chn,
|
||||
txn->status = 408;
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
s->flags |= SF_ERR_CLITO;
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_req);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_req);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->failed_req);
|
||||
goto abort;
|
||||
|
||||
|
@ -1110,7 +1110,7 @@ void listener_accept(struct listener *l)
|
||||
int max = 0;
|
||||
int it;
|
||||
|
||||
for (it = 0; it < global.nbtgroups; it++)
|
||||
for (it = 0; (it < global.nbtgroups && p->fe_counters.shared.tg[it]); it++)
|
||||
max += freq_ctr_remain(&p->fe_counters.shared.tg[it]->sess_per_sec, p->fe_sps_lim, 0);
|
||||
|
||||
if (unlikely(!max)) {
|
||||
|
10
src/log.c
10
src/log.c
@ -5949,16 +5949,18 @@ missing_budget:
|
||||
return;
|
||||
|
||||
parse_error:
|
||||
if (l->counters)
|
||||
if (s->sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sess->li_tgcounters->failed_req);
|
||||
_HA_ATOMIC_INC(&s->sess->fe_tgcounters->failed_req);
|
||||
if (s->sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sess->fe_tgcounters->failed_req);
|
||||
|
||||
goto error;
|
||||
|
||||
cli_abort:
|
||||
if (l->counters)
|
||||
if (s->sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sess->li_tgcounters->cli_aborts);
|
||||
_HA_ATOMIC_INC(&s->sess->fe_tgcounters->cli_aborts);
|
||||
if (s->sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sess->fe_tgcounters->cli_aborts);
|
||||
|
||||
error:
|
||||
applet_set_eos(appctx);
|
||||
|
32
src/mux_h1.c
32
src/mux_h1.c
@ -3745,9 +3745,11 @@ static int h1_handle_internal_err(struct h1c *h1c)
|
||||
}
|
||||
session_inc_http_req_ctr(sess);
|
||||
proxy_inc_fe_req_ctr(sess->listener, sess->fe, 1);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->p.http.rsp[5]);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters) {
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->p.http.rsp[5]);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
}
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->internal_errors);
|
||||
|
||||
h1c->errcode = 500;
|
||||
@ -3781,9 +3783,11 @@ static int h1_handle_parsing_error(struct h1c *h1c)
|
||||
session_inc_http_req_ctr(sess);
|
||||
session_inc_http_err_ctr(sess);
|
||||
proxy_inc_fe_req_ctr(sess->listener, sess->fe, 1);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->p.http.rsp[4]);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_req);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters) {
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->p.http.rsp[4]);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_req);
|
||||
}
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->failed_req);
|
||||
|
||||
if (!h1c->errcode)
|
||||
@ -3818,9 +3822,11 @@ static int h1_handle_not_impl_err(struct h1c *h1c)
|
||||
|
||||
session_inc_http_req_ctr(sess);
|
||||
proxy_inc_fe_req_ctr(sess->listener, sess->fe, 1);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->p.http.rsp[4]);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_req);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters) {
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->p.http.rsp[4]);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_req);
|
||||
}
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->failed_req);
|
||||
|
||||
h1c->errcode = 501;
|
||||
@ -3853,9 +3859,11 @@ static int h1_handle_req_tout(struct h1c *h1c)
|
||||
|
||||
session_inc_http_req_ctr(sess);
|
||||
proxy_inc_fe_req_ctr(sess->listener, sess->fe, 1);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->p.http.rsp[4]);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_req);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters) {
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->p.http.rsp[4]);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_req);
|
||||
}
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->failed_req);
|
||||
|
||||
h1c->errcode = 408;
|
||||
|
@ -7125,7 +7125,8 @@ static void srv_update_status(struct server *s, int type, int cause)
|
||||
}
|
||||
else if (s->cur_state == SRV_ST_STOPPED) {
|
||||
/* server was up and is currently down */
|
||||
HA_ATOMIC_INC(&s->counters.shared.tg[tgid - 1]->down_trans);
|
||||
if (s->counters.shared.tg[tgid - 1])
|
||||
HA_ATOMIC_INC(&s->counters.shared.tg[tgid - 1]->down_trans);
|
||||
_srv_event_hdl_publish(EVENT_HDL_SUB_SERVER_DOWN, cb_data.common, s);
|
||||
}
|
||||
|
||||
@ -7137,7 +7138,8 @@ static void srv_update_status(struct server *s, int type, int cause)
|
||||
HA_ATOMIC_STORE(&s->proxy->ready_srv, NULL);
|
||||
|
||||
s->last_change = ns_to_sec(now_ns);
|
||||
HA_ATOMIC_STORE(&s->counters.shared.tg[tgid - 1]->last_state_change, s->last_change);
|
||||
if (s->counters.shared.tg[tgid - 1])
|
||||
HA_ATOMIC_STORE(&s->counters.shared.tg[tgid - 1]->last_state_change, s->last_change);
|
||||
|
||||
/* publish the state change */
|
||||
_srv_event_hdl_prepare_state(&cb_data.state,
|
||||
@ -7157,7 +7159,8 @@ static void srv_update_status(struct server *s, int type, int cause)
|
||||
if (last_change < ns_to_sec(now_ns)) // ignore negative times
|
||||
s->proxy->down_time += ns_to_sec(now_ns) - last_change;
|
||||
s->proxy->last_change = ns_to_sec(now_ns);
|
||||
HA_ATOMIC_STORE(&s->proxy->be_counters.shared.tg[tgid - 1]->last_state_change, s->proxy->last_change);
|
||||
if (s->proxy->be_counters.shared.tg[tgid - 1])
|
||||
HA_ATOMIC_STORE(&s->proxy->be_counters.shared.tg[tgid - 1]->last_state_change, s->proxy->last_change);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,7 +322,8 @@ static void srv_state_srv_update(struct server *srv, int version, char **params)
|
||||
}
|
||||
|
||||
srv->last_change = ns_to_sec(now_ns) - srv_last_time_change;
|
||||
HA_ATOMIC_STORE(&srv->counters.shared.tg[0]->last_state_change, srv->last_change);
|
||||
if (srv->counters.shared.tg[0])
|
||||
HA_ATOMIC_STORE(&srv->counters.shared.tg[0]->last_state_change, srv->last_change);
|
||||
srv->check.status = srv_check_status;
|
||||
srv->check.result = srv_check_result;
|
||||
|
||||
|
@ -102,6 +102,8 @@ struct session *session_new(struct proxy *fe, struct listener *li, enum obj_type
|
||||
sess->fe_tgcounters = sess->fe->fe_counters.shared.tg[tgid - 1];
|
||||
if (sess->listener && sess->listener->counters)
|
||||
sess->li_tgcounters = sess->listener->counters->shared.tg[tgid - 1];
|
||||
else
|
||||
sess->li_tgcounters = NULL;
|
||||
TRACE_STATE("new session", SESS_EV_NEW, sess);
|
||||
}
|
||||
TRACE_LEAVE(SESS_EV_NEW);
|
||||
|
@ -294,6 +294,9 @@ static int parse_stat_line(struct ist line,
|
||||
return 0; /* silently ignored fe/be mismatch */
|
||||
|
||||
base_off_shared = (char *)px->fe_counters.shared.tg[0];
|
||||
if (!base_off_shared)
|
||||
return 0; // not allocated
|
||||
|
||||
base_off = (char *)&px->fe_counters;
|
||||
|
||||
off = 0;
|
||||
@ -303,6 +306,9 @@ static int parse_stat_line(struct ist line,
|
||||
return 0; /* silently ignored fe/be mismatch */
|
||||
|
||||
base_off_shared = (char *)px->be_counters.shared.tg[0];
|
||||
if (!base_off_shared)
|
||||
return 0; // not allocated
|
||||
|
||||
base_off = (char *)&px->be_counters;
|
||||
|
||||
off = 1;
|
||||
@ -323,6 +329,9 @@ static int parse_stat_line(struct ist line,
|
||||
return 0;
|
||||
|
||||
base_off_shared = (char *)li->counters->shared.tg[0];
|
||||
if (!base_off_shared)
|
||||
return 0; // not allocated
|
||||
|
||||
base_off = (char *)li->counters;
|
||||
|
||||
off = 0;
|
||||
@ -334,6 +343,9 @@ static int parse_stat_line(struct ist line,
|
||||
|
||||
srv = __objt_server(node->obj_type);
|
||||
base_off_shared = (char *)srv->counters.shared.tg[0];
|
||||
if (!base_off_shared)
|
||||
return 0; // not allocated
|
||||
|
||||
base_off = (char *)&srv->counters;
|
||||
|
||||
off = 1;
|
||||
@ -752,7 +764,8 @@ static void shm_stats_file_preload(void)
|
||||
|
||||
BUG_ON(curr_obj->type != SHM_STATS_FILE_OBJECT_TYPE_FE);
|
||||
li = __objt_listener(node->obj_type);
|
||||
if (li->counters) // counters are optional for listeners
|
||||
// counters are optional for listeners
|
||||
if (li->counters && li->counters->shared.tg[obj_tgid - 1])
|
||||
li->counters->shared.tg[obj_tgid - 1] = &curr_obj->data.fe;
|
||||
break;
|
||||
}
|
||||
@ -762,7 +775,8 @@ static void shm_stats_file_preload(void)
|
||||
|
||||
BUG_ON(curr_obj->type != SHM_STATS_FILE_OBJECT_TYPE_BE);
|
||||
sv = __objt_server(node->obj_type);
|
||||
sv->counters.shared.tg[obj_tgid - 1] = &curr_obj->data.be;
|
||||
if (sv->counters.shared.tg[obj_tgid - 1])
|
||||
sv->counters.shared.tg[obj_tgid - 1] = &curr_obj->data.be;
|
||||
break;
|
||||
}
|
||||
case OBJ_TYPE_PROXY:
|
||||
@ -770,9 +784,11 @@ static void shm_stats_file_preload(void)
|
||||
struct proxy *px;
|
||||
|
||||
px = __objt_proxy(node->obj_type);
|
||||
if (curr_obj->type == SHM_STATS_FILE_OBJECT_TYPE_FE)
|
||||
if (curr_obj->type == SHM_STATS_FILE_OBJECT_TYPE_FE &&
|
||||
px->fe_counters.shared.tg[obj_tgid - 1])
|
||||
px->fe_counters.shared.tg[obj_tgid - 1] = &curr_obj->data.fe;
|
||||
else if (curr_obj->type == SHM_STATS_FILE_OBJECT_TYPE_BE)
|
||||
else if (curr_obj->type == SHM_STATS_FILE_OBJECT_TYPE_BE &&
|
||||
px->be_counters.shared.tg[obj_tgid - 1])
|
||||
px->be_counters.shared.tg[obj_tgid - 1] = &curr_obj->data.be;
|
||||
else
|
||||
goto release; // not supported
|
||||
|
133
src/stream.c
133
src/stream.c
@ -451,6 +451,7 @@ struct stream *stream_new(struct session *sess, struct stconn *sc, struct buffer
|
||||
*/
|
||||
s->be = sess->fe;
|
||||
s->be_tgcounters = sess->fe->be_counters.shared.tg[tgid - 1];
|
||||
s->sv_tgcounters = NULL; // default value
|
||||
|
||||
s->req_cap = NULL;
|
||||
s->res_cap = NULL;
|
||||
@ -825,13 +826,15 @@ void stream_process_counters(struct stream *s)
|
||||
bytes = s->req.total - s->logs.bytes_in;
|
||||
s->logs.bytes_in = s->req.total;
|
||||
if (bytes) {
|
||||
_HA_ATOMIC_ADD(&sess->fe_tgcounters->bytes_in, bytes);
|
||||
_HA_ATOMIC_ADD(&s->be_tgcounters->bytes_in, bytes);
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_ADD(&sess->fe_tgcounters->bytes_in, bytes);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_ADD(&s->be_tgcounters->bytes_in, bytes);
|
||||
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_ADD(&s->sv_tgcounters->bytes_in, bytes);
|
||||
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_ADD(&sess->li_tgcounters->bytes_in, bytes);
|
||||
|
||||
for (i = 0; i < global.tune.nb_stk_ctr; i++) {
|
||||
@ -843,13 +846,15 @@ void stream_process_counters(struct stream *s)
|
||||
bytes = s->res.total - s->logs.bytes_out;
|
||||
s->logs.bytes_out = s->res.total;
|
||||
if (bytes) {
|
||||
_HA_ATOMIC_ADD(&sess->fe_tgcounters->bytes_out, bytes);
|
||||
_HA_ATOMIC_ADD(&s->be_tgcounters->bytes_out, bytes);
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_ADD(&sess->fe_tgcounters->bytes_out, bytes);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_ADD(&s->be_tgcounters->bytes_out, bytes);
|
||||
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_ADD(&s->sv_tgcounters->bytes_out, bytes);
|
||||
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_ADD(&sess->li_tgcounters->bytes_out, bytes);
|
||||
|
||||
for (i = 0; i < global.tune.nb_stk_ctr; i++) {
|
||||
@ -1014,8 +1019,9 @@ void sess_set_term_flags(struct stream *s)
|
||||
if (!(s->flags & SF_FINST_MASK)) {
|
||||
if (s->scb->state == SC_ST_INI) {
|
||||
/* anything before REQ in fact */
|
||||
_HA_ATOMIC_INC(&s->sess->fe_tgcounters->failed_req);
|
||||
if (strm_li(s) && strm_li(s)->counters)
|
||||
if (s->sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sess->fe_tgcounters->failed_req);
|
||||
if (s->sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sess->li_tgcounters->failed_req);
|
||||
|
||||
s->flags |= SF_FINST_R;
|
||||
@ -1062,7 +1068,8 @@ enum act_return process_use_service(struct act_rule *rule, struct proxy *px,
|
||||
appctx = __sc_appctx(s->scb);
|
||||
|
||||
if (rule->from != ACT_F_HTTP_REQ) {
|
||||
if (sess->fe == s->be) /* report it if the request was intercepted by the frontend */
|
||||
/* report it if the request was intercepted by the frontend */
|
||||
if (sess->fe == s->be && sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->intercepted_req);
|
||||
|
||||
/* The flag SF_ASSIGNED prevent from server assignment. */
|
||||
@ -1848,11 +1855,13 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
|
||||
sc_shutdown(scf);
|
||||
if (!(req->analysers) && !(res->analysers)) {
|
||||
COUNT_IF(1, "Report a client abort (no analysers)");
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->cli_aborts);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->cli_aborts);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->cli_aborts);
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->cli_aborts);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->cli_aborts);
|
||||
if (srv)
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->cli_aborts);
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
s->flags |= SF_ERR_CLICL;
|
||||
@ -1866,16 +1875,19 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
|
||||
if (sc_state_in(scb->state, SC_SB_EST|SC_SB_DIS)) {
|
||||
sc_abort(scb);
|
||||
sc_shutdown(scb);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_resp);
|
||||
if (srv)
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_resp);
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_resp);
|
||||
if (!(req->analysers) && !(res->analysers)) {
|
||||
COUNT_IF(1, "Report a client abort (no analysers)");
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->srv_aborts);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->srv_aborts);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->srv_aborts);
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->srv_aborts);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->srv_aborts);
|
||||
if (srv)
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->srv_aborts);
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
s->flags |= SF_ERR_SRVCL;
|
||||
@ -2180,31 +2192,37 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
|
||||
req->analysers &= AN_REQ_FLT_END;
|
||||
channel_auto_close(req);
|
||||
if (scf->flags & SC_FL_ERROR) {
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->cli_aborts);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->cli_aborts);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->cli_aborts);
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->cli_aborts);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->cli_aborts);
|
||||
if (srv)
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->cli_aborts);
|
||||
s->flags |= SF_ERR_CLICL;
|
||||
COUNT_IF(1, "Report unhandled client error");
|
||||
}
|
||||
else if (req->flags & CF_READ_TIMEOUT) {
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->cli_aborts);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->cli_aborts);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->cli_aborts);
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->cli_aborts);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->cli_aborts);
|
||||
if (srv)
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->cli_aborts);
|
||||
s->flags |= SF_ERR_CLITO;
|
||||
COUNT_IF(1, "Report unhandled client timeout (RD)");
|
||||
}
|
||||
else {
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->srv_aborts);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->srv_aborts);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->srv_aborts);
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->srv_aborts);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->srv_aborts);
|
||||
if (srv)
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->srv_aborts);
|
||||
s->flags |= SF_ERR_SRVTO;
|
||||
COUNT_IF(1, "Report unhandled server timeout (WR)");
|
||||
@ -2229,31 +2247,37 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
|
||||
res->analysers &= AN_RES_FLT_END;
|
||||
channel_auto_close(res);
|
||||
if (scb->flags & SC_FL_ERROR) {
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->srv_aborts);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->srv_aborts);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->srv_aborts);
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->srv_aborts);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->srv_aborts);
|
||||
if (srv)
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->srv_aborts);
|
||||
s->flags |= SF_ERR_SRVCL;
|
||||
COUNT_IF(1, "Report unhandled server error");
|
||||
}
|
||||
else if (res->flags & CF_READ_TIMEOUT) {
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->srv_aborts);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->srv_aborts);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->srv_aborts);
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->srv_aborts);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->srv_aborts);
|
||||
if (srv)
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->srv_aborts);
|
||||
s->flags |= SF_ERR_SRVTO;
|
||||
COUNT_IF(1, "Report unhandled server timeout (RD)");
|
||||
}
|
||||
else {
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->cli_aborts);
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->cli_aborts);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->cli_aborts);
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->cli_aborts);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->cli_aborts);
|
||||
if (srv)
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->cli_aborts);
|
||||
s->flags |= SF_ERR_CLITO;
|
||||
COUNT_IF(1, "Report unhandled client timeout (WR)");
|
||||
@ -2626,11 +2650,12 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
|
||||
if (n < 1 || n > 5)
|
||||
n = 0;
|
||||
|
||||
if (sess->fe->mode == PR_MODE_HTTP) {
|
||||
if (sess->fe->mode == PR_MODE_HTTP && sess->fe_tgcounters) {
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->p.http.rsp[n]);
|
||||
}
|
||||
if ((s->flags & SF_BE_ASSIGNED) &&
|
||||
(s->be->mode == PR_MODE_HTTP)) {
|
||||
(s->be->mode == PR_MODE_HTTP) &&
|
||||
s->be_tgcounters) {
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->p.http.rsp[n]);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->p.http.cum_req);
|
||||
}
|
||||
@ -2696,8 +2721,11 @@ void stream_update_time_stats(struct stream *s)
|
||||
|
||||
srv = objt_server(s->target);
|
||||
if (srv) {
|
||||
samples_window = (((s->be->mode == PR_MODE_HTTP) ?
|
||||
HA_ATOMIC_LOAD(&s->sv_tgcounters->p.http.cum_req) : HA_ATOMIC_LOAD(&s->sv_tgcounters->cum_lbconn)) > TIME_STATS_SAMPLES) ? TIME_STATS_SAMPLES : 0;
|
||||
if (s->sv_tgcounters)
|
||||
samples_window = (((s->be->mode == PR_MODE_HTTP) ?
|
||||
HA_ATOMIC_LOAD(&s->sv_tgcounters->p.http.cum_req) : HA_ATOMIC_LOAD(&s->sv_tgcounters->cum_lbconn)) > TIME_STATS_SAMPLES) ? TIME_STATS_SAMPLES : 0;
|
||||
else
|
||||
samples_window = 0;
|
||||
swrate_add_dynamic(&srv->counters.q_time, samples_window, t_queue);
|
||||
swrate_add_dynamic(&srv->counters.c_time, samples_window, t_connect);
|
||||
swrate_add_dynamic(&srv->counters.d_time, samples_window, t_data);
|
||||
@ -2707,8 +2735,11 @@ void stream_update_time_stats(struct stream *s)
|
||||
HA_ATOMIC_UPDATE_MAX(&srv->counters.dtime_max, t_data);
|
||||
HA_ATOMIC_UPDATE_MAX(&srv->counters.ttime_max, t_close);
|
||||
}
|
||||
samples_window = (((s->be->mode == PR_MODE_HTTP) ?
|
||||
HA_ATOMIC_LOAD(&s->be_tgcounters->p.http.cum_req) : HA_ATOMIC_LOAD(&s->be_tgcounters->cum_lbconn)) > TIME_STATS_SAMPLES) ? TIME_STATS_SAMPLES : 0;
|
||||
if (s->be_tgcounters)
|
||||
samples_window = (((s->be->mode == PR_MODE_HTTP) ?
|
||||
HA_ATOMIC_LOAD(&s->be_tgcounters->p.http.cum_req) : HA_ATOMIC_LOAD(&s->be_tgcounters->cum_lbconn)) > TIME_STATS_SAMPLES) ? TIME_STATS_SAMPLES : 0;
|
||||
else
|
||||
samples_window = 0;
|
||||
swrate_add_dynamic(&s->be->be_counters.q_time, samples_window, t_queue);
|
||||
swrate_add_dynamic(&s->be->be_counters.c_time, samples_window, t_connect);
|
||||
swrate_add_dynamic(&s->be->be_counters.d_time, samples_window, t_data);
|
||||
|
@ -396,7 +396,7 @@ static enum act_return tcp_exec_action_silent_drop(struct act_rule *rule, struct
|
||||
stream_abort(strm);
|
||||
strm->req.analysers &= AN_REQ_FLT_END;
|
||||
strm->res.analysers &= AN_RES_FLT_END;
|
||||
if (strm->flags & SF_BE_ASSIGNED)
|
||||
if ((strm->flags & SF_BE_ASSIGNED) && strm->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&strm->be_tgcounters->denied_req);
|
||||
if (!(strm->flags & SF_ERR_MASK))
|
||||
strm->flags |= SF_ERR_PRXCOND;
|
||||
@ -404,8 +404,9 @@ static enum act_return tcp_exec_action_silent_drop(struct act_rule *rule, struct
|
||||
strm->flags |= SF_FINST_R;
|
||||
}
|
||||
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->denied_req);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->denied_req);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->denied_req);
|
||||
|
||||
return ACT_RET_ABRT;
|
||||
|
@ -264,15 +264,17 @@ resume_execution:
|
||||
return 0;
|
||||
|
||||
deny:
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->denied_req);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->denied_req);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->denied_req);
|
||||
stream_report_term_evt(s->scf, strm_tevt_type_intercepted);
|
||||
goto reject;
|
||||
|
||||
internal:
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->internal_errors);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->internal_errors);
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
s->flags |= SF_ERR_INTERNAL;
|
||||
@ -280,8 +282,9 @@ resume_execution:
|
||||
goto reject;
|
||||
|
||||
invalid:
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_req);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->failed_req);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->failed_req);
|
||||
stream_report_term_evt(s->scf, strm_tevt_type_proto_err);
|
||||
|
||||
@ -486,21 +489,25 @@ resume_execution:
|
||||
return 0;
|
||||
|
||||
deny:
|
||||
_HA_ATOMIC_INC(&s->sess->fe_tgcounters->denied_resp);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->denied_resp);
|
||||
if (s->sess->listener && s->sess->listener->counters)
|
||||
if (s->sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sess->fe_tgcounters->denied_resp);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->denied_resp);
|
||||
if (s->sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sess->li_tgcounters->denied_resp);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->denied_resp);
|
||||
stream_report_term_evt(s->scb, strm_tevt_type_intercepted);
|
||||
goto reject;
|
||||
|
||||
internal:
|
||||
_HA_ATOMIC_INC(&s->sess->fe_tgcounters->internal_errors);
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->internal_errors);
|
||||
if (s->sess->listener && s->sess->listener->counters)
|
||||
if (s->sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sess->fe_tgcounters->internal_errors);
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->internal_errors);
|
||||
if (s->sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sess->li_tgcounters->internal_errors);
|
||||
if (objt_server(s->target))
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->internal_errors);
|
||||
if (!(s->flags & SF_ERR_MASK))
|
||||
s->flags |= SF_ERR_INTERNAL;
|
||||
@ -508,8 +515,9 @@ resume_execution:
|
||||
goto reject;
|
||||
|
||||
invalid:
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_resp);
|
||||
if (objt_server(s->target))
|
||||
if (s->be_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->be_tgcounters->failed_resp);
|
||||
if (s->sv_tgcounters)
|
||||
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_resp);
|
||||
stream_report_term_evt(s->scf, strm_tevt_type_proto_err);
|
||||
|
||||
@ -585,8 +593,9 @@ int tcp_exec_l4_rules(struct session *sess)
|
||||
goto end;
|
||||
}
|
||||
else if (rule->action == ACT_ACTION_DENY) {
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->denied_conn);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->denied_conn);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->denied_conn);
|
||||
|
||||
result = 0;
|
||||
@ -673,8 +682,9 @@ int tcp_exec_l5_rules(struct session *sess)
|
||||
goto end;
|
||||
}
|
||||
else if (rule->action == ACT_ACTION_DENY) {
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->denied_sess);
|
||||
if (sess->listener && sess->listener->counters)
|
||||
if (sess->fe_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->fe_tgcounters->denied_sess);
|
||||
if (sess->li_tgcounters)
|
||||
_HA_ATOMIC_INC(&sess->li_tgcounters->denied_sess);
|
||||
|
||||
result = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user