]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: flags/htx: use flag dumping to show htx and start-line flags
authorWilly Tarreau <w@1wt.eu>
Fri, 9 Sep 2022 14:59:29 +0000 (16:59 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 9 Sep 2022 14:59:29 +0000 (16:59 +0200)
The function are respectively htx_show_flags() and hsl_show_flags().

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

index b16bed2ee55e51b1043aa7258e8d5d40f7700c04..1afa9a9e2c4bd380c23b049eb1b070b95c2ace40 100644 (file)
@@ -5,6 +5,7 @@
 #include <haproxy/connection-t.h>
 #include <haproxy/stconn-t.h>
 #include <haproxy/http_ana-t.h>
+#include <haproxy/htx-t.h>
 #include <haproxy/stream-t.h>
 #include <haproxy/task-t.h>
 
 #define SHOW_AS_TASK  0x00000040
 #define SHOW_AS_TXN   0x00000080
 #define SHOW_AS_SD    0x00000100
+#define SHOW_AS_HSL   0x00000200
+#define SHOW_AS_HTX   0x00000400
 
 // 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", };
+const char *show_as_words[] = { "ana", "chn", "conn", "sc", "stet", "strm", "task", "txn", "sd", "hsl", "htx", };
 
 /* will be sufficient for even largest flag names */
 static char buf[4096];
@@ -124,6 +127,8 @@ int main(int argc, char **argv)
                if (show_as & SHOW_AS_STRM)  printf("strm->flags = %s\n", (strm_show_flags   (buf, bsz, " | ", flags), buf));
                if (show_as & SHOW_AS_TASK)  printf("task->state = %s\n", (task_show_state   (buf, bsz, " | ", flags), buf));
                if (show_as & SHOW_AS_TXN)   printf("txn->flags = %s\n",  (txn_show_flags    (buf, bsz, " | ", flags), buf));
+               if (show_as & SHOW_AS_HSL)   printf("sl->flags = %s\n",   (hsl_show_flags    (buf, bsz, " | ", flags), buf));
+               if (show_as & SHOW_AS_HTX)   printf("htx->flags = %s\n",  (htx_show_flags    (buf, bsz, " | ", flags), buf));
        }
        return 0;
 }
index 404a66e80dd6d9a2ed1ed533a7ae629e8aaec81a..1c970eb1b8ff759d2e0eeee6cdef8b91ed6c40df 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <haproxy/api.h>
 #include <haproxy/http-t.h>
+#include <haproxy/show_flags-t.h>
 
 /*
  * The internal representation of an HTTP message, called HTX, is a structure
  *
  */
 
-/* HTX start-line flags */
+/* HTX start-line flags.
+ * Please also update the se_show_flags() function below in case of changes.
+ */
 #define HTX_SL_F_NONE           0x00000000
 #define HTX_SL_F_IS_RESP        0x00000001 /* It is the response start-line (unset means the request one) */
 #define HTX_SL_F_XFER_LEN       0x00000002 /* The message xfer size can be dertermined */
 #define HTX_SL_F_NORMALIZED_URI 0x00000800 /* The received URI is normalized (an implicit absolute-uri form) */
 #define HTX_SL_F_CONN_UPG       0x00001000 /* The message contains "connection: upgrade" header */
 
-/* HTX flags */
+/* 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 *hsl_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 */
+
+       _(HTX_SL_F_IS_RESP, _(HTX_SL_F_XFER_LEN, _(HTX_SL_F_XFER_ENC,
+       _(HTX_SL_F_CLEN, _(HTX_SL_F_CHNK, _(HTX_SL_F_VER_11,
+       _(HTX_SL_F_BODYLESS, _(HTX_SL_F_HAS_SCHM, _(HTX_SL_F_SCHM_HTTP,
+       _(HTX_SL_F_SCHM_HTTPS, _(HTX_SL_F_HAS_AUTHORITY,
+       _(HTX_SL_F_NORMALIZED_URI, _(HTX_SL_F_CONN_UPG)))))))))))));
+       /* epilogue */
+       _(~0U);
+       return buf;
+#undef _
+}
+
+/* HTX flags.
+ * Please also update the htx_show_flags() function below in case of changes.
+ */
 #define HTX_FL_NONE              0x00000000
 #define HTX_FL_PARSING_ERROR     0x00000001 /* Set when a parsing error occurred */
 #define HTX_FL_PROCESSING_ERROR  0x00000002 /* Set when a processing error occurred */
 #define HTX_FL_EOM               0x00000010 /* Set when end-of-message is reached from the HTTP point of view
                                             * (at worst, on the EOM block is missing)
                                             */
+/* 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 *htx_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 */
+       _(HTX_FL_PARSING_ERROR, _(HTX_FL_PROCESSING_ERROR,
+       _(HTX_FL_FRAGMENTED, _(HTX_FL_PROXY_RESP, _(HTX_FL_EOM)))));
+       /* epilogue */
+       _(~0U);
+       return buf;
+#undef _
+}
+
 
 /* HTX block's type (max 15). */
 enum htx_blk_type {