gfe-relnote: Remove the use of QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT.

PiperOrigin-RevId: 251847850
Change-Id: I0018b01d89e52a75d3259a22c6c5bfaac87b18b9
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc
index 83e6f04..5e8e100 100644
--- a/quic/core/quic_connection.cc
+++ b/quic/core/quic_connection.cc
@@ -3144,14 +3144,8 @@
     SendConnectionClosePacket(error, error_details);
   }
 
-  ConnectionCloseSource source = ConnectionCloseSource::FROM_SELF;
-  if (perspective_ == Perspective::IS_CLIENT &&
-      error == QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT) {
-    // Regard stateless rejected connection as closed by server.
-    source = ConnectionCloseSource::FROM_PEER;
-  }
-
-  TearDownLocalConnectionState(error, error_details, source);
+  TearDownLocalConnectionState(error, error_details,
+                               ConnectionCloseSource::FROM_SELF);
 }
 
 void QuicConnection::SendConnectionClosePacket(QuicErrorCode error,
diff --git a/quic/core/quic_connection_test.cc b/quic/core/quic_connection_test.cc
index b7c45d5..a2612b9 100644
--- a/quic/core/quic_connection_test.cc
+++ b/quic/core/quic_connection_test.cc
@@ -7685,17 +7685,6 @@
   EXPECT_TRUE(writer_->ack_frames().empty());
 }
 
-TEST_P(QuicConnectionTest, CloseConnectionForStatelessReject) {
-  std::string error_details("stateless reject");
-  EXPECT_CALL(visitor_, OnConnectionClosed(
-                            QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT,
-                            error_details, ConnectionCloseSource::FROM_PEER));
-  connection_.set_perspective(Perspective::IS_CLIENT);
-  connection_.CloseConnection(QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT,
-                              error_details,
-                              ConnectionCloseBehavior::SILENT_CLOSE);
-}
-
 // Regression test for b/63620844.
 TEST_P(QuicConnectionTest, FailedToWriteHandshakePacket) {
   SimulateNextPacketTooLarge();
diff --git a/quic/core/quic_dispatcher.cc b/quic/core/quic_dispatcher.cc
index 7228af3..8a91711 100644
--- a/quic/core/quic_dispatcher.cc
+++ b/quic/core/quic_dispatcher.cc
@@ -623,13 +623,8 @@
 
 void QuicDispatcher::CleanUpSession(SessionMap::iterator it,
                                     QuicConnection* connection,
-                                    bool should_close_statelessly,
                                     ConnectionCloseSource source) {
   write_blocked_list_.erase(connection);
-  if (should_close_statelessly) {
-    DCHECK(connection->termination_packets() != nullptr &&
-           !connection->termination_packets()->empty());
-  }
   QuicTimeWaitListManager::TimeWaitAction action =
       QuicTimeWaitListManager::SEND_STATELESS_RESET;
   if (connection->termination_packets() != nullptr &&
@@ -762,9 +757,7 @@
     }
     closed_session_list_.push_back(std::move(it->second));
   }
-  const bool should_close_statelessly =
-      (error == QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT);
-  CleanUpSession(it, connection, should_close_statelessly, source);
+  CleanUpSession(it, connection, source);
 }
 
 void QuicDispatcher::OnWriteBlocked(
diff --git a/quic/core/quic_dispatcher.h b/quic/core/quic_dispatcher.h
index 790d4d2..1a023e0 100644
--- a/quic/core/quic_dispatcher.h
+++ b/quic/core/quic_dispatcher.h
@@ -324,11 +324,9 @@
       QuicConnectionId server_connection_id);
 
   // Removes the session from the session map and write blocked list, and adds
-  // the ConnectionId to the time-wait list.  If |session_closed_statelessly| is
-  // true, any future packets for the ConnectionId will be black-holed.
+  // the ConnectionId to the time-wait list.
   virtual void CleanUpSession(SessionMap::iterator it,
                               QuicConnection* connection,
-                              bool session_closed_statelessly,
                               ConnectionCloseSource source);
 
   void StopAcceptingNewConnections();
diff --git a/quic/core/quic_error_codes.cc b/quic/core/quic_error_codes.cc
index 86c0896..cf95e1d 100644
--- a/quic/core/quic_error_codes.cc
+++ b/quic/core/quic_error_codes.cc
@@ -71,7 +71,6 @@
     RETURN_STRING_LITERAL(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE);
     RETURN_STRING_LITERAL(QUIC_CRYPTO_INTERNAL_ERROR);
     RETURN_STRING_LITERAL(QUIC_CRYPTO_VERSION_NOT_SUPPORTED);
-    RETURN_STRING_LITERAL(QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT);
     RETURN_STRING_LITERAL(QUIC_CRYPTO_NO_SUPPORT);
     RETURN_STRING_LITERAL(QUIC_INVALID_CRYPTO_MESSAGE_TYPE);
     RETURN_STRING_LITERAL(QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER);
diff --git a/quic/core/quic_error_codes.h b/quic/core/quic_error_codes.h
index c8259f7..3de93f6 100644
--- a/quic/core/quic_error_codes.h
+++ b/quic/core/quic_error_codes.h
@@ -216,8 +216,8 @@
   QUIC_CRYPTO_INTERNAL_ERROR = 38,
   // A crypto handshake message specified an unsupported version.
   QUIC_CRYPTO_VERSION_NOT_SUPPORTED = 39,
-  // A crypto handshake message resulted in a stateless reject.
-  QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT = 72,
+  // (Deprecated) A crypto handshake message resulted in a stateless reject.
+  // QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT = 72,
   // There was no intersection between the crypto primitives supported by the
   // peer and ourselves.
   QUIC_CRYPTO_NO_SUPPORT = 40,
diff --git a/quic/tools/quic_client_base.cc b/quic/tools/quic_client_base.cc
index fbda267..eb4ac14 100644
--- a/quic/tools/quic_client_base.cc
+++ b/quic/tools/quic_client_base.cc
@@ -83,21 +83,12 @@
     }
     ParsedQuicVersion version = UnsupportedQuicVersion();
     if (session() != nullptr &&
-        session()->error() != QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT &&
         !CanReconnectWithDifferentVersion(&version)) {
-      // We've successfully created a session but we're not connected, and there
-      // is no stateless reject to recover from and cannot try to reconnect with
-      // different version.  Give up trying.
+      // We've successfully created a session but we're not connected, and we
+      // cannot reconnect with a different version.  Give up trying.
       break;
     }
   }
-  if (!connected() &&
-      GetNumSentClientHellos() > QuicCryptoClientStream::kMaxClientHellos &&
-      session() != nullptr &&
-      session()->error() == QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT) {
-    // The overall connection failed due too many stateless rejects.
-    set_connection_error(QUIC_CRYPTO_TOO_MANY_REJECTS);
-  }
   return session()->connection()->connected();
 }
 
@@ -109,12 +100,9 @@
   const bool can_reconnect_with_different_version =
       CanReconnectWithDifferentVersion(&mutual_version);
   if (connected_or_attempting_connect()) {
-    // If the last error was not a stateless reject, then the queued up data
-    // does not need to be resent.
-    // Keep queued up data if client can try to connect with a different
+    // Clear queued up data if client can not try to connect with a different
     // version.
-    if (session()->error() != QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT &&
-        !can_reconnect_with_different_version) {
+    if (!can_reconnect_with_different_version) {
       ClearDataToResend();
     }
     // Before we destroy the last session and create a new one, gather its stats
@@ -176,11 +164,7 @@
 
   DCHECK(session() != nullptr);
   ParsedQuicVersion version = UnsupportedQuicVersion();
-  if (!connected() &&
-
-      CanReconnectWithDifferentVersion(&version)) {
-    DCHECK_NE(session()->error(), QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT);
-
+  if (!connected() && CanReconnectWithDifferentVersion(&version)) {
     QUIC_DLOG(INFO) << "Can reconnect with version: " << version
                     << ", attempting to reconnect.";
 
@@ -276,9 +260,6 @@
 
 void QuicClientBase::UpdateStats() {
   num_sent_client_hellos_ += GetNumSentClientHellosFromSession();
-  if (session()->error() == QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT) {
-    ++num_stateless_rejects_received_;
-  }
 }
 
 int QuicClientBase::GetNumReceivedServerConfigUpdates() {
diff --git a/quic/tools/quic_client_base.h b/quic/tools/quic_client_base.h
index 134404b..13f7c94 100644
--- a/quic/tools/quic_client_base.h
+++ b/quic/tools/quic_client_base.h
@@ -331,9 +331,7 @@
 
   // The number of stateless rejects received during the current/latest
   // connection.
-  // TODO(jokulik): Consider some consistent naming scheme (or other) for member
-  // variables that are kept per-request, per-connection, and over the client's
-  // lifetime.
+  // TODO(wub): Remove this.
   int num_stateless_rejects_received_;
 
   // The number of hellos sent during the current/latest connection.