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

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

Issue 2487613002: Landing Recent QUIC changes until 12:43 PM, Nov 5, 2016 UTC+8 (Closed)
Patch Set: Created 4 years, 1 month 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_packet_writer_wrapper.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 <memory> 7 #include <memory>
8 #include <ostream> 8 #include <ostream>
9 #include <string> 9 #include <string>
10 10
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 .Times(1) 698 .Times(1)
699 .WillOnce(testing::WithArgs<2>( 699 .WillOnce(testing::WithArgs<2>(
700 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket, 700 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket,
701 base::Unretained(this), connection_id)))); 701 base::Unretained(this), connection_id))));
702 } 702 }
703 ProcessPacket(client_address, connection_id, true, false, "data"); 703 ProcessPacket(client_address, connection_id, true, false, "data");
704 } 704 }
705 705
706 TEST_P(QuicDispatcherStatelessRejectTest, CheapRejects) { 706 TEST_P(QuicDispatcherStatelessRejectTest, CheapRejects) {
707 FLAGS_quic_use_cheap_stateless_rejects = true; 707 FLAGS_quic_use_cheap_stateless_rejects = true;
708 FLAGS_quic_buffer_packet_till_chlo = true;
709 CreateTimeWaitListManager(); 708 CreateTimeWaitListManager();
710 709
711 IPEndPoint client_address(net::test::Loopback4(), 1); 710 IPEndPoint client_address(net::test::Loopback4(), 1);
712 QuicConnectionId connection_id = 1; 711 QuicConnectionId connection_id = 1;
713 if (GetParam().enable_stateless_rejects_via_flag) { 712 if (GetParam().enable_stateless_rejects_via_flag) {
714 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) 713 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address))
715 .Times(0); 714 .Times(0);
716 } else { 715 } else {
717 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) 716 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address))
718 .WillOnce(testing::Return( 717 .WillOnce(testing::Return(
(...skipping 28 matching lines...) Expand all
747 } 746 }
748 } 747 }
749 748
750 TEST_P(QuicDispatcherStatelessRejectTest, BufferNonChlo) { 749 TEST_P(QuicDispatcherStatelessRejectTest, BufferNonChlo) {
751 FLAGS_quic_use_cheap_stateless_rejects = true; 750 FLAGS_quic_use_cheap_stateless_rejects = true;
752 CreateTimeWaitListManager(); 751 CreateTimeWaitListManager();
753 752
754 const IPEndPoint client_address(net::test::Loopback4(), 1); 753 const IPEndPoint client_address(net::test::Loopback4(), 1);
755 const QuicConnectionId connection_id = 1; 754 const QuicConnectionId connection_id = 1;
756 755
757 if (!GetParam().enable_stateless_rejects_via_flag &&
758 !FLAGS_quic_buffer_packet_till_chlo) {
759 // If stateless rejects are not being used and early arrived packets are not
760 // buffered, then a connection will be created immediately.
761 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address))
762 .WillOnce(testing::Return(
763 CreateSessionBasedOnTestParams(connection_id, client_address)));
764 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()),
765 ProcessUdpPacket(_, client_address, _))
766 .WillOnce(testing::WithArg<2>(
767 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket,
768 base::Unretained(this), connection_id))));
769 }
770 bool first_packet_dropped = GetParam().enable_stateless_rejects_via_flag &&
771 !FLAGS_quic_buffer_packet_till_chlo;
772 if (first_packet_dropped) {
773 // Never do stateless reject while
774 // FLAGS_quic_buffer_packet_till_chlo is off.
775 EXPECT_QUIC_BUG(
776 ProcessPacket(client_address, connection_id, true, false,
777 "NOT DATA FOR A CHLO"),
778 "Have to drop packet because buffering non-chlo packet is "
779 "not supported while trying to do stateless reject. "
780 "--gfe2_reloadable_flag_quic_buffer_packet_till_chlo false "
781 "--gfe2_reloadable_flag_quic_use_cheap_stateless_rejects true");
782 } else {
783 ProcessPacket(client_address, connection_id, true, false, 756 ProcessPacket(client_address, connection_id, true, false,
784 "NOT DATA FOR A CHLO"); 757 "NOT DATA FOR A CHLO");
785 }
786 758
787 // Process the first packet for the connection. 759 // Process the first packet for the connection.
788 // clang-format off 760 // clang-format off
789 CryptoHandshakeMessage client_hello = CryptoTestUtils::Message( 761 CryptoHandshakeMessage client_hello = CryptoTestUtils::Message(
790 "CHLO", 762 "CHLO",
791 "AEAD", "AESG", 763 "AEAD", "AESG",
792 "KEXS", "C255", 764 "KEXS", "C255",
793 "NONC", "1234567890123456789012", 765 "NONC", "1234567890123456789012",
794 "VER\0", "Q025", 766 "VER\0", "Q025",
795 "$padding", static_cast<int>(kClientHelloMinimumSize), 767 "$padding", static_cast<int>(kClientHelloMinimumSize),
796 nullptr); 768 nullptr);
797 // clang-format on 769 // clang-format on
798 770
799 if (GetParam().enable_stateless_rejects_via_flag ||
800 FLAGS_quic_buffer_packet_till_chlo) {
801 // If stateless rejects are enabled then a connection will be created now 771 // If stateless rejects are enabled then a connection will be created now
802 // and the buffered packet will be processed 772 // and the buffered packet will be processed
803 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) 773 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address))
804 .WillOnce(testing::Return( 774 .WillOnce(testing::Return(
805 CreateSessionBasedOnTestParams(connection_id, client_address))); 775 CreateSessionBasedOnTestParams(connection_id, client_address)));
806 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), 776 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()),
807 ProcessUdpPacket(_, client_address, _)) 777 ProcessUdpPacket(_, client_address, _))
808 .WillOnce(testing::WithArg<2>( 778 .WillOnce(testing::WithArg<2>(
809 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket, 779 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket,
810 base::Unretained(this), connection_id)))); 780 base::Unretained(this), connection_id))));
811 }
812 if (!first_packet_dropped) {
813 // Expect both packets to be passed to ProcessUdpPacket(). And one of them 781 // Expect both packets to be passed to ProcessUdpPacket(). And one of them
814 // is already expected in CreateSessionBasedOnTestParams(). 782 // is already expected in CreateSessionBasedOnTestParams().
815 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), 783 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()),
816 ProcessUdpPacket(_, client_address, _)) 784 ProcessUdpPacket(_, client_address, _))
817 .WillOnce(testing::WithArg<2>( 785 .WillOnce(testing::WithArg<2>(
818 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket, 786 Invoke(CreateFunctor(&QuicDispatcherTest::ValidatePacket,
819 base::Unretained(this), connection_id)))) 787 base::Unretained(this), connection_id))))
820 .RetiresOnSaturation(); 788 .RetiresOnSaturation();
821 } else { 789 ProcessPacket(client_address, connection_id, true, false,
822 // Since first packet is dropped, remove it from map to skip 790 client_hello.GetSerialized().AsStringPiece().as_string());
823 // ValidatePacket() on it. 791 EXPECT_FALSE(
824 data_connection_map_[connection_id].pop_front(); 792 time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id));
825 }
826 ProcessPacket(client_address, connection_id, true, false,
827 client_hello.GetSerialized().AsStringPiece().as_string());
828 EXPECT_FALSE(
829 time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id));
830 } 793 }
831 794
832 // Verify the stopgap test: Packets with truncated connection IDs should be 795 // Verify the stopgap test: Packets with truncated connection IDs should be
833 // dropped. 796 // dropped.
834 class QuicDispatcherTestStrayPacketConnectionId : public QuicDispatcherTest {}; 797 class QuicDispatcherTestStrayPacketConnectionId : public QuicDispatcherTest {};
835 798
836 // Packets with truncated connection IDs should be dropped. 799 // Packets with truncated connection IDs should be dropped.
837 TEST_F(QuicDispatcherTestStrayPacketConnectionId, 800 TEST_F(QuicDispatcherTestStrayPacketConnectionId,
838 StrayPacketTruncatedConnectionId) { 801 StrayPacketTruncatedConnectionId) {
839 CreateTimeWaitListManager(); 802 CreateTimeWaitListManager();
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 1058
1096 // A dispatcher whose stateless rejector will always ACCEPTs CHLO. 1059 // A dispatcher whose stateless rejector will always ACCEPTs CHLO.
1097 class BufferedPacketStoreTest 1060 class BufferedPacketStoreTest
1098 : public QuicDispatcherTest, 1061 : public QuicDispatcherTest,
1099 public ::testing::WithParamInterface<BufferedPacketStoreTestParams> { 1062 public ::testing::WithParamInterface<BufferedPacketStoreTestParams> {
1100 public: 1063 public:
1101 BufferedPacketStoreTest() 1064 BufferedPacketStoreTest()
1102 : QuicDispatcherTest(), 1065 : QuicDispatcherTest(),
1103 client_addr_(Loopback4(), 1234), 1066 client_addr_(Loopback4(), 1234),
1104 proof_(new QuicCryptoProof) { 1067 proof_(new QuicCryptoProof) {
1105 FLAGS_quic_buffer_packet_till_chlo = true;
1106 FLAGS_quic_use_cheap_stateless_rejects = 1068 FLAGS_quic_use_cheap_stateless_rejects =
1107 GetParam().support_cheap_stateless_reject; 1069 GetParam().support_cheap_stateless_reject;
1108 FLAGS_enable_quic_stateless_reject_support = 1070 FLAGS_enable_quic_stateless_reject_support =
1109 GetParam().enable_stateless_rejects_via_flag; 1071 GetParam().enable_stateless_rejects_via_flag;
1110 } 1072 }
1111 1073
1112 void SetUp() override { 1074 void SetUp() override {
1113 QuicDispatcherTest::SetUp(); 1075 QuicDispatcherTest::SetUp();
1114 clock_ = QuicDispatcherPeer::GetHelper(dispatcher_.get())->GetClock(); 1076 clock_ = QuicDispatcherPeer::GetHelper(dispatcher_.get())->GetClock();
1115 1077
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 // of stateless rejection. 1507 // of stateless rejection.
1546 class AsyncGetProofTest : public QuicDispatcherTest { 1508 class AsyncGetProofTest : public QuicDispatcherTest {
1547 public: 1509 public:
1548 AsyncGetProofTest() 1510 AsyncGetProofTest()
1549 : QuicDispatcherTest( 1511 : QuicDispatcherTest(
1550 std::unique_ptr<FakeProofSource>(new FakeProofSource())), 1512 std::unique_ptr<FakeProofSource>(new FakeProofSource())),
1551 client_addr_(net::test::Loopback4(), 1234), 1513 client_addr_(net::test::Loopback4(), 1234),
1552 crypto_config_peer_(&crypto_config_), 1514 crypto_config_peer_(&crypto_config_),
1553 proof_(new QuicCryptoProof) { 1515 proof_(new QuicCryptoProof) {
1554 FLAGS_enable_async_get_proof = true; 1516 FLAGS_enable_async_get_proof = true;
1555 FLAGS_quic_buffer_packet_till_chlo = true;
1556 FLAGS_enable_quic_stateless_reject_support = true; 1517 FLAGS_enable_quic_stateless_reject_support = true;
1557 FLAGS_quic_use_cheap_stateless_rejects = true; 1518 FLAGS_quic_use_cheap_stateless_rejects = true;
1558 FLAGS_quic_create_session_after_insertion = true; 1519 FLAGS_quic_create_session_after_insertion = true;
1559 } 1520 }
1560 1521
1561 void SetUp() override { 1522 void SetUp() override {
1562 QuicDispatcherTest::SetUp(); 1523 QuicDispatcherTest::SetUp();
1563 1524
1564 clock_ = QuicDispatcherPeer::GetHelper(dispatcher_.get())->GetClock(); 1525 clock_ = QuicDispatcherPeer::GetHelper(dispatcher_.get())->GetClock();
1565 QuicVersion version = AllSupportedVersions().front(); 1526 QuicVersion version = AllSupportedVersions().front();
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
2023 check.Call(2); 1984 check.Call(2);
2024 GetFakeProofSource()->InvokePendingCallback(0); 1985 GetFakeProofSource()->InvokePendingCallback(0);
2025 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 0); 1986 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 0);
2026 EXPECT_FALSE(store->HasBufferedPackets(conn_id)); 1987 EXPECT_FALSE(store->HasBufferedPackets(conn_id));
2027 EXPECT_FALSE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id)); 1988 EXPECT_FALSE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id));
2028 } 1989 }
2029 1990
2030 } // namespace 1991 } // namespace
2031 } // namespace test 1992 } // namespace test
2032 } // namespace net 1993 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_dispatcher.cc ('k') | net/tools/quic/quic_packet_writer_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698