From: Hugo Landau Date: Fri, 8 Sep 2023 12:32:17 +0000 (+0100) Subject: QLOG: Events: Implement recovery:packet_lost X-Git-Tag: openssl-3.3.0-alpha1~218 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=faf0912a2f0ef4450f0f7082b177b1990662b809;p=thirdparty%2Fopenssl.git QLOG: Events: Implement recovery:packet_lost Reviewed-by: Matt Caswell Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/22037) --- diff --git a/include/internal/qlog_event_helpers.h b/include/internal/qlog_event_helpers.h index 4a19a79e252..49bbe717d0a 100644 --- a/include/internal/qlog_event_helpers.h +++ b/include/internal/qlog_event_helpers.h @@ -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 diff --git a/include/internal/qlog_events.h b/include/internal/qlog_events.h index ec365c00098..3b8cf78f434 100644 --- a/include/internal/qlog_events.h +++ b/include/internal/qlog_events.h @@ -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) diff --git a/ssl/quic/qlog_event_helpers.c b/ssl/quic/qlog_event_helpers.c index d8deac6e02e..d31a60b2f80 100644 --- a/ssl/quic/qlog_event_helpers.c +++ b/ssl/quic/qlog_event_helpers.c @@ -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 +} diff --git a/ssl/quic/quic_fifd.c b/ssl/quic/quic_fifd.c index 14ae8f07baa..acd836eff38 100644 --- a/ssl/quic/quic_fifd.c +++ b/ssl/quic/quic_fifd.c @@ -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,