CLEANUP: counters: move from 3 types to 2 types

We used to have 3 types of counters with a huge overlap :
  - listener counters : stats collected for each bind line
  - proxy counters : union of the frontend and backend counters
  - server counters : stats collected per server

It happens that quite a good part was common between listeners and
proxies due to the frontend counters being updated at the two locations,
and that similarly the server and proxy counters were overlapping and
being updated together.

This patch cleans this up to propose only two types of counters :
  - fe_counters: used by frontends and listeners, related to
    incoming connections activity
  - be_counters: used by backends and servers, related to outgoing
    connections activity

This allowed to remove some non-sensical counters from both parts. For
frontends, the following entries were removed :

  cum_lbconn, last_sess, nbpend_max, failed_conns, failed_resp,
  retries, redispatches, q_time, c_time, d_time, t_time

For backends, this ones was removed : intercepted_req.

While doing this it was discovered that we used to incorrectly report
intercepted_req for backends in the HTML stats, which was always zero
since it's never updated.

Also it revealed a few inconsistencies (which were not fixed as they
are harmless). For example, backends count connections (cum_conn)
instead of sessions while servers count sessions and not connections.

Over the long term, some extra cleanups may be performed by having
some counters update functions touching both the server and backend
at the same time, as well as both the frontend and listener, to
ensure that all sides have all their stats properly filled. The stats
dump will also be able to factor the dump functions by counter types.
diff --git a/include/types/counters.h b/include/types/counters.h
index 3e62763..06ce617 100644
--- a/include/types/counters.h
+++ b/include/types/counters.h
@@ -23,17 +23,14 @@
 #ifndef _TYPES_COUNTERS_H
 #define _TYPES_COUNTERS_H
 
-/* maybe later we might thing about having a different struct for FE and BE */
-struct pxcounters {
+/* counters used by listeners and frontends */
+struct fe_counters {
 	unsigned int conn_max;                  /* max # of active sessions */
 	long long    cum_conn;                  /* cumulated number of received connections */
 	long long    cum_sess;                  /* cumulated number of accepted connections */
-	long long  cum_lbconn;                  /* cumulated number of sessions processed by load balancing (BE only) */
-	unsigned long last_sess;                /* last session time */
 
 	unsigned int cps_max;                   /* maximum of new connections received per second */
 	unsigned int sps_max;                   /* maximum of new connections accepted per second (sessions) */
-	unsigned int nbpend_max;                /* max number of pending connections with no server assigned yet (BE only) */
 
 	long long bytes_in;                     /* number of bytes transferred from the client to the server */
 	long long bytes_out;                    /* number of bytes transferred from the server to the client */
@@ -42,22 +39,16 @@
 	long long comp_out;                     /* output bytes emitted by the compressor */
 	long long comp_byp;                     /* input bytes that bypassed the compressor (cpu/ram/bw limitation) */
 
-	long long denied_req;                   /* blocked requests/responses because of security concerns */
-	long long denied_resp;                  /* blocked requests/responses because of security concerns */
+	long long denied_req;                   /* blocked requests because of security concerns */
+	long long denied_resp;                  /* blocked responses because of security concerns */
 	long long failed_req;                   /* failed requests (eg: invalid or timeout) */
 	long long denied_conn;                  /* denied connection requests (tcp-req-conn rules) */
 	long long denied_sess;                  /* denied session requests (tcp-req-sess rules) */
 
-	long long failed_conns;                 /* failed connect() attempts (BE only) */
-	long long failed_resp;                  /* failed responses (BE only) */
 	long long cli_aborts;                   /* aborted responses during DATA phase caused by the client */
 	long long srv_aborts;                   /* aborted responses during DATA phase caused by the server */
-	long long retries;                      /* retried and redispatched connections (BE only) */
-	long long redispatches;                 /* retried and redispatched connections (BE only) */
 	long long intercepted_req;              /* number of monitoring or stats requests intercepted by the frontend */
 
-	unsigned int q_time, c_time, d_time, t_time; /* sums of conn_time, queue_time, data_time, total_time */
-
 	union {
 		struct {
 			long long cum_req;      /* cumulated number of processed HTTP requests */
@@ -68,48 +59,50 @@
 	} p;                                    /* protocol-specific stats */
 };
 
-struct licounters {
-	unsigned int conn_max;			/* max # of active listener sessions */
-
-	long long cum_conn;			/* cumulated number of received connections */
-	long long cum_sess;			/* cumulated number of accepted sessions */
-
-	long long bytes_in;			/* number of bytes transferred from the client to the server */
-	long long bytes_out;			/* number of bytes transferred from the server to the client */
-
-	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-conn rules) */
-	long long denied_sess;                  /* denied session requests (tcp-req-sess rules) */
-};
+/* counters used by listeners and frontends */
+struct be_counters {
+	unsigned int conn_max;                  /* max # of active sessions */
+	long long    cum_conn;                  /* cumulated number of received connections */
+	long long    cum_sess;                  /* cumulated number of accepted connections */
+	long long  cum_lbconn;                  /* cumulated number of sessions processed by load balancing (BE only) */
+	unsigned long last_sess;                /* last session time */
 
-struct srvcounters {
+	unsigned int cps_max;                   /* maximum of new connections received per second */
+	unsigned int sps_max;                   /* maximum of new connections accepted per second (sessions) */
+	unsigned int nbpend_max;                /* max number of pending connections with no server assigned yet (BE only) */
 	unsigned int cur_sess_max;		/* max number of currently active sessions */
-	unsigned int nbpend_max;		/* max number of pending connections reached */
-	unsigned int sps_max;			/* maximum of new sessions per second seen on this server */
 
-	long long cum_sess;			/* cumulated number of sessions really sent to this server */
-	long long cum_lbconn;			/* cumulated number of sessions directed by load balancing */
-	unsigned long last_sess;                 /* last session time */
+	long long bytes_in;                     /* number of bytes transferred from the client to the server */
+	long long bytes_out;                    /* number of bytes transferred from the server to the client */
 
-	long long bytes_in;			/* number of bytes transferred from the client to the server */
-	long long bytes_out;			/* number of bytes transferred from the server to the client */
+	long long comp_in;                      /* input bytes fed to the compressor */
+	long long comp_out;                     /* output bytes emitted by the compressor */
+	long long comp_byp;                     /* input bytes that bypassed the compressor (cpu/ram/bw limitation) */
 
-	long long failed_conns, failed_resp;	/* failed connect() and responses */
-	long long cli_aborts, srv_aborts;	/* aborted responses during DATA phase due to client or server */
-	long long retries, redispatches;	/* retried and redispatched connections */
+	long long denied_req;                   /* blocked requests because of security concerns */
+	long long denied_resp;                  /* blocked responses because of security concerns */
+
+	long long failed_conns;                 /* failed connect() attempts (BE only) */
+	long long failed_resp;                  /* failed responses (BE only) */
+	long long cli_aborts;                   /* aborted responses during DATA phase caused by the client */
+	long long srv_aborts;                   /* aborted responses during DATA phase caused by the server */
+	long long retries;                      /* retried and redispatched connections (BE only) */
+	long long redispatches;                 /* retried and redispatched connections (BE only) */
 	long long failed_secu;			/* blocked responses because of security concerns */
 
+	long long failed_checks, failed_hana;	/* failed health checks and health analyses for servers */
+	long long down_trans;			/* up->down transitions */
+
 	unsigned int q_time, c_time, d_time, t_time; /* sums of conn_time, queue_time, data_time, total_time */
 
 	union {
 		struct {
-			long long rsp[6];	/* http response codes */
+			long long cum_req;      /* cumulated number of processed HTTP requests */
+			long long comp_rsp;     /* number of compressed responses */
+			unsigned int rps_max;   /* maximum of new HTTP requests second observed */
+			long long rsp[6];       /* http response codes */
 		} http;
-	} p;
-
-	long long failed_checks, failed_hana;	/* failed health checks and health analyses */
-	long long down_trans;			/* up->down transitions */
+	} p;                                    /* protocol-specific stats */
 };
 
 #endif /* _TYPES_COUNTERS_H */
diff --git a/include/types/listener.h b/include/types/listener.h
index 1f14cc0..d06e4e7 100644
--- a/include/types/listener.h
+++ b/include/types/listener.h
@@ -39,7 +39,7 @@
 struct protocol;
 struct xprt_ops;
 struct proxy;
-struct licounters;
+struct fe_counters;
 
 /* listener state */
 enum li_state {
@@ -171,7 +171,7 @@
 	char *name;			/* listener's name */
 	int luid;			/* listener universally unique ID, used for SNMP */
 	int options;			/* socket options : LI_O_* */
-	struct licounters *counters;	/* statistics counters */
+	struct fe_counters *counters;	/* statistics counters */
 	struct protocol *proto;		/* protocol this listener belongs to */
 	struct xprt_ops *xprt;          /* transport-layer operations for this socket */
 	int nbconn;			/* current number of connections on this listener */
diff --git a/include/types/proxy.h b/include/types/proxy.h
index 0b194cb..3bf5a4d 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -362,8 +362,8 @@
 	struct pool_head *req_cap_pool,		/* pools of pre-allocated char ** used to build the streams */
 	                 *rsp_cap_pool;
 	struct list req_add, rsp_add;           /* headers to be added */
-	struct pxcounters be_counters;		/* backend statistics counters */
-	struct pxcounters fe_counters;		/* frontend statistics counters */
+	struct be_counters be_counters;		/* backend statistics counters */
+	struct fe_counters fe_counters;		/* frontend statistics counters */
 
 	struct list listener_queue;		/* list of the temporarily limited listeners because of lack of a proxy resource */
 	struct stktable table;			/* table for storing sticking streams */
diff --git a/include/types/server.h b/include/types/server.h
index c6c581c..20c314b 100644
--- a/include/types/server.h
+++ b/include/types/server.h
@@ -192,7 +192,7 @@
 	int nbpend;				/* number of pending connections */
 	int maxqueue;				/* maximum number of pending connections allowed */
 	struct freq_ctr sess_per_sec;		/* sessions per second on this server */
-	struct srvcounters counters;		/* statistics counters */
+	struct be_counters counters;		/* statistics counters */
 
 	struct list pendconns;			/* pending connections */
 	struct list actconns;			/* active connections */
diff --git a/src/cfgparse.c b/src/cfgparse.c
index fbd7364..4fc63bd 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -9009,7 +9009,7 @@
 
 			/* enable separate counters */
 			if (curproxy->options2 & PR_O2_SOCKSTAT) {
-				listener->counters = calloc(1, sizeof(struct licounters));
+				listener->counters = calloc(1, sizeof(*listener->counters));
 				if (!listener->name)
 					memprintf(&listener->name, "sock-%d", listener->luid);
 			}
diff --git a/src/stats.c b/src/stats.c
index bfd1699..497aa47 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -929,7 +929,6 @@
 			              "<tr><th>- HTTP 4xx responses:</th><td>%s</td></tr>"
 			              "<tr><th>- HTTP 5xx responses:</th><td>%s</td></tr>"
 			              "<tr><th>- other responses:</th><td>%s</td></tr>"
-			              "<tr><th>Intercepted requests:</th><td>%s</td></tr>"
 				      "<tr><th colspan=3>Avg over last 1024 success. conn.</th></tr>"
 			              "",
 			              U2H(stats[ST_F_REQ_TOT].u.u64),
@@ -941,8 +940,7 @@
 			              U2H(stats[ST_F_HRSP_3XX].u.u64),
 			              U2H(stats[ST_F_HRSP_4XX].u.u64),
 			              U2H(stats[ST_F_HRSP_5XX].u.u64),
-			              U2H(stats[ST_F_HRSP_OTHER].u.u64),
-			              U2H(stats[ST_F_INTERCEPTED].u.u64));
+			              U2H(stats[ST_F_HRSP_OTHER].u.u64));
 		}
 
 		chunk_appendf(out, "<tr><th>- Queue time:</th><td>%s</td><td>ms</td></tr>",   U2H(stats[ST_F_QTIME].u.u32));
@@ -1547,7 +1545,6 @@
 		stats[ST_F_HRSP_4XX]    = mkf_u64(FN_COUNTER, px->be_counters.p.http.rsp[4]);
 		stats[ST_F_HRSP_5XX]    = mkf_u64(FN_COUNTER, px->be_counters.p.http.rsp[5]);
 		stats[ST_F_HRSP_OTHER]  = mkf_u64(FN_COUNTER, px->be_counters.p.http.rsp[0]);
-		stats[ST_F_INTERCEPTED] = mkf_u64(FN_COUNTER, px->be_counters.intercepted_req);
 	}
 
 	stats[ST_F_CLI_ABRT]     = mkf_u64(FN_COUNTER, px->be_counters.cli_aborts);
@@ -3065,7 +3062,6 @@
 			px->fe_counters.p.http.rps_max = 0;
 			px->fe_counters.sps_max = 0;
 			px->fe_counters.cps_max = 0;
-			px->fe_counters.nbpend_max = 0;
 		}
 
 		for (sv = px->srv; sv; sv = sv->next)