]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
Revert "BUG/MAJOR: stats-file: ensure shm_stats_file_object struct mapping consistency"
authorAurelien DARRAGON <adarragon@haproxy.com>
Fri, 24 Oct 2025 07:08:56 +0000 (09:08 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Fri, 24 Oct 2025 07:35:25 +0000 (09:35 +0200)
This reverts commit d30b88a6cc47d662e92b524ad5818be312401d0e.
As discussed in GH #3168, this works but it is not the proper way to fix
the issue. See following commits.

include/haproxy/counters-t.h

index 5ea153cf48fb774c9b97860196f0ecf28da3f988..13dd8f88a39d084301ab23de1df190b67e920386 100644 (file)
  */
 #define COUNTERS_SHARED_TG                                                           \
        struct {                                                                     \
-               FIXED_SIZE(8, unsigned long, last_state_change); /* last time, when the state was changed */\
-               FIXED_SIZE(8, long long, srv_aborts);            /* aborted responses during DATA phase caused by the server */\
-               FIXED_SIZE(8, long long, cli_aborts);            /* aborted responses during DATA phase caused by the client */\
-               FIXED_SIZE(8, long long, internal_errors);       /* internal processing errors */\
-               FIXED_SIZE(8, long long, failed_rewrites);       /* failed rewrites (warning) */\
-               FIXED_SIZE(8, long long, bytes_out);             /* number of bytes transferred from the server to the client */\
-               FIXED_SIZE(8, long long, bytes_in);              /* number of bytes transferred from the client to the server */\
-               FIXED_SIZE(8, long long, denied_resp);           /* blocked responses because of security concerns */\
-               FIXED_SIZE(8, long long, denied_req);            /* blocked requests because of security concerns */\
-               FIXED_SIZE(8, long long, cum_sess);              /* cumulated number of accepted connections */\
+               unsigned long last_state_change;        /* last time, when the state was changed */\
+               long long srv_aborts;                   /* aborted responses during DATA phase caused by the server */\
+               long long cli_aborts;                   /* aborted responses during DATA phase caused by the client */\
+               long long internal_errors;              /* internal processing errors */\
+               long long failed_rewrites;              /* failed rewrites (warning) */\
+               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 denied_resp;                  /* blocked responses because of security concerns */\
+               long long denied_req;                   /* blocked requests because of security concerns */\
+               long long    cum_sess;                  /* cumulated number of accepted connections */\
                /* compression counters, index 0 for requests, 1 for responses */\
-               FIXED_SIZE_ARRAY(8, 2, long long, comp_in);      /* input bytes fed to the compressor */\
-               FIXED_SIZE_ARRAY(8, 2, long long, comp_out);     /* output bytes emitted by the compressor */\
-               FIXED_SIZE_ARRAY(8, 2, long long, comp_byp);     /* input bytes that bypassed the compressor (cpu/ram/bw limitation) */\
-               struct freq_ctr sess_per_sec;                    /* sessions per second on this server */\
-               ALWAYS_PAD(4);                                   /* ensure 4 bytes hole is consistent 32bits vs 64 bits systems */\
-       };
+               long long comp_in[2];                   /* input bytes fed to the compressor */\
+               long long comp_out[2];                  /* output bytes emitted by the compressor */\
+               long long comp_byp[2];                  /* input bytes that bypassed the compressor (cpu/ram/bw limitation) */\
+               struct freq_ctr sess_per_sec;           /* sessions per second on this server */\
+       }
 
 // for convenience (generic pointer)
 struct counters_shared {
@@ -70,32 +69,30 @@ struct counters_shared {
  * /!\ any change performed here will impact shm-stats-file mapping because the
  * struct is embedded in shm_stats_file_object struct, so proceed with caution
  * and change shm stats file version if needed
- *
- * fixed width integers should be used
  */
 struct fe_counters_shared_tg {
        COUNTERS_SHARED_TG;
 
-       FIXED_SIZE(8, long long, denied_sess);                      /* denied session requests (tcp-req-sess rules) */
-       FIXED_SIZE(8, long long, denied_conn);                      /* denied connection requests (tcp-req-conn rules) */
-       FIXED_SIZE(8, long long, intercepted_req);                  /* number of monitoring or stats requests intercepted by the frontend */
-       FIXED_SIZE(8, long long, cum_conn);                         /* cumulated number of received connections */
-       struct freq_ctr conn_per_sec;                               /* received connections per second on the frontend */
+       long long denied_sess;                  /* denied session requests (tcp-req-sess rules) */
+       long long denied_conn;                  /* denied connection requests (tcp-req-conn rules) */
+       long long intercepted_req;              /* number of monitoring or stats requests intercepted by the frontend */
+       long long    cum_conn;                  /* cumulated number of received connections */
+       struct freq_ctr conn_per_sec;           /* received connections per second on the frontend */
 
-       struct freq_ctr req_per_sec;                                /* HTTP requests per second on the frontend */
+       struct freq_ctr req_per_sec;            /* HTTP requests per second on the frontend */
 
-       FIXED_SIZE_ARRAY(8, 3, long long, cum_sess_ver);            /* cumulated number of h1/h2/h3 sessions */
+       long long    cum_sess_ver[3];           /* cumulated number of h1/h2/h3 sessions */
        union {
                struct {
-                       FIXED_SIZE_ARRAY(8, 4, long long, cum_req); /* cumulated number of processed other/h1/h2/h3 requests */
-                       FIXED_SIZE(8, long long, cache_hits);       /* cache hits */
-                       FIXED_SIZE(8, long long, cache_lookups);    /* cache lookups */
-                       FIXED_SIZE(8, long long, comp_rsp);         /* number of compressed responses */
-                       FIXED_SIZE_ARRAY(8, 6, long long, rsp);     /* http response codes */
+                       long long cum_req[4];   /* cumulated number of processed other/h1/h2/h3 requests */
+                       long long cache_hits;   /* cache hits */
+                       long long cache_lookups;/* cache lookups */
+                       long long comp_rsp;     /* number of compressed responses */
+                       long long rsp[6];       /* http response codes */
                } http;
-       } p;                                                        /* protocol-specific stats */
+       } p;                                    /* protocol-specific stats */
 
-       FIXED_SIZE(8, long long, failed_req);                       /* failed requests (eg: invalid or timeout) */
+       long long failed_req;                   /* failed requests (eg: invalid or timeout) */
 };
 
 struct fe_counters_shared {
@@ -124,36 +121,35 @@ struct fe_counters {
 /* /!\ any change performed here will impact shm-stats-file mapping because the
  * struct is embedded in shm_stats_file_object struct, so proceed with caution
  * and change shm stats file version if needed
- *
- * fixed width integer types should be used
  */
 struct be_counters_shared_tg {
        COUNTERS_SHARED_TG;
 
-       FIXED_SIZE(8, long long, cum_lbconn);                   /* cumulated number of sessions processed by load balancing (BE only) */
+       long long  cum_lbconn;                  /* cumulated number of sessions processed by load balancing (BE only) */
 
-       FIXED_SIZE(8, long long, connect);                      /* number of connection establishment attempts */
-       FIXED_SIZE(8, long long, reuse);                        /* number of connection reuses */
-       FIXED_SIZE(8, unsigned long, last_sess);                /* last session time */
+       long long connect;                      /* number of connection establishment attempts */
+       long long reuse;                        /* number of connection reuses */
+       unsigned long last_sess;                /* last session time */
 
-       FIXED_SIZE(8, long long, failed_checks);                /* failed health checks */
-       FIXED_SIZE(8, long long, failed_hana);                  /* failed health analyses */
-       FIXED_SIZE(8, long long, down_trans);                   /* up->down transitions */
+       long long failed_checks, failed_hana;   /* failed health checks and health analyses for servers */
+       long long down_trans;                   /* up->down transitions */
 
        union {
                struct {
-                       FIXED_SIZE(8, long long, cum_req);      /* cumulated number of processed HTTP requests */
-                       FIXED_SIZE(8, long long, cache_hits);   /* cache hits */
-                       FIXED_SIZE(8, long long, cache_lookups);/* cache lookups */
-                       FIXED_SIZE(8, long long, comp_rsp);     /* number of compressed responses */
-                       FIXED_SIZE_ARRAY(8, 6, long long, rsp); /* http response codes */
+                       long long cum_req;      /* cumulated number of processed HTTP requests */
+
+                       long long cache_hits;   /* cache hits */
+                       long long cache_lookups;/* cache lookups */
+                       long long comp_rsp;     /* number of compressed responses */
+                       long long rsp[6];       /* http response codes */
+
                } http;
-       } p;                                                    /* protocol-specific stats */
+       } p;                                    /* protocol-specific stats */
 
-       FIXED_SIZE(8, long long, redispatches);                 /* retried and redispatched connections (BE only) */
-       FIXED_SIZE(8, long long, retries);                      /* retried and redispatched connections (BE only) */
-       FIXED_SIZE(8, long long, failed_resp);                  /* failed responses (BE only) */
-       FIXED_SIZE(8, long long, failed_conns);                 /* failed connect() attempts (BE only) */
+       long long redispatches;                 /* retried and redispatched connections (BE only) */
+       long long retries;                      /* retried and redispatched connections (BE only) */
+       long long failed_resp;                  /* failed responses (BE only) */
+       long long failed_conns;                 /* failed connect() attempts (BE only) */
 };
 
 struct be_counters_shared {