blob: 3657f308c461daee3e701ae71013d84a7545718e [file] [log] [blame]
Amaury Denoyelle5c25dc52022-09-30 17:44:15 +02001#include <haproxy/quic_frame-t.h>
Frédéric Lécaillea58cafe2022-05-18 14:30:03 +02002#include <haproxy/quic_stats-t.h>
3#include <haproxy/stats.h>
4
Frédéric Lécaillea58cafe2022-05-18 14:30:03 +02005static struct name_desc quic_stats[] = {
Amaury Denoyelle735b44f2022-10-27 17:56:27 +02006 [QUIC_ST_RXBUF_FULL] = { .name = "quic_rxbuf_full",
7 .desc = "Total number of cancelled reception due to full receiver buffer" },
Frédéric Lécailleeb791452022-05-24 16:01:39 +02008 [QUIC_ST_DROPPED_PACKET] = { .name = "quic_dropped_pkt",
Frédéric Lécaillea58cafe2022-05-18 14:30:03 +02009 .desc = "Total number of dropped packets" },
Frédéric Lécaille45a16292022-06-29 12:03:34 +020010 [QUIC_ST_DROPPED_PACKET_BUFOVERRUN] = { .name = "quic_dropped_pkt_bufoverrun",
11 .desc = "Total number of dropped packets because of buffer overrun" },
Frédéric Lécailleeb791452022-05-24 16:01:39 +020012 [QUIC_ST_DROPPED_PARSING] = { .name = "quic_dropped_parsing_pkt",
13 .desc = "Total number of dropped packets upon parsing error" },
Frédéric Lécaille8ecb7362022-08-04 12:00:00 +020014 [QUIC_ST_SOCKET_FULL] = { .name = "quic_socket_full",
15 .desc = "Total number of EAGAIN error on sendto() calls" },
16 [QUIC_ST_SENDTO_ERR] = { .name = "quic_sendto_err",
17 .desc = "Total number of error on sendto() calls, EAGAIN excepted" },
Amaury Denoyelle7941ead2022-10-24 10:44:34 +020018 [QUIC_ST_SENDTO_ERR_UNKNWN] = { .name = "quic_sendto_err_unknwn",
Ilya Shipitsin4a689da2022-10-29 09:34:32 +050019 .desc = "Total number of error on sendto() calls not explicitly listed" },
Frédéric Lécaille12a815a2023-05-24 15:55:14 +020020 [QUIC_ST_SENT_PACKET] = { .name = "quic_sent_pkt",
21 .desc = "Total number of sent packets" },
Frédéric Lécailleeb791452022-05-24 16:01:39 +020022 [QUIC_ST_LOST_PACKET] = { .name = "quic_lost_pkt",
23 .desc = "Total number of lost sent packets" },
Frédéric Lécaille3ccea6d2022-05-23 22:54:54 +020024 [QUIC_ST_TOO_SHORT_INITIAL_DGRAM] = { .name = "quic_too_short_dgram",
25 .desc = "Total number of too short dgrams with Initial packets" },
Frédéric Lécaillea58cafe2022-05-18 14:30:03 +020026 [QUIC_ST_RETRY_SENT] = { .name = "quic_retry_sent",
27 .desc = "Total number of Retry sent" },
28 [QUIC_ST_RETRY_VALIDATED] = { .name = "quic_retry_validated",
29 .desc = "Total number of validated Retry tokens" },
30 [QUIC_ST_RETRY_ERRORS] = { .name = "quic_retry_error",
31 .desc = "Total number of Retry tokens errors" },
Frédéric Lécailleeb791452022-05-24 16:01:39 +020032 [QUIC_ST_HALF_OPEN_CONN] = { .name = "quic_half_open_conn",
33 .desc = "Total number of half open connections" },
34 [QUIC_ST_HDSHK_FAIL] = { .name = "quic_hdshk_fail",
Frédéric Lécaillea58cafe2022-05-18 14:30:03 +020035 .desc = "Total number of handshake failures" },
Frédéric Lécailleeb791452022-05-24 16:01:39 +020036 [QUIC_ST_STATELESS_RESET_SENT] = { .name = "quic_stless_rst_sent",
37 .desc = "Total number of stateless reset packet sent" },
Amaury Denoyelleeec0b3c2022-12-02 09:57:32 +010038 /* Special events of interest */
39 [QUIC_ST_CONN_MIGRATION_DONE] = { .name = "quic_conn_migration_done",
40 .desc = "Total number of connection migration proceeded" },
Frédéric Lécaille3ccea6d2022-05-23 22:54:54 +020041 /* Transport errors */
42 [QUIC_ST_TRANSP_ERR_NO_ERROR] = { .name = "quic_transp_err_no_error",
43 .desc = "Total number of NO_ERROR errors received" },
44 [QUIC_ST_TRANSP_ERR_INTERNAL_ERROR] = { .name = "quic_transp_err_internal_error",
45 .desc = "Total number of INTERNAL_ERROR errors received" },
46 [QUIC_ST_TRANSP_ERR_CONNECTION_REFUSED] = { .name = "quic_transp_err_connection_refused",
47 .desc = "Total number of CONNECTION_REFUSED errors received" },
48 [QUIC_ST_TRANSP_ERR_FLOW_CONTROL_ERROR] = { .name = "quic_transp_err_flow_control_error",
49 .desc = "Total number of FLOW_CONTROL_ERROR errors received" },
50 [QUIC_ST_TRANSP_ERR_STREAM_LIMIT_ERROR] = { .name = "quic_transp_err_stream_limit_error",
51 .desc = "Total number of STREAM_LIMIT_ERROR errors received" },
52 [QUIC_ST_TRANSP_ERR_STREAM_STATE_ERROR] = { .name = "quic_transp_err_stream_state_error",
53 .desc = "Total number of STREAM_STATE_ERROR errors received" },
54 [QUIC_ST_TRANSP_ERR_FINAL_SIZE_ERROR] = { .name = "quic_transp_err_final_size_error",
55 .desc = "Total number of FINAL_SIZE_ERROR errors received" },
56 [QUIC_ST_TRANSP_ERR_FRAME_ENCODING_ERROR] = { .name = "quic_transp_err_frame_encoding_error",
57 .desc = "Total number of FRAME_ENCODING_ERROR errors received" },
58 [QUIC_ST_TRANSP_ERR_TRANSPORT_PARAMETER_ERROR] = { .name = "quic_transp_err_transport_parameter_error",
59 .desc = "Total number of TRANSPORT_PARAMETER_ERROR errors received" },
60 [QUIC_ST_TRANSP_ERR_CONNECTION_ID_LIMIT_ERROR] = { .name = "quic_transp_err_connection_id_limit",
61 .desc = "Total number of CONNECTION_ID_LIMIT_ERROR errors received" },
62 [QUIC_ST_TRANSP_ERR_PROTOCOL_VIOLATION] = { .name = "quic_transp_err_protocol_violation_error",
63 .desc = "Total number of PROTOCOL_VIOLATION errors received" },
64 [QUIC_ST_TRANSP_ERR_INVALID_TOKEN] = { .name = "quic_transp_err_invalid_token",
65 .desc = "Total number of INVALID_TOKEN errors received" },
66 [QUIC_ST_TRANSP_ERR_APPLICATION_ERROR] = { .name = "quic_transp_err_application_error",
67 .desc = "Total number of APPLICATION_ERROR errors received" },
68 [QUIC_ST_TRANSP_ERR_CRYPTO_BUFFER_EXCEEDED] = { .name = "quic_transp_err_crypto_buffer_exceeded",
69 .desc = "Total number of CRYPTO_BUFFER_EXCEEDED errors received" },
70 [QUIC_ST_TRANSP_ERR_KEY_UPDATE_ERROR] = { .name = "quic_transp_err_key_update_error",
71 .desc = "Total number of KEY_UPDATE_ERROR errors received" },
72 [QUIC_ST_TRANSP_ERR_AEAD_LIMIT_REACHED] = { .name = "quic_transp_err_aead_limit_reached",
73 .desc = "Total number of AEAD_LIMIT_REACHED errors received" },
74 [QUIC_ST_TRANSP_ERR_NO_VIABLE_PATH] = { .name = "quic_transp_err_no_viable_path",
75 .desc = "Total number of NO_VIABLE_PATH errors received" },
76 [QUIC_ST_TRANSP_ERR_CRYPTO_ERROR] = { .name = "quic_transp_err_crypto_error",
77 .desc = "Total number of CRYPTO_ERROR errors received" },
78 [QUIC_ST_TRANSP_ERR_UNKNOWN_ERROR] = { .name = "quic_transp_err_unknown_error",
79 .desc = "Total number of UNKNOWN_ERROR errors received" },
Frédéric Lécaillea58cafe2022-05-18 14:30:03 +020080 /* Streams related counters */
81 [QUIC_ST_DATA_BLOCKED] = { .name = "quic_data_blocked",
Frédéric Lécailleeb791452022-05-24 16:01:39 +020082 .desc = "Total number of received DATA_BLOCKED frames" },
Frédéric Lécaillea58cafe2022-05-18 14:30:03 +020083 [QUIC_ST_STREAM_DATA_BLOCKED] = { .name = "quic_stream_data_blocked",
Amaury Denoyelle6d6ee0d2023-05-25 10:36:04 +020084 .desc = "Total number of received STREAM_DATA_BLOCKED frames" },
85 [QUIC_ST_STREAMS_BLOCKED_BIDI] = { .name = "quic_streams_blocked_bidi",
86 .desc = "Total number of received STREAMS_BLOCKED_BIDI frames" },
87 [QUIC_ST_STREAMS_BLOCKED_UNI] = { .name = "quic_streams_blocked_uni",
88 .desc = "Total number of received STREAMS_BLOCKED_UNI frames" },
Frédéric Lécaillea58cafe2022-05-18 14:30:03 +020089};
90
91struct quic_counters quic_counters;
92
93static void quic_fill_stats(void *data, struct field *stats)
94{
95 struct quic_counters *counters = data;
96
Amaury Denoyelle735b44f2022-10-27 17:56:27 +020097 stats[QUIC_ST_RXBUF_FULL] = mkf_u64(FN_COUNTER, counters->rxbuf_full);
Frédéric Lécailleeb791452022-05-24 16:01:39 +020098 stats[QUIC_ST_DROPPED_PACKET] = mkf_u64(FN_COUNTER, counters->dropped_pkt);
Frédéric Lécaille45a16292022-06-29 12:03:34 +020099 stats[QUIC_ST_DROPPED_PACKET_BUFOVERRUN] = mkf_u64(FN_COUNTER, counters->dropped_pkt_bufoverrun);
Frédéric Lécailleeb791452022-05-24 16:01:39 +0200100 stats[QUIC_ST_DROPPED_PARSING] = mkf_u64(FN_COUNTER, counters->dropped_parsing);
Frédéric Lécaille8ecb7362022-08-04 12:00:00 +0200101 stats[QUIC_ST_SOCKET_FULL] = mkf_u64(FN_COUNTER, counters->socket_full);
102 stats[QUIC_ST_SENDTO_ERR] = mkf_u64(FN_COUNTER, counters->sendto_err);
Amaury Denoyelle7941ead2022-10-24 10:44:34 +0200103 stats[QUIC_ST_SENDTO_ERR_UNKNWN] = mkf_u64(FN_COUNTER, counters->sendto_err_unknown);
Frédéric Lécaille12a815a2023-05-24 15:55:14 +0200104 stats[QUIC_ST_SENT_PACKET] = mkf_u64(FN_COUNTER, counters->sent_pkt);
Frédéric Lécailleeb791452022-05-24 16:01:39 +0200105 stats[QUIC_ST_LOST_PACKET] = mkf_u64(FN_COUNTER, counters->lost_pkt);
Frédéric Lécaille3ccea6d2022-05-23 22:54:54 +0200106 stats[QUIC_ST_TOO_SHORT_INITIAL_DGRAM] = mkf_u64(FN_COUNTER, counters->too_short_initial_dgram);
Frédéric Lécaillea58cafe2022-05-18 14:30:03 +0200107 stats[QUIC_ST_RETRY_SENT] = mkf_u64(FN_COUNTER, counters->retry_sent);
108 stats[QUIC_ST_RETRY_VALIDATED] = mkf_u64(FN_COUNTER, counters->retry_validated);
109 stats[QUIC_ST_RETRY_ERRORS] = mkf_u64(FN_COUNTER, counters->retry_error);
Frédéric Lécailleeb791452022-05-24 16:01:39 +0200110 stats[QUIC_ST_HALF_OPEN_CONN] = mkf_u64(FN_GAUGE, counters->half_open_conn);
111 stats[QUIC_ST_HDSHK_FAIL] = mkf_u64(FN_COUNTER, counters->hdshk_fail);
112 stats[QUIC_ST_STATELESS_RESET_SENT] = mkf_u64(FN_COUNTER, counters->stateless_reset_sent);
Amaury Denoyelleeec0b3c2022-12-02 09:57:32 +0100113 /* Special events of interest */
114 stats[QUIC_ST_CONN_MIGRATION_DONE] = mkf_u64(FN_COUNTER, counters->conn_migration_done);
Frédéric Lécaille3ccea6d2022-05-23 22:54:54 +0200115 /* Transport errors */
116 stats[QUIC_ST_TRANSP_ERR_NO_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_no_error);
117 stats[QUIC_ST_TRANSP_ERR_INTERNAL_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_internal_error);
118 stats[QUIC_ST_TRANSP_ERR_CONNECTION_REFUSED] = mkf_u64(FN_COUNTER, counters->quic_transp_err_connection_refused);
119 stats[QUIC_ST_TRANSP_ERR_FLOW_CONTROL_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_flow_control_error);
120 stats[QUIC_ST_TRANSP_ERR_STREAM_LIMIT_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_stream_limit_error);
121 stats[QUIC_ST_TRANSP_ERR_STREAM_STATE_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_stream_state_error);
122 stats[QUIC_ST_TRANSP_ERR_FINAL_SIZE_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_final_size_error);
123 stats[QUIC_ST_TRANSP_ERR_FRAME_ENCODING_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_frame_encoding_error);
124 stats[QUIC_ST_TRANSP_ERR_TRANSPORT_PARAMETER_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_transport_parameter_error);
125 stats[QUIC_ST_TRANSP_ERR_CONNECTION_ID_LIMIT_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_connection_id_limit);
126 stats[QUIC_ST_TRANSP_ERR_PROTOCOL_VIOLATION] = mkf_u64(FN_COUNTER, counters->quic_transp_err_protocol_violation);
127 stats[QUIC_ST_TRANSP_ERR_INVALID_TOKEN] = mkf_u64(FN_COUNTER, counters->quic_transp_err_invalid_token);
128 stats[QUIC_ST_TRANSP_ERR_APPLICATION_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_application_error);
129 stats[QUIC_ST_TRANSP_ERR_CRYPTO_BUFFER_EXCEEDED] = mkf_u64(FN_COUNTER, counters->quic_transp_err_crypto_buffer_exceeded);
130 stats[QUIC_ST_TRANSP_ERR_KEY_UPDATE_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_key_update_error);
131 stats[QUIC_ST_TRANSP_ERR_AEAD_LIMIT_REACHED] = mkf_u64(FN_COUNTER, counters->quic_transp_err_aead_limit_reached);
132 stats[QUIC_ST_TRANSP_ERR_NO_VIABLE_PATH] = mkf_u64(FN_COUNTER, counters->quic_transp_err_no_viable_path);
133 stats[QUIC_ST_TRANSP_ERR_CRYPTO_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_crypto_error);
134 stats[QUIC_ST_TRANSP_ERR_UNKNOWN_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_unknown_error);
Frédéric Lécaillea58cafe2022-05-18 14:30:03 +0200135 /* Streams related counters */
136 stats[QUIC_ST_DATA_BLOCKED] = mkf_u64(FN_COUNTER, counters->data_blocked);
137 stats[QUIC_ST_STREAM_DATA_BLOCKED] = mkf_u64(FN_COUNTER, counters->stream_data_blocked);
Amaury Denoyelle6d6ee0d2023-05-25 10:36:04 +0200138 stats[QUIC_ST_STREAMS_BLOCKED_BIDI] = mkf_u64(FN_COUNTER, counters->streams_blocked_bidi);
139 stats[QUIC_ST_STREAMS_BLOCKED_UNI] = mkf_u64(FN_COUNTER, counters->streams_blocked_uni);
Frédéric Lécaillea58cafe2022-05-18 14:30:03 +0200140}
141
142struct stats_module quic_stats_module = {
143 .name = "quic",
144 .fill_stats = quic_fill_stats,
145 .stats = quic_stats,
146 .stats_count = QUIC_STATS_COUNT,
147 .counters = &quic_counters,
148 .counters_size = sizeof(quic_counters),
149 .domain_flags = MK_STATS_PROXY_DOMAIN(STATS_PX_CAP_FE),
150 .clearable = 1,
151};
152
153INITCALL1(STG_REGISTER, stats_register_module, &quic_stats_module);
Frédéric Lécaille3ccea6d2022-05-23 22:54:54 +0200154
155void quic_stats_transp_err_count_inc(struct quic_counters *ctrs, int error_code)
156{
157 switch (error_code) {
158 case QC_ERR_NO_ERROR:
159 HA_ATOMIC_INC(&ctrs->quic_transp_err_no_error);
160 break;
161 case QC_ERR_INTERNAL_ERROR:
162 HA_ATOMIC_INC(&ctrs->quic_transp_err_internal_error);
163 break;
164 case QC_ERR_CONNECTION_REFUSED:
165 HA_ATOMIC_INC(&ctrs->quic_transp_err_connection_refused);
166 break;
167 case QC_ERR_FLOW_CONTROL_ERROR:
168 HA_ATOMIC_INC(&ctrs->quic_transp_err_flow_control_error);
169 break;
170 case QC_ERR_STREAM_LIMIT_ERROR:
171 HA_ATOMIC_INC(&ctrs->quic_transp_err_stream_limit_error);
172 break;
173 case QC_ERR_STREAM_STATE_ERROR:
174 HA_ATOMIC_INC(&ctrs->quic_transp_err_stream_state_error);
175 break;
176 case QC_ERR_FINAL_SIZE_ERROR:
177 HA_ATOMIC_INC(&ctrs->quic_transp_err_final_size_error);
178 break;
179 case QC_ERR_FRAME_ENCODING_ERROR:
180 HA_ATOMIC_INC(&ctrs->quic_transp_err_frame_encoding_error);
181 break;
182 case QC_ERR_TRANSPORT_PARAMETER_ERROR:
183 HA_ATOMIC_INC(&ctrs->quic_transp_err_transport_parameter_error);
184 break;
185 case QC_ERR_CONNECTION_ID_LIMIT_ERROR:
186 HA_ATOMIC_INC(&ctrs->quic_transp_err_connection_id_limit);
187 break;
188 case QC_ERR_PROTOCOL_VIOLATION:
189 HA_ATOMIC_INC(&ctrs->quic_transp_err_protocol_violation);
190 break;
191 case QC_ERR_INVALID_TOKEN:
192 HA_ATOMIC_INC(&ctrs->quic_transp_err_invalid_token);
193 break;
194 case QC_ERR_APPLICATION_ERROR:
195 HA_ATOMIC_INC(&ctrs->quic_transp_err_application_error);
196 break;
197 case QC_ERR_CRYPTO_BUFFER_EXCEEDED:
198 HA_ATOMIC_INC(&ctrs->quic_transp_err_crypto_buffer_exceeded);
199 break;
200 case QC_ERR_KEY_UPDATE_ERROR:
201 HA_ATOMIC_INC(&ctrs->quic_transp_err_key_update_error);
202 break;
203 case QC_ERR_AEAD_LIMIT_REACHED:
204 HA_ATOMIC_INC(&ctrs->quic_transp_err_aead_limit_reached);
205 break;
206 case QC_ERR_NO_VIABLE_PATH:
207 HA_ATOMIC_INC(&ctrs->quic_transp_err_no_viable_path);
208 break;
209 default:
210 if (error_code >= 0x100 && error_code <= 0x1ff)
211 HA_ATOMIC_INC(&ctrs->quic_transp_err_crypto_error);
212 else
213 HA_ATOMIC_INC(&ctrs->quic_transp_err_unknown_error);
214 }
215}