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.
This commit is contained in:
Frdric Lcaille 2023-05-24 15:55:14 +02:00 committed by Willy Tarreau
parent bdd64fd71d
commit 12a815ad19
4 changed files with 8 additions and 0 deletions

View 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 */

View 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 */

View 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 */

View 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);