From 7d0c19e82d169ad2a6377f6ba37aeca3d50828f1 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 6 Oct 2020 14:23:34 +0200 Subject: [PATCH] MINOR: session: Add functions to increase http values of tracked counters cumulative numbers of http request and http errors of counters tracked at the session level and their rates can now be updated at the session level thanks to two new functions. These functions are not used for now, but it will be called to keep tracked counters up-to-date if an error occurs before the stream creation. --- include/haproxy/session.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/haproxy/session.h b/include/haproxy/session.h index fa21dda6c..205bd82ac 100644 --- a/include/haproxy/session.h +++ b/include/haproxy/session.h @@ -73,6 +73,30 @@ static inline void session_store_counters(struct session *sess) } } +/* Increase the number of cumulated HTTP requests in the tracked counters */ +static inline void session_inc_http_req_ctr(struct session *sess) +{ + int i; + + for (i = 0; i < MAX_SESS_STKCTR; i++) + stkctr_inc_http_req_ctr(&sess->stkctr[i]); +} + +/* Increase the number of cumulated failed HTTP requests in the tracked + * counters. Only 4xx requests should be counted here so that we can + * distinguish between errors caused by client behaviour and other ones. + * Note that even 404 are interesting because they're generally caused by + * vulnerability scans. + */ +static inline void session_inc_http_err_ctr(struct session *sess) +{ + int i; + + for (i = 0; i < MAX_SESS_STKCTR; i++) + stkctr_inc_http_err_ctr(&sess->stkctr[i]); +} + + /* Remove the connection from the session list, and destroy the srv_list if it's now empty */ static inline void session_unown_conn(struct session *sess, struct connection *conn) {