QLOG: Events: Implement recovery:packet_lost
authorHugo Landau <hlandau@openssl.org>
Fri, 8 Sep 2023 12:32:17 +0000 (13:32 +0100)
committerHugo Landau <hlandau@openssl.org>
Fri, 2 Feb 2024 11:49:34 +0000 (11:49 +0000)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22037)

include/internal/qlog_event_helpers.h
include/internal/qlog_events.h
ssl/quic/qlog_event_helpers.c
ssl/quic/quic_fifd.c

index 4a19a79e2529a6f116a95b08c43f9723afc1ec32..49bbe717d0a681d4c70c1efed4bb354efb4679e1 100644 (file)
@@ -14,6 +14,7 @@
 # include "internal/qlog.h"
 # include "internal/quic_types.h"
 # include "internal/quic_channel.h"
+# include "internal/quic_txpim.h"
 
 /* connectivity:connection_started */
 void ossl_qlog_event_connectivity_connection_started(QLOG *qlog,
@@ -30,4 +31,8 @@ void ossl_qlog_event_connectivity_connection_state_updated(QLOG *qlog,
 void ossl_qlog_event_connectivity_connection_closed(QLOG *qlog,
                                                     const QUIC_TERMINATE_CAUSE *tcause);
 
+/* recovery:packet_lost */
+void ossl_qlog_event_recovery_packet_lost(QLOG *qlog,
+                                          const QUIC_TXPIM_PKT *tpkt);
+
 #endif
index ec365c0009897aff28e886f9e60b6fdebf1af668..3b8cf78f434f53cdec0323aae872f701de5b6245 100644 (file)
@@ -10,3 +10,4 @@ QLOG_EVENT(connectivity, connection_started)
 QLOG_EVENT(connectivity, connection_state_updated)
 QLOG_EVENT(connectivity, connection_closed)
 QLOG_EVENT(transport, parameters_set)
+QLOG_EVENT(recovery, packet_lost)
index d8deac6e02e356de2501ebfca7aa40b42feab2c7..d31a60b2f8003a2fb043755bcece12158860ff4b 100644 (file)
@@ -145,3 +145,39 @@ void ossl_qlog_event_connectivity_connection_closed(QLOG *qlog,
     QLOG_EVENT_END()
 #endif
 }
+
+#ifndef OPENSSL_NO_QLOG
+static const char *quic_pkt_type_to_qlog(uint32_t pkt_type)
+{
+    switch (pkt_type) {
+        case QUIC_PKT_TYPE_INITIAL:
+            return "initial";
+        case QUIC_PKT_TYPE_HANDSHAKE:
+            return "handshake";
+        case QUIC_PKT_TYPE_0RTT:
+            return "0RTT";
+        case QUIC_PKT_TYPE_1RTT:
+            return "1RTT";
+        case QUIC_PKT_TYPE_VERSION_NEG:
+            return "version_negotiation";
+        case QUIC_PKT_TYPE_RETRY:
+            return "retry";
+        default:
+            return "unknown";
+    }
+}
+#endif
+
+void ossl_qlog_event_recovery_packet_lost(QLOG *qlog,
+                                          const QUIC_TXPIM_PKT *tpkt)
+{
+#ifndef OPENSSL_NO_QLOG
+    QLOG_EVENT_BEGIN(qlog, recovery, packet_lost)
+        QLOG_BEGIN("header")
+            QLOG_STR("packet_type", quic_pkt_type_to_qlog(tpkt->pkt_type));
+            if (ossl_quic_pkt_type_has_pn(tpkt->pkt_type))
+                QLOG_U64("packet_number", tpkt->ackm_pkt.pkt_num);
+        QLOG_END()
+    QLOG_EVENT_END()
+#endif
+}
index 14ae8f07baa9ad8082f5cf8c5aa299f598471979..acd836eff38bc3a501e7e74a7fff613b37154d8e 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "internal/quic_fifd.h"
 #include "internal/quic_wire.h"
+#include "internal/qlog_event_helpers.h"
 
 DEFINE_LIST_OF(tx_history, OSSL_ACKM_TX_PKT);
 
@@ -119,6 +120,8 @@ static void on_lost(void *arg)
     QUIC_CFQ_ITEM *cfq_item, *cfq_item_next;
     int sstream_updated;
 
+    ossl_qlog_event_recovery_packet_lost(fifd->qlog, pkt);
+
     /* STREAM and CRYPTO stream chunks, FIN and stream FC frames */
     for (i = 0; i < num_chunks; ++i) {
         sstream = fifd->get_sstream_by_id(chunks[i].stream_id,