Refactor QuicDispatcher connection ID replacement
Historically, QuicDispatcher needed the ability to generate a new distinct connection ID for the purpose of QUIC_CRYPTO stateless rejects. Due to how stateless rejects were designed, they needed a new connection ID distinct from the current one, but that still routes to the same server instance. For that reason, QuicDispatcher::GenerateNewServerConnectionId would just hash the connection ID and GfeQuicDispatcher::GenerateNewServerConnectionId would just add 1 to the lowest order bit. However, since then, stateless rejects have been deprecated and entirely removed from the codebase. Separately, we started using GenerateNewServerConnectionId to truncate client-provided connection IDs that were too long. Additionally, with cl/311115671 we no longer increment the connection ID by one because we no longer have the requirement of it being different.
All of this to say that the code no longer matches what it is used for, and this CL refactors it to make it clearer, without changing any behavior.
Refactor, no behavior change, not flag protected
PiperOrigin-RevId: 311788800
Change-Id: I44c16f2fc91babb0607159a4d1f2e580ec17317c
diff --git a/quic/core/quic_utils.h b/quic/core/quic_utils.h
index eec9a5f..e470e6f 100644
--- a/quic/core/quic_utils.h
+++ b/quic/core/quic_utils.h
@@ -168,11 +168,19 @@
QuicTransportVersion version,
Perspective perspective);
- // Generates a 64bit connection ID derived from the input connection ID.
+ // Generates a connection ID of length |expected_connection_id_length|
+ // derived from |connection_id|.
// This is guaranteed to be deterministic (calling this method with two
// connection IDs that are equal is guaranteed to produce the same result).
static QuicConnectionId CreateReplacementConnectionId(
- QuicConnectionId connection_id);
+ const QuicConnectionId& connection_id,
+ uint8_t expected_connection_id_length);
+
+ // Generates a 64bit connection ID derived from |connection_id|.
+ // This is guaranteed to be deterministic (calling this method with two
+ // connection IDs that are equal is guaranteed to produce the same result).
+ static QuicConnectionId CreateReplacementConnectionId(
+ const QuicConnectionId& connection_id);
// Generates a random 64bit connection ID.
static QuicConnectionId CreateRandomConnectionId();