From aaf32f0c83750f4157e0deba6905361f549d3781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= Date: Fri, 12 May 2023 17:37:29 +0200 Subject: [PATCH] MINOR: quic: Add low level traces (addresses, DCID) Add source and destination addresses to QUIC_EV_CONN_RCV trace event. This is used by datagram/socket level functions (quic_sock.c). Must be backported to 2.7. --- src/quic_conn.c | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/src/quic_conn.c b/src/quic_conn.c index edcaf6b7b2..1f5a54e95a 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -742,13 +742,6 @@ static void quic_trace(enum trace_level level, uint64_t mask, const struct trace } - if (mask & QUIC_EV_CONN_RCV) { - const struct quic_dgram *dgram = a2; - - if (dgram) - chunk_appendf(&trace_buf, " dgram.len=%zu", dgram->len); - } - if (mask & QUIC_EV_CONN_IDLE_TIMER) { if (tick_isset(qc->ack_expire)) chunk_appendf(&trace_buf, " ack_expire=%ums", @@ -761,6 +754,38 @@ static void quic_trace(enum trace_level level, uint64_t mask, const struct trace TICKS_TO_MS(tick_remain(now_ms, qc->idle_timer_task->expire))); } } + + if (mask & QUIC_EV_CONN_RCV) { + int i; + const struct quic_dgram *dgram = a2; + char bufaddr[INET6_ADDRSTRLEN], bufport[6]; + + if (qc) { + addr_to_str(&qc->peer_addr, bufaddr, sizeof(bufaddr)); + port_to_str(&qc->peer_addr, bufport, sizeof(bufport)); + chunk_appendf(&trace_buf, " peer_addr=%s:%s ", bufaddr, bufport); + } + + if (dgram) { + chunk_appendf(&trace_buf, " dgram.len=%zu", dgram->len); + /* Socket */ + if (dgram->saddr.ss_family == AF_INET || + dgram->saddr.ss_family == AF_INET6) { + addr_to_str(&dgram->saddr, bufaddr, sizeof(bufaddr)); + port_to_str(&dgram->saddr, bufport, sizeof(bufport)); + chunk_appendf(&trace_buf, "saddr=%s:%s ", bufaddr, bufport); + + addr_to_str(&dgram->daddr, bufaddr, sizeof(bufaddr)); + port_to_str(&dgram->daddr, bufport, sizeof(bufport)); + chunk_appendf(&trace_buf, "daddr=%s:%s ", bufaddr, bufport); + } + /* DCID */ + for (i = 0; i < dgram->dcid_len; ++i) + chunk_appendf(&trace_buf, "%02x", dgram->dcid[i]); + + } + } + if (mask & QUIC_EV_CONN_LPKT) { const struct quic_rx_packet *pkt = a2; const uint64_t *len = a3;