Ignore stateless reset packet received on a probing path.

Client side change only. not protected.

PiperOrigin-RevId: 312125302
Change-Id: I113d78c8c0a1443815a9b50cee9240b79c0a90f7
diff --git a/quic/core/quic_connection_test.cc b/quic/core/quic_connection_test.cc
index 7fb8453..2e48f49 100644
--- a/quic/core/quic_connection_test.cc
+++ b/quic/core/quic_connection_test.cc
@@ -28,6 +28,7 @@
 #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_reference_counted.h"
+#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
 #include "net/third_party/quiche/src/quic/test_tools/mock_clock.h"
 #include "net/third_party/quiche/src/quic/test_tools/mock_random.h"
@@ -7368,6 +7369,33 @@
               IsError(QUIC_PUBLIC_RESET));
 }
 
+TEST_P(QuicConnectionTest, IetfStatelessResetOnProbingPath) {
+  if (!VersionHasIetfInvariantHeader(GetParam().version.transport_version)) {
+    return;
+  }
+  const QuicUint128 kTestStatelessResetToken = 1010101;
+  QuicConfig config;
+  QuicConfigPeer::SetReceivedStatelessResetToken(&config,
+                                                 kTestStatelessResetToken);
+  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+  connection_.SetFromConfig(config);
+
+  // Process a normal packet first to set the self address.
+  QuicReceivedPacket encrypted(nullptr, 0, QuicTime::Zero());
+  connection_.ProcessUdpPacket(kSelfAddress, kPeerAddress, encrypted);
+
+  std::unique_ptr<QuicEncryptedPacket> packet(
+      QuicFramer::BuildIetfStatelessResetPacket(connection_id_,
+                                                kTestStatelessResetToken));
+  std::unique_ptr<QuicReceivedPacket> received(
+      ConstructReceivedPacket(*packet, QuicTime::Zero()));
+  EXPECT_CALL(visitor_, OnConnectionClosed(_, _)).Times(0);
+  EXPECT_CALL(visitor_, OnStatelessResetForProbing());
+  auto host = kSelfAddress.host();
+  QuicSocketAddress alternate_address(host, 80);
+  connection_.ProcessUdpPacket(alternate_address, kPeerAddress, *received);
+}
+
 TEST_P(QuicConnectionTest, GoAway) {
   if (VersionHasIetfQuicFrames(GetParam().version.transport_version)) {
     // GoAway is not available in version 99.