Allow long connection IDs for unknown QUIC versions
In particular, if we're a server and a client sends us a packet with an unknown version and a connection ID of any length between 8 and 255, we must respond with a version negotiation packet that includes that same connection ID.
gfe-relnote: allow longer connection IDs, protected by new disabled flag gfe2_restart_flag_quic_allow_very_long_connection_ids
PiperOrigin-RevId: 286015388
Change-Id: I53ff4e602a19f30f56aba10ad7d877776597a5cf
diff --git a/quic/core/quic_utils.cc b/quic/core/quic_utils.cc
index a695c94..e37d019 100644
--- a/quic/core/quic_utils.cc
+++ b/quic/core/quic_utils.cc
@@ -545,6 +545,16 @@
static_cast<size_t>(std::numeric_limits<uint8_t>::max())) {
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;
+ }
+ }
+
const uint8_t connection_id_length8 =
static_cast<uint8_t>(connection_id_length);
// Versions that do not support variable lengths only support length 8.