Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: net/tools/quic/quic_dispatcher_test.cc

Issue 1135113003: Added support for stateless time-wait entries. Will be used in a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Remove_flag_quic_use_optimized_packet_reader_93331362
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/tools/quic/quic_dispatcher.cc ('k') | net/tools/quic/quic_time_wait_list_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "net/tools/quic/quic_dispatcher.h" 5 #include "net/tools/quic/quic_dispatcher.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_piece.h" 9 #include "base/strings/string_piece.h"
10 #include "net/quic/crypto/crypto_handshake.h" 10 #include "net/quic/crypto/crypto_handshake.h"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 .WillOnce(Invoke( 262 .WillOnce(Invoke(
263 reinterpret_cast<MockConnection*>(session1_->connection()), 263 reinterpret_cast<MockConnection*>(session1_->connection()),
264 &MockConnection::ReallyProcessUdpPacket)); 264 &MockConnection::ReallyProcessUdpPacket));
265 dispatcher_.ProcessPacket(IPEndPoint(), client_address, *encrypted); 265 dispatcher_.ProcessPacket(IPEndPoint(), client_address, *encrypted);
266 EXPECT_TRUE(time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)); 266 EXPECT_TRUE(time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id));
267 267
268 // Dispatcher forwards subsequent packets for this connection_id to the time 268 // Dispatcher forwards subsequent packets for this connection_id to the time
269 // wait list manager. 269 // wait list manager.
270 EXPECT_CALL(*time_wait_list_manager_, 270 EXPECT_CALL(*time_wait_list_manager_,
271 ProcessPacket(_, _, connection_id, _, _)).Times(1); 271 ProcessPacket(_, _, connection_id, _, _)).Times(1);
272 EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _)) 272 EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _, _))
273 .Times(0); 273 .Times(0);
274 ProcessPacket(client_address, connection_id, true, "foo"); 274 ProcessPacket(client_address, connection_id, true, "foo");
275 } 275 }
276 276
277 TEST_F(QuicDispatcherTest, NoVersionPacketToTimeWaitListManager) { 277 TEST_F(QuicDispatcherTest, NoVersionPacketToTimeWaitListManager) {
278 CreateTimeWaitListManager(); 278 CreateTimeWaitListManager();
279 279
280 IPEndPoint client_address(net::test::Loopback4(), 1); 280 IPEndPoint client_address(net::test::Loopback4(), 1);
281 QuicConnectionId connection_id = 1; 281 QuicConnectionId connection_id = 1;
282 // Dispatcher forwards all packets for this connection_id to the time wait 282 // Dispatcher forwards all packets for this connection_id to the time wait
283 // list manager. 283 // list manager.
284 EXPECT_CALL(dispatcher_, CreateQuicSession(_, _, _)).Times(0); 284 EXPECT_CALL(dispatcher_, CreateQuicSession(_, _, _)).Times(0);
285 EXPECT_CALL(*time_wait_list_manager_, 285 EXPECT_CALL(*time_wait_list_manager_,
286 ProcessPacket(_, _, connection_id, _, _)).Times(1); 286 ProcessPacket(_, _, connection_id, _, _)).Times(1);
287 EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _)) 287 EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _, _))
288 .Times(1); 288 .Times(1);
289 ProcessPacket(client_address, connection_id, false, "data"); 289 ProcessPacket(client_address, connection_id, false, "data");
290 } 290 }
291 291
292 TEST_F(QuicDispatcherTest, ProcessPacketWithZeroPort) { 292 TEST_F(QuicDispatcherTest, ProcessPacketWithZeroPort) {
293 CreateTimeWaitListManager(); 293 CreateTimeWaitListManager();
294 294
295 IPEndPoint client_address(net::test::Loopback4(), 0); 295 IPEndPoint client_address(net::test::Loopback4(), 0);
296 server_address_ = IPEndPoint(net::test::Any4(), 5); 296 server_address_ = IPEndPoint(net::test::Any4(), 5);
297 297
298 // dispatcher_ should drop this packet. 298 // dispatcher_ should drop this packet.
299 EXPECT_CALL(dispatcher_, CreateQuicSession(1, _, client_address)).Times(0); 299 EXPECT_CALL(dispatcher_, CreateQuicSession(1, _, client_address)).Times(0);
300 EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _)).Times(0); 300 EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _)).Times(0);
301 EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _)) 301 EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _, _))
302 .Times(0); 302 .Times(0);
303 ProcessPacket(client_address, 1, true, "foo"); 303 ProcessPacket(client_address, 1, true, "foo");
304 } 304 }
305 305
306 TEST_F(QuicDispatcherTest, OKSeqNoPacketProcessed) { 306 TEST_F(QuicDispatcherTest, OKSeqNoPacketProcessed) {
307 IPEndPoint client_address(net::test::Loopback4(), 1); 307 IPEndPoint client_address(net::test::Loopback4(), 1);
308 QuicConnectionId connection_id = 1; 308 QuicConnectionId connection_id = 1;
309 server_address_ = IPEndPoint(net::test::Any4(), 5); 309 server_address_ = IPEndPoint(net::test::Any4(), 5);
310 310
311 EXPECT_CALL(dispatcher_, CreateQuicSession(1, _, client_address)) 311 EXPECT_CALL(dispatcher_, CreateQuicSession(1, _, client_address))
(...skipping 11 matching lines...) Expand all
323 TEST_F(QuicDispatcherTest, TooBigSeqNoPacketToTimeWaitListManager) { 323 TEST_F(QuicDispatcherTest, TooBigSeqNoPacketToTimeWaitListManager) {
324 CreateTimeWaitListManager(); 324 CreateTimeWaitListManager();
325 325
326 IPEndPoint client_address(net::test::Loopback4(), 1); 326 IPEndPoint client_address(net::test::Loopback4(), 1);
327 QuicConnectionId connection_id = 1; 327 QuicConnectionId connection_id = 1;
328 // Dispatcher forwards this packet for this connection_id to the time wait 328 // Dispatcher forwards this packet for this connection_id to the time wait
329 // list manager. 329 // list manager.
330 EXPECT_CALL(dispatcher_, CreateQuicSession(_, _, _)).Times(0); 330 EXPECT_CALL(dispatcher_, CreateQuicSession(_, _, _)).Times(0);
331 EXPECT_CALL(*time_wait_list_manager_, 331 EXPECT_CALL(*time_wait_list_manager_,
332 ProcessPacket(_, _, connection_id, _, _)).Times(1); 332 ProcessPacket(_, _, connection_id, _, _)).Times(1);
333 EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _)) 333 EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _, _))
334 .Times(1); 334 .Times(1);
335 // A packet whose sequence number is one to large to be allowed to start a 335 // A packet whose sequence number is one to large to be allowed to start a
336 // connection. 336 // connection.
337 ProcessPacket(client_address, connection_id, true, "data", 337 ProcessPacket(client_address, connection_id, true, "data",
338 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_SEQUENCE_NUMBER, 338 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_SEQUENCE_NUMBER,
339 QuicDispatcher::kMaxReasonableInitialSequenceNumber + 1); 339 QuicDispatcher::kMaxReasonableInitialSequenceNumber + 1);
340 } 340 }
341 341
342 // Verify the stopgap test: Packets with truncated connection IDs should be 342 // Verify the stopgap test: Packets with truncated connection IDs should be
343 // dropped. 343 // dropped.
344 class QuicDispatcherTestStrayPacketConnectionId 344 class QuicDispatcherTestStrayPacketConnectionId
345 : public QuicDispatcherTest, 345 : public QuicDispatcherTest,
346 public ::testing::WithParamInterface<QuicConnectionIdLength> {}; 346 public ::testing::WithParamInterface<QuicConnectionIdLength> {};
347 347
348 // Packets with truncated connection IDs should be dropped. 348 // Packets with truncated connection IDs should be dropped.
349 TEST_P(QuicDispatcherTestStrayPacketConnectionId, 349 TEST_P(QuicDispatcherTestStrayPacketConnectionId,
350 StrayPacketTruncatedConnectionId) { 350 StrayPacketTruncatedConnectionId) {
351 const QuicConnectionIdLength connection_id_length = GetParam(); 351 const QuicConnectionIdLength connection_id_length = GetParam();
352 352
353 CreateTimeWaitListManager(); 353 CreateTimeWaitListManager();
354 354
355 IPEndPoint client_address(net::test::Loopback4(), 1); 355 IPEndPoint client_address(net::test::Loopback4(), 1);
356 QuicConnectionId connection_id = 1; 356 QuicConnectionId connection_id = 1;
357 // Dispatcher drops this packet. 357 // Dispatcher drops this packet.
358 EXPECT_CALL(dispatcher_, CreateQuicSession(_, _, _)).Times(0); 358 EXPECT_CALL(dispatcher_, CreateQuicSession(_, _, _)).Times(0);
359 EXPECT_CALL(*time_wait_list_manager_, 359 EXPECT_CALL(*time_wait_list_manager_,
360 ProcessPacket(_, _, connection_id, _, _)).Times(0); 360 ProcessPacket(_, _, connection_id, _, _)).Times(0);
361 EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _)) 361 EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _, _, _))
362 .Times(0); 362 .Times(0);
363 ProcessPacket(client_address, connection_id, true, "data", 363 ProcessPacket(client_address, connection_id, true, "data",
364 connection_id_length, PACKET_6BYTE_SEQUENCE_NUMBER); 364 connection_id_length, PACKET_6BYTE_SEQUENCE_NUMBER);
365 } 365 }
366 366
367 INSTANTIATE_TEST_CASE_P(ConnectionIdLength, 367 INSTANTIATE_TEST_CASE_P(ConnectionIdLength,
368 QuicDispatcherTestStrayPacketConnectionId, 368 QuicDispatcherTestStrayPacketConnectionId,
369 ::testing::Values(PACKET_0BYTE_CONNECTION_ID, 369 ::testing::Values(PACKET_0BYTE_CONNECTION_ID,
370 PACKET_1BYTE_CONNECTION_ID, 370 PACKET_1BYTE_CONNECTION_ID,
371 PACKET_4BYTE_CONNECTION_ID)); 371 PACKET_4BYTE_CONNECTION_ID));
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 // And we'll resume where we left off when we get another call. 561 // And we'll resume where we left off when we get another call.
562 EXPECT_CALL(*connection2(), OnCanWrite()); 562 EXPECT_CALL(*connection2(), OnCanWrite());
563 dispatcher_.OnCanWrite(); 563 dispatcher_.OnCanWrite();
564 EXPECT_FALSE(dispatcher_.HasPendingWrites()); 564 EXPECT_FALSE(dispatcher_.HasPendingWrites());
565 } 565 }
566 566
567 } // namespace 567 } // namespace
568 } // namespace test 568 } // namespace test
569 } // namespace tools 569 } // namespace tools
570 } // namespace net 570 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_dispatcher.cc ('k') | net/tools/quic/quic_time_wait_list_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698