]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEV: flags/applet: decode appctx flags
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 24 Sep 2024 16:26:36 +0000 (18:26 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 24 Sep 2024 16:26:36 +0000 (18:26 +0200)
Decode APPCTX flags via appctx_show_flags() function.

dev/flags/flags.c
include/haproxy/applet-t.h

index 195fdc344c4d4894e3a02991d58fae8fde0ee83b..96d06130f1715f62c66de8e247d86a4797cb17de 100644 (file)
@@ -4,6 +4,7 @@
 /* make the include files below expose their flags */
 #define HA_EXPOSE_FLAGS
 
+#include <haproxy/applet-t.h>
 #include <haproxy/channel-t.h>
 #include <haproxy/connection-t.h>
 #include <haproxy/fd-t.h>
 #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<<i.
 const char *show_as_words[] = { "ana", "chn", "conn", "sc", "stet", "strm", "task", "txn", "sd", "hsl", "htx", "hmsg", "fd", "h2c", "h2s",  "h1c", "h1s", "fconn", "fstrm",
-                               "peers", "peer", "qc", "spopc", "spops", "qcc", "qcs"};
+                               "peers", "peer", "qc", "spopc", "spops", "qcc", "qcs", "appctx"};
 
 /* will be sufficient for even largest flag names */
 static char buf[4096];
@@ -171,6 +173,7 @@ int main(int argc, char **argv)
                if (show_as & SHOW_AS_SPOPS) printf("spops->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;
 }
index ced9d15c1cdb152af3365d370c9c43c28bd0001f..8f0b37e1c90f00c52e87b3706fa0365cf87d22a0 100644 (file)
@@ -27,6 +27,7 @@
 #include <haproxy/dynbuf-t.h>
 #include <haproxy/freq_ctr-t.h>
 #include <haproxy/obj_type-t.h>
+#include <haproxy/show_flags-t.h>
 #include <haproxy/task-t.h>
 #include <haproxy/xref-t.h>
 
@@ -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 */