Set idle timeout correctly between TLS handshake completion & LOAS authentication completion for QBONE with IETF-QUIC.
On the client side, protected by --qbone_client_use_h3_loas.
Protected by FLAGS_qbone_server_support_h3_loas.
PiperOrigin-RevId: 421046135
diff --git a/quic/test_tools/crypto_test_utils.cc b/quic/test_tools/crypto_test_utils.cc
index 634c16f..cbf4fe2 100644
--- a/quic/test_tools/crypto_test_utils.cc
+++ b/quic/test_tools/crypto_test_utils.cc
@@ -393,6 +393,53 @@
}
}
+bool CommunicateHandshakeMessagesUntil(PacketSavingConnection* client_conn,
+ QuicCryptoStream* client,
+ std::function<bool()> client_condition,
+ PacketSavingConnection* server_conn,
+ QuicCryptoStream* server,
+ std::function<bool()> server_condition) {
+ size_t client_next_packet_to_deliver =
+ client_conn->number_of_packets_delivered_;
+ size_t server_next_packet_to_deliver =
+ server_conn->number_of_packets_delivered_;
+ while (
+ client_conn->connected() && server_conn->connected() &&
+ (!client_condition() || !server_condition()) &&
+ (client_conn->encrypted_packets_.size() > client_next_packet_to_deliver ||
+ server_conn->encrypted_packets_.size() >
+ server_next_packet_to_deliver)) {
+ if (!server_condition()) {
+ QUIC_LOG(INFO) << "Processing "
+ << client_conn->encrypted_packets_.size() -
+ client_next_packet_to_deliver
+ << " packets client->server";
+ MovePackets(client_conn, &client_next_packet_to_deliver, server,
+ server_conn, Perspective::IS_SERVER);
+ }
+ if (!client_condition()) {
+ QUIC_LOG(INFO) << "Processing "
+ << server_conn->encrypted_packets_.size() -
+ server_next_packet_to_deliver
+ << " packets server->client";
+ MovePackets(server_conn, &server_next_packet_to_deliver, client,
+ client_conn, Perspective::IS_CLIENT);
+ }
+ }
+ client_conn->number_of_packets_delivered_ = client_next_packet_to_deliver;
+ server_conn->number_of_packets_delivered_ = server_next_packet_to_deliver;
+ bool result = client_condition() && server_condition();
+ if (!result) {
+ QUIC_LOG(INFO) << "CommunicateHandshakeMessagesUnti failed with state: "
+ "client connected? "
+ << client_conn->connected() << " server connected? "
+ << server_conn->connected() << " client condition met? "
+ << client_condition() << " server condition met? "
+ << server_condition();
+ }
+ return result;
+}
+
std::pair<size_t, size_t> AdvanceHandshake(PacketSavingConnection* client_conn,
QuicCryptoStream* client,
size_t client_i,
diff --git a/quic/test_tools/crypto_test_utils.h b/quic/test_tools/crypto_test_utils.h
index 87e354a..b4d772a 100644
--- a/quic/test_tools/crypto_test_utils.h
+++ b/quic/test_tools/crypto_test_utils.h
@@ -109,6 +109,19 @@
PacketSavingConnection* server_conn,
QuicCryptoStream* server);
+// CommunicateHandshakeMessagesUntil:
+// 1) Moves messages from |client| to |server| until |server_condition| is met.
+// 2) Moves messages from |server| to |client| until |client_condition| is met.
+// 3) Returns true if both conditions are met.
+// 4) Returns false if either connection is closed or there is no more packet to
+// deliver before both conditions are met.
+bool CommunicateHandshakeMessagesUntil(PacketSavingConnection* client_conn,
+ QuicCryptoStream* client,
+ std::function<bool()> client_condition,
+ PacketSavingConnection* server_conn,
+ QuicCryptoStream* server,
+ std::function<bool()> server_condition);
+
// AdvanceHandshake attempts to moves messages from |client| to |server| and
// |server| to |client|. Returns the number of messages moved.
std::pair<size_t, size_t> AdvanceHandshake(PacketSavingConnection* client_conn,
diff --git a/quic/test_tools/quic_connection_peer.cc b/quic/test_tools/quic_connection_peer.cc
index b511949..ec579be 100644
--- a/quic/test_tools/quic_connection_peer.cc
+++ b/quic/test_tools/quic_connection_peer.cc
@@ -57,6 +57,12 @@
}
// static
+QuicTime::Delta QuicConnectionPeer::GetHandshakeTimeout(
+ QuicConnection* connection) {
+ return connection->idle_network_detector_.handshake_timeout_;
+}
+
+// static
void QuicConnectionPeer::SetPerspective(QuicConnection* connection,
Perspective perspective) {
connection->perspective_ = perspective;
diff --git a/quic/test_tools/quic_connection_peer.h b/quic/test_tools/quic_connection_peer.h
index aa30c24..26d2f41 100644
--- a/quic/test_tools/quic_connection_peer.h
+++ b/quic/test_tools/quic_connection_peer.h
@@ -50,6 +50,8 @@
static QuicTime::Delta GetNetworkTimeout(QuicConnection* connection);
+ static QuicTime::Delta GetHandshakeTimeout(QuicConnection* connection);
+
static void SetPerspective(QuicConnection* connection,
Perspective perspective);
diff --git a/quic/test_tools/quic_test_utils.h b/quic/test_tools/quic_test_utils.h
index 051ab62..44e9ca2 100644
--- a/quic/test_tools/quic_test_utils.h
+++ b/quic/test_tools/quic_test_utils.h
@@ -745,6 +745,9 @@
MOCK_METHOD(void, OnPacketSent, (EncryptionLevel, TransmissionType));
std::vector<std::unique_ptr<QuicEncryptedPacket>> encrypted_packets_;
+ // Number of packets in encrypted_packets that has been delivered to the peer
+ // connection.
+ size_t number_of_packets_delivered_ = 0;
MockClock clock_;
};