mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-28 22:31:06 +01:00
[MINOR] frontend: count denied TCP requests separately
It's very disturbing to see the "denied req" counter increase without any other session counter moving. In fact, we can't count a rejected TCP connection as "denied req" as we have not yet instanciated any session at all. Let's use a new counter for that.
This commit is contained in:
parent
24dcaf3450
commit
2799e98a36
@ -5225,8 +5225,10 @@ tcp-request reject [{if | unless} <condition>]
|
|||||||
connection, which implies that the "tcp-request accept" statement will only
|
connection, which implies that the "tcp-request accept" statement will only
|
||||||
make sense when combined with another "tcp-request reject" statement.
|
make sense when combined with another "tcp-request reject" statement.
|
||||||
|
|
||||||
Rejected connections are accounted in stats but are not logged. The reason is
|
Rejected connections do not even become a session, which is why they are
|
||||||
that these rules should only be used to filter extremely high connection
|
accounted separately for in the stats, as "denied connections". They are not
|
||||||
|
considered for the session rate-limit and are not logged either. The reason
|
||||||
|
is that these rules should only be used to filter extremely high connection
|
||||||
rates such as the ones encountered during a massive DDoS attack. Under these
|
rates such as the ones encountered during a massive DDoS attack. Under these
|
||||||
conditions, the simple action of logging each event would make the system
|
conditions, the simple action of logging each event would make the system
|
||||||
collapse and would considerably lower the filtering capacity. If logging is
|
collapse and would considerably lower the filtering capacity. If logging is
|
||||||
|
|||||||
@ -40,6 +40,7 @@ struct pxcounters {
|
|||||||
|
|
||||||
long long denied_req, denied_resp; /* blocked requests/responses because of security concerns */
|
long long denied_req, denied_resp; /* blocked requests/responses because of security concerns */
|
||||||
long long failed_req; /* failed requests (eg: invalid or timeout) */
|
long long failed_req; /* failed requests (eg: invalid or timeout) */
|
||||||
|
long long denied_conn; /* denied connection requests (tcp-req rules) */
|
||||||
|
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
@ -63,6 +64,7 @@ struct licounters {
|
|||||||
|
|
||||||
long long denied_req, denied_resp; /* blocked requests/responses because of security concerns */
|
long long denied_req, denied_resp; /* blocked requests/responses because of security concerns */
|
||||||
long long failed_req; /* failed requests (eg: invalid or timeout) */
|
long long failed_req; /* failed requests (eg: invalid or timeout) */
|
||||||
|
long long denied_conn; /* denied connection requests (tcp-req rules) */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct srvcounters {
|
struct srvcounters {
|
||||||
|
|||||||
@ -731,9 +731,9 @@ int tcp_exec_req_rules(struct session *s)
|
|||||||
if (ret) {
|
if (ret) {
|
||||||
/* we have a matching rule. */
|
/* we have a matching rule. */
|
||||||
if (rule->action == TCP_ACT_REJECT) {
|
if (rule->action == TCP_ACT_REJECT) {
|
||||||
s->fe->counters.denied_req++;
|
s->fe->counters.denied_conn++;
|
||||||
if (s->listener->counters)
|
if (s->listener->counters)
|
||||||
s->listener->counters->denied_req++;
|
s->listener->counters->denied_conn++;
|
||||||
|
|
||||||
if (!(s->flags & SN_ERR_MASK))
|
if (!(s->flags & SN_ERR_MASK))
|
||||||
s->flags |= SN_ERR_PRXCOND;
|
s->flags |= SN_ERR_PRXCOND;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user