From 5dfdf3e5b03f09aa46a516cd8bbd56581db5ed0d Mon Sep 17 00:00:00 2001
From: Amaury Denoyelle <adenoyelle@haproxy.com>
Date: Wed, 5 May 2021 17:09:12 +0200
Subject: [PATCH] MINOR: stats: report tainted on show info

Add a new info field ST_F_TAINTED to dump tainted status at the end of
the 'show info' output.
---
 include/haproxy/stats-t.h | 1 +
 src/stats.c               | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/include/haproxy/stats-t.h b/include/haproxy/stats-t.h
index a9bf25e31..4ab1138ea 100644
--- a/include/haproxy/stats-t.h
+++ b/include/haproxy/stats-t.h
@@ -329,6 +329,7 @@ enum info_field {
 	INF_POOL_ALLOC_BYTES,
 	INF_POOL_USED_BYTES,
 	INF_START_TIME_SEC,
+	INF_TAINTED,
 
 	/* must always be the last one */
 	INF_TOTAL_FIELDS
diff --git a/src/stats.c b/src/stats.c
index d6d3129d1..9862fdd35 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -153,6 +153,7 @@ const struct name_desc info_fields[INF_TOTAL_FIELDS] = {
 	[INF_DEBUG_COMMANDS_ISSUED]          = { .name = "DebugCommandsIssued",         .desc = "Number of debug commands issued on this process (anything > 0 is unsafe)" },
 	[INF_CUM_LOG_MSGS]                   = { .name = "CumRecvLogs",                 .desc = "Total number of log messages received by log-forwarding listeners on this worker process since started" },
 	[INF_BUILD_INFO]                     = { .name = "Build info",                  .desc = "Build info" },
+	[INF_TAINTED]                        = { .name = "Tainted",                     .desc = "Experimental features used" },
 };
 
 const struct name_desc stat_fields[ST_F_TOTAL_FIELDS] = {
@@ -4385,6 +4386,10 @@ int stats_fill_info(struct field *info, int len)
 	info[INF_BYTES_OUT_RATE]                 = mkf_u64(FN_RATE, (unsigned long long)read_freq_ctr(&global.out_32bps) * 32);
 	info[INF_DEBUG_COMMANDS_ISSUED]          = mkf_u32(0, debug_commands_issued);
 	info[INF_CUM_LOG_MSGS]                   = mkf_u32(FN_COUNTER, cum_log_messages);
+
+	info[INF_TAINTED]                        = mkf_str(FO_STATUS, chunk_newstr(out));
+	chunk_appendf(out, "%#x", get_tainted());
+
 	return 1;
 }