Deprecate quic_allow_very_long_connection_ids

gfe-relnote: deprecate gfe2_restart_flag_quic_allow_very_long_connection_ids
PiperOrigin-RevId: 293391205
Change-Id: I075bf308aa3a7b668ccaaa67efdeecabd51df714
diff --git a/quic/core/quic_connection_id.cc b/quic/core/quic_connection_id.cc
index c514450..7e31f16 100644
--- a/quic/core/quic_connection_id.cc
+++ b/quic/core/quic_connection_id.cc
@@ -53,20 +53,6 @@
 QuicConnectionId::QuicConnectionId() : QuicConnectionId(nullptr, 0) {}
 
 QuicConnectionId::QuicConnectionId(const char* data, uint8_t length) {
-  if (!GetQuicRestartFlag(quic_allow_very_long_connection_ids)) {
-    // TODO(dschinazi) remove kQuicMaxConnectionIdAllVersionsLength entirely
-    // when we deprecate quic_allow_very_long_connection_ids.
-    static_assert(kQuicMaxConnectionIdAllVersionsLength <=
-                      std::numeric_limits<uint8_t>::max(),
-                  "kQuicMaxConnectionIdAllVersionsLength too high");
-    if (length > kQuicMaxConnectionIdAllVersionsLength) {
-      QUIC_BUG << "Attempted to create connection ID of length "
-               << static_cast<int>(length);
-      length = kQuicMaxConnectionIdAllVersionsLength;
-    }
-  } else {
-    QUIC_RESTART_FLAG_COUNT_N(quic_allow_very_long_connection_ids, 3, 5);
-  }
   length_ = length;
   if (length_ == 0) {
     return;
@@ -115,15 +101,6 @@
 }
 
 void QuicConnectionId::set_length(uint8_t length) {
-  if (!GetQuicRestartFlag(quic_allow_very_long_connection_ids)) {
-    if (length > kQuicMaxConnectionIdAllVersionsLength) {
-      QUIC_BUG << "Attempted to set connection ID length to "
-               << static_cast<int>(length);
-      length = kQuicMaxConnectionIdAllVersionsLength;
-    }
-  } else {
-    QUIC_RESTART_FLAG_COUNT_N(quic_allow_very_long_connection_ids, 4, 5);
-  }
   char temporary_data[sizeof(data_short_)];
   if (length > sizeof(data_short_)) {
     if (length_ <= sizeof(data_short_)) {
diff --git a/quic/core/quic_connection_id.h b/quic/core/quic_connection_id.h
index 25af43d..52d5e11 100644
--- a/quic/core/quic_connection_id.h
+++ b/quic/core/quic_connection_id.h
@@ -25,9 +25,6 @@
   CONNECTION_ID_ABSENT = 2,
 };
 
-// Maximum connection ID length that we support in any packet or version.
-const uint8_t kQuicMaxConnectionIdAllVersionsLength = 20;
-
 // Maximum connection ID length supported by versions that use the encoding from
 // draft-ietf-quic-invariants-06.
 const uint8_t kQuicMaxConnectionIdWithLengthPrefixLength = 20;
diff --git a/quic/core/quic_connection_id_test.cc b/quic/core/quic_connection_id_test.cc
index dbc8214..3fa7c02 100644
--- a/quic/core/quic_connection_id_test.cc
+++ b/quic/core/quic_connection_id_test.cc
@@ -92,7 +92,6 @@
 
   // Verify that any two all-zero connection IDs of different lengths never
   // have the same hash.
-  SetQuicRestartFlag(quic_allow_very_long_connection_ids, true);
   const char connection_id_bytes[255] = {};
   for (uint8_t i = 0; i < sizeof(connection_id_bytes) - 1; ++i) {
     QuicConnectionId connection_id_i(connection_id_bytes, i);
diff --git a/quic/core/quic_data_reader.cc b/quic/core/quic_data_reader.cc
index 882573d..fac462a 100644
--- a/quic/core/quic_data_reader.cc
+++ b/quic/core/quic_data_reader.cc
@@ -60,15 +60,6 @@
 
 bool QuicDataReader::ReadConnectionId(QuicConnectionId* connection_id,
                                       uint8_t length) {
-  if (!GetQuicRestartFlag(quic_allow_very_long_connection_ids)) {
-    if (length > kQuicMaxConnectionIdAllVersionsLength) {
-      QUIC_BUG << "Attempted to read connection ID with length too high "
-               << static_cast<int>(length);
-      return false;
-    }
-  } else {
-    QUIC_RESTART_FLAG_COUNT_N(quic_allow_very_long_connection_ids, 1, 5);
-  }
   if (length == 0) {
     connection_id->set_length(0);
     return true;
@@ -91,13 +82,6 @@
   if (!ReadUInt8(&connection_id_length)) {
     return false;
   }
-  if (!GetQuicRestartFlag(quic_allow_very_long_connection_ids)) {
-    if (connection_id_length > kQuicMaxConnectionIdAllVersionsLength) {
-      return false;
-    }
-  } else {
-    QUIC_RESTART_FLAG_COUNT_N(quic_allow_very_long_connection_ids, 2, 5);
-  }
   return ReadConnectionId(connection_id, connection_id_length);
 }
 
diff --git a/quic/core/quic_data_writer_test.cc b/quic/core/quic_data_writer_test.cc
index e655905..d27b8b1 100644
--- a/quic/core/quic_data_writer_test.cc
+++ b/quic/core/quic_data_writer_test.cc
@@ -1167,26 +1167,6 @@
   EXPECT_EQ(8, reader4.PeekVarInt62Length());
 }
 
-TEST_P(QuicDataWriterTest, InvalidConnectionIdLengthRead) {
-  SetQuicRestartFlag(quic_allow_very_long_connection_ids, false);
-  // TODO(dschinazi) delete this test when we deprecate
-  // quic_allow_very_long_connection_ids.
-  static const uint8_t bad_connection_id_length = 200;
-  static_assert(
-      bad_connection_id_length > kQuicMaxConnectionIdAllVersionsLength,
-      "bad lengths");
-  char buffer[255] = {};
-  QuicDataReader reader(buffer, sizeof(buffer));
-  QuicConnectionId connection_id;
-  bool ok;
-  EXPECT_QUIC_BUG(
-      ok = reader.ReadConnectionId(&connection_id, bad_connection_id_length),
-      quiche::QuicheStrCat(
-          "Attempted to read connection ID with length too high ",
-          static_cast<int>(bad_connection_id_length)));
-  EXPECT_FALSE(ok);
-}
-
 // Test that ReadVarIntU32 works properly. Tests a valid stream count
 // (a 32 bit number) and an invalid one (a >32 bit number)
 TEST_P(QuicDataWriterTest, ValidU32) {
diff --git a/quic/core/quic_dispatcher_test.cc b/quic/core/quic_dispatcher_test.cc
index ac35793..44e2bb7 100644
--- a/quic/core/quic_dispatcher_test.cc
+++ b/quic/core/quic_dispatcher_test.cc
@@ -537,7 +537,6 @@
 
 TEST_F(QuicDispatcherTest,
        StatelessVersionNegotiationWithVeryLongConnectionId) {
-  SetQuicRestartFlag(quic_allow_very_long_connection_ids, true);
   QuicConnectionId connection_id = QuicUtils::CreateRandomConnectionId(33);
   CreateTimeWaitListManager();
   QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1);
diff --git a/quic/core/quic_framer_test.cc b/quic/core/quic_framer_test.cc
index 8e272ce..88845af 100644
--- a/quic/core/quic_framer_test.cc
+++ b/quic/core/quic_framer_test.cc
@@ -10591,13 +10591,8 @@
       AssemblePacketFromFragments(packet99));
   EXPECT_FALSE(framer_.ProcessPacket(*encrypted));
   EXPECT_THAT(framer_.error(), IsError(QUIC_INVALID_NEW_CONNECTION_ID_DATA));
-  if (!GetQuicRestartFlag(quic_allow_very_long_connection_ids)) {
-    EXPECT_EQ("Unable to read new connection ID frame connection id.",
-              framer_.detailed_error());
-  } else {
-    EXPECT_EQ("Invalid new connection ID length for version.",
-              framer_.detailed_error());
-  }
+  EXPECT_EQ("Invalid new connection ID length for version.",
+            framer_.detailed_error());
 }
 
 // Verifies that parsing a NEW_CONNECTION_ID frame with an invalid
diff --git a/quic/core/quic_utils.cc b/quic/core/quic_utils.cc
index f5eecd7..8057a7d 100644
--- a/quic/core/quic_utils.cc
+++ b/quic/core/quic_utils.cc
@@ -548,13 +548,10 @@
     return false;
   }
 
-  if (GetQuicRestartFlag(quic_allow_very_long_connection_ids)) {
-    QUIC_RESTART_FLAG_COUNT_N(quic_allow_very_long_connection_ids, 5, 5);
-    if (transport_version == QUIC_VERSION_UNSUPPORTED ||
-        transport_version == QUIC_VERSION_RESERVED_FOR_NEGOTIATION) {
-      // Unknown versions could allow connection ID lengths up to 255.
-      return true;
-    }
+  if (transport_version == QUIC_VERSION_UNSUPPORTED ||
+      transport_version == QUIC_VERSION_RESERVED_FOR_NEGOTIATION) {
+    // Unknown versions could allow connection ID lengths up to 255.
+    return true;
   }
 
   const uint8_t connection_id_length8 =
diff --git a/quic/core/quic_utils_test.cc b/quic/core/quic_utils_test.cc
index e6fe1a2..1381b20 100644
--- a/quic/core/quic_utils_test.cc
+++ b/quic/core/quic_utils_test.cc
@@ -184,7 +184,6 @@
 
 TEST_F(QuicUtilsTest, ReplacementConnectionIdLengthIsCorrect) {
   // Verify that all lengths get replaced by kQuicDefaultConnectionIdLength.
-  SetQuicRestartFlag(quic_allow_very_long_connection_ids, true);
   const char connection_id_bytes[255] = {};
   for (uint8_t i = 0; i < sizeof(connection_id_bytes) - 1; ++i) {
     QuicConnectionId connection_id(connection_id_bytes, i);