]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MAJOR: conn-idle: fix hash indexing issues on idle conns
authorWilly Tarreau <w@1wt.eu>
Thu, 29 Sep 2022 18:32:43 +0000 (20:32 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 3 Oct 2022 10:06:36 +0000 (12:06 +0200)
commit852234848241f61a976f8856123a34a3c19275ba
tree7f029fc4c4146cb811e7d64aee202e46637e788c
parent94ab139266a2d2d39f7254644f69fb699559e8e2
BUG/MAJOR: conn-idle: fix hash indexing issues on idle conns

Idle connections do not work on 32-bit machines due to an alignment issue
causing the connection nodes to be indexed with their lower 32-bits set to
zero and the higher 32 ones containing the 32 lower bitss of the hash. The
cause is the use of ebmb_node with an aligned data, as on this platform
ebmb_node is only 32-bit aligned, leaving a hole before the following hash
which is a uint64_t:

  $ pahole -C conn_hash_node ./haproxy
  struct conn_hash_node {
        struct ebmb_node           node;                 /*     0    20 */

        /* XXX 4 bytes hole, try to pack */

        int64_t                    hash;                 /*    24     8 */
        struct connection *        conn;                 /*    32     4 */

        /* size: 40, cachelines: 1, members: 3 */
        /* sum members: 32, holes: 1, sum holes: 4 */
        /* padding: 4 */
        /* last cacheline: 40 bytes */
  };

Instead, eb64 nodes should be used when it comes to simply storing a
64-bit key, and that is what this patch does.

For backports, a variant consisting in simply marking the "hash" member
with a "packed" attribute on the struct also does the job (tested), and
might be preferable if the fix is difficult to adapt. Only 2.6 and 2.5
are affected by this.
include/haproxy/connection-t.h
include/haproxy/connection.h
include/haproxy/session.h
src/backend.c
src/connection.c
src/mux_fcgi.c
src/mux_h1.c
src/mux_h2.c
src/server.c
src/ssl_sock.c