]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Transport parameters dump
authorFrédéric Lécaille <flecaille@haproxy.com>
Mon, 23 May 2022 07:08:54 +0000 (09:08 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 30 May 2022 07:59:26 +0000 (09:59 +0200)
Add quic_transport_params_dump() static inline function to do so for
a quic_transport_parameters struct as parameter.
We use the trace API do dump these transport parameters both
after they have been initialized (RX/local) or received (TX/remote).

include/haproxy/quic_tp.h
include/haproxy/xprt_quic-t.h
src/quic_tp.c
src/xprt_quic.c

index 92ec9fedd021b6935a9730a01678312780615643..5343e2576203a150ad3ca3c06f162a4f822d25fd 100644 (file)
@@ -5,6 +5,7 @@
 #error "Must define USE_OPENSSL"
 #endif
 
+#include <haproxy/chunk.h>
 #include <haproxy/quic_tp-t.h>
 #include <haproxy/xprt_quic-t.h>
 
@@ -24,5 +25,51 @@ int qc_lstnr_params_init(struct quic_conn *qc,
                          const unsigned char *dcid, size_t dcidlen,
                          const unsigned char *scid, size_t scidlen,
                          const unsigned char *odcid, size_t odcidlen, int token);
+
+/* Dump <cid> transport parameter connection ID value if present (non null length).
+ * Used only for debugging purposes.
+ */
+static inline void quic_tp_cid_dump(struct buffer *buf,
+                                    const struct tp_cid *cid)
+{
+       int i;
+
+       chunk_appendf(buf, "(%d", cid->len);
+       if (cid->len)
+               chunk_appendf(buf, ",");
+       for (i = 0; i < cid->len; i++)
+               chunk_appendf(buf, "%02x", cid->data[i]);
+       chunk_appendf(buf, ")");
+}
+
+static inline void quic_transport_params_dump(struct buffer *b,
+                                              const struct quic_transport_params *p)
+{
+       chunk_appendf(b, "\n\toriginal_destination_connection_id:");
+       quic_tp_cid_dump(b, &p->original_destination_connection_id);
+       chunk_appendf(b, "\n\tinitial_source_connection_id:");
+       quic_tp_cid_dump(b, &p->initial_source_connection_id);
+       chunk_appendf(b, "\n\tretry_source_connection_id:");
+       quic_tp_cid_dump(b, &p->retry_source_connection_id);
+
+       chunk_appendf(b, "\n\tmax_idle_timeout=%llu", (ull)p->max_idle_timeout);
+       chunk_appendf(b, "\n\tmax_udp_payload_size=%llu", (ull)p->max_udp_payload_size);
+       chunk_appendf(b, "\n\tinitial_max_data=%llu", (ull)p->initial_max_data);
+       chunk_appendf(b, "\n\tinitial_max_stream_data_bidi_local=%llu",
+                     (ull)p->initial_max_stream_data_bidi_local);
+       chunk_appendf(b, "\n\tinitial_max_stream_data_bidi_remote=%llu",
+                     (ull)p->initial_max_stream_data_bidi_remote);
+       chunk_appendf(b, "\n\tinitial_max_stream_data_uni=%llu",
+                     (ull)p->initial_max_stream_data_uni);
+       chunk_appendf(b, "\n\tinitial_max_streams_bidi=%llu", (ull)p->initial_max_streams_bidi);
+       chunk_appendf(b, "\n\tinitial_max_streams_uni=%llu", (ull)p->initial_max_streams_uni);
+       chunk_appendf(b, "\n\tack_delay_exponent=%llu", (ull)p->ack_delay_exponent);
+       chunk_appendf(b, "\n\tmax_ack_delay=%llu", (ull)p->max_ack_delay);
+       chunk_appendf(b, "\n\tactive_connection_id_limit=%llu", (ull)p->active_connection_id_limit);
+       chunk_appendf(b, "\n\tdisable_active_migration? %s", p->disable_active_migration ? "yes" : "no");
+       chunk_appendf(b, "\n\twith_stateless_reset_token? %s", p->with_stateless_reset_token ? "yes" : "no");
+       chunk_appendf(b, "\n\twith_preferred_address? %s", p->with_preferred_address ? "yes" : "no");
+}
+
 #endif /* USE_QUIC */
 #endif /* _HAPROXY_QUIC_TP_H */
index b9c728c6f3a6a0b0e499d89aee08bc465a12cdd0..36b85e8b27c7f8088a8ab4bb3010fb8732304b9e 100644 (file)
@@ -239,6 +239,7 @@ enum quic_pkt_type {
 #define           QUIC_EV_CONN_ACKSTRM   (1ULL << 41)
 #define           QUIC_EV_CONN_FRMLIST   (1ULL << 42)
 #define           QUIC_EV_STATELESS_RST  (1ULL << 43)
+#define           QUIC_EV_TRANSP_PARAMS  (1ULL << 44)
 
 /* Similar to kernel min()/max() definitions. */
 #define QUIC_MIN(a, b) ({ \
index 522ff576e76e77e4de6b3011e612eb706af491b8..23a1ff72552b85eccd6ccd1c8eda2710088b1809 100644 (file)
@@ -3,10 +3,13 @@
 #include <haproxy/net_helper.h>
 #include <haproxy/quic_enc.h>
 #include <haproxy/quic_tp.h>
+#include <haproxy/trace.h>
 #include <haproxy/xprt_quic-t.h>
 
 #define QUIC_MAX_UDP_PAYLOAD_SIZE     2048
 
+#define TRACE_SOURCE       &trace_quic
+
 /* This is the values of some QUIC transport parameters when absent.
  * Should be used to initialize any transport parameters (local or remote)
  * before updating them with customized values.
@@ -523,6 +526,8 @@ int quic_transport_params_store(struct quic_conn *qc, int server,
                qc->max_idle_timeout =
                        QUIC_MAX(tx_params->max_idle_timeout, rx_params->max_idle_timeout);
 
+       TRACE_PROTO("\nTX(remote) transp. params.", QUIC_EV_TRANSP_PARAMS, qc, tx_params);
+
        return 1;
 }
 
@@ -564,6 +569,7 @@ int qc_lstnr_params_init(struct quic_conn *qc,
        /* Copy the initial source connection ID. */
        memcpy(rx_params->initial_source_connection_id.data, scid, scidlen);
        rx_params->initial_source_connection_id.len = scidlen;
+       TRACE_PROTO("\nRX(local) transp. params.", QUIC_EV_TRANSP_PARAMS, qc, rx_params);
 
        return 1;
 }
index 502db44af63b9747b6b21629853d8980147d3e97..6df7df604a5616aba1f31da474b7f63e399d872f 100644 (file)
@@ -113,6 +113,7 @@ static const struct trace_event quic_trace_events[] = {
        { .mask = QUIC_EV_CONN_ACKSTRM,  .name = "ack_strm",         .desc = "STREAM ack."},
        { .mask = QUIC_EV_CONN_FRMLIST,  .name = "frm_list",         .desc = "frame list"},
        { .mask = QUIC_EV_STATELESS_RST, .name = "stateless_reset",  .desc = "stateless reset sent"},
+       { .mask = QUIC_EV_TRANSP_PARAMS, .name = "transport_params", .desc = "transport parameters"},
        { /* end */ }
 };
 
@@ -215,6 +216,11 @@ static void quic_trace(enum trace_level level, uint64_t mask, const struct trace
                        quic_cid_dump(&trace_buf, &qc->scid);
                }
 
+               if (mask & QUIC_EV_TRANSP_PARAMS) {
+                       const struct quic_transport_params *p = a2;
+                       quic_transport_params_dump(&trace_buf, p);
+               }
+
                if (mask & QUIC_EV_CONN_ADDDATA) {
                        const enum ssl_encryption_level_t *level = a2;
                        const size_t *len = a3;