]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: flags/mux-quic: decode qcc and qcs flags
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 31 Jul 2024 15:58:02 +0000 (17:58 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 31 Jul 2024 15:59:35 +0000 (17:59 +0200)
Decode QUIC MUX connection and stream elements via qcc_show_flags() and
qcs_show_flags(). Flags definition have been moved outside of USE_QUIC
to ease compilation of flags binary.

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

index 4d1bc2c4f7d05e9a9c4df34f17dbbad26746b660..195fdc344c4d4894e3a02991d58fae8fde0ee83b 100644 (file)
@@ -12,6 +12,7 @@
 #include <haproxy/mux_fcgi-t.h>
 #include <haproxy/mux_h2-t.h>
 #include <haproxy/mux_h1-t.h>
+#include <haproxy/mux_quic-t.h>
 #include <haproxy/mux_spop-t.h>
 #include <haproxy/peers-t.h>
 #include <haproxy/quic_conn-t.h>
 #define SHOW_AS_QC    0x00200000
 #define SHOW_AS_SPOPC 0x00400000
 #define SHOW_AS_SPOPS 0x00800000
+#define SHOW_AS_QCC   0x01000000
+#define SHOW_AS_QCS   0x02000000
 
 // 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"};
+                               "peers", "peer", "qc", "spopc", "spops", "qcc", "qcs"};
 
 /* will be sufficient for even largest flag names */
 static char buf[4096];
@@ -166,6 +169,8 @@ int main(int argc, char **argv)
                if (show_as & SHOW_AS_QC)    printf("qc->flags = %s\n",   (qc_show_flags     (buf, bsz, " | ", flags), buf));
                if (show_as & SHOW_AS_SPOPC) printf("spopc->flags = %s\n",(spop_conn_show_flags(buf, bsz, " | ", flags), buf));
                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));
        }
        return 0;
 }
index 02f8a72fe59d7f387b9ad1cf288418ad32d87236..daf39f1e87aac7e51e1a6e9928c9ca097bdd9d80 100644 (file)
@@ -29,13 +29,6 @@ enum qcs_type {
        QCS_MAX_TYPES
 };
 
-#define QC_CF_ERRL      0x00000001 /* fatal error detected locally, connection should be closed soon */
-#define QC_CF_ERRL_DONE 0x00000002 /* local error properly handled, connection can be released */
-/* unused 0x00000004 */
-#define QC_CF_CONN_FULL 0x00000008 /* no stream buffers available on connection */
-#define QC_CF_APP_SHUT  0x00000010 /* Application layer shutdown done. */
-#define QC_CF_ERR_CONN  0x00000020 /* fatal error reported by transport layer */
-
 struct qcc {
        struct connection *conn;
        uint64_t nb_sc; /* number of attached stream connectors */
@@ -103,20 +96,6 @@ struct qcc {
        void *ctx; /* Application layer context */
 };
 
-#define QC_SF_NONE              0x00000000
-#define QC_SF_SIZE_KNOWN        0x00000001  /* last frame received for this stream */
-#define QC_SF_FIN_STREAM        0x00000002  /* FIN bit must be set for last frame of the stream */
-#define QC_SF_BLK_MROOM         0x00000004  /* app layer is blocked waiting for room in the qcs.tx.buf */
-#define QC_SF_DETACH            0x00000008  /* sc is detached but there is remaining data to send */
-/* unused 0x00000010 */
-#define QC_SF_DEM_FULL          0x00000020  /* demux blocked on request channel buffer full */
-#define QC_SF_READ_ABORTED      0x00000040  /* Rx closed using STOP_SENDING*/
-#define QC_SF_TO_RESET          0x00000080  /* a RESET_STREAM must be sent */
-#define QC_SF_HREQ_RECV         0x00000100  /* a full HTTP request has been received */
-#define QC_SF_TO_STOP_SENDING   0x00000200  /* a STOP_SENDING must be sent */
-#define QC_SF_UNKNOWN_PL_LENGTH 0x00000400  /* HTX EOM may be missing from the stream layer */
-#define QC_SF_RECV_RESET        0x00000800  /* a RESET_STREAM was received */
-
 /* Maximum size of stream Rx buffer. */
 #define QC_S_RX_BUF_SZ   (global.tune.bufsize - NCB_RESERVED_SZ)
 
@@ -223,4 +202,73 @@ struct qcc_app_ops {
 
 #endif /* USE_QUIC */
 
+#define QC_CF_ERRL      0x00000001 /* fatal error detected locally, connection should be closed soon */
+#define QC_CF_ERRL_DONE 0x00000002 /* local error properly handled, connection can be released */
+/* unused 0x00000004 */
+#define QC_CF_CONN_FULL 0x00000008 /* no stream buffers available on connection */
+#define QC_CF_APP_SHUT  0x00000010 /* Application layer shutdown done. */
+#define QC_CF_ERR_CONN  0x00000020 /* fatal error reported by transport layer */
+
+/* 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 *qcc_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 */
+       _(QC_CF_ERRL,
+       _(QC_CF_ERRL_DONE,
+       _(QC_CF_CONN_FULL,
+       _(QC_CF_APP_SHUT,
+       _(QC_CF_ERR_CONN)))));
+       /* epilogue */
+       _(~0U);
+       return buf;
+#undef _
+}
+
+#define QC_SF_NONE              0x00000000
+#define QC_SF_SIZE_KNOWN        0x00000001  /* last frame received for this stream */
+#define QC_SF_FIN_STREAM        0x00000002  /* FIN bit must be set for last frame of the stream */
+#define QC_SF_BLK_MROOM         0x00000004  /* app layer is blocked waiting for room in the qcs.tx.buf */
+#define QC_SF_DETACH            0x00000008  /* sc is detached but there is remaining data to send */
+/* unused 0x00000010 */
+#define QC_SF_DEM_FULL          0x00000020  /* demux blocked on request channel buffer full */
+#define QC_SF_READ_ABORTED      0x00000040  /* Rx closed using STOP_SENDING*/
+#define QC_SF_TO_RESET          0x00000080  /* a RESET_STREAM must be sent */
+#define QC_SF_HREQ_RECV         0x00000100  /* a full HTTP request has been received */
+#define QC_SF_TO_STOP_SENDING   0x00000200  /* a STOP_SENDING must be sent */
+#define QC_SF_UNKNOWN_PL_LENGTH 0x00000400  /* HTX EOM may be missing from the stream layer */
+#define QC_SF_RECV_RESET        0x00000800  /* a RESET_STREAM was received */
+
+/* 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 *qcs_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 */
+       _(QC_SF_SIZE_KNOWN,
+       _(QC_SF_FIN_STREAM,
+       _(QC_SF_BLK_MROOM,
+       _(QC_SF_DETACH,
+       _(QC_SF_DEM_FULL,
+       _(QC_SF_READ_ABORTED,
+       _(QC_SF_TO_RESET,
+       _(QC_SF_HREQ_RECV,
+       _(QC_SF_TO_STOP_SENDING,
+       _(QC_SF_UNKNOWN_PL_LENGTH,
+       _(QC_SF_RECV_RESET)))))))))));
+       /* epilogue */
+       _(~0U);
+       return buf;
+#undef _
+}
+
 #endif /* _HAPROXY_MUX_QUIC_T_H */