]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Add a counter for sent packets
authorFrédéric Lécaille <flecaille@haproxy.com>
Wed, 24 May 2023 13:55:14 +0000 (15:55 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 24 May 2023 14:30:11 +0000 (16:30 +0200)
Add ->sent_pkt counter to quic_conn struct to count the packet at QUIC connection
level. Then, when the connection is released, the ->sent_pkt counter value
is added to the one for the listener.

Must be backported to 2.7.

include/haproxy/quic_conn-t.h
include/haproxy/quic_stats-t.h
src/quic_conn.c
src/quic_stats.c

index 94b1b1b1e7bb06733e0a8e7da1745ca27d05a9a0..a245a2a94fdf35c18a7d74488fcebef88e68c4b1 100644 (file)
@@ -608,6 +608,7 @@ struct quic_conn_cntrs {
        long long socket_full;           /* total number of EAGAIN errors on sendto() calls */
        long long sendto_err;            /* total number of errors on sendto() calls, EAGAIN excepted */
        long long sendto_err_unknown;    /* total number of errors on sendto() calls which are currently not supported */
+       long long sent_pkt;              /* total number of sent packets */
        long long lost_pkt;              /* total number of lost packets */
        long long conn_migration_done;   /* total number of connection migration handled */
        /* Streams related counters */
index 56961e0476638577698e7e9154929f2d55fb158e..75775f53f33e020a76093bbb4a2a1841a652ba2a 100644 (file)
@@ -16,6 +16,7 @@ enum {
        QUIC_ST_SOCKET_FULL,
        QUIC_ST_SENDTO_ERR,
        QUIC_ST_SENDTO_ERR_UNKNWN,
+       QUIC_ST_SENT_PACKET,
        QUIC_ST_LOST_PACKET,
        QUIC_ST_TOO_SHORT_INITIAL_DGRAM,
        QUIC_ST_RETRY_SENT,
@@ -62,6 +63,7 @@ struct quic_counters {
        long long socket_full;       /* total number of EAGAIN errors on sendto() calls */
        long long sendto_err;        /* total number of errors on sendto() calls, EAGAIN excepted */
        long long sendto_err_unknown; /* total number of errors on sendto() calls which are currently not supported */
+       long long sent_pkt;          /* total number of sent packets */
        long long lost_pkt;          /* total number of lost packets */
        long long too_short_initial_dgram; /* total number of too short datagrams with Initial packets */
        long long retry_sent;        /* total number of Retry sent */
index d5ee3b1fc690beb15c4306ece1f0eb80dce1c26b..4b6c3b318960d1f17deb44523269a116d3ffe5e7 100644 (file)
@@ -3893,6 +3893,7 @@ int qc_send_ppkts(struct buffer *buf, struct ssl_sock_ctx *ctx)
                         * Initial packets to at least the smallest allowed maximum datagram size of
                         * 1200 bytes.
                         */
+                       qc->cntrs.sent_pkt++;
                        BUG_ON_HOT(pkt->type == QUIC_PACKET_TYPE_INITIAL &&
                                   (pkt->flags & QUIC_FL_TX_PACKET_ACK_ELICITING) &&
                                   dglen < QUIC_INITIAL_PACKET_MINLEN);
@@ -5732,6 +5733,7 @@ static inline void quic_conn_prx_cntrs_update(struct quic_conn *qc)
        HA_ATOMIC_ADD(&qc->prx_counters->socket_full, qc->cntrs.socket_full);
        HA_ATOMIC_ADD(&qc->prx_counters->sendto_err, qc->cntrs.sendto_err);
        HA_ATOMIC_ADD(&qc->prx_counters->sendto_err_unknown, qc->cntrs.sendto_err_unknown);
+       HA_ATOMIC_ADD(&qc->prx_counters->sent_pkt, qc->cntrs.sent_pkt);
        HA_ATOMIC_ADD(&qc->prx_counters->lost_pkt, qc->path->loss.nb_lost_pkt);
        HA_ATOMIC_ADD(&qc->prx_counters->conn_migration_done, qc->cntrs.conn_migration_done);
        /* Stream related counters */
index 7f1f2cd6cd495b103011b97e1531dc37a7b624e7..8289b24f7b3eb9a9f6ab5fdfd71e7819cc509b9c 100644 (file)
@@ -17,6 +17,8 @@ static struct name_desc quic_stats[] = {
                                          .desc = "Total number of error on sendto() calls, EAGAIN excepted" },
        [QUIC_ST_SENDTO_ERR_UNKNWN]   = { .name = "quic_sendto_err_unknwn",
                                          .desc = "Total number of error on sendto() calls not explicitly listed" },
+       [QUIC_ST_SENT_PACKET]         = { .name = "quic_sent_pkt",
+                                         .desc = "Total number of sent packets" },
        [QUIC_ST_LOST_PACKET]         = { .name = "quic_lost_pkt",
                                          .desc = "Total number of lost sent packets" },
        [QUIC_ST_TOO_SHORT_INITIAL_DGRAM] = { .name = "quic_too_short_dgram",
@@ -99,6 +101,7 @@ static void quic_fill_stats(void *data, struct field *stats)
        stats[QUIC_ST_SOCKET_FULL]       = mkf_u64(FN_COUNTER, counters->socket_full);
        stats[QUIC_ST_SENDTO_ERR]        = mkf_u64(FN_COUNTER, counters->sendto_err);
        stats[QUIC_ST_SENDTO_ERR_UNKNWN] = mkf_u64(FN_COUNTER, counters->sendto_err_unknown);
+       stats[QUIC_ST_SENT_PACKET]       = mkf_u64(FN_COUNTER, counters->sent_pkt);
        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);
        stats[QUIC_ST_RETRY_SENT]        = mkf_u64(FN_COUNTER, counters->retry_sent);