Do not create multi-port path if the connection has active migration disabled.
PiperOrigin-RevId: 538268315
diff --git a/quiche/quic/core/quic_connection.cc b/quiche/quic/core/quic_connection.cc
index fc5e097..e1ec2d8 100644
--- a/quiche/quic/core/quic_connection.cc
+++ b/quiche/quic/core/quic_connection.cc
@@ -555,6 +555,10 @@
OnNewConnectionIdFrameInner(frame);
}
+ if (config.DisableConnectionMigration()) {
+ active_migration_disabled_ = true;
+ }
+
sent_packet_manager_.SetFromConfig(config);
if (perspective_ == Perspective::IS_SERVER &&
config.HasClientSentConnectionOption(kAFF2, perspective_)) {
@@ -3992,6 +3996,14 @@
void QuicConnection::MaybeCreateMultiPortPath() {
QUICHE_DCHECK_EQ(Perspective::IS_CLIENT, perspective_);
+ QUIC_CLIENT_HISTOGRAM_BOOL(
+ "QuicConnection.ServerAllowsActiveMigrationForMultiPort",
+ !active_migration_disabled_,
+ "Whether the server allows active migration that's required for "
+ "multi-port");
+ if (active_migration_disabled_) {
+ return;
+ }
if (path_validator_.HasPendingPathValidation()) {
QUIC_CLIENT_HISTOGRAM_ENUM("QuicConnection.MultiPortPathCreationCancelled",
path_validator_.GetPathValidationReason(),
diff --git a/quiche/quic/core/quic_connection.h b/quiche/quic/core/quic_connection.h
index e1832ab..a650978 100644
--- a/quiche/quic/core/quic_connection.h
+++ b/quiche/quic/core/quic_connection.h
@@ -2360,6 +2360,8 @@
std::unique_ptr<MultiPortStats> multi_port_stats_;
+ bool active_migration_disabled_ = false;
+
RetransmittableOnWireBehavior retransmittable_on_wire_behavior_ = DEFAULT;
// Server addresses that are known to the client.
diff --git a/quiche/quic/core/quic_connection_test.cc b/quiche/quic/core/quic_connection_test.cc
index fae2512..c501347 100644
--- a/quiche/quic/core/quic_connection_test.cc
+++ b/quiche/quic/core/quic_connection_test.cc
@@ -13265,6 +13265,39 @@
connection_.ProcessUdpPacket(kNewSelfAddress, kPeerAddress, *received);
}
+// Test that if the client's active migration is disabled, multi-port will not
+// be attempted.
+TEST_P(QuicConnectionTest, MultiPortPathRespectsActiveMigrationConfig) {
+ set_perspective(Perspective::IS_CLIENT);
+ QuicConfig config;
+ QuicConfigPeer::SetReceivedStatelessResetToken(&config,
+ kTestStatelessResetToken);
+ QuicConfigPeer::SetReceivedDisableConnectionMigration(&config);
+ config.SetClientConnectionOptions(QuicTagVector{kMPQC});
+ EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+ connection_.SetFromConfig(config);
+ if (!connection_.connection_migration_use_new_cid()) {
+ return;
+ }
+ connection_.CreateConnectionIdManager();
+ connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
+ connection_.OnHandshakeComplete();
+
+ EXPECT_CALL(visitor_, OnPathDegrading());
+ connection_.OnPathDegradingDetected();
+
+ QuicNewConnectionIdFrame frame;
+ frame.connection_id = TestConnectionId(1234);
+ ASSERT_NE(frame.connection_id, connection_.connection_id());
+ frame.stateless_reset_token =
+ QuicUtils::GenerateStatelessResetToken(frame.connection_id);
+ frame.retire_prior_to = 0u;
+ frame.sequence_number = 1u;
+ EXPECT_CALL(visitor_, CreateContextForMultiPortPath).Times(0);
+ connection_.OnNewConnectionIdFrame(frame);
+ EXPECT_FALSE(connection_.HasPendingPathValidation());
+}
+
// Verify that when multi-port is enabled and path degrading is triggered, if
// the alt-path is not ready, nothing happens.
TEST_P(QuicConnectionTest, PathDegradingWhenAltPathIsNotReady) {