CLEANUP: stream: make the dump code not depend on the CLI appctx

The HA_ANON_CLI() helper relies on the CLI appctx and prevents the code
from being made more generic. Let's extract the CLI's anon key separately
and pass it via HA_ANON_STR() instead.
This commit is contained in:
Willy Tarreau 2023-09-27 08:06:18 +02:00
parent 48b2233d36
commit 6c2af048d6
1 changed files with 8 additions and 7 deletions

View File

@ -3253,6 +3253,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm
char pn[INET6_ADDRSTRLEN];
struct connection *conn;
struct appctx *tmpctx;
uint32_t anon_key = appctx->cli_anon_key;
chunk_reset(&trash);
@ -3285,7 +3286,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm
case AF_INET:
case AF_INET6:
chunk_appendf(&trash, " source=%s:%d\n",
HA_ANON_CLI(pn), get_host_port(conn->src));
HA_ANON_STR(anon_key, pn), get_host_port(conn->src));
break;
case AF_UNIX:
chunk_appendf(&trash, " source=unix:%d\n", strm_li(strm)->luid);
@ -3308,7 +3309,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm
chunk_appendf(&trash,
" frontend=%s (id=%u mode=%s), listener=%s (id=%u)",
HA_ANON_CLI(strm_fe(strm)->id), strm_fe(strm)->uuid, proxy_mode_str(strm_fe(strm)->mode),
HA_ANON_STR(anon_key, strm_fe(strm)->id), strm_fe(strm)->uuid, proxy_mode_str(strm_fe(strm)->mode),
strm_li(strm) ? strm_li(strm)->name ? strm_li(strm)->name : "?" : "?",
strm_li(strm) ? strm_li(strm)->luid : 0);
@ -3316,7 +3317,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm
case AF_INET:
case AF_INET6:
chunk_appendf(&trash, " addr=%s:%d\n",
HA_ANON_CLI(pn), get_host_port(conn->dst));
HA_ANON_STR(anon_key, pn), get_host_port(conn->dst));
break;
case AF_UNIX:
chunk_appendf(&trash, " addr=unix:%d\n", strm_li(strm)->luid);
@ -3330,7 +3331,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm
if (strm->be->cap & PR_CAP_BE)
chunk_appendf(&trash,
" backend=%s (id=%u mode=%s)",
HA_ANON_CLI(strm->be->id),
HA_ANON_STR(anon_key, strm->be->id),
strm->be->uuid, proxy_mode_str(strm->be->mode));
else
chunk_appendf(&trash, " backend=<NONE> (id=-1 mode=-)");
@ -3340,7 +3341,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm
case AF_INET:
case AF_INET6:
chunk_appendf(&trash, " addr=%s:%d\n",
HA_ANON_CLI(pn), get_host_port(conn->src));
HA_ANON_STR(anon_key, pn), get_host_port(conn->src));
break;
case AF_UNIX:
chunk_appendf(&trash, " addr=unix\n");
@ -3354,7 +3355,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm
if (strm->be->cap & PR_CAP_BE)
chunk_appendf(&trash,
" server=%s (id=%u)",
objt_server(strm->target) ? HA_ANON_CLI(__objt_server(strm->target)->id) : "<none>",
objt_server(strm->target) ? HA_ANON_STR(anon_key, __objt_server(strm->target)->id) : "<none>",
objt_server(strm->target) ? __objt_server(strm->target)->puid : 0);
else
chunk_appendf(&trash, " server=<NONE> (id=-1)");
@ -3363,7 +3364,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm
case AF_INET:
case AF_INET6:
chunk_appendf(&trash, " addr=%s:%d\n",
HA_ANON_CLI(pn), get_host_port(conn->dst));
HA_ANON_STR(anon_key, pn), get_host_port(conn->dst));
break;
case AF_UNIX:
chunk_appendf(&trash, " addr=unix\n");