From: Frédéric Lécaille Date: Mon, 12 Jun 2023 16:54:29 +0000 (+0200) Subject: MINOR: quic: Implement a packet number space identification function X-Git-Tag: v2.9-dev1~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=411b6f73b71c1db7aff367fda467e69317aee357;p=thirdparty%2Fhaproxy.git MINOR: quic: Implement a packet number space identification function Implement quic_pktns_char() to identify a packet number space from a quic_conn object. Usefull only for traces. --- diff --git a/include/haproxy/quic_tls.h b/include/haproxy/quic_tls.h index 28f59f0bc8..74a436a0f8 100644 --- a/include/haproxy/quic_tls.h +++ b/include/haproxy/quic_tls.h @@ -322,6 +322,23 @@ static inline char quic_packet_type_enc_level_char(int packet_type) } } +/* Return a character to identify the packet number space of QUIC + * connection. 'I' for Initial packet number space, 'H' for Handshake packet + * space, and 'A' for Application data number space, or '-' if not found. + */ +static inline char quic_pktns_char(const struct quic_conn *qc, + const struct quic_pktns *pktns) +{ + if (pktns == &qc->pktns[QUIC_TLS_PKTNS_01RTT]) + return 'A'; + else if (pktns == &qc->pktns[QUIC_TLS_PKTNS_HANDSHAKE]) + return 'H'; + else if (pktns == &qc->pktns[QUIC_TLS_PKTNS_INITIAL]) + return 'I'; + + return '-'; +} + /* Return the TLS encryption level to be used for * QUIC packet type. * Returns -1 if there is no TLS encryption level for diff --git a/src/quic_conn.c b/src/quic_conn.c index fa68ef5f3c..847046f50b 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -614,9 +614,7 @@ static void quic_trace(enum trace_level level, uint64_t mask, const struct trace const struct list *lost_pkts = a3; if (pktns) { - chunk_appendf(&trace_buf, " pktns=%s", - pktns == &qc->pktns[QUIC_TLS_PKTNS_INITIAL] ? "I" : - pktns == &qc->pktns[QUIC_TLS_PKTNS_01RTT] ? "01RTT": "H"); + chunk_appendf(&trace_buf, " pktns=%c", quic_pktns_char(qc, pktns)); if (pktns->tx.loss_time) chunk_appendf(&trace_buf, " loss_time=%dms", TICKS_TO_MS(tick_remain(now_ms, pktns->tx.loss_time))); @@ -639,9 +637,8 @@ static void quic_trace(enum trace_level level, uint64_t mask, const struct trace chunk_appendf(&trace_buf, " ifae_pkts=%llu", (unsigned long long)*ifae_pkts); if (pktns) { - chunk_appendf(&trace_buf, " pktns=%s pp=%d", - pktns == &qc->pktns[QUIC_TLS_PKTNS_INITIAL] ? "I" : - pktns == &qc->pktns[QUIC_TLS_PKTNS_01RTT] ? "01RTT": "H", + chunk_appendf(&trace_buf, " pktns=%c pp=%d", + quic_pktns_char(qc, pktns), pktns->tx.pto_probe); if (mask & (QUIC_EV_CONN_STIMER|QUIC_EV_CONN_SPTO)) { if (pktns->tx.in_flight) @@ -677,10 +674,9 @@ static void quic_trace(enum trace_level level, uint64_t mask, const struct trace const struct quic_frame *frm; if (pkt->flags & QUIC_FL_TX_PACKET_ACK) chunk_appendf(&trace_buf, " ack"); - chunk_appendf(&trace_buf, " pn=%lu(%s) iflen=%llu", + chunk_appendf(&trace_buf, " pn=%lu(%c) iflen=%llu", (unsigned long)pkt->pn_node.key, - pkt->pktns == &qc->pktns[QUIC_TLS_PKTNS_INITIAL] ? "I" : - pkt->pktns == &qc->pktns[QUIC_TLS_PKTNS_01RTT] ? "01RTT": "H", + quic_pktns_char(qc, pkt->pktns), (unsigned long long)pkt->in_flight_len); chunk_appendf(&trace_buf, " rx.bytes=%llu tx.bytes=%llu", (unsigned long long)qc->rx.bytes,