Relax QUIC connection migration restriction to allow peer address port change during handshake.
Protected by FLAGS_quic_reloadable_flag_quic_start_peer_migration_earlier_2 and existing flag --quic_reloadable_flag_quic_update_packet_content_returns_connected.
PiperOrigin-RevId: 354587392
Change-Id: Ie18e16a08788d0bcc346b64284c326d065afd30d
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc
index 5c14542..38355d5 100644
--- a/quic/core/quic_connection.cc
+++ b/quic/core/quic_connection.cc
@@ -4942,20 +4942,12 @@
if (!start_peer_migration_earlier_) {
return;
}
- QUIC_CODE_COUNT(quic_start_peer_migration_earlier);
+ QUIC_CODE_COUNT(quic_start_peer_migration_earlier_2);
if (current_effective_peer_migration_type_ != NO_CHANGE &&
+ current_effective_peer_migration_type_ != PORT_CHANGE &&
!IsHandshakeConfirmed()) {
- QUIC_LOG_EVERY_N_SEC(INFO, 60)
- << ENDPOINT << "Effective peer's ip:port changed from "
- << effective_peer_address_.ToString() << " to "
- << GetEffectivePeerAddressFromCurrentPacket().ToString()
- << " before handshake confirmed, "
- "current_effective_peer_migration_type_: "
- << current_effective_peer_migration_type_;
// Peer migrated before handshake gets confirmed.
- CloseConnection((current_effective_peer_migration_type_ == PORT_CHANGE
- ? QUIC_PEER_PORT_CHANGE_HANDSHAKE_UNCONFIRMED
- : QUIC_CONNECTION_MIGRATION_HANDSHAKE_UNCONFIRMED),
+ CloseConnection(QUIC_CONNECTION_MIGRATION_HANDSHAKE_UNCONFIRMED,
"Peer address changed before handshake is confirmed.",
ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
return;
diff --git a/quic/core/quic_connection.h b/quic/core/quic_connection.h
index b098367..f368bc4 100644
--- a/quic/core/quic_connection.h
+++ b/quic/core/quic_connection.h
@@ -1188,6 +1188,10 @@
virtual std::vector<QuicConnectionId> GetActiveServerConnectionIds() const;
+ bool start_peer_migration_earlier() const {
+ return start_peer_migration_earlier_;
+ }
+
protected:
// Calls cancel() on all the alarms owned by this connection.
void CancelAllAlarms();
@@ -1995,9 +1999,6 @@
size_t anti_amplification_factor_ =
GetQuicFlag(FLAGS_quic_anti_amplification_factor);
- bool start_peer_migration_earlier_ =
- GetQuicReloadableFlag(quic_start_peer_migration_earlier);
-
// latch --gfe2_reloadable_flag_quic_send_path_response and
// --gfe2_reloadable_flag_quic_start_peer_migration_earlier.
bool send_path_response_ = start_peer_migration_earlier_ &&
@@ -2054,6 +2055,10 @@
bool update_packet_content_returns_connected_ =
GetQuicReloadableFlag(quic_update_packet_content_returns_connected);
+
+ bool start_peer_migration_earlier_ =
+ update_packet_content_returns_connected_ &&
+ GetQuicReloadableFlag(quic_start_peer_migration_earlier_2);
};
} // namespace quic
diff --git a/quic/core/quic_connection_test.cc b/quic/core/quic_connection_test.cc
index a32d9e4..ad74905 100644
--- a/quic/core/quic_connection_test.cc
+++ b/quic/core/quic_connection_test.cc
@@ -1652,7 +1652,7 @@
.WillOnce(Invoke(
[=]() { EXPECT_EQ(kPeerAddress, connection_.peer_address()); }))
.WillOnce(Invoke([=]() {
- EXPECT_EQ((GetQuicReloadableFlag(quic_start_peer_migration_earlier) ||
+ EXPECT_EQ((connection_.start_peer_migration_earlier() ||
!GetParam().version.HasIetfQuicFrames()
? kNewPeerAddress
: kPeerAddress),
@@ -13280,7 +13280,7 @@
// Regression test for b/177312785
TEST_P(QuicConnectionTest, PeerMigrateBeforeHandshakeConfirm) {
if (!VersionHasIetfQuicFrames(version().transport_version) ||
- !GetQuicReloadableFlag(quic_start_peer_migration_earlier)) {
+ !connection_.start_peer_migration_earlier()) {
return;
}
set_perspective(Perspective::IS_SERVER);
@@ -13298,7 +13298,7 @@
EXPECT_FALSE(connection_.effective_peer_address().IsInitialized());
const QuicSocketAddress kNewPeerAddress =
- QuicSocketAddress(QuicIpAddress::Loopback6(), /*port=*/23456);
+ QuicSocketAddress(QuicIpAddress::Loopback4(), /*port=*/23456);
EXPECT_CALL(visitor_, OnCryptoFrame(_)).Times(AnyNumber());
ProcessFramePacketWithAddresses(MakeCryptoFrame(), kSelfAddress, kPeerAddress,
ENCRYPTION_INITIAL);
@@ -13311,7 +13311,7 @@
EXPECT_CALL(visitor_, BeforeConnectionCloseSent());
EXPECT_CALL(visitor_,
OnConnectionClosed(_, ConnectionCloseSource::FROM_SELF));
- EXPECT_CALL(visitor_, OnConnectionMigration(PORT_CHANGE)).Times(0u);
+ EXPECT_CALL(visitor_, OnConnectionMigration(_)).Times(0u);
if (!GetQuicReloadableFlag(quic_update_packet_content_returns_connected)) {
EXPECT_CALL(*send_algorithm_, OnCongestionEvent(_, _, _, _, _));
EXPECT_QUIC_BUG(
diff --git a/quic/core/quic_flags_list.h b/quic/core/quic_flags_list.h
index aa198ce..c4c92b6 100644
--- a/quic/core/quic_flags_list.h
+++ b/quic/core/quic_flags_list.h
@@ -55,7 +55,7 @@
QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_send_tls_crypto_error_code, false)
QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_single_ack_in_packet2, false)
QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_split_up_send_rst_2, true)
-QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_start_peer_migration_earlier, false)
+QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_start_peer_migration_earlier_2, false)
QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_testonly_default_false, false)
QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_testonly_default_true, true)
QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_tls_use_early_select_cert, true)