blob: 494b03c4cbeb7652c6876874dbf9fd6200c4fc42 [file] [log] [blame]
ttuttleb1607372016-02-09 16:27:161// 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
7namespace domain_reliability {
8
9namespace {
10
11const struct QuicErrorMapping {
12 net::QuicErrorCode quic_error;
13 const char* beacon_quic_error;
14} kQuicErrorMap[] = {
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" },
jri78ec06a2016-03-31 18:19:4032 // Attempt to send unencrypted STREAM frame.
33 { net::QUIC_ATTEMPT_TO_SEND_UNENCRYPTED_STREAM_DATA,
34 "quic.attempt.to.unencrypted.stream.data" },
danzh1401f0a2016-05-19 13:41:1035 // Received a frame which is likely the result of memory corruption.
36 { net::QUIC_MAYBE_CORRUPTED_MEMORY, "quic.maybe.corrupted.momery" },
ttuttleb1607372016-02-09 16:27:1637 // 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" },
56
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" },
62
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" },
83
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,
94 "quic.connection.handshake_timed_out" },
zhongyi2341cda2016-03-10 04:09:3495 // There was an error encountered migrating addresses.
ttuttleb1607372016-02-09 16:27:1696 { net::QUIC_ERROR_MIGRATING_ADDRESS, "quic.error_migrating_address" },
zhongyi2341cda2016-03-10 04:09:3497 // There was an error encountered migrating port only.
98 { net::QUIC_ERROR_MIGRATING_PORT, "quic.error_migrating_port" },
ttuttleb1607372016-02-09 16:27:1699 // There was an error while writing to the socket.
100 { net::QUIC_PACKET_WRITE_ERROR, "quic.packet.write_error" },
101 // There was an error while reading from the socket.
102 { net::QUIC_PACKET_READ_ERROR, "quic.packet.read_error" },
103 // We received a STREAM_FRAME with no data and no fin flag set.
jokulikf2bd55c52016-03-24 22:35:30104 { net::QUIC_EMPTY_STREAM_FRAME_NO_FIN, "quic.empty_stream_frame_no_fin" },
ttuttleb1607372016-02-09 16:27:16105 // We received invalid data on the headers stream.
106 { net::QUIC_INVALID_HEADERS_STREAM_DATA, "quic.invalid_headers_stream_data" },
107 // The peer received too much data, violating flow control.
108 { net::QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA,
109 "quic.flow_control.received_too_much_data" },
110 // The peer sent too much data, violating flow control.
111 { net::QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA,
112 "quic.flow_control.sent_too_much_data" },
113 // The peer received an invalid flow control window.
114 { net::QUIC_FLOW_CONTROL_INVALID_WINDOW, "quic.flow_control.invalid_window" },
115 // The connection has been IP pooled into an existing connection.
116 { net::QUIC_CONNECTION_IP_POOLED, "quic.connection.ip_pooled" },
117 // The connection has too many outstanding sent packets.
118 { net::QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS,
119 "quic.too_many_outstanding_sent_packets" },
120 // The connection has too many outstanding received packets.
121 { net::QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS,
122 "quic.too_many_outstanding_received_packets" },
123 // The quic connection job to load server config is cancelled.
124 { net::QUIC_CONNECTION_CANCELLED, "quic.connection.cancelled" },
125 // Disabled QUIC because of high packet loss rate.
126 { net::QUIC_BAD_PACKET_LOSS_RATE, "quic.bad_packet_loss_rate" },
127 // Disabled QUIC because of too many PUBLIC_RESETs post handshake.
128 { net::QUIC_PUBLIC_RESETS_POST_HANDSHAKE,
129 "quic.public_resets_post_handshake" },
130 // Disabled QUIC because of too many timeouts with streams open.
131 { net::QUIC_TIMEOUTS_WITH_OPEN_STREAMS, "quic.timeouts_with_open_streams" },
132 // Closed because we failed to serialize a packet.
133 { net::QUIC_FAILED_TO_SERIALIZE_PACKET, "quic.failed_to_serialize_packet" },
zhongyi2341cda2016-03-10 04:09:34134 // QUIC timed out after too many RTOs.
135 { net::QUIC_TOO_MANY_RTOS, "quic.too_many_rtos" },
ttuttleb1607372016-02-09 16:27:16136 // Crypto errors.
137
138 // Hanshake failed.
139 { net::QUIC_HANDSHAKE_FAILED, "quic.handshake_failed" },
140 // Handshake message contained out of order tags.
141 { net::QUIC_CRYPTO_TAGS_OUT_OF_ORDER, "quic.crypto.tags_out_of_order" },
142 // Handshake message contained too many entries.
143 { net::QUIC_CRYPTO_TOO_MANY_ENTRIES, "quic.crypto.too_many_entries" },
144 // Handshake message contained an invalid value length.
145 { net::QUIC_CRYPTO_INVALID_VALUE_LENGTH, "quic.crypto.invalid_value_length" },
146 // A crypto message was received after the handshake was complete.
147 { net::QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE,
148 "quic.crypto_message_after_handshake_complete" },
149 // A crypto message was received with an illegal message tag.
150 { net::QUIC_INVALID_CRYPTO_MESSAGE_TYPE, "quic.invalid_crypto_message_type" },
151 // A crypto message was received with an illegal parameter.
152 { net::QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER,
153 "quic.invalid_crypto_message_parameter" },
154 // An invalid channel id signature was supplied.
155 { net::QUIC_INVALID_CHANNEL_ID_SIGNATURE,
156 "quic.invalid_channel_id_signature" },
157 // A crypto message was received with a mandatory parameter missing.
158 { net::QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND,
159 "quic.crypto_message.parameter_not_found" },
160 // A crypto message was received with a parameter that has no overlap
161 // with the local parameter.
162 { net::QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP,
163 "quic.crypto_message.parameter_no_overlap" },
164 // A crypto message was received that contained a parameter with too few
165 // values.
166 { net::QUIC_CRYPTO_MESSAGE_INDEX_NOT_FOUND,
167 "quic_crypto_message_index_not_found" },
168 // An internal error occured in crypto processing.
169 { net::QUIC_CRYPTO_INTERNAL_ERROR, "quic.crypto.internal_error" },
170 // A crypto handshake message specified an unsupported version.
171 { net::QUIC_CRYPTO_VERSION_NOT_SUPPORTED,
172 "quic.crypto.version_not_supported" },
173 // A crypto handshake message resulted in a stateless reject.
174 { net::QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT,
175 "quic.crypto.handshake_stateless_reject" },
176 // There was no intersection between the crypto primitives supported by the
177 // peer and ourselves.
178 { net::QUIC_CRYPTO_NO_SUPPORT, "quic.crypto.no_support" },
179 // The server rejected our client hello messages too many times.
180 { net::QUIC_CRYPTO_TOO_MANY_REJECTS, "quic.crypto.too_many_rejects" },
181 // The client rejected the server's certificate chain or signature.
182 { net::QUIC_PROOF_INVALID, "quic.proof_invalid" },
183 // A crypto message was received with a duplicate tag.
184 { net::QUIC_CRYPTO_DUPLICATE_TAG, "quic.crypto.duplicate_tag" },
185 // A crypto message was received with the wrong encryption level (i.e. it
186 // should have been encrypted but was not.)
187 { net::QUIC_CRYPTO_ENCRYPTION_LEVEL_INCORRECT,
188 "quic.crypto.encryption_level_incorrect" },
189 // The server config for a server has expired.
190 { net::QUIC_CRYPTO_SERVER_CONFIG_EXPIRED,
191 "quic.crypto.server_config_expired" },
192 // We failed to setup the symmetric keys for a connection.
193 { net::QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED,
194 "quic.crypto.symmetric_key_setup_failed" },
195 // A handshake message arrived, but we are still validating the
196 // previous handshake message.
197 { net::QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO,
198 "quic.crypto_message_while_validating_client_hello" },
199 // A server config update arrived before the handshake is complete.
200 { net::QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE,
201 "quic.crypto.update_before_handshake_complete" },
fayang70dfb8762016-05-27 16:25:11202 // CHLO cannot fit in one packet.
203 { net::QUIC_CRYPTO_CHLO_TOO_LARGE,
204 "quic.crypto.chlo_too_large" },
ttuttleb1607372016-02-09 16:27:16205 // This connection involved a version negotiation which appears to have been
206 // tampered with.
207 { net::QUIC_VERSION_NEGOTIATION_MISMATCH,
208 "quic.version_negotiation_mismatch" },
209
210 // Multipath is not enabled, but a packet with multipath flag on is received.
211 { net::QUIC_BAD_MULTIPATH_FLAG, "quic.bad_multipath_flag" },
212
213 // Network change and connection migration errors.
214
215 // IP address changed causing connection close.
216 { net::QUIC_IP_ADDRESS_CHANGED, "quic.ip_address_changed" },
217 // Network changed, but connection had no migratable streams.
218 { net::QUIC_CONNECTION_MIGRATION_NO_MIGRATABLE_STREAMS,
219 "quic.connection_migration_no_migratable_streams" },
220 // Connection changed networks too many times.
221 { net::QUIC_CONNECTION_MIGRATION_TOO_MANY_CHANGES,
222 "quic.connection_migration_too_many_changes" },
223 // Connection migration was attempted, but there was no new network to
224 // migrate to.
225 { net::QUIC_CONNECTION_MIGRATION_NO_NEW_NETWORK,
226 "quic.connection_migration_no_new_network" },
jri231c2972016-03-08 19:50:11227 // Network changed, but connection had one or more non-migratable streams.
228 { net::QUIC_CONNECTION_MIGRATION_NON_MIGRATABLE_STREAM,
229 "quic.connection_migration_non_migratable_stream" },
jokulikf2bd55c52016-03-24 22:35:30230 // Stream frame overlaps with buffered data.
231 { net::QUIC_OVERLAPPING_STREAM_DATA,
232 "quic.overlapping_stream_data" },
ttuttleb1607372016-02-09 16:27:16233
234 // No error. Used as bound while iterating.
235 { net::QUIC_LAST_ERROR, "quic.last_error"}
236};
237
zhongyic47bd312016-05-31 21:43:25238// Must be updated any time a net::QuicErrorCode is deprecated in
239// net/quic/quic_protocol.h.
240const int kDeprecatedQuicErrorCount = 4;
241const int kActiveQuicErrorCount =
242 net::QUIC_LAST_ERROR - kDeprecatedQuicErrorCount;
243
244static_assert(arraysize(kQuicErrorMap) == kActiveQuicErrorCount,
zhongyi1715b9b2016-05-29 00:14:24245 "quic_error_map is not in sync with quic protocol!");
246
ttuttleb1607372016-02-09 16:27:16247} // namespace
248
249// static
250bool GetDomainReliabilityBeaconQuicError(net::QuicErrorCode quic_error,
251 std::string* beacon_quic_error_out) {
252 if (quic_error != net::QUIC_NO_ERROR) {
253 // Convert a QUIC error.
ttuttle960fcbf2016-04-19 13:26:32254 // TODO(juliatuttle): Consider sorting and using binary search?
ttuttleb1607372016-02-09 16:27:16255 for (size_t i = 0; i < arraysize(kQuicErrorMap); i++) {
256 if (kQuicErrorMap[i].quic_error == quic_error) {
257 *beacon_quic_error_out = kQuicErrorMap[i].beacon_quic_error;
258 return true;
259 }
260 }
261 }
262 beacon_quic_error_out->clear();
263 return false;
264}
265
266} // namespace domain_reliability