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

Unified Diff: net/tools/quic/quic_dispatcher_test.cc

Issue 1761253002: Make QUIC version negotiation stateless. The QUIC dispatcher now detects version mismatch before cr… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@115591435
Patch Set: Update dependency Created 4 years, 10 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/quic_dispatcher_test.cc
diff --git a/net/tools/quic/quic_dispatcher_test.cc b/net/tools/quic/quic_dispatcher_test.cc
index 30642618bc6d656ef445fb53847aaf69633d5c02..169dc6304afc3e51123afadd1596ed3ee8e96553 100644
--- a/net/tools/quic/quic_dispatcher_test.cc
+++ b/net/tools/quic/quic_dispatcher_test.cc
@@ -164,6 +164,9 @@ class QuicDispatcherTest : public ::testing::Test {
return reinterpret_cast<MockConnection*>(session2_->connection());
}
+ // Process a packet with an 8 byte connection id,
+ // 6 byte packet number, default path id, and packet number 1,
+ // using the first supported version.
void ProcessPacket(IPEndPoint client_address,
QuicConnectionId connection_id,
bool has_version_flag,
@@ -174,6 +177,8 @@ class QuicDispatcherTest : public ::testing::Test {
PACKET_6BYTE_PACKET_NUMBER);
}
+ // Process a packet with a default path id, and packet number 1,
+ // using the first supported version.
void ProcessPacket(IPEndPoint client_address,
QuicConnectionId connection_id,
bool has_version_flag,
@@ -186,6 +191,7 @@ class QuicDispatcherTest : public ::testing::Test {
packet_number_length, kDefaultPathId, 1);
}
+ // Process a packet using the first supported version.
void ProcessPacket(IPEndPoint client_address,
QuicConnectionId connection_id,
bool has_version_flag,
@@ -195,9 +201,25 @@ class QuicDispatcherTest : public ::testing::Test {
QuicPacketNumberLength packet_number_length,
QuicPathId path_id,
QuicPacketNumber packet_number) {
+ ProcessPacket(client_address, connection_id, has_version_flag,
+ QuicSupportedVersions().front(), data, connection_id_length,
+ packet_number_length, packet_number);
+ }
+
+ // Processes a packet.
+ void ProcessPacket(IPEndPoint client_address,
+ QuicConnectionId connection_id,
+ bool has_version_flag,
+ QuicVersion version,
+ const string& data,
+ QuicConnectionIdLength connection_id_length,
+ QuicPacketNumberLength packet_number_length,
+ QuicPacketNumber packet_number) {
+ QuicVersionVector versions(SupportedVersions(version));
scoped_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket(
- connection_id, has_version_flag, has_multipath_flag, false, path_id,
- packet_number, data, connection_id_length, packet_number_length));
+ connection_id, has_version_flag, false, false, 0, packet_number, data,
+ connection_id_length, packet_number_length, &versions));
+
data_ = string(packet->data(), packet->length());
dispatcher_.ProcessPacket(server_address_, client_address, *packet);
}
@@ -254,6 +276,31 @@ TEST_F(QuicDispatcherTest, ProcessPackets) {
ProcessPacket(client_address, 1, false, false, "eep");
}
+TEST_F(QuicDispatcherTest, StatelessVersionNegotiation) {
+ ValueRestore<bool> old_flag(&FLAGS_quic_stateless_version_negotiation, true);
+ IPEndPoint client_address(net::test::Loopback4(), 1);
+ server_address_ = IPEndPoint(net::test::Any4(), 5);
+
+ EXPECT_CALL(dispatcher_, CreateQuicSession(1, client_address)).Times(0);
+ QuicVersion version = static_cast<QuicVersion>(QuicVersionMin() - 1);
+ ProcessPacket(client_address, 1, true, version, "foo",
+ PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER, 1);
+}
+
+TEST_F(QuicDispatcherTest, StatefulVersionNegotiation) {
+ ValueRestore<bool> old_flag(&FLAGS_quic_stateless_version_negotiation, false);
+ IPEndPoint client_address(net::test::Loopback4(), 1);
+ server_address_ = IPEndPoint(net::test::Any4(), 5);
+
+ EXPECT_CALL(dispatcher_, CreateQuicSession(1, client_address))
+ .WillOnce(testing::Return(CreateSession(&dispatcher_, config_, 1,
+ client_address, &mock_helper_,
+ &crypto_config_, &session1_)));
+ QuicVersion version = static_cast<QuicVersion>(QuicVersionMin() - 1);
+ ProcessPacket(client_address, 1, true, version, "foo",
+ PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER, 1);
+}
+
TEST_F(QuicDispatcherTest, Shutdown) {
IPEndPoint client_address(net::test::Loopback4(), 1);
« 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