OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stddef.h> | 5 #include <stddef.h> |
6 #include <sys/epoll.h> | 6 #include <sys/epoll.h> |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 vector<TestParams> GetTestParams() { | 146 vector<TestParams> GetTestParams() { |
147 // Divide the versions into buckets in which the intra-frame format | 147 // Divide the versions into buckets in which the intra-frame format |
148 // is compatible. When clients encounter QUIC version negotiation | 148 // is compatible. When clients encounter QUIC version negotiation |
149 // they simply retransmit all packets using the new version's | 149 // they simply retransmit all packets using the new version's |
150 // QUIC framing. However, they are unable to change the intra-frame | 150 // QUIC framing. However, they are unable to change the intra-frame |
151 // layout (for example to change SPDY/4 headers to SPDY/3). So | 151 // layout (for example to change SPDY/4 headers to SPDY/3). So |
152 // these tests need to ensure that clients are never attempting | 152 // these tests need to ensure that clients are never attempting |
153 // to do 0-RTT across incompatible versions. Chromium only supports | 153 // to do 0-RTT across incompatible versions. Chromium only supports |
154 // a single version at a time anyway. :) | 154 // a single version at a time anyway. :) |
155 QuicVersionVector all_supported_versions = QuicSupportedVersions(); | 155 QuicVersionVector all_supported_versions = QuicSupportedVersions(); |
156 QuicVersionVector version_buckets[5]; | 156 QuicVersionVector version_buckets[4]; |
157 | 157 |
158 for (const QuicVersion version : all_supported_versions) { | 158 for (const QuicVersion version : all_supported_versions) { |
159 if (version <= QUIC_VERSION_25) { | 159 if (version <= QUIC_VERSION_30) { |
160 // Versions: 25 | 160 // Versions: 30 |
161 // SPDY/4 | 161 // v26 adds a hash of the expected leaf cert in the XLCT tag. |
162 version_buckets[0].push_back(version); | 162 version_buckets[0].push_back(version); |
163 } else if (version <= QUIC_VERSION_30) { | |
164 // Versions: 26-30 | |
165 // v26 adds a hash of the expected leaf cert in the XLCT tag. | |
166 version_buckets[1].push_back(version); | |
167 } else if (version <= QUIC_VERSION_32) { | 163 } else if (version <= QUIC_VERSION_32) { |
168 // Versions: 31-32 | 164 // Versions: 31-32 |
169 // v31 adds a hash of the CHLO into the proof signature. | 165 // v31 adds a hash of the CHLO into the proof signature. |
170 version_buckets[2].push_back(version); | 166 version_buckets[1].push_back(version); |
171 } else if (version <= QUIC_VERSION_33) { | 167 } else if (version <= QUIC_VERSION_33) { |
172 // Versions: 33 | 168 // Versions: 33 |
173 // v33 adds a diversification nonce into the hkdf. | 169 // v33 adds a diversification nonce into the hkdf. |
174 version_buckets[3].push_back(version); | 170 version_buckets[2].push_back(version); |
175 } else { | 171 } else { |
176 // Versions: 34+ | 172 // Versions: 34+ |
177 // QUIC_VERSION_34 deprecates entropy and uses new ack and stop waiting | 173 // QUIC_VERSION_34 deprecates entropy and uses new ack and stop waiting |
178 // wire formats. | 174 // wire formats. |
179 version_buckets[4].push_back(version); | 175 version_buckets[3].push_back(version); |
180 } | 176 } |
181 } | 177 } |
182 | 178 |
183 // This must be kept in sync with the number of nested for-loops below as it | 179 // This must be kept in sync with the number of nested for-loops below as it |
184 // is used to prune the number of tests that are run. | 180 // is used to prune the number of tests that are run. |
185 const int kMaxEnabledOptions = 5; | 181 const int kMaxEnabledOptions = 5; |
186 int max_enabled_options = 0; | 182 int max_enabled_options = 0; |
187 vector<TestParams> params; | 183 vector<TestParams> params; |
188 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) { | 184 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) { |
189 for (bool client_supports_stateless_rejects : {true, false}) { | 185 for (bool client_supports_stateless_rejects : {true, false}) { |
(...skipping 25 matching lines...) Expand all Loading... |
215 max_enabled_options = enabled_options; | 211 max_enabled_options = enabled_options; |
216 } | 212 } |
217 | 213 |
218 // Run tests with no options, a single option, or all the options | 214 // Run tests with no options, a single option, or all the options |
219 // enabled to avoid a combinatorial explosion. | 215 // enabled to avoid a combinatorial explosion. |
220 if (enabled_options > 1 && enabled_options < kMaxEnabledOptions) { | 216 if (enabled_options > 1 && enabled_options < kMaxEnabledOptions) { |
221 continue; | 217 continue; |
222 } | 218 } |
223 | 219 |
224 for (const QuicVersionVector& client_versions : version_buckets) { | 220 for (const QuicVersionVector& client_versions : version_buckets) { |
225 if (client_versions.front() < QUIC_VERSION_30 && | |
226 FLAGS_quic_disable_pre_30) { | |
227 continue; | |
228 } | |
229 CHECK(!client_versions.empty()); | 221 CHECK(!client_versions.empty()); |
230 // Add an entry for server and client supporting all versions. | 222 // Add an entry for server and client supporting all versions. |
231 params.push_back(TestParams( | 223 params.push_back(TestParams( |
232 client_versions, all_supported_versions, | 224 client_versions, all_supported_versions, |
233 client_versions.front(), client_supports_stateless_rejects, | 225 client_versions.front(), client_supports_stateless_rejects, |
234 server_uses_stateless_rejects_if_peer_supported, | 226 server_uses_stateless_rejects_if_peer_supported, |
235 congestion_control_tag, auto_tune_flow_control_window, | 227 congestion_control_tag, auto_tune_flow_control_window, |
236 disable_hpack_dynamic_table, force_hol_blocking)); | 228 disable_hpack_dynamic_table, force_hol_blocking)); |
237 | 229 |
238 // Run version negotiation tests tests with no options, or all | 230 // Run version negotiation tests tests with no options, or all |
239 // the options enabled to avoid a combinatorial explosion. | 231 // the options enabled to avoid a combinatorial explosion. |
240 if (enabled_options > 0 && | 232 if (enabled_options > 0 && |
241 enabled_options < kMaxEnabledOptions) { | 233 enabled_options < kMaxEnabledOptions) { |
242 continue; | 234 continue; |
243 } | 235 } |
244 | 236 |
245 // Test client supporting all versions and server | 237 // Test client supporting all versions and server |
246 // supporting 1 version. Simulate an old server and | 238 // supporting 1 version. Simulate an old server and |
247 // exercise version downgrade in the client. Protocol | 239 // exercise version downgrade in the client. Protocol |
248 // negotiation should occur. Skip the i = 0 case | 240 // negotiation should occur. Skip the i = 0 case |
249 // because it is essentially the same as the default | 241 // because it is essentially the same as the default |
250 // case. | 242 // case. |
251 for (size_t i = 1; i < client_versions.size(); ++i) { | 243 for (size_t i = 1; i < client_versions.size(); ++i) { |
252 if (client_versions[i] < QUIC_VERSION_30 && | |
253 FLAGS_quic_disable_pre_30) { | |
254 continue; | |
255 } | |
256 QuicVersionVector server_supported_versions; | 244 QuicVersionVector server_supported_versions; |
257 server_supported_versions.push_back(client_versions[i]); | 245 server_supported_versions.push_back(client_versions[i]); |
258 params.push_back(TestParams( | 246 params.push_back(TestParams( |
259 client_versions, server_supported_versions, | 247 client_versions, server_supported_versions, |
260 server_supported_versions.front(), | 248 server_supported_versions.front(), |
261 client_supports_stateless_rejects, | 249 client_supports_stateless_rejects, |
262 server_uses_stateless_rejects_if_peer_supported, | 250 server_uses_stateless_rejects_if_peer_supported, |
263 congestion_control_tag, auto_tune_flow_control_window, | 251 congestion_control_tag, auto_tune_flow_control_window, |
264 disable_hpack_dynamic_table, force_hol_blocking)); | 252 disable_hpack_dynamic_table, force_hol_blocking)); |
265 } | 253 } |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 request.AddHeader("content-length", "3"); | 1205 request.AddHeader("content-length", "3"); |
1218 request.set_has_complete_message(false); | 1206 request.set_has_complete_message(false); |
1219 | 1207 |
1220 // The server supports a small number of additional streams beyond the | 1208 // The server supports a small number of additional streams beyond the |
1221 // negotiated limit. Open enough streams to go beyond that limit. | 1209 // negotiated limit. Open enough streams to go beyond that limit. |
1222 for (int i = 0; i < kServerMaxStreams + 1; ++i) { | 1210 for (int i = 0; i < kServerMaxStreams + 1; ++i) { |
1223 client_->SendMessage(request); | 1211 client_->SendMessage(request); |
1224 } | 1212 } |
1225 client_->WaitForResponse(); | 1213 client_->WaitForResponse(); |
1226 | 1214 |
1227 if (negotiated_version_ <= QUIC_VERSION_27) { | 1215 EXPECT_TRUE(client_->connected()); |
1228 EXPECT_FALSE(client_->connected()); | 1216 EXPECT_EQ(QUIC_REFUSED_STREAM, client_->stream_error()); |
1229 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); | 1217 EXPECT_EQ(QUIC_NO_ERROR, client_->connection_error()); |
1230 EXPECT_EQ(QUIC_TOO_MANY_OPEN_STREAMS, client_->connection_error()); | |
1231 } else { | |
1232 EXPECT_TRUE(client_->connected()); | |
1233 EXPECT_EQ(QUIC_REFUSED_STREAM, client_->stream_error()); | |
1234 EXPECT_EQ(QUIC_NO_ERROR, client_->connection_error()); | |
1235 } | |
1236 } | 1218 } |
1237 | 1219 |
1238 TEST_P(EndToEndTest, MaxIncomingDynamicStreamsLimitRespected) { | 1220 TEST_P(EndToEndTest, MaxIncomingDynamicStreamsLimitRespected) { |
1239 // Set a limit on maximum number of incoming dynamic streams. | 1221 // Set a limit on maximum number of incoming dynamic streams. |
1240 // Make sure the limit is respected. | 1222 // Make sure the limit is respected. |
1241 const uint32_t kServerMaxIncomingDynamicStreams = 1; | 1223 const uint32_t kServerMaxIncomingDynamicStreams = 1; |
1242 server_config_.SetMaxIncomingDynamicStreamsToSend( | 1224 server_config_.SetMaxIncomingDynamicStreamsToSend( |
1243 kServerMaxIncomingDynamicStreams); | 1225 kServerMaxIncomingDynamicStreams); |
1244 ASSERT_TRUE(Initialize()); | 1226 ASSERT_TRUE(Initialize()); |
1245 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1227 client_->client()->WaitForCryptoHandshakeConfirmed(); |
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2404 set_server_initial_stream_flow_control_receive_window(kWindowSize); | 2386 set_server_initial_stream_flow_control_receive_window(kWindowSize); |
2405 set_server_initial_session_flow_control_receive_window(kWindowSize); | 2387 set_server_initial_session_flow_control_receive_window(kWindowSize); |
2406 | 2388 |
2407 ASSERT_TRUE(Initialize()); | 2389 ASSERT_TRUE(Initialize()); |
2408 | 2390 |
2409 client_->client()->WaitForCryptoHandshakeConfirmed(); | 2391 client_->client()->WaitForCryptoHandshakeConfirmed(); |
2410 | 2392 |
2411 // POST to a URL that gets an early error response, after the headers are | 2393 // POST to a URL that gets an early error response, after the headers are |
2412 // received and before the body is received. | 2394 // received and before the body is received. |
2413 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/garbage"); | 2395 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/garbage"); |
2414 const uint32_t kBodySize = 2 * kWindowSize; | |
2415 // Invalid content-length so the request will receive an early 500 response. | 2396 // Invalid content-length so the request will receive an early 500 response. |
2416 request.AddHeader("content-length", "-1"); | 2397 request.AddHeader("content-length", "-1"); |
2417 request.set_skip_message_validation(true); | 2398 request.set_skip_message_validation(true); |
2418 request.set_has_complete_message(false); | 2399 request.set_has_complete_message(false); |
2419 | 2400 |
2420 // Tell the client to not close the stream if it receives an early response. | 2401 // Tell the client to not close the stream if it receives an early response. |
2421 client_->set_allow_bidirectional_data(true); | 2402 client_->set_allow_bidirectional_data(true); |
2422 // Send the headers. | 2403 // Send the headers. |
2423 client_->SendMessage(request); | 2404 client_->SendMessage(request); |
2424 // Receive the response and let the server close writing. | 2405 // Receive the response and let the server close writing. |
2425 client_->WaitForInitialResponse(); | 2406 client_->WaitForInitialResponse(); |
2426 EXPECT_EQ(500u, client_->response_headers()->parsed_response_code()); | 2407 EXPECT_EQ(500u, client_->response_headers()->parsed_response_code()); |
2427 | 2408 |
2428 if (negotiated_version_ > QUIC_VERSION_28) { | 2409 // Receive the reset stream from server on early response. |
2429 // Receive the reset stream from server on early response. | |
2430 client_->WaitForResponseForMs(100); | |
2431 ReliableQuicStream* stream = | |
2432 client_->client()->session()->GetOrCreateStream(kClientDataStreamId1); | |
2433 // The stream is reset by server's reset stream. | |
2434 EXPECT_EQ(stream, nullptr); | |
2435 return; | |
2436 } | |
2437 | |
2438 // Send a body larger than the stream flow control window. | |
2439 string body; | |
2440 GenerateBody(&body, kBodySize); | |
2441 client_->SendData(body, true); | |
2442 | |
2443 // Run the client to let any buffered data be sent. | |
2444 // (This is OK despite already waiting for a response.) | |
2445 client_->WaitForResponse(); | |
2446 // There should be no buffered data to write in the client's stream. | |
2447 ReliableQuicStream* stream = | 2410 ReliableQuicStream* stream = |
2448 client_->client()->session()->GetOrCreateStream(kClientDataStreamId1); | 2411 client_->client()->session()->GetOrCreateStream(kClientDataStreamId1); |
2449 EXPECT_FALSE(stream != nullptr && stream->HasBufferedData()); | 2412 // The stream is reset by server's reset stream. |
| 2413 EXPECT_EQ(stream, nullptr); |
2450 } | 2414 } |
2451 | 2415 |
2452 TEST_P(EndToEndTest, Trailers) { | 2416 TEST_P(EndToEndTest, Trailers) { |
2453 // Test sending and receiving HTTP/2 Trailers (trailing HEADERS frames). | 2417 // Test sending and receiving HTTP/2 Trailers (trailing HEADERS frames). |
2454 ASSERT_TRUE(Initialize()); | 2418 ASSERT_TRUE(Initialize()); |
2455 client_->client()->WaitForCryptoHandshakeConfirmed(); | 2419 client_->client()->WaitForCryptoHandshakeConfirmed(); |
2456 | 2420 |
2457 // Set reordering to ensure that Trailers arriving before body is ok. | 2421 // Set reordering to ensure that Trailers arriving before body is ok. |
2458 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); | 2422 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); |
2459 SetReorderPercentage(30); | 2423 SetReorderPercentage(30); |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2838 client_->WaitForResponse(); | 2802 client_->WaitForResponse(); |
2839 // TODO(fayang): Fix this test to work with stateless rejects. | 2803 // TODO(fayang): Fix this test to work with stateless rejects. |
2840 if (!BothSidesSupportStatelessRejects()) { | 2804 if (!BothSidesSupportStatelessRejects()) { |
2841 VerifyCleanConnection(true); | 2805 VerifyCleanConnection(true); |
2842 } | 2806 } |
2843 } | 2807 } |
2844 | 2808 |
2845 } // namespace | 2809 } // namespace |
2846 } // namespace test | 2810 } // namespace test |
2847 } // namespace net | 2811 } // namespace net |
OLD | NEW |