New error code for QUIC packet/connection version mismatch
Previously shared with QUIC_INVALID_VERSION but now separated
to a new QUIC_PACKET_WRONG_VERSION error.
PiperOrigin-RevId: 439399874
diff --git a/quic/core/quic_error_codes.cc b/quic/core/quic_error_codes.cc
index c7da0ae..36c5510 100644
--- a/quic/core/quic_error_codes.cc
+++ b/quic/core/quic_error_codes.cc
@@ -112,6 +112,7 @@
RETURN_STRING_LITERAL(QUIC_TOO_MANY_OPEN_STREAMS);
RETURN_STRING_LITERAL(QUIC_PUBLIC_RESET);
RETURN_STRING_LITERAL(QUIC_INVALID_VERSION);
+ RETURN_STRING_LITERAL(QUIC_PACKET_WRONG_VERSION);
RETURN_STRING_LITERAL(QUIC_INVALID_0RTT_PACKET_NUMBER_OUT_OF_ORDER);
RETURN_STRING_LITERAL(QUIC_INVALID_HEADER_ID);
RETURN_STRING_LITERAL(QUIC_INVALID_NEGOTIATED_VALUE);
@@ -405,6 +406,8 @@
return {true, static_cast<uint64_t>(INTERNAL_ERROR)};
case QUIC_INVALID_VERSION:
return {true, static_cast<uint64_t>(PROTOCOL_VIOLATION)};
+ case QUIC_PACKET_WRONG_VERSION:
+ return {true, static_cast<uint64_t>(PROTOCOL_VIOLATION)};
case QUIC_INVALID_0RTT_PACKET_NUMBER_OUT_OF_ORDER:
return {true, static_cast<uint64_t>(PROTOCOL_VIOLATION)};
case QUIC_INVALID_HEADER_ID:
diff --git a/quic/core/quic_error_codes.h b/quic/core/quic_error_codes.h
index 469f3c5..09e6fb2 100644
--- a/quic/core/quic_error_codes.h
+++ b/quic/core/quic_error_codes.h
@@ -190,8 +190,10 @@
QUIC_TOO_MANY_AVAILABLE_STREAMS = 76,
// Received public reset for this connection.
QUIC_PUBLIC_RESET = 19,
- // Invalid protocol version.
+ // Version selected by client is not acceptable to the server.
QUIC_INVALID_VERSION = 20,
+ // Received packet indicates version that does not match connection version.
+ QUIC_PACKET_WRONG_VERSION = 212,
// The Header ID for a stream was too far from the previous.
QUIC_INVALID_HEADER_ID = 22,
@@ -613,7 +615,7 @@
QUIC_UNEXPECTED_DATA_BEFORE_ENCRYPTION_ESTABLISHED = 211,
// No error. Used as bound while iterating.
- QUIC_LAST_ERROR = 212,
+ QUIC_LAST_ERROR = 213,
};
// QuicErrorCodes is encoded as four octets on-the-wire when doing Google QUIC,
// or a varint62 when doing IETF QUIC. Ensure that its value does not exceed
diff --git a/quic/core/quic_framer.cc b/quic/core/quic_framer.cc
index 65b44d5..c1b3228 100644
--- a/quic/core/quic_framer.cc
+++ b/quic/core/quic_framer.cc
@@ -1520,7 +1520,7 @@
<< ParsedQuicVersionToString(header.version)
<< " instead of " << ParsedQuicVersionToString(version_);
set_detailed_error("Client received unexpected version.");
- return RaiseError(QUIC_INVALID_VERSION);
+ return RaiseError(QUIC_PACKET_WRONG_VERSION);
}
}
diff --git a/quic/core/quic_framer_test.cc b/quic/core/quic_framer_test.cc
index 9e1b866..40692cd 100644
--- a/quic/core/quic_framer_test.cc
+++ b/quic/core/quic_framer_test.cc
@@ -38,8 +38,6 @@
using testing::_;
using testing::ContainerEq;
-using testing::Eq;
-using testing::IsNull;
using testing::Return;
namespace quic {
@@ -14771,7 +14769,7 @@
EXPECT_TRUE(visitor_.coalesced_packets_.empty());
}
-TEST_P(QuicFramerTest, ClientReceivesInvalidVersion) {
+TEST_P(QuicFramerTest, ClientReceivesWrongVersion) {
if (!framer_.version().HasIetfInvariantHeader()) {
return;
}
@@ -14797,7 +14795,7 @@
QuicEncryptedPacket encrypted(AsChars(packet), ABSL_ARRAYSIZE(packet), false);
EXPECT_FALSE(framer_.ProcessPacket(encrypted));
- EXPECT_THAT(framer_.error(), IsError(QUIC_INVALID_VERSION));
+ EXPECT_THAT(framer_.error(), IsError(QUIC_PACKET_WRONG_VERSION));
EXPECT_EQ("Client received unexpected version.", framer_.detailed_error());
}