Add feature flag to disable Legacy Version Encapsulation in QUIC.
This is a the first step in deprecating LVE.
Protected by FLAGS_quic_restart_flag_quic_disable_legacy_version_encapsulation.
PiperOrigin-RevId: 454650691
diff --git a/quiche/quic/core/http/end_to_end_test.cc b/quiche/quic/core/http/end_to_end_test.cc
index d602f38..b304c3d 100644
--- a/quiche/quic/core/http/end_to_end_test.cc
+++ b/quiche/quic/core/http/end_to_end_test.cc
@@ -5950,6 +5950,10 @@
}
TEST_P(EndToEndTest, LegacyVersionEncapsulation) {
+ if (GetQuicRestartFlag(quic_disable_legacy_version_encapsulation)) {
+ ASSERT_TRUE(Initialize());
+ return;
+ }
if (!version_.HasLongHeaderLengths() ||
override_server_connection_id_length_ > -1) {
// Decapsulating Legacy Version Encapsulation packets from these versions
@@ -5968,6 +5972,10 @@
}
TEST_P(EndToEndTest, LegacyVersionEncapsulationWithMultiPacketChlo) {
+ if (GetQuicRestartFlag(quic_disable_legacy_version_encapsulation)) {
+ ASSERT_TRUE(Initialize());
+ return;
+ }
if (!version_.HasLongHeaderLengths() ||
override_server_connection_id_length_ > -1) {
// Decapsulating Legacy Version Encapsulation packets from these versions
@@ -5996,6 +6004,10 @@
}
TEST_P(EndToEndTest, LegacyVersionEncapsulationWithVersionNegotiation) {
+ if (GetQuicRestartFlag(quic_disable_legacy_version_encapsulation)) {
+ ASSERT_TRUE(Initialize());
+ return;
+ }
if (!version_.HasLongHeaderLengths() ||
override_server_connection_id_length_ > -1) {
// Decapsulating Legacy Version Encapsulation packets from these versions
@@ -6016,6 +6028,10 @@
}
TEST_P(EndToEndTest, LegacyVersionEncapsulationWithLoss) {
+ if (GetQuicRestartFlag(quic_disable_legacy_version_encapsulation)) {
+ ASSERT_TRUE(Initialize());
+ return;
+ }
if (!version_.HasLongHeaderLengths() ||
override_server_connection_id_length_ > -1) {
// Decapsulating Legacy Version Encapsulation packets from these versions
diff --git a/quiche/quic/core/http/quic_spdy_client_session.cc b/quiche/quic/core/http/quic_spdy_client_session.cc
index 171e0c4..707281a 100644
--- a/quiche/quic/core/http/quic_spdy_client_session.cc
+++ b/quiche/quic/core/http/quic_spdy_client_session.cc
@@ -38,7 +38,11 @@
crypto_stream_ = CreateQuicCryptoStream();
if (config()->HasClientRequestedIndependentOption(kQLVE,
Perspective::IS_CLIENT)) {
- connection()->EnableLegacyVersionEncapsulation(server_id_.host());
+ if (GetQuicRestartFlag(quic_disable_legacy_version_encapsulation)) {
+ QUIC_CODE_COUNT(quic_disable_legacy_version_encapsulation_client_init);
+ } else {
+ connection()->EnableLegacyVersionEncapsulation(server_id_.host());
+ }
}
QuicSpdyClientSessionBase::Initialize();
}
diff --git a/quiche/quic/core/quic_dispatcher.cc b/quiche/quic/core/quic_dispatcher.cc
index 9166a93..3d97b1e 100644
--- a/quiche/quic/core/quic_dispatcher.cc
+++ b/quiche/quic/core/quic_dispatcher.cc
@@ -255,6 +255,7 @@
QuicDispatcher* dispatcher,
std::string legacy_version_encapsulation_inner_packet,
const ReceivedPacketInfo& packet_info) {
+ QUICHE_DCHECK(!GetQuicRestartFlag(quic_disable_legacy_version_encapsulation));
if (legacy_version_encapsulation_inner_packet.empty()) {
// This CHLO did not contain the Legacy Version Encapsulation tag.
return false;
@@ -587,16 +588,21 @@
packet_info.version == LegacyVersionForEncapsulation()) {
// This packet is using the Legacy Version Encapsulation version but the
// corresponding session isn't, attempt extraction of inner packet.
- ChloAlpnSniExtractor alpn_extractor;
- if (ChloExtractor::Extract(packet_info.packet, packet_info.version,
- config_->create_session_tag_indicators(),
- &alpn_extractor,
- server_connection_id.length())) {
- if (MaybeHandleLegacyVersionEncapsulation(
- this,
- alpn_extractor.ConsumeLegacyVersionEncapsulationInnerPacket(),
- packet_info)) {
- return true;
+ if (GetQuicRestartFlag(quic_disable_legacy_version_encapsulation)) {
+ QUIC_CODE_COUNT(
+ quic_disable_legacy_version_encapsulation_dispatch_packet);
+ } else {
+ ChloAlpnSniExtractor alpn_extractor;
+ if (ChloExtractor::Extract(packet_info.packet, packet_info.version,
+ config_->create_session_tag_indicators(),
+ &alpn_extractor,
+ server_connection_id.length())) {
+ if (MaybeHandleLegacyVersionEncapsulation(
+ this,
+ alpn_extractor.ConsumeLegacyVersionEncapsulationInnerPacket(),
+ packet_info)) {
+ return true;
+ }
}
}
}
@@ -725,10 +731,17 @@
QUICHE_DCHECK(
parsed_chlo->legacy_version_encapsulation_inner_packet.empty() ||
!packet_info->version.UsesTls());
- if (MaybeHandleLegacyVersionEncapsulation(
- this, parsed_chlo->legacy_version_encapsulation_inner_packet,
- *packet_info)) {
- return;
+ if (GetQuicRestartFlag(quic_disable_legacy_version_encapsulation)) {
+ if (!parsed_chlo->legacy_version_encapsulation_inner_packet.empty()) {
+ QUIC_CODE_COUNT(
+ quic_disable_legacy_version_encapsulation_process_header);
+ }
+ } else {
+ if (MaybeHandleLegacyVersionEncapsulation(
+ this, parsed_chlo->legacy_version_encapsulation_inner_packet,
+ *packet_info)) {
+ return;
+ }
}
ProcessChlo(*std::move(parsed_chlo), packet_info);
diff --git a/quiche/quic/core/quic_dispatcher_test.cc b/quiche/quic/core/quic_dispatcher_test.cc
index e5e6ea2..f8c169c 100644
--- a/quiche/quic/core/quic_dispatcher_test.cc
+++ b/quiche/quic/core/quic_dispatcher_test.cc
@@ -645,6 +645,9 @@
}
TEST_P(QuicDispatcherTestAllVersions, LegacyVersionEncapsulation) {
+ if (GetQuicRestartFlag(quic_disable_legacy_version_encapsulation)) {
+ return;
+ }
if (!version_.HasLongHeaderLengths()) {
// Decapsulating Legacy Version Encapsulation packets from these versions
// is not currently supported in QuicDispatcher.
diff --git a/quiche/quic/core/quic_flags_list.h b/quiche/quic/core/quic_flags_list.h
index e7748cb..83d7446 100644
--- a/quiche/quic/core/quic_flags_list.h
+++ b/quiche/quic/core/quic_flags_list.h
@@ -17,6 +17,8 @@
QUIC_FLAG(quic_restart_flag_quic_testonly_default_true, true)
// If bytes in flight has dipped below 1.25*MaxBW in the last round, do not exit PROBE_UP due to excess queue buildup.
QUIC_FLAG(quic_reloadable_flag_quic_bbr2_no_probe_up_exit_if_no_queue, true)
+// If true, QUIC Legacy Version Encapsulation will be disabled.
+QUIC_FLAG(quic_restart_flag_quic_disable_legacy_version_encapsulation, false)
// If true, QUIC will default enable MTU discovery at server, with a target of 1450 bytes.
QUIC_FLAG(quic_reloadable_flag_quic_enable_mtu_discovery_at_server, false)
// If true, QuicGsoBatchWriter will support release time if it is available and the process has the permission to do so.