ttuttle | b160737 | 2016-02-09 16:27:16 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "components/domain_reliability/quic_error_mapping.h" |
| 6 | |
| 7 | namespace domain_reliability { |
| 8 | |
| 9 | namespace { |
| 10 | |
| 11 | const struct QuicErrorMapping { |
| 12 | net::QuicErrorCode quic_error; |
| 13 | const char* beacon_quic_error; |
| 14 | } kQuicErrorMap[] = { |
jokulik | 14e0d83b | 2017-03-10 22:09:37 | [diff] [blame] | 15 | // Connection has reached an invalid state. |
| 16 | {net::QUIC_INTERNAL_ERROR, "quic.internal_error"}, |
| 17 | // There were data frames after the a fin or reset. |
| 18 | {net::QUIC_STREAM_DATA_AFTER_TERMINATION, |
| 19 | "quic.stream_data.after_termination"}, |
| 20 | // Control frame is malformed. |
| 21 | {net::QUIC_INVALID_PACKET_HEADER, "quic.invalid.packet_header"}, |
| 22 | // Frame data is malformed. |
| 23 | {net::QUIC_INVALID_FRAME_DATA, "quic.invalid_frame_data"}, |
| 24 | // The packet contained no payload. |
| 25 | {net::QUIC_MISSING_PAYLOAD, "quic.missing.payload"}, |
| 26 | // FEC data is malformed. |
| 27 | {net::QUIC_INVALID_FEC_DATA, "quic.invalid.fec_data"}, |
| 28 | // STREAM frame data is malformed. |
| 29 | {net::QUIC_INVALID_STREAM_DATA, "quic.invalid.stream_data"}, |
| 30 | // STREAM frame data is not encrypted. |
| 31 | {net::QUIC_UNENCRYPTED_STREAM_DATA, "quic.unencrypted.stream_data"}, |
| 32 | // Attempt to send unencrypted STREAM frame. |
| 33 | {net::QUIC_ATTEMPT_TO_SEND_UNENCRYPTED_STREAM_DATA, |
| 34 | "quic.attempt.to.unencrypted.stream.data"}, |
| 35 | // Received a frame which is likely the result of memory corruption. |
| 36 | {net::QUIC_MAYBE_CORRUPTED_MEMORY, "quic.maybe.corrupted.momery"}, |
| 37 | // FEC frame data is not encrypted. |
| 38 | {net::QUIC_UNENCRYPTED_FEC_DATA, "quic.unencrypted.fec.data"}, |
| 39 | // RST_STREAM frame data is malformed. |
| 40 | {net::QUIC_INVALID_RST_STREAM_DATA, "quic.invalid.rst_stream_data"}, |
| 41 | // CONNECTION_CLOSE frame data is malformed. |
| 42 | {net::QUIC_INVALID_CONNECTION_CLOSE_DATA, |
| 43 | "quic.invalid.connection_close_data"}, |
| 44 | // GOAWAY frame data is malformed. |
| 45 | {net::QUIC_INVALID_GOAWAY_DATA, "quic.invalid.goaway_data"}, |
| 46 | // WINDOW_UPDATE frame data is malformed. |
| 47 | {net::QUIC_INVALID_WINDOW_UPDATE_DATA, "quic.invalid.window_update_data"}, |
| 48 | // BLOCKED frame data is malformed. |
| 49 | {net::QUIC_INVALID_BLOCKED_DATA, "quic.invalid.blocked_data"}, |
| 50 | // STOP_WAITING frame data is malformed. |
| 51 | {net::QUIC_INVALID_STOP_WAITING_DATA, "quic.invalid.stop_waiting_data"}, |
| 52 | // PATH_CLOSE frame data is malformed. |
| 53 | {net::QUIC_INVALID_PATH_CLOSE_DATA, "quic.invalid_path_close_data"}, |
| 54 | // ACK frame data is malformed. |
| 55 | {net::QUIC_INVALID_ACK_DATA, "quic.invalid.ack_data"}, |
ttuttle | b160737 | 2016-02-09 16:27:16 | [diff] [blame] | 56 | |
jokulik | 14e0d83b | 2017-03-10 22:09:37 | [diff] [blame] | 57 | // Version negotiation packet is malformed. |
| 58 | {net::QUIC_INVALID_VERSION_NEGOTIATION_PACKET, |
| 59 | "quic_invalid_version_negotiation_packet"}, |
| 60 | // Public RST packet is malformed. |
| 61 | {net::QUIC_INVALID_PUBLIC_RST_PACKET, "quic.invalid.public_rst_packet"}, |
ttuttle | b160737 | 2016-02-09 16:27:16 | [diff] [blame] | 62 | |
jokulik | 14e0d83b | 2017-03-10 22:09:37 | [diff] [blame] | 63 | // There was an error decrypting. |
| 64 | {net::QUIC_DECRYPTION_FAILURE, "quic.decryption.failure"}, |
| 65 | // There was an error encrypting. |
| 66 | {net::QUIC_ENCRYPTION_FAILURE, "quic.encryption.failure"}, |
| 67 | // The packet exceeded kMaxPacketSize. |
| 68 | {net::QUIC_PACKET_TOO_LARGE, "quic.packet.too_large"}, |
| 69 | // The peer is going away. May be a client or server. |
| 70 | {net::QUIC_PEER_GOING_AWAY, "quic.peer_going_away"}, |
| 71 | // A stream ID was invalid. |
| 72 | {net::QUIC_INVALID_STREAM_ID, "quic.invalid_stream_id"}, |
| 73 | // A priority was invalid. |
| 74 | {net::QUIC_INVALID_PRIORITY, "quic.invalid_priority"}, |
| 75 | // Too many streams already open. |
| 76 | {net::QUIC_TOO_MANY_OPEN_STREAMS, "quic.too_many_open_streams"}, |
| 77 | // The peer created too many available streams. |
| 78 | {net::QUIC_TOO_MANY_AVAILABLE_STREAMS, "quic.too_many_available_streams"}, |
| 79 | // Received public reset for this connection. |
| 80 | {net::QUIC_PUBLIC_RESET, "quic.public_reset"}, |
| 81 | // Invalid protocol version. |
| 82 | {net::QUIC_INVALID_VERSION, "quic.invalid_version"}, |
ttuttle | b160737 | 2016-02-09 16:27:16 | [diff] [blame] | 83 | |
jokulik | 14e0d83b | 2017-03-10 22:09:37 | [diff] [blame] | 84 | // The Header ID for a stream was too far from the previous. |
| 85 | {net::QUIC_INVALID_HEADER_ID, "quic.invalid_header_id"}, |
| 86 | // Negotiable parameter received during handshake had invalid value. |
| 87 | {net::QUIC_INVALID_NEGOTIATED_VALUE, "quic.invalid_negotiated_value"}, |
| 88 | // There was an error decompressing data. |
| 89 | {net::QUIC_DECOMPRESSION_FAILURE, "quic.decompression_failure"}, |
| 90 | // We hit our prenegotiated (or default) timeout |
| 91 | {net::QUIC_NETWORK_IDLE_TIMEOUT, "quic.connection.idle_time_out"}, |
| 92 | // We hit our overall connection timeout |
| 93 | {net::QUIC_HANDSHAKE_TIMEOUT, "quic.connection.handshake_timed_out"}, |
| 94 | // There was an error encountered migrating addresses. |
| 95 | {net::QUIC_ERROR_MIGRATING_ADDRESS, "quic.error_migrating_address"}, |
| 96 | // There was an error encountered migrating port only. |
| 97 | {net::QUIC_ERROR_MIGRATING_PORT, "quic.error_migrating_port"}, |
| 98 | // There was an error while writing to the socket. |
| 99 | {net::QUIC_PACKET_WRITE_ERROR, "quic.packet.write_error"}, |
| 100 | // There was an error while reading from the socket. |
| 101 | {net::QUIC_PACKET_READ_ERROR, "quic.packet.read_error"}, |
| 102 | // We received a STREAM_FRAME with no data and no fin flag set. |
| 103 | {net::QUIC_EMPTY_STREAM_FRAME_NO_FIN, "quic.empty_stream_frame_no_fin"}, |
| 104 | // We received invalid data on the headers stream. |
| 105 | {net::QUIC_INVALID_HEADERS_STREAM_DATA, "quic.invalid_headers_stream_data"}, |
| 106 | // The peer received too much data, violating flow control. |
| 107 | {net::QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA, |
| 108 | "quic.flow_control.received_too_much_data"}, |
| 109 | // The peer sent too much data, violating flow control. |
| 110 | {net::QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA, |
| 111 | "quic.flow_control.sent_too_much_data"}, |
| 112 | // The peer received an invalid flow control window. |
| 113 | {net::QUIC_FLOW_CONTROL_INVALID_WINDOW, "quic.flow_control.invalid_window"}, |
| 114 | // The connection has been IP pooled into an existing connection. |
| 115 | {net::QUIC_CONNECTION_IP_POOLED, "quic.connection.ip_pooled"}, |
| 116 | // The connection has too many outstanding sent packets. |
| 117 | {net::QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS, |
| 118 | "quic.too_many_outstanding_sent_packets"}, |
| 119 | // The connection has too many outstanding received packets. |
| 120 | {net::QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS, |
| 121 | "quic.too_many_outstanding_received_packets"}, |
| 122 | // The quic connection job to load server config is cancelled. |
| 123 | {net::QUIC_CONNECTION_CANCELLED, "quic.connection.cancelled"}, |
| 124 | // Disabled QUIC because of high packet loss rate. |
| 125 | {net::QUIC_BAD_PACKET_LOSS_RATE, "quic.bad_packet_loss_rate"}, |
| 126 | // Disabled QUIC because of too many PUBLIC_RESETs post handshake. |
| 127 | {net::QUIC_PUBLIC_RESETS_POST_HANDSHAKE, |
| 128 | "quic.public_resets_post_handshake"}, |
jokulik | 14e0d83b | 2017-03-10 22:09:37 | [diff] [blame] | 129 | // Closed because we failed to serialize a packet. |
| 130 | {net::QUIC_FAILED_TO_SERIALIZE_PACKET, "quic.failed_to_serialize_packet"}, |
| 131 | // QUIC timed out after too many RTOs. |
| 132 | {net::QUIC_TOO_MANY_RTOS, "quic.too_many_rtos"}, |
| 133 | // Crypto errors. |
ttuttle | b160737 | 2016-02-09 16:27:16 | [diff] [blame] | 134 | |
jokulik | 14e0d83b | 2017-03-10 22:09:37 | [diff] [blame] | 135 | // Hanshake failed. |
| 136 | {net::QUIC_HANDSHAKE_FAILED, "quic.handshake_failed"}, |
| 137 | // Handshake message contained out of order tags. |
| 138 | {net::QUIC_CRYPTO_TAGS_OUT_OF_ORDER, "quic.crypto.tags_out_of_order"}, |
| 139 | // Handshake message contained too many entries. |
| 140 | {net::QUIC_CRYPTO_TOO_MANY_ENTRIES, "quic.crypto.too_many_entries"}, |
| 141 | // Handshake message contained an invalid value length. |
| 142 | {net::QUIC_CRYPTO_INVALID_VALUE_LENGTH, "quic.crypto.invalid_value_length"}, |
| 143 | // A crypto message was received after the handshake was complete. |
| 144 | {net::QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE, |
| 145 | "quic.crypto_message_after_handshake_complete"}, |
| 146 | // A crypto message was received with an illegal message tag. |
| 147 | {net::QUIC_INVALID_CRYPTO_MESSAGE_TYPE, "quic.invalid_crypto_message_type"}, |
| 148 | // A crypto message was received with an illegal parameter. |
| 149 | {net::QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER, |
| 150 | "quic.invalid_crypto_message_parameter"}, |
| 151 | // An invalid channel id signature was supplied. |
| 152 | {net::QUIC_INVALID_CHANNEL_ID_SIGNATURE, |
| 153 | "quic.invalid_channel_id_signature"}, |
| 154 | // A crypto message was received with a mandatory parameter missing. |
| 155 | {net::QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND, |
| 156 | "quic.crypto_message.parameter_not_found"}, |
| 157 | // A crypto message was received with a parameter that has no overlap |
| 158 | // with the local parameter. |
| 159 | {net::QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP, |
| 160 | "quic.crypto_message.parameter_no_overlap"}, |
| 161 | // A crypto message was received that contained a parameter with too few |
| 162 | // values. |
| 163 | {net::QUIC_CRYPTO_MESSAGE_INDEX_NOT_FOUND, |
| 164 | "quic_crypto_message_index_not_found"}, |
| 165 | // A demand for an unsupport proof type was received. |
| 166 | {net::QUIC_UNSUPPORTED_PROOF_DEMAND, "quic.unsupported_proof_demand"}, |
| 167 | // An internal error occured in crypto processing. |
| 168 | {net::QUIC_CRYPTO_INTERNAL_ERROR, "quic.crypto.internal_error"}, |
| 169 | // A crypto handshake message specified an unsupported version. |
| 170 | {net::QUIC_CRYPTO_VERSION_NOT_SUPPORTED, |
| 171 | "quic.crypto.version_not_supported"}, |
| 172 | // A crypto handshake message resulted in a stateless reject. |
| 173 | {net::QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT, |
| 174 | "quic.crypto.handshake_stateless_reject"}, |
| 175 | // There was no intersection between the crypto primitives supported by the |
| 176 | // peer and ourselves. |
| 177 | {net::QUIC_CRYPTO_NO_SUPPORT, "quic.crypto.no_support"}, |
| 178 | // The server rejected our client hello messages too many times. |
| 179 | {net::QUIC_CRYPTO_TOO_MANY_REJECTS, "quic.crypto.too_many_rejects"}, |
| 180 | // The client rejected the server's certificate chain or signature. |
| 181 | {net::QUIC_PROOF_INVALID, "quic.proof_invalid"}, |
| 182 | // A crypto message was received with a duplicate tag. |
| 183 | {net::QUIC_CRYPTO_DUPLICATE_TAG, "quic.crypto.duplicate_tag"}, |
| 184 | // A crypto message was received with the wrong encryption level (i.e. it |
| 185 | // should have been encrypted but was not.) |
| 186 | {net::QUIC_CRYPTO_ENCRYPTION_LEVEL_INCORRECT, |
| 187 | "quic.crypto.encryption_level_incorrect"}, |
| 188 | // The server config for a server has expired. |
| 189 | {net::QUIC_CRYPTO_SERVER_CONFIG_EXPIRED, |
| 190 | "quic.crypto.server_config_expired"}, |
| 191 | // We failed to setup the symmetric keys for a connection. |
| 192 | {net::QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED, |
| 193 | "quic.crypto.symmetric_key_setup_failed"}, |
| 194 | // A handshake message arrived, but we are still validating the |
| 195 | // previous handshake message. |
| 196 | {net::QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO, |
| 197 | "quic.crypto_message_while_validating_client_hello"}, |
| 198 | // A server config update arrived before the handshake is complete. |
| 199 | {net::QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE, |
| 200 | "quic.crypto.update_before_handshake_complete"}, |
| 201 | // CHLO cannot fit in one packet. |
| 202 | {net::QUIC_CRYPTO_CHLO_TOO_LARGE, "quic.crypto.chlo_too_large"}, |
| 203 | // This connection involved a version negotiation which appears to have been |
| 204 | // tampered with. |
| 205 | {net::QUIC_VERSION_NEGOTIATION_MISMATCH, |
| 206 | "quic.version_negotiation_mismatch"}, |
ttuttle | b160737 | 2016-02-09 16:27:16 | [diff] [blame] | 207 | |
jokulik | 14e0d83b | 2017-03-10 22:09:37 | [diff] [blame] | 208 | // Multipath is not enabled, but a packet with multipath flag on is |
| 209 | // received. |
| 210 | {net::QUIC_BAD_MULTIPATH_FLAG, "quic.bad_multipath_flag"}, |
| 211 | // A path is supposed to exist but does not. |
| 212 | {net::QUIC_MULTIPATH_PATH_DOES_NOT_EXIST, |
| 213 | "quic.quic_multipath_path_does_not_exist"}, |
| 214 | // A path is supposed to be active but is not. |
| 215 | {net::QUIC_MULTIPATH_PATH_NOT_ACTIVE, |
| 216 | "quic.quic_multipath_path_not_active"}, |
ttuttle | b160737 | 2016-02-09 16:27:16 | [diff] [blame] | 217 | |
jokulik | 14e0d83b | 2017-03-10 22:09:37 | [diff] [blame] | 218 | // Network change and connection migration errors. |
ttuttle | b160737 | 2016-02-09 16:27:16 | [diff] [blame] | 219 | |
jokulik | 14e0d83b | 2017-03-10 22:09:37 | [diff] [blame] | 220 | // IP address changed causing connection close. |
| 221 | {net::QUIC_IP_ADDRESS_CHANGED, "quic.ip_address_changed"}, |
| 222 | // Network changed, but connection had no migratable streams. |
| 223 | {net::QUIC_CONNECTION_MIGRATION_NO_MIGRATABLE_STREAMS, |
| 224 | "quic.connection_migration_no_migratable_streams"}, |
| 225 | // Connection changed networks too many times. |
| 226 | {net::QUIC_CONNECTION_MIGRATION_TOO_MANY_CHANGES, |
| 227 | "quic.connection_migration_too_many_changes"}, |
| 228 | // Connection migration was attempted, but there was no new network to |
| 229 | // migrate to. |
| 230 | {net::QUIC_CONNECTION_MIGRATION_NO_NEW_NETWORK, |
| 231 | "quic.connection_migration_no_new_network"}, |
| 232 | // Network changed, but connection had one or more non-migratable streams. |
| 233 | {net::QUIC_CONNECTION_MIGRATION_NON_MIGRATABLE_STREAM, |
| 234 | "quic.connection_migration_non_migratable_stream"}, |
| 235 | // Stream frame overlaps with buffered data. |
| 236 | {net::QUIC_OVERLAPPING_STREAM_DATA, "quic.overlapping_stream_data"}, |
| 237 | // Stream frames arrived too discontiguously so that stream sequencer buffer |
Michael Warres | ed8ebd5 | 2017-12-22 22:42:04 | [diff] [blame] | 238 | // maintains too many intervals. |
| 239 | {net::QUIC_TOO_MANY_STREAM_DATA_INTERVALS, |
| 240 | "quic.too_many_stream_data_intervals"}, |
jokulik | 14e0d83b | 2017-03-10 22:09:37 | [diff] [blame] | 241 | // Sequencer buffer get into weird state where continuing read/write |
| 242 | // will lead to crash. |
| 243 | {net::QUIC_STREAM_SEQUENCER_INVALID_STATE, |
| 244 | "quic.stream_sequencer_invalid_state"}, |
| 245 | // Connection closed because of server hits max number of sessions allowed. |
| 246 | {net::QUIC_TOO_MANY_SESSIONS_ON_SERVER, "quic.too_many_sessions_on_server"}, |
| 247 | // There was an error decompressing data. |
| 248 | {net::QUIC_DECOMPRESSION_FAILURE, "quic.decompression_failure"}, |
Dan Zhang | fefaf5b | 2017-12-11 17:06:24 | [diff] [blame] | 249 | // Receive a RST_STREAM with offset larger than kMaxStreamLength. |
| 250 | {net::QUIC_STREAM_LENGTH_OVERFLOW, "quic.stream_length_overflow"}, |
ttuttle | b160737 | 2016-02-09 16:27:16 | [diff] [blame] | 251 | |
jokulik | 14e0d83b | 2017-03-10 22:09:37 | [diff] [blame] | 252 | // No error. Used as bound while iterating. |
| 253 | {net::QUIC_LAST_ERROR, "quic.last_error"}}; |
ttuttle | b160737 | 2016-02-09 16:27:16 | [diff] [blame] | 254 | |
zhongyi | c47bd31 | 2016-05-31 21:43:25 | [diff] [blame] | 255 | // Must be updated any time a net::QuicErrorCode is deprecated in |
vasilvv | 28270e8f | 2016-12-01 21:38:09 | [diff] [blame] | 256 | // net/quic/core/quic_packets.h. |
danzh | 7510498 | 2017-04-14 21:58:09 | [diff] [blame] | 257 | const int kDeprecatedQuicErrorCount = 5; |
zhongyi | c47bd31 | 2016-05-31 21:43:25 | [diff] [blame] | 258 | const int kActiveQuicErrorCount = |
| 259 | net::QUIC_LAST_ERROR - kDeprecatedQuicErrorCount; |
| 260 | |
| 261 | static_assert(arraysize(kQuicErrorMap) == kActiveQuicErrorCount, |
zhongyi | 1715b9b | 2016-05-29 00:14:24 | [diff] [blame] | 262 | "quic_error_map is not in sync with quic protocol!"); |
| 263 | |
ttuttle | b160737 | 2016-02-09 16:27:16 | [diff] [blame] | 264 | } // namespace |
| 265 | |
| 266 | // static |
| 267 | bool GetDomainReliabilityBeaconQuicError(net::QuicErrorCode quic_error, |
| 268 | std::string* beacon_quic_error_out) { |
| 269 | if (quic_error != net::QUIC_NO_ERROR) { |
| 270 | // Convert a QUIC error. |
ttuttle | 960fcbf | 2016-04-19 13:26:32 | [diff] [blame] | 271 | // TODO(juliatuttle): Consider sorting and using binary search? |
ttuttle | b160737 | 2016-02-09 16:27:16 | [diff] [blame] | 272 | for (size_t i = 0; i < arraysize(kQuicErrorMap); i++) { |
| 273 | if (kQuicErrorMap[i].quic_error == quic_error) { |
| 274 | *beacon_quic_error_out = kQuicErrorMap[i].beacon_quic_error; |
| 275 | return true; |
| 276 | } |
| 277 | } |
| 278 | } |
| 279 | beacon_quic_error_out->clear(); |
| 280 | return false; |
| 281 | } |
| 282 | |
| 283 | } // namespace domain_reliability |