From 45a16295e358b76761ff2301242bf39d25dda277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= Date: Wed, 29 Jun 2022 12:03:34 +0200 Subject: [PATCH] MINOR: quic: Add new stats counter to diagnose RX buffer overrun Remove the call to qc_list_all_rx_pkts() which print messages on stderr during RX buffer overruns and add a new counter for the number of dropped packets because of such events. Must be backported to 2.6 --- include/haproxy/quic_stats-t.h | 2 ++ src/quic_stats.c | 3 +++ src/xprt_quic.c | 7 ++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/haproxy/quic_stats-t.h b/include/haproxy/quic_stats-t.h index 6f5fca850..4b76b931c 100644 --- a/include/haproxy/quic_stats-t.h +++ b/include/haproxy/quic_stats-t.h @@ -10,6 +10,7 @@ extern struct stats_module quic_stats_module; enum { QUIC_ST_DROPPED_PACKET, + QUIC_ST_DROPPED_PACKET_BUFOVERRUN, QUIC_ST_DROPPED_PARSING, QUIC_ST_LOST_PACKET, QUIC_ST_TOO_SHORT_INITIAL_DGRAM, @@ -49,6 +50,7 @@ enum { struct quic_counters { long long dropped_pkt; /* total number of dropped packets */ + long long dropped_pkt_bufoverrun;/* total number of dropped packets because of buffer overrun */ long long dropped_parsing; /* total number of dropped packets upon parsing errors */ long long lost_pkt; /* total number of lost packets */ long long too_short_initial_dgram; /* total number of too short datagrams with Initial packets */ diff --git a/src/quic_stats.c b/src/quic_stats.c index 160ee7d8f..c34d87334 100644 --- a/src/quic_stats.c +++ b/src/quic_stats.c @@ -4,6 +4,8 @@ static struct name_desc quic_stats[] = { [QUIC_ST_DROPPED_PACKET] = { .name = "quic_dropped_pkt", .desc = "Total number of dropped packets" }, + [QUIC_ST_DROPPED_PACKET_BUFOVERRUN] = { .name = "quic_dropped_pkt_bufoverrun", + .desc = "Total number of dropped packets because of buffer overrun" }, [QUIC_ST_DROPPED_PARSING] = { .name = "quic_dropped_parsing_pkt", .desc = "Total number of dropped packets upon parsing error" }, [QUIC_ST_LOST_PACKET] = { .name = "quic_lost_pkt", @@ -79,6 +81,7 @@ static void quic_fill_stats(void *data, struct field *stats) struct quic_counters *counters = data; stats[QUIC_ST_DROPPED_PACKET] = mkf_u64(FN_COUNTER, counters->dropped_pkt); + stats[QUIC_ST_DROPPED_PACKET_BUFOVERRUN] = mkf_u64(FN_COUNTER, counters->dropped_pkt_bufoverrun); stats[QUIC_ST_DROPPED_PARSING] = mkf_u64(FN_COUNTER, counters->dropped_parsing); stats[QUIC_ST_LOST_PACKET] = mkf_u64(FN_COUNTER, counters->lost_pkt); stats[QUIC_ST_TOO_SHORT_INITIAL_DGRAM] = mkf_u64(FN_COUNTER, counters->too_short_initial_dgram); diff --git a/src/xprt_quic.c b/src/xprt_quic.c index 0be3e64bd..018975dd3 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -5575,7 +5575,8 @@ static void qc_lstnr_pkt_rcv(unsigned char *buf, const unsigned char *end, if (b_tail(&qc->rx.buf) + b_cspace < b_wrap(&qc->rx.buf)) { TRACE_PROTO("Packet dropped", QUIC_EV_CONN_LPKT, qc, NULL, NULL, qv); - goto drop; + HA_ATOMIC_INC(&prx_counters->dropped_pkt_bufoverrun); + goto drop_no_conn; } /* Let us consume the remaining contiguous space. */ @@ -5587,8 +5588,8 @@ static void qc_lstnr_pkt_rcv(unsigned char *buf, const unsigned char *end, if (b_contig_space(&qc->rx.buf) < pkt->len) { TRACE_PROTO("Too big packet", QUIC_EV_CONN_LPKT, qc, pkt, &pkt->len, qv); - qc_list_all_rx_pkts(qc); - goto drop; + HA_ATOMIC_INC(&prx_counters->dropped_pkt_bufoverrun); + goto drop_no_conn; } }