From: Frédéric Lécaille Date: Wed, 24 May 2023 13:55:14 +0000 (+0200) Subject: MINOR: quic: Add a counter for sent packets X-Git-Tag: v2.8-dev13~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12a815ad19427ccfadeadfc33ac8ef4ebcd083c3;p=thirdparty%2Fhaproxy.git MINOR: quic: Add a counter for sent packets 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. --- diff --git a/include/haproxy/quic_conn-t.h b/include/haproxy/quic_conn-t.h index 94b1b1b1e7..a245a2a94f 100644 --- a/include/haproxy/quic_conn-t.h +++ b/include/haproxy/quic_conn-t.h @@ -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 */ diff --git a/include/haproxy/quic_stats-t.h b/include/haproxy/quic_stats-t.h index 56961e0476..75775f53f3 100644 --- a/include/haproxy/quic_stats-t.h +++ b/include/haproxy/quic_stats-t.h @@ -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 */ diff --git a/src/quic_conn.c b/src/quic_conn.c index d5ee3b1fc6..4b6c3b3189 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -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 */ diff --git a/src/quic_stats.c b/src/quic_stats.c index 7f1f2cd6cd..8289b24f7b 100644 --- a/src/quic_stats.c +++ b/src/quic_stats.c @@ -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);