Commit 3090e576 authored by jri's avatar jri Committed by Commit bot
Browse files

Disable QUIC v29 and earlier. Protected by FLAGS_quic_disable_pre_30.

Merge internal change: 125080101

R=rch@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2100863003
Cr-Commit-Position: refs/heads/master@{#402327}
parent 3e2695d9
......@@ -160,3 +160,6 @@ bool FLAGS_quic_socket_walltimestamps = false;
// server side, and the IPFS connection option disables this instead of
// enabling it.
bool FLAGS_quic_default_immediate_forward_secure = false;
// If true, disables support for QUIC version 29 and earlier.
bool FLAGS_quic_disable_pre_30 = false;
......@@ -51,5 +51,6 @@ NET_EXPORT_PRIVATE extern bool FLAGS_quic_rate_based_sending;
NET_EXPORT_PRIVATE extern bool FLAGS_quic_use_cheap_stateless_rejects;
NET_EXPORT_PRIVATE extern bool FLAGS_quic_socket_walltimestamps;
NET_EXPORT_PRIVATE extern bool FLAGS_quic_default_immediate_forward_secure;
NET_EXPORT_PRIVATE extern bool FLAGS_quic_disable_pre_30;
#endif // NET_QUIC_QUIC_FLAGS_H_
......@@ -179,6 +179,17 @@ QuicVersionVector QuicSupportedVersions() {
return supported_versions;
}
QuicVersionVector FilterSupportedVersions(QuicVersionVector versions) {
QuicVersionVector filtered_versions(versions.size());
filtered_versions.clear(); // Guaranteed by spec not to change capacity.
for (QuicVersion version : versions) {
if (!FLAGS_quic_disable_pre_30 || version >= QUIC_VERSION_30) {
filtered_versions.push_back(version);
}
}
return filtered_versions;
}
QuicTag QuicVersionToQuicTag(const QuicVersion version) {
switch (version) {
case QUIC_VERSION_25:
......
......@@ -390,6 +390,11 @@ typedef std::vector<QuicVersion> QuicVersionVector;
// Returns a vector of QUIC versions in kSupportedQuicVersions.
NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions();
// Returns a vector of QUIC versions from |versions| which exclude any versions
// which are disabled by flags.
NET_EXPORT_PRIVATE QuicVersionVector
FilterSupportedVersions(QuicVersionVector versions);
// QuicTag is written to and read from the wire, but we prefer to use
// the more readable QuicVersion at other levels.
// Helper function which translates from a QuicVersion to a QuicTag. Returns 0
......
......@@ -7,6 +7,7 @@
#include <sstream>
#include "base/stl_util.h"
#include "net/quic/quic_flags.h"
#include "net/quic/quic_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -282,6 +283,17 @@ TEST(QuicProtocolTest, PathCloseFrameToString) {
EXPECT_EQ("{ path_id: 1 }\n", stream.str());
}
TEST(QuicProtocolTest, FilterSupportedVersions) {
QuicVersionVector all_versions = {QUIC_VERSION_25, QUIC_VERSION_26,
QUIC_VERSION_27, QUIC_VERSION_29,
QUIC_VERSION_30};
FLAGS_quic_disable_pre_30 = true;
QuicVersionVector filtered_versions = FilterSupportedVersions(all_versions);
ASSERT_EQ(1u, filtered_versions.size());
EXPECT_EQ(QUIC_VERSION_30, filtered_versions[0]);
}
// Tests that a queue contains the expected data after calls to Add().
TEST(PacketNumberQueueTest, AddRange) {
PacketNumberQueue queue;
......
......@@ -209,6 +209,10 @@ vector<TestParams> GetTestParams() {
}
for (const QuicVersionVector& client_versions : version_buckets) {
if (client_versions.front() < QUIC_VERSION_30 &&
FLAGS_quic_disable_pre_30) {
continue;
}
CHECK(!client_versions.empty());
// Add an entry for server and client supporting all versions.
params.push_back(TestParams(
......@@ -229,6 +233,10 @@ vector<TestParams> GetTestParams() {
// in the client. Protocol negotiation should occur. Skip the i =
// 0 case because it is essentially the same as the default case.
for (size_t i = 1; i < client_versions.size(); ++i) {
if (client_versions[i] < QUIC_VERSION_30 &&
FLAGS_quic_disable_pre_30) {
continue;
}
QuicVersionVector server_supported_versions;
server_supported_versions.push_back(client_versions[i]);
params.push_back(TestParams(
......
......@@ -201,6 +201,8 @@ QuicDispatcher::QuicDispatcher(
delete_sessions_alarm_(
alarm_factory_->CreateAlarm(new DeleteSessionsAlarm(this))),
supported_versions_(supported_versions),
disable_quic_pre_30_(FLAGS_quic_disable_pre_30),
allowed_supported_versions_(supported_versions),
current_packet_(nullptr),
framer_(supported_versions,
/*unused*/ QuicTime::Zero(),
......@@ -283,7 +285,7 @@ bool QuicDispatcher::OnUnauthenticatedPublicHeader(
// Unless the packet provides a version, assume that we can continue
// processing using our preferred version.
QuicVersion version = supported_versions_.front();
QuicVersion version = GetSupportedVersions().front();
if (header.version_flag) {
QuicVersion packet_version = header.versions.front();
if (!framer_.IsSupportedVersion(packet_version)) {
......@@ -293,7 +295,7 @@ bool QuicDispatcher::OnUnauthenticatedPublicHeader(
// Since the version is not supported, send a version negotiation
// packet and stop processing the current packet.
time_wait_list_manager()->SendVersionNegotiationPacket(
connection_id, supported_versions_, current_server_address_,
connection_id, GetSupportedVersions(), current_server_address_,
current_client_address_);
return false;
}
......@@ -599,7 +601,7 @@ QuicServerSessionBase* QuicDispatcher::CreateQuicSession(
QuicConnection* connection = new QuicConnection(
connection_id, client_address, helper_.get(), alarm_factory_.get(),
CreatePerConnectionWriter(),
/* owns_writer= */ true, Perspective::IS_SERVER, supported_versions_);
/* owns_writer= */ true, Perspective::IS_SERVER, GetSupportedVersions());
QuicServerSessionBase* session = new QuicSimpleServerSession(
config_, connection, this, session_helper_.get(), crypto_config_,
......@@ -720,4 +722,15 @@ QuicDispatcher::QuicPacketFate QuicDispatcher::MaybeRejectStatelessly(
return kFateDrop;
}
const QuicVersionVector& QuicDispatcher::GetSupportedVersions() {
// Filter (or un-filter) the list of supported versions based on the flag.
if (disable_quic_pre_30_ != FLAGS_quic_disable_pre_30) {
DCHECK_EQ(supported_versions_.capacity(),
allowed_supported_versions_.capacity());
disable_quic_pre_30_ = FLAGS_quic_disable_pre_30;
supported_versions_ = FilterSupportedVersions(allowed_supported_versions_);
}
return supported_versions_;
}
} // namespace net
......@@ -180,9 +180,7 @@ class QuicDispatcher : public QuicServerSessionBase::Visitor,
return time_wait_list_manager_.get();
}
const QuicVersionVector& supported_versions() const {
return supported_versions_;
}
const QuicVersionVector& GetSupportedVersions();
const IPEndPoint& current_server_address() { return current_server_address_; }
const IPEndPoint& current_client_address() { return current_client_address_; }
......@@ -222,8 +220,7 @@ class QuicDispatcher : public QuicServerSessionBase::Visitor,
void SetLastError(QuicErrorCode error);
// Called when the public header has been parsed and the session has been
// looked up, and the session was not found in the active std::list of
// sessions.
// looked up, and the session was not found in the active list of sessions.
// Returns false if processing should stop after this call.
virtual bool OnUnauthenticatedUnknownPublicHeader(
const QuicPacketPublicHeader& header);
......@@ -282,7 +279,13 @@ class QuicDispatcher : public QuicServerSessionBase::Visitor,
// This should be ordered such that the highest supported version is the first
// element, with subsequent elements in descending order (versions can be
// skipped as necessary).
const QuicVersionVector supported_versions_;
QuicVersionVector supported_versions_;
// FLAGS_quic_disable_pre_30
bool disable_quic_pre_30_;
// The list of versions that may be supported by this dispatcher.
// |supported_versions| is derived from this list and |disable_quic_pre_30_|.
const QuicVersionVector allowed_supported_versions_;
// Information about the packet currently being handled.
IPEndPoint current_client_address_;
......
......@@ -103,7 +103,8 @@ class QuicTestDispatcher : public QuicDispatcher {
}
QuicConnection* connection = new QuicConnection(
id, client, helper(), alarm_factory(), CreatePerConnectionWriter(),
/* owns_writer= */ true, Perspective::IS_SERVER, supported_versions());
/* owns_writer= */ true, Perspective::IS_SERVER,
GetSupportedVersions());
QuicServerSessionBase* session = nullptr;
if (stream_factory_ != nullptr || crypto_stream_factory_ != nullptr) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment