]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: flags/mux-h1: decode H1C and H1S flags
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 15 Sep 2022 08:54:36 +0000 (10:54 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 15 Sep 2022 09:01:59 +0000 (11:01 +0200)
The new functions h1c_show_flags() and h1s_show_flags() decode the flags
state into a string, and are used by dev/flags:

$ /dev/flags/flags h1c 0x2200
h1c->flags = H1C_F_ST_READY | H1C_F_ST_ATTACHED

./dev/flags/flags h1s 0x190
h1s->flags = H1S_F_BODYLESS_RESP | H1S_F_NOT_FIRST | H1S_F_WANT_KAL

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

index c587cab990938566975f6e09f3790db4b4755786..c0cc067f4c51a8d49e9fe545669492d3b2b0f893 100644 (file)
@@ -7,6 +7,7 @@
 #include <haproxy/http_ana-t.h>
 #include <haproxy/htx-t.h>
 #include <haproxy/mux_h2-t.h>
+#include <haproxy/mux_h1-t.h>
 #include <haproxy/stconn-t.h>
 #include <haproxy/stream-t.h>
 #include <haproxy/task-t.h>
 #define SHOW_AS_FD    0x00001000
 #define SHOW_AS_H2C   0x00002000
 #define SHOW_AS_H2S   0x00004000
+#define SHOW_AS_H1C   0x00008000
+#define SHOW_AS_H1S   0x00010000
 
 // 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", };
+const char *show_as_words[] = { "ana", "chn", "conn", "sc", "stet", "strm", "task", "txn", "sd", "hsl", "htx", "hmsg", "fd", "h2c", "h2s",  "h1c", "h1s", };
 
 /* will be sufficient for even largest flag names */
 static char buf[4096];
@@ -139,6 +142,8 @@ int main(int argc, char **argv)
                if (show_as & SHOW_AS_FD)    printf("fd->flags = %s\n",   (fd_show_flags     (buf, bsz, " | ", flags), buf));
                if (show_as & SHOW_AS_H2C)   printf("h2c->flags = %s\n",  (h2c_show_flags    (buf, bsz, " | ", flags), buf));
                if (show_as & SHOW_AS_H2S)   printf("h2s->flags = %s\n",  (h2s_show_flags    (buf, bsz, " | ", flags), buf));
+               if (show_as & SHOW_AS_H1C)   printf("h1c->flags = %s\n",  (h1c_show_flags    (buf, bsz, " | ", flags), buf));
+               if (show_as & SHOW_AS_H1S)   printf("h1s->flags = %s\n",  (h1s_show_flags    (buf, bsz, " | ", flags), buf));
        }
        return 0;
 }
index e8effb0b58af31495eb735bbf5a04367123e327a..18e0c0f42abec631f102dcec196c8f2cbad93092 100644 (file)
@@ -23,6 +23,7 @@
 #define _HAPROXY_MUX_H1_T_H
 
 #include <haproxy/api-t.h>
+#include <haproxy/show_flags-t.h>
 
 /**** Connection flags (32 bit), in h1c->flags ****/
 #define H1C_F_NONE           0x00000000
 #define H1C_F_IS_BACK        0x80000000 /* Set on outgoing connection */
 
 
+/* 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 *h1c_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 */
+       _(H1C_F_OUT_ALLOC, _(H1C_F_OUT_FULL,
+       _(H1C_F_IN_ALLOC, _(H1C_F_IN_FULL, _(H1C_F_IN_SALLOC,
+       _(H1C_F_ST_EMBRYONIC, _(H1C_F_ST_ATTACHED, _(H1C_F_ST_IDLE,
+       _(H1C_F_ST_ERROR, _(H1C_F_ST_SHUTDOWN, _(H1C_F_ST_READY,
+       _(H1C_F_ST_SILENT_SHUT, _(H1C_F_WANT_SPLICE, _(H1C_F_ERR_PENDING,
+       _(H1C_F_WAIT_NEXT_REQ, _(H1C_F_UPG_H2C, _(H1C_F_CO_MSG_MORE,
+       _(H1C_F_CO_STREAMER, _(H1C_F_IS_BACK)))))))))))))))))));
+       /* epilogue */
+       _(~0U);
+       return buf;
+#undef _
+}
+
+
 /**** H1 stream flags (32 bit), in h1s->flags ****/
 #define H1S_F_NONE           0x00000000
 
 #define H1S_F_HAVE_SRV_NAME  0x00002000 /* Set during output process if the server name header was added to the request */
 #define H1S_F_HAVE_O_CONN    0x00004000 /* Set during output process to know connection mode was processed */
 
+/* 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 *h1s_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 */
+       _(H1S_F_RX_BLK, _(H1S_F_TX_BLK, _(H1S_F_RX_CONGESTED,
+       _(H1S_F_REOS, _(H1S_F_WANT_KAL, _(H1S_F_WANT_TUN, _(H1S_F_WANT_CLO,
+       _(H1S_F_NOT_FIRST, _(H1S_F_BODYLESS_RESP,
+       _(H1S_F_NOT_IMPL_ERROR, _(H1S_F_PARSING_ERROR, _(H1S_F_PROCESSING_ERROR,
+       _(H1S_F_HAVE_SRV_NAME, _(H1S_F_HAVE_O_CONN))))))))))))));
+       /* epilogue */
+       _(~0U);
+       return buf;
+#undef _
+}
+
 
 #endif /* _HAPROXY_MUX_H1_T_H */