Amaury Denoyelle | 5c25dc5 | 2022-09-30 17:44:15 +0200 | [diff] [blame] | 1 | #include <haproxy/quic_frame-t.h> |
Frédéric Lécaille | a58cafe | 2022-05-18 14:30:03 +0200 | [diff] [blame] | 2 | #include <haproxy/quic_stats-t.h> |
| 3 | #include <haproxy/stats.h> |
| 4 | |
Frédéric Lécaille | a58cafe | 2022-05-18 14:30:03 +0200 | [diff] [blame] | 5 | static struct name_desc quic_stats[] = { |
Amaury Denoyelle | 735b44f | 2022-10-27 17:56:27 +0200 | [diff] [blame] | 6 | [QUIC_ST_RXBUF_FULL] = { .name = "quic_rxbuf_full", |
| 7 | .desc = "Total number of cancelled reception due to full receiver buffer" }, |
Frédéric Lécaille | eb79145 | 2022-05-24 16:01:39 +0200 | [diff] [blame] | 8 | [QUIC_ST_DROPPED_PACKET] = { .name = "quic_dropped_pkt", |
Frédéric Lécaille | a58cafe | 2022-05-18 14:30:03 +0200 | [diff] [blame] | 9 | .desc = "Total number of dropped packets" }, |
Frédéric Lécaille | 45a1629 | 2022-06-29 12:03:34 +0200 | [diff] [blame] | 10 | [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écaille | eb79145 | 2022-05-24 16:01:39 +0200 | [diff] [blame] | 12 | [QUIC_ST_DROPPED_PARSING] = { .name = "quic_dropped_parsing_pkt", |
| 13 | .desc = "Total number of dropped packets upon parsing error" }, |
Frédéric Lécaille | 8ecb736 | 2022-08-04 12:00:00 +0200 | [diff] [blame] | 14 | [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 Denoyelle | 7941ead | 2022-10-24 10:44:34 +0200 | [diff] [blame] | 18 | [QUIC_ST_SENDTO_ERR_UNKNWN] = { .name = "quic_sendto_err_unknwn", |
Ilya Shipitsin | 4a689da | 2022-10-29 09:34:32 +0500 | [diff] [blame] | 19 | .desc = "Total number of error on sendto() calls not explicitly listed" }, |
Frédéric Lécaille | eb79145 | 2022-05-24 16:01:39 +0200 | [diff] [blame] | 20 | [QUIC_ST_LOST_PACKET] = { .name = "quic_lost_pkt", |
| 21 | .desc = "Total number of lost sent packets" }, |
Frédéric Lécaille | 3ccea6d | 2022-05-23 22:54:54 +0200 | [diff] [blame] | 22 | [QUIC_ST_TOO_SHORT_INITIAL_DGRAM] = { .name = "quic_too_short_dgram", |
| 23 | .desc = "Total number of too short dgrams with Initial packets" }, |
Frédéric Lécaille | a58cafe | 2022-05-18 14:30:03 +0200 | [diff] [blame] | 24 | [QUIC_ST_RETRY_SENT] = { .name = "quic_retry_sent", |
| 25 | .desc = "Total number of Retry sent" }, |
| 26 | [QUIC_ST_RETRY_VALIDATED] = { .name = "quic_retry_validated", |
| 27 | .desc = "Total number of validated Retry tokens" }, |
| 28 | [QUIC_ST_RETRY_ERRORS] = { .name = "quic_retry_error", |
| 29 | .desc = "Total number of Retry tokens errors" }, |
Frédéric Lécaille | eb79145 | 2022-05-24 16:01:39 +0200 | [diff] [blame] | 30 | [QUIC_ST_HALF_OPEN_CONN] = { .name = "quic_half_open_conn", |
| 31 | .desc = "Total number of half open connections" }, |
| 32 | [QUIC_ST_HDSHK_FAIL] = { .name = "quic_hdshk_fail", |
Frédéric Lécaille | a58cafe | 2022-05-18 14:30:03 +0200 | [diff] [blame] | 33 | .desc = "Total number of handshake failures" }, |
Frédéric Lécaille | eb79145 | 2022-05-24 16:01:39 +0200 | [diff] [blame] | 34 | [QUIC_ST_STATELESS_RESET_SENT] = { .name = "quic_stless_rst_sent", |
| 35 | .desc = "Total number of stateless reset packet sent" }, |
Frédéric Lécaille | 3ccea6d | 2022-05-23 22:54:54 +0200 | [diff] [blame] | 36 | /* Transport errors */ |
| 37 | [QUIC_ST_TRANSP_ERR_NO_ERROR] = { .name = "quic_transp_err_no_error", |
| 38 | .desc = "Total number of NO_ERROR errors received" }, |
| 39 | [QUIC_ST_TRANSP_ERR_INTERNAL_ERROR] = { .name = "quic_transp_err_internal_error", |
| 40 | .desc = "Total number of INTERNAL_ERROR errors received" }, |
| 41 | [QUIC_ST_TRANSP_ERR_CONNECTION_REFUSED] = { .name = "quic_transp_err_connection_refused", |
| 42 | .desc = "Total number of CONNECTION_REFUSED errors received" }, |
| 43 | [QUIC_ST_TRANSP_ERR_FLOW_CONTROL_ERROR] = { .name = "quic_transp_err_flow_control_error", |
| 44 | .desc = "Total number of FLOW_CONTROL_ERROR errors received" }, |
| 45 | [QUIC_ST_TRANSP_ERR_STREAM_LIMIT_ERROR] = { .name = "quic_transp_err_stream_limit_error", |
| 46 | .desc = "Total number of STREAM_LIMIT_ERROR errors received" }, |
| 47 | [QUIC_ST_TRANSP_ERR_STREAM_STATE_ERROR] = { .name = "quic_transp_err_stream_state_error", |
| 48 | .desc = "Total number of STREAM_STATE_ERROR errors received" }, |
| 49 | [QUIC_ST_TRANSP_ERR_FINAL_SIZE_ERROR] = { .name = "quic_transp_err_final_size_error", |
| 50 | .desc = "Total number of FINAL_SIZE_ERROR errors received" }, |
| 51 | [QUIC_ST_TRANSP_ERR_FRAME_ENCODING_ERROR] = { .name = "quic_transp_err_frame_encoding_error", |
| 52 | .desc = "Total number of FRAME_ENCODING_ERROR errors received" }, |
| 53 | [QUIC_ST_TRANSP_ERR_TRANSPORT_PARAMETER_ERROR] = { .name = "quic_transp_err_transport_parameter_error", |
| 54 | .desc = "Total number of TRANSPORT_PARAMETER_ERROR errors received" }, |
| 55 | [QUIC_ST_TRANSP_ERR_CONNECTION_ID_LIMIT_ERROR] = { .name = "quic_transp_err_connection_id_limit", |
| 56 | .desc = "Total number of CONNECTION_ID_LIMIT_ERROR errors received" }, |
| 57 | [QUIC_ST_TRANSP_ERR_PROTOCOL_VIOLATION] = { .name = "quic_transp_err_protocol_violation_error", |
| 58 | .desc = "Total number of PROTOCOL_VIOLATION errors received" }, |
| 59 | [QUIC_ST_TRANSP_ERR_INVALID_TOKEN] = { .name = "quic_transp_err_invalid_token", |
| 60 | .desc = "Total number of INVALID_TOKEN errors received" }, |
| 61 | [QUIC_ST_TRANSP_ERR_APPLICATION_ERROR] = { .name = "quic_transp_err_application_error", |
| 62 | .desc = "Total number of APPLICATION_ERROR errors received" }, |
| 63 | [QUIC_ST_TRANSP_ERR_CRYPTO_BUFFER_EXCEEDED] = { .name = "quic_transp_err_crypto_buffer_exceeded", |
| 64 | .desc = "Total number of CRYPTO_BUFFER_EXCEEDED errors received" }, |
| 65 | [QUIC_ST_TRANSP_ERR_KEY_UPDATE_ERROR] = { .name = "quic_transp_err_key_update_error", |
| 66 | .desc = "Total number of KEY_UPDATE_ERROR errors received" }, |
| 67 | [QUIC_ST_TRANSP_ERR_AEAD_LIMIT_REACHED] = { .name = "quic_transp_err_aead_limit_reached", |
| 68 | .desc = "Total number of AEAD_LIMIT_REACHED errors received" }, |
| 69 | [QUIC_ST_TRANSP_ERR_NO_VIABLE_PATH] = { .name = "quic_transp_err_no_viable_path", |
| 70 | .desc = "Total number of NO_VIABLE_PATH errors received" }, |
| 71 | [QUIC_ST_TRANSP_ERR_CRYPTO_ERROR] = { .name = "quic_transp_err_crypto_error", |
| 72 | .desc = "Total number of CRYPTO_ERROR errors received" }, |
| 73 | [QUIC_ST_TRANSP_ERR_UNKNOWN_ERROR] = { .name = "quic_transp_err_unknown_error", |
| 74 | .desc = "Total number of UNKNOWN_ERROR errors received" }, |
Frédéric Lécaille | a58cafe | 2022-05-18 14:30:03 +0200 | [diff] [blame] | 75 | /* Streams related counters */ |
| 76 | [QUIC_ST_DATA_BLOCKED] = { .name = "quic_data_blocked", |
Frédéric Lécaille | eb79145 | 2022-05-24 16:01:39 +0200 | [diff] [blame] | 77 | .desc = "Total number of received DATA_BLOCKED frames" }, |
Frédéric Lécaille | a58cafe | 2022-05-18 14:30:03 +0200 | [diff] [blame] | 78 | [QUIC_ST_STREAM_DATA_BLOCKED] = { .name = "quic_stream_data_blocked", |
Frédéric Lécaille | eb79145 | 2022-05-24 16:01:39 +0200 | [diff] [blame] | 79 | .desc = "Total number of received STREAMS_BLOCKED frames" }, |
Frédéric Lécaille | a58cafe | 2022-05-18 14:30:03 +0200 | [diff] [blame] | 80 | [QUIC_ST_STREAMS_DATA_BLOCKED_BIDI] = { .name = "quic_streams_data_blocked_bidi", |
Frédéric Lécaille | eb79145 | 2022-05-24 16:01:39 +0200 | [diff] [blame] | 81 | .desc = "Total number of received STREAM_DATA_BLOCKED_BIDI frames" }, |
Frédéric Lécaille | 483499d | 2022-06-20 14:35:40 +0200 | [diff] [blame] | 82 | [QUIC_ST_STREAMS_DATA_BLOCKED_UNI] = { .name = "quic_streams_data_blocked_uni", |
Frédéric Lécaille | eb79145 | 2022-05-24 16:01:39 +0200 | [diff] [blame] | 83 | .desc = "Total number of received STREAM_DATA_BLOCKED_UNI frames" }, |
Frédéric Lécaille | a58cafe | 2022-05-18 14:30:03 +0200 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | struct quic_counters quic_counters; |
| 87 | |
| 88 | static void quic_fill_stats(void *data, struct field *stats) |
| 89 | { |
| 90 | struct quic_counters *counters = data; |
| 91 | |
Amaury Denoyelle | 735b44f | 2022-10-27 17:56:27 +0200 | [diff] [blame] | 92 | stats[QUIC_ST_RXBUF_FULL] = mkf_u64(FN_COUNTER, counters->rxbuf_full); |
Frédéric Lécaille | eb79145 | 2022-05-24 16:01:39 +0200 | [diff] [blame] | 93 | stats[QUIC_ST_DROPPED_PACKET] = mkf_u64(FN_COUNTER, counters->dropped_pkt); |
Frédéric Lécaille | 45a1629 | 2022-06-29 12:03:34 +0200 | [diff] [blame] | 94 | stats[QUIC_ST_DROPPED_PACKET_BUFOVERRUN] = mkf_u64(FN_COUNTER, counters->dropped_pkt_bufoverrun); |
Frédéric Lécaille | eb79145 | 2022-05-24 16:01:39 +0200 | [diff] [blame] | 95 | stats[QUIC_ST_DROPPED_PARSING] = mkf_u64(FN_COUNTER, counters->dropped_parsing); |
Frédéric Lécaille | 8ecb736 | 2022-08-04 12:00:00 +0200 | [diff] [blame] | 96 | stats[QUIC_ST_SOCKET_FULL] = mkf_u64(FN_COUNTER, counters->socket_full); |
| 97 | stats[QUIC_ST_SENDTO_ERR] = mkf_u64(FN_COUNTER, counters->sendto_err); |
Amaury Denoyelle | 7941ead | 2022-10-24 10:44:34 +0200 | [diff] [blame] | 98 | stats[QUIC_ST_SENDTO_ERR_UNKNWN] = mkf_u64(FN_COUNTER, counters->sendto_err_unknown); |
Frédéric Lécaille | eb79145 | 2022-05-24 16:01:39 +0200 | [diff] [blame] | 99 | stats[QUIC_ST_LOST_PACKET] = mkf_u64(FN_COUNTER, counters->lost_pkt); |
Frédéric Lécaille | 3ccea6d | 2022-05-23 22:54:54 +0200 | [diff] [blame] | 100 | stats[QUIC_ST_TOO_SHORT_INITIAL_DGRAM] = mkf_u64(FN_COUNTER, counters->too_short_initial_dgram); |
Frédéric Lécaille | a58cafe | 2022-05-18 14:30:03 +0200 | [diff] [blame] | 101 | stats[QUIC_ST_RETRY_SENT] = mkf_u64(FN_COUNTER, counters->retry_sent); |
| 102 | stats[QUIC_ST_RETRY_VALIDATED] = mkf_u64(FN_COUNTER, counters->retry_validated); |
| 103 | stats[QUIC_ST_RETRY_ERRORS] = mkf_u64(FN_COUNTER, counters->retry_error); |
Frédéric Lécaille | eb79145 | 2022-05-24 16:01:39 +0200 | [diff] [blame] | 104 | stats[QUIC_ST_HALF_OPEN_CONN] = mkf_u64(FN_GAUGE, counters->half_open_conn); |
| 105 | stats[QUIC_ST_HDSHK_FAIL] = mkf_u64(FN_COUNTER, counters->hdshk_fail); |
| 106 | stats[QUIC_ST_STATELESS_RESET_SENT] = mkf_u64(FN_COUNTER, counters->stateless_reset_sent); |
Frédéric Lécaille | 3ccea6d | 2022-05-23 22:54:54 +0200 | [diff] [blame] | 107 | /* Transport errors */ |
| 108 | stats[QUIC_ST_TRANSP_ERR_NO_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_no_error); |
| 109 | stats[QUIC_ST_TRANSP_ERR_INTERNAL_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_internal_error); |
| 110 | stats[QUIC_ST_TRANSP_ERR_CONNECTION_REFUSED] = mkf_u64(FN_COUNTER, counters->quic_transp_err_connection_refused); |
| 111 | stats[QUIC_ST_TRANSP_ERR_FLOW_CONTROL_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_flow_control_error); |
| 112 | stats[QUIC_ST_TRANSP_ERR_STREAM_LIMIT_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_stream_limit_error); |
| 113 | stats[QUIC_ST_TRANSP_ERR_STREAM_STATE_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_stream_state_error); |
| 114 | stats[QUIC_ST_TRANSP_ERR_FINAL_SIZE_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_final_size_error); |
| 115 | stats[QUIC_ST_TRANSP_ERR_FRAME_ENCODING_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_frame_encoding_error); |
| 116 | stats[QUIC_ST_TRANSP_ERR_TRANSPORT_PARAMETER_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_transport_parameter_error); |
| 117 | stats[QUIC_ST_TRANSP_ERR_CONNECTION_ID_LIMIT_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_connection_id_limit); |
| 118 | stats[QUIC_ST_TRANSP_ERR_PROTOCOL_VIOLATION] = mkf_u64(FN_COUNTER, counters->quic_transp_err_protocol_violation); |
| 119 | stats[QUIC_ST_TRANSP_ERR_INVALID_TOKEN] = mkf_u64(FN_COUNTER, counters->quic_transp_err_invalid_token); |
| 120 | stats[QUIC_ST_TRANSP_ERR_APPLICATION_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_application_error); |
| 121 | stats[QUIC_ST_TRANSP_ERR_CRYPTO_BUFFER_EXCEEDED] = mkf_u64(FN_COUNTER, counters->quic_transp_err_crypto_buffer_exceeded); |
| 122 | stats[QUIC_ST_TRANSP_ERR_KEY_UPDATE_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_key_update_error); |
| 123 | stats[QUIC_ST_TRANSP_ERR_AEAD_LIMIT_REACHED] = mkf_u64(FN_COUNTER, counters->quic_transp_err_aead_limit_reached); |
| 124 | stats[QUIC_ST_TRANSP_ERR_NO_VIABLE_PATH] = mkf_u64(FN_COUNTER, counters->quic_transp_err_no_viable_path); |
| 125 | stats[QUIC_ST_TRANSP_ERR_CRYPTO_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_crypto_error); |
| 126 | stats[QUIC_ST_TRANSP_ERR_UNKNOWN_ERROR] = mkf_u64(FN_COUNTER, counters->quic_transp_err_unknown_error); |
Frédéric Lécaille | a58cafe | 2022-05-18 14:30:03 +0200 | [diff] [blame] | 127 | /* Streams related counters */ |
| 128 | stats[QUIC_ST_DATA_BLOCKED] = mkf_u64(FN_COUNTER, counters->data_blocked); |
| 129 | stats[QUIC_ST_STREAM_DATA_BLOCKED] = mkf_u64(FN_COUNTER, counters->stream_data_blocked); |
| 130 | stats[QUIC_ST_STREAMS_DATA_BLOCKED_BIDI] = mkf_u64(FN_COUNTER, counters->streams_data_blocked_bidi); |
| 131 | stats[QUIC_ST_STREAMS_DATA_BLOCKED_UNI] = mkf_u64(FN_COUNTER, counters->streams_data_blocked_uni); |
| 132 | } |
| 133 | |
| 134 | struct stats_module quic_stats_module = { |
| 135 | .name = "quic", |
| 136 | .fill_stats = quic_fill_stats, |
| 137 | .stats = quic_stats, |
| 138 | .stats_count = QUIC_STATS_COUNT, |
| 139 | .counters = &quic_counters, |
| 140 | .counters_size = sizeof(quic_counters), |
| 141 | .domain_flags = MK_STATS_PROXY_DOMAIN(STATS_PX_CAP_FE), |
| 142 | .clearable = 1, |
| 143 | }; |
| 144 | |
| 145 | INITCALL1(STG_REGISTER, stats_register_module, &quic_stats_module); |
Frédéric Lécaille | 3ccea6d | 2022-05-23 22:54:54 +0200 | [diff] [blame] | 146 | |
| 147 | void quic_stats_transp_err_count_inc(struct quic_counters *ctrs, int error_code) |
| 148 | { |
| 149 | switch (error_code) { |
| 150 | case QC_ERR_NO_ERROR: |
| 151 | HA_ATOMIC_INC(&ctrs->quic_transp_err_no_error); |
| 152 | break; |
| 153 | case QC_ERR_INTERNAL_ERROR: |
| 154 | HA_ATOMIC_INC(&ctrs->quic_transp_err_internal_error); |
| 155 | break; |
| 156 | case QC_ERR_CONNECTION_REFUSED: |
| 157 | HA_ATOMIC_INC(&ctrs->quic_transp_err_connection_refused); |
| 158 | break; |
| 159 | case QC_ERR_FLOW_CONTROL_ERROR: |
| 160 | HA_ATOMIC_INC(&ctrs->quic_transp_err_flow_control_error); |
| 161 | break; |
| 162 | case QC_ERR_STREAM_LIMIT_ERROR: |
| 163 | HA_ATOMIC_INC(&ctrs->quic_transp_err_stream_limit_error); |
| 164 | break; |
| 165 | case QC_ERR_STREAM_STATE_ERROR: |
| 166 | HA_ATOMIC_INC(&ctrs->quic_transp_err_stream_state_error); |
| 167 | break; |
| 168 | case QC_ERR_FINAL_SIZE_ERROR: |
| 169 | HA_ATOMIC_INC(&ctrs->quic_transp_err_final_size_error); |
| 170 | break; |
| 171 | case QC_ERR_FRAME_ENCODING_ERROR: |
| 172 | HA_ATOMIC_INC(&ctrs->quic_transp_err_frame_encoding_error); |
| 173 | break; |
| 174 | case QC_ERR_TRANSPORT_PARAMETER_ERROR: |
| 175 | HA_ATOMIC_INC(&ctrs->quic_transp_err_transport_parameter_error); |
| 176 | break; |
| 177 | case QC_ERR_CONNECTION_ID_LIMIT_ERROR: |
| 178 | HA_ATOMIC_INC(&ctrs->quic_transp_err_connection_id_limit); |
| 179 | break; |
| 180 | case QC_ERR_PROTOCOL_VIOLATION: |
| 181 | HA_ATOMIC_INC(&ctrs->quic_transp_err_protocol_violation); |
| 182 | break; |
| 183 | case QC_ERR_INVALID_TOKEN: |
| 184 | HA_ATOMIC_INC(&ctrs->quic_transp_err_invalid_token); |
| 185 | break; |
| 186 | case QC_ERR_APPLICATION_ERROR: |
| 187 | HA_ATOMIC_INC(&ctrs->quic_transp_err_application_error); |
| 188 | break; |
| 189 | case QC_ERR_CRYPTO_BUFFER_EXCEEDED: |
| 190 | HA_ATOMIC_INC(&ctrs->quic_transp_err_crypto_buffer_exceeded); |
| 191 | break; |
| 192 | case QC_ERR_KEY_UPDATE_ERROR: |
| 193 | HA_ATOMIC_INC(&ctrs->quic_transp_err_key_update_error); |
| 194 | break; |
| 195 | case QC_ERR_AEAD_LIMIT_REACHED: |
| 196 | HA_ATOMIC_INC(&ctrs->quic_transp_err_aead_limit_reached); |
| 197 | break; |
| 198 | case QC_ERR_NO_VIABLE_PATH: |
| 199 | HA_ATOMIC_INC(&ctrs->quic_transp_err_no_viable_path); |
| 200 | break; |
| 201 | default: |
| 202 | if (error_code >= 0x100 && error_code <= 0x1ff) |
| 203 | HA_ATOMIC_INC(&ctrs->quic_transp_err_crypto_error); |
| 204 | else |
| 205 | HA_ATOMIC_INC(&ctrs->quic_transp_err_unknown_error); |
| 206 | } |
| 207 | } |