]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] frontend: count denied TCP requests separately
authorWilly Tarreau <w@1wt.eu>
Sat, 5 Jun 2010 13:43:21 +0000 (15:43 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 14 Jun 2010 08:53:20 +0000 (10:53 +0200)
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.

doc/configuration.txt
include/types/counters.h
src/proto_tcp.c

index 7aa12a71a9300e3a42ea56a478c4ed123f023ace..a9a5793b05fba18838f4df673c7a7156675171f5 100644 (file)
@@ -5225,8 +5225,10 @@ tcp-request reject [{if | unless} <condition>]
   connection, which implies that the "tcp-request accept" statement will only
   make sense when combined with another "tcp-request reject" statement.
 
-  Rejected connections are accounted in stats but are not logged. The reason is
-  that these rules should only be used to filter extremely high connection
+  Rejected connections do not even become a session, which is why they are
+  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
   conditions, the simple action of logging each event would make the system
   collapse and would considerably lower the filtering capacity. If logging is
index 7a0ff1d3424cee6d60a4d656ce6291853d491dd6..a333219cb569cf5afecc0e978c62aa4daee48aa3 100644 (file)
@@ -40,6 +40,7 @@ struct pxcounters {
 
        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 denied_conn;                  /* denied connection requests (tcp-req rules) */
 
        union {
                struct {
@@ -63,6 +64,7 @@ struct licounters {
 
        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 denied_conn;                  /* denied connection requests (tcp-req rules) */
 };
 
 struct srvcounters {
index 3a1abad9e6e12942cbbb4678b923d12c4dafe08f..1c93396089f2fc0081b1ee0052b1b48b09ee8cd8 100644 (file)
@@ -731,9 +731,9 @@ int tcp_exec_req_rules(struct session *s)
                if (ret) {
                        /* we have a matching rule. */
                        if (rule->action == TCP_ACT_REJECT) {
-                               s->fe->counters.denied_req++;
+                               s->fe->counters.denied_conn++;
                                if (s->listener->counters)
-                                       s->listener->counters->denied_req++;
+                                       s->listener->counters->denied_conn++;
 
                                if (!(s->flags & SN_ERR_MASK))
                                        s->flags |= SN_ERR_PRXCOND;