From 96edacc5465a0029368e3b874beb4a612de63bd0 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 24 Sep 2024 18:26:36 +0200 Subject: [PATCH] DEV: flags/applet: decode appctx flags Decode APPCTX flags via appctx_show_flags() function. --- dev/flags/flags.c | 5 ++++- include/haproxy/applet-t.h | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/dev/flags/flags.c b/dev/flags/flags.c index 195fdc344c..96d06130f1 100644 --- a/dev/flags/flags.c +++ b/dev/flags/flags.c @@ -4,6 +4,7 @@ /* make the include files below expose their flags */ #define HA_EXPOSE_FLAGS +#include #include #include #include @@ -47,11 +48,12 @@ #define SHOW_AS_SPOPS 0x00800000 #define SHOW_AS_QCC 0x01000000 #define SHOW_AS_QCS 0x02000000 +#define SHOW_AS_APPCTX 0x04000000 // command line names, must be in exact same order as the SHOW_AS_* flags above // so that show_as_words[i] matches flag 1U<flags = %s\n",(spop_strm_show_flags(buf, bsz, " | ", flags), buf)); if (show_as & SHOW_AS_QCC) printf("qcc->flags = %s\n", (qcc_show_flags (buf, bsz, " | ", flags), buf)); if (show_as & SHOW_AS_QCS) printf("qcs->flags = %s\n", (qcs_show_flags (buf, bsz, " | ", flags), buf)); + if (show_as & SHOW_AS_APPCTX) printf("appctx->flags = %s\n", (appctx_show_flags(buf, bsz, " | ", flags), buf)); } return 0; } diff --git a/include/haproxy/applet-t.h b/include/haproxy/applet-t.h index ced9d15c1c..8f0b37e1c9 100644 --- a/include/haproxy/applet-t.h +++ b/include/haproxy/applet-t.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -58,6 +59,28 @@ struct sedesc; struct se_abort_info; struct session; +/* This function is used to report flags in debugging tools. Please reflect + * below any single-bit flag addition above in the same order via the + * __APPEND_FLAG macro. The new end of the buffer is returned. + */ +static forceinline char *appctx_show_flags(char *buf, size_t len, const char *delim, uint flg) +{ +#define _(f, ...) __APPEND_FLAG(buf, len, delim, flg, f, #f, __VA_ARGS__) + /* prologue */ + _(0); + /* flags */ + _(APPCTX_FL_INBLK_ALLOC, _(APPCTX_FL_INBLK_FULL, + _(APPCTX_FL_OUTBLK_ALLOC, _(APPCTX_FL_OUTBLK_FULL, + _(APPCTX_FL_EOI, _(APPCTX_FL_EOS, + _(APPCTX_FL_ERR_PENDING, _(APPCTX_FL_ERROR, + _(APPCTX_FL_SHUTDOWN, _(APPCTX_FL_WANT_DIE, _(APPCTX_FL_INOUT_BUFS, + _(APPCTX_FL_FASTFWD, _(APPCTX_FL_IN_MAYALLOC, _(APPCTX_FL_OUT_MAYALLOC)))))))))))))); + /* epilogue */ + _(~0U); + return buf; +#undef _ +} + /* Applet descriptor */ struct applet { enum obj_type obj_type; /* object type = OBJ_TYPE_APPLET */