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