diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-05-20 09:47:09 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-06-07 11:15:42 +0000 |
commit | 189d4fd8fad9e3c776873be51938cd31a42b6177 (patch) | |
tree | 6497caeff5e383937996768766ab3bb2081a40b2 /chromium/net/third_party/quiche/src/quic | |
parent | 8bc75099d364490b22f43a7ce366b366c08f4164 (diff) | |
download | qtwebengine-chromium-189d4fd8fad9e3c776873be51938cd31a42b6177.tar.gz |
BASELINE: Update Chromium to 90.0.4430.221
Change-Id: Iff4d9d18d2fcf1a576f3b1f453010f744a232920
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/net/third_party/quiche/src/quic')
947 files changed, 20335 insertions, 12700 deletions
diff --git a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_base.cc b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_base.cc index 29cbccc97e5..b2fd80c9a72 100644 --- a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_base.cc +++ b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_base.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_base.h" +#include "quic/core/batch_writer/quic_batch_writer_base.h" #include <cstdint> -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_server_stats.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/platform/api/quic_server_stats.h" namespace quic { @@ -141,12 +141,12 @@ QuicBatchWriterBase::FlushImplResult QuicBatchWriterBase::CheckedFlush() { // Either flush_result.write_result.status is not WRITE_STATUS_OK, or it is // WRITE_STATUS_OK and batch_buffer is empty. - DCHECK(flush_result.write_result.status != WRITE_STATUS_OK || - buffered_writes().empty()); + QUICHE_DCHECK(flush_result.write_result.status != WRITE_STATUS_OK || + buffered_writes().empty()); // Flush should never return WRITE_STATUS_BLOCKED_DATA_BUFFERED. - DCHECK(flush_result.write_result.status != - WRITE_STATUS_BLOCKED_DATA_BUFFERED); + QUICHE_DCHECK(flush_result.write_result.status != + WRITE_STATUS_BLOCKED_DATA_BUFFERED); return flush_result; } diff --git a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_base.h b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_base.h index 30e1af44007..ff924d0481c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_base.h +++ b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_base.h @@ -6,11 +6,11 @@ #define QUICHE_QUIC_PLATFORM_IMPL_BATCH_WRITER_QUIC_BATCH_WRITER_BASE_H_ #include <cstdint> -#include "net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_buffer.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/batch_writer/quic_batch_writer_buffer.h" +#include "quic/core/quic_packet_writer.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { @@ -75,7 +75,8 @@ class QUIC_EXPORT_PRIVATE QuicBatchWriterBase : public QuicPacketWriter { }; virtual ReleaseTime GetReleaseTime( const PerPacketOptions* /*options*/) const { - DCHECK(false) << "Should not be called since release time is unsupported."; + QUICHE_DCHECK(false) + << "Should not be called since release time is unsupported."; return ReleaseTime{0, QuicTime::Delta::Zero()}; } diff --git a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_buffer.cc b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_buffer.cc index 893b501d7c5..0de792dded8 100644 --- a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_buffer.cc +++ b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_buffer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_buffer.h" +#include "quic/core/batch_writer/quic_batch_writer_buffer.h" #include <sstream> @@ -60,8 +60,8 @@ QuicBatchWriterBuffer::PushResult QuicBatchWriterBuffer::PushBufferedWrite( const QuicSocketAddress& peer_address, const PerPacketOptions* options, uint64_t release_time) { - DCHECK(Invariants()); - DCHECK_LE(buf_len, kMaxOutgoingPacketSize); + QUICHE_DCHECK(Invariants()); + QUICHE_DCHECK_LE(buf_len, kMaxOutgoingPacketSize); PushResult result = {/*succeeded=*/false, /*buffer_copied=*/false}; char* next_write_location = GetNextWriteLocation(); @@ -91,7 +91,7 @@ QuicBatchWriterBuffer::PushResult QuicBatchWriterBuffer::PushBufferedWrite( options ? options->Clone() : std::unique_ptr<PerPacketOptions>(), release_time); - DCHECK(Invariants()); + QUICHE_DCHECK(Invariants()); result.succeeded = true; return result; @@ -105,9 +105,10 @@ void QuicBatchWriterBuffer::UndoLastPush() { QuicBatchWriterBuffer::PopResult QuicBatchWriterBuffer::PopBufferedWrite( int32_t num_buffered_writes) { - DCHECK(Invariants()); - DCHECK_GE(num_buffered_writes, 0); - DCHECK_LE(static_cast<size_t>(num_buffered_writes), buffered_writes_.size()); + QUICHE_DCHECK(Invariants()); + QUICHE_DCHECK_GE(num_buffered_writes, 0); + QUICHE_DCHECK_LE(static_cast<size_t>(num_buffered_writes), + buffered_writes_.size()); PopResult result = {/*num_buffers_popped=*/0, /*moved_remaining_buffers=*/false}; @@ -135,9 +136,9 @@ QuicBatchWriterBuffer::PopResult QuicBatchWriterBuffer::PopBufferedWrite( buffered_write.buffer -= distance_to_move; } - DCHECK_EQ(buffer_, buffered_writes_.front().buffer); + QUICHE_DCHECK_EQ(buffer_, buffered_writes_.front().buffer); } - DCHECK(Invariants()); + QUICHE_DCHECK(Invariants()); return result; } diff --git a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_buffer.h b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_buffer.h index 88183f366b3..007c2834cc5 100644 --- a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_buffer.h +++ b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_buffer.h @@ -6,11 +6,11 @@ #define QUICHE_QUIC_PLATFORM_IMPL_BATCH_WRITER_QUIC_BATCH_WRITER_BUFFER_H_ #include "absl/base/optimization.h" -#include "net/third_party/quiche/src/quic/core/quic_circular_deque.h" -#include "net/third_party/quiche/src/quic/core/quic_linux_socket_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_writer.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/quic_circular_deque.h" +#include "quic/core/quic_linux_socket_utils.h" +#include "quic/core/quic_packet_writer.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_buffer_test.cc b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_buffer_test.cc index 4d9a46b258d..a234e5ede3a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_buffer_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_buffer_test.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_buffer.h" +#include "quic/core/batch_writer/quic_batch_writer_buffer.h" #include <memory> #include <string> -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.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 "quic/core/quic_constants.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_test.cc b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_test.cc index 11007616c6e..5f0dc9b0a53 100644 --- a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_test.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_test.h" -#include "net/third_party/quiche/src/quic/core/batch_writer/quic_gso_batch_writer.h" -#include "net/third_party/quiche/src/quic/core/batch_writer/quic_sendmmsg_batch_writer.h" +#include "quic/core/batch_writer/quic_batch_writer_test.h" +#include "quic/core/batch_writer/quic_gso_batch_writer.h" +#include "quic/core/batch_writer/quic_sendmmsg_batch_writer.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_test.h b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_test.h index adbcdc261e2..820100adabd 100644 --- a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_test.h +++ b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_test.h @@ -12,9 +12,9 @@ #include <iostream> #include <utility> -#include "net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_base.h" -#include "net/third_party/quiche/src/quic/core/quic_udp_socket.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/batch_writer/quic_batch_writer_base.h" +#include "quic/core/quic_udp_socket.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { @@ -45,7 +45,7 @@ static bool CreateSocket(int family, QuicSocketAddress* address, int* fd) { if (family == AF_INET) { *address = QuicSocketAddress(QuicIpAddress::Loopback4(), 0); } else { - DCHECK_EQ(family, AF_INET6); + QUICHE_DCHECK_EQ(family, AF_INET6); *address = QuicSocketAddress(QuicIpAddress::Loopback6(), 0); } diff --git a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_gso_batch_writer.cc b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_gso_batch_writer.cc index d83b83b3389..fa26516872e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_gso_batch_writer.cc +++ b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_gso_batch_writer.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/batch_writer/quic_gso_batch_writer.h" +#include "quic/core/batch_writer/quic_gso_batch_writer.h" #include <time.h> #include <ctime> -#include "net/third_party/quiche/src/quic/core/quic_linux_socket_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_server_stats.h" +#include "quic/core/quic_linux_socket_utils.h" +#include "quic/platform/api/quic_server_stats.h" namespace quic { @@ -101,7 +101,7 @@ QuicGsoBatchWriter::CanBatchResult QuicGsoBatchWriter::CanBatch( QuicGsoBatchWriter::ReleaseTime QuicGsoBatchWriter::GetReleaseTime( const PerPacketOptions* options) const { - DCHECK(SupportsReleaseTime()); + QUICHE_DCHECK(SupportsReleaseTime()); if (options == nullptr) { return {0, QuicTime::Delta::Zero()}; diff --git a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_gso_batch_writer.h b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_gso_batch_writer.h index 0c2fd1f99f7..75683d17b6d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_gso_batch_writer.h +++ b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_gso_batch_writer.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_PLATFORM_IMPL_BATCH_WRITER_QUIC_GSO_BATCH_WRITER_H_ #define QUICHE_QUIC_PLATFORM_IMPL_BATCH_WRITER_QUIC_GSO_BATCH_WRITER_H_ -#include "net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_base.h" +#include "quic/core/batch_writer/quic_batch_writer_base.h" namespace quic { @@ -61,8 +61,8 @@ class QUIC_EXPORT_PRIVATE QuicGsoBatchWriter : public QuicUdpBatchWriter { template <size_t CmsgSpace, typename CmsgBuilderT> FlushImplResult InternalFlushImpl(CmsgBuilderT cmsg_builder) { - DCHECK(!IsWriteBlocked()); - DCHECK(!buffered_writes().empty()); + QUICHE_DCHECK(!IsWriteBlocked()); + QUICHE_DCHECK(!buffered_writes().empty()); FlushImplResult result = {WriteResult(WRITE_STATUS_OK, 0), /*num_packets_sent=*/0, /*bytes_written=*/0}; diff --git a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_gso_batch_writer_test.cc b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_gso_batch_writer_test.cc index 731b19f07ff..ec08164e529 100644 --- a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_gso_batch_writer_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_gso_batch_writer_test.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/batch_writer/quic_gso_batch_writer.h" +#include "quic/core/batch_writer/quic_gso_batch_writer.h" #include <cstdint> #include <limits> #include <memory> #include <utility> -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_mock_syscall_wrapper.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_mock_syscall_wrapper.h" using testing::_; using testing::Invoke; diff --git a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_sendmmsg_batch_writer.cc b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_sendmmsg_batch_writer.cc index c0909a6f39d..ec8e4ae55be 100644 --- a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_sendmmsg_batch_writer.cc +++ b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_sendmmsg_batch_writer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/batch_writer/quic_sendmmsg_batch_writer.h" +#include "quic/core/batch_writer/quic_sendmmsg_batch_writer.h" namespace quic { @@ -32,8 +32,8 @@ QuicSendmmsgBatchWriter::FlushImplResult QuicSendmmsgBatchWriter::FlushImpl() { QuicSendmmsgBatchWriter::FlushImplResult QuicSendmmsgBatchWriter::InternalFlushImpl(size_t cmsg_space, const CmsgBuilder& cmsg_builder) { - DCHECK(!IsWriteBlocked()); - DCHECK(!buffered_writes().empty()); + QUICHE_DCHECK(!IsWriteBlocked()); + QUICHE_DCHECK(!buffered_writes().empty()); FlushImplResult result = {WriteResult(WRITE_STATUS_OK, 0), /*num_packets_sent=*/0, /*bytes_written=*/0}; @@ -52,7 +52,7 @@ QuicSendmmsgBatchWriter::InternalFlushImpl(size_t cmsg_space, << " packets. WriteResult=" << write_result; if (write_result.status != WRITE_STATUS_OK) { - DCHECK_EQ(0, num_packets_sent); + QUICHE_DCHECK_EQ(0, num_packets_sent); break; } else if (num_packets_sent == 0) { QUIC_BUG << "WriteMultiplePackets returned OK, but no packets were sent."; diff --git a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_sendmmsg_batch_writer.h b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_sendmmsg_batch_writer.h index 3b80395412a..5efcb1de48b 100644 --- a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_sendmmsg_batch_writer.h +++ b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_sendmmsg_batch_writer.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_PLATFORM_IMPL_QUIC_SENDMMSG_BATCH_WRITER_H_ #define QUICHE_QUIC_PLATFORM_IMPL_QUIC_SENDMMSG_BATCH_WRITER_H_ -#include "net/third_party/quiche/src/quic/core/batch_writer/quic_batch_writer_base.h" -#include "net/third_party/quiche/src/quic/core/quic_linux_socket_utils.h" +#include "quic/core/batch_writer/quic_batch_writer_base.h" +#include "quic/core/quic_linux_socket_utils.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_sendmmsg_batch_writer_test.cc b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_sendmmsg_batch_writer_test.cc index 4dcc33c91d3..1265fae7f78 100644 --- a/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_sendmmsg_batch_writer_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/batch_writer/quic_sendmmsg_batch_writer_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/batch_writer/quic_sendmmsg_batch_writer.h" +#include "quic/core/batch_writer/quic_sendmmsg_batch_writer.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/chlo_extractor.cc b/chromium/net/third_party/quiche/src/quic/core/chlo_extractor.cc index 851967a977f..198d455b724 100644 --- a/chromium/net/third_party/quiche/src/quic/core/chlo_extractor.cc +++ b/chromium/net/third_party/quiche/src/quic/core/chlo_extractor.cc @@ -2,21 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/chlo_extractor.h" +#include "quic/core/chlo_extractor.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_framer.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/crypto_framer.h" +#include "quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/crypto_handshake_message.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/crypto_utils.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/frames/quic_ack_frequency_frame.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_utils.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { @@ -45,7 +45,8 @@ class ChloFramerVisitor : public QuicFramerVisitorInterface, absl::string_view /*retry_without_tag*/) override {} bool OnUnauthenticatedPublicHeader(const QuicPacketHeader& header) override; bool OnUnauthenticatedHeader(const QuicPacketHeader& header) override; - void OnDecryptedPacket(EncryptionLevel /*level*/) override {} + void OnDecryptedPacket(size_t /*length*/, + EncryptionLevel /*level*/) override {} bool OnPacketHeader(const QuicPacketHeader& header) override; void OnCoalescedPacket(const QuicEncryptedPacket& packet) override; void OnUndecryptablePacket(const QuicEncryptedPacket& packet, diff --git a/chromium/net/third_party/quiche/src/quic/core/chlo_extractor.h b/chromium/net/third_party/quiche/src/quic/core/chlo_extractor.h index 89dffe16a24..4e5bbe1c871 100644 --- a/chromium/net/third_party/quiche/src/quic/core/chlo_extractor.h +++ b/chromium/net/third_party/quiche/src/quic/core/chlo_extractor.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_CORE_CHLO_EXTRACTOR_H_ #define QUICHE_QUIC_CORE_CHLO_EXTRACTOR_H_ -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" +#include "quic/core/crypto/crypto_handshake_message.h" +#include "quic/core/quic_packets.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/chlo_extractor_test.cc b/chromium/net/third_party/quiche/src/quic/core/chlo_extractor_test.cc index f051b9a821f..69006203cd4 100644 --- a/chromium/net/third_party/quiche/src/quic/core/chlo_extractor_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/chlo_extractor_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/chlo_extractor.h" +#include "quic/core/chlo_extractor.h" #include <memory> #include <string> @@ -10,12 +10,12 @@ #include "absl/base/macros.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/first_flight.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/first_flight.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bandwidth_sampler.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bandwidth_sampler.cc index 6eacef38e2e..babb6e35f0a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bandwidth_sampler.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bandwidth_sampler.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/bandwidth_sampler.h" +#include "quic/core/congestion_control/bandwidth_sampler.h" #include <algorithm> -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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 "quic/core/quic_types.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -168,15 +168,34 @@ void BandwidthSampler::OnPacketSent( if (!connection_state_map_.IsEmpty() && packet_number > connection_state_map_.last_packet() + max_tracked_packets_) { - if (unacked_packet_map_ != nullptr) { + if (unacked_packet_map_ != nullptr && !unacked_packet_map_->empty()) { + QuicPacketNumber maybe_least_unacked = + unacked_packet_map_->GetLeastUnacked(); QUIC_BUG << "BandwidthSampler in-flight packet map has exceeded maximum " "number of tracked packets(" << max_tracked_packets_ << "). First tracked: " << connection_state_map_.first_packet() << "; last tracked: " << connection_state_map_.last_packet() - << "; least unacked: " << unacked_packet_map_->GetLeastUnacked() - << "; packet number: " << packet_number << "; largest observed: " - << unacked_packet_map_->largest_acked(); + << "; entry_slots_used: " + << connection_state_map_.entry_slots_used() + << "; number_of_present_entries: " + << connection_state_map_.number_of_present_entries() + << "; packet number: " << packet_number + << "; unacked_map: " << unacked_packet_map_->DebugString() + << "; total_bytes_sent: " << total_bytes_sent_ + << "; total_bytes_acked: " << total_bytes_acked_ + << "; total_bytes_lost: " << total_bytes_lost_ + << "; total_bytes_neutered: " << total_bytes_neutered_ + << "; last_acked_packet_sent_time: " + << last_acked_packet_sent_time_ + << "; total_bytes_sent_at_last_acked_packet: " + << total_bytes_sent_at_last_acked_packet_ + << "; least_unacked_packet_info: " + << (unacked_packet_map_->IsUnacked(maybe_least_unacked) + ? unacked_packet_map_ + ->GetTransmissionInfo(maybe_least_unacked) + .DebugString() + : "n/a"); } else { QUIC_BUG << "BandwidthSampler in-flight packet map has exceeded maximum " "number of tracked packets."; diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bandwidth_sampler.h b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bandwidth_sampler.h index 2d06560f2bc..7a34097fd54 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bandwidth_sampler.h +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bandwidth_sampler.h @@ -5,17 +5,17 @@ #ifndef QUICHE_QUIC_CORE_CONGESTION_CONTROL_BANDWIDTH_SAMPLER_H_ #define QUICHE_QUIC_CORE_CONGESTION_CONTROL_BANDWIDTH_SAMPLER_H_ -#include "net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/windowed_filter.h" -#include "net/third_party/quiche/src/quic/core/packet_number_indexed_queue.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_circular_deque.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_unacked_packet_map.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "quic/core/congestion_control/send_algorithm_interface.h" +#include "quic/core/congestion_control/windowed_filter.h" +#include "quic/core/packet_number_indexed_queue.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_circular_deque.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_unacked_packet_map.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_flags.h" namespace quic { @@ -369,7 +369,7 @@ class QUIC_EXPORT_PRIVATE BandwidthSampler : public BandwidthSamplerInterface { class QUIC_NO_EXPORT RecentAckPoints { public: void Update(QuicTime ack_time, QuicByteCount total_bytes_acked) { - DCHECK_GE(total_bytes_acked, ack_points_[1].total_bytes_acked); + QUICHE_DCHECK_GE(total_bytes_acked, ack_points_[1].total_bytes_acked); if (ack_time < ack_points_[1].ack_time) { // This can only happen when time goes backwards, we use the smaller diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bandwidth_sampler_test.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bandwidth_sampler_test.cc index f689553bc5b..67dad1cb675 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bandwidth_sampler_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bandwidth_sampler_test.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/bandwidth_sampler.h" +#include "quic/core/congestion_control/bandwidth_sampler.h" #include <cstdint> #include <set> -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#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_test.h" -#include "net/third_party/quiche/src/quic/test_tools/mock_clock.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_drain.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_drain.cc index 60226392d57..69befb51531 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_drain.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_drain.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_drain.h" +#include "quic/core/congestion_control/bbr2_drain.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_sender.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/congestion_control/bbr2_sender.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -18,29 +18,28 @@ Bbr2Mode Bbr2DrainMode::OnCongestionEvent( model_->set_pacing_gain(Params().drain_pacing_gain); // Only STARTUP can transition to DRAIN, both of them use the same cwnd gain. - DCHECK_EQ(model_->cwnd_gain(), Params().drain_cwnd_gain); + QUICHE_DCHECK_EQ(model_->cwnd_gain(), Params().drain_cwnd_gain); model_->set_cwnd_gain(Params().drain_cwnd_gain); QuicByteCount drain_target = DrainTarget(); if (congestion_event.bytes_in_flight <= drain_target) { QUIC_DVLOG(3) << sender_ << " Exiting DRAIN. bytes_in_flight:" << congestion_event.bytes_in_flight - << ", bdp:" << model_->BDP(model_->MaxBandwidth()) + << ", bdp:" << model_->BDP() << ", drain_target:" << drain_target << " @ " << congestion_event.event_time; return Bbr2Mode::PROBE_BW; } QUIC_DVLOG(3) << sender_ << " Staying in DRAIN. bytes_in_flight:" - << congestion_event.bytes_in_flight - << ", bdp:" << model_->BDP(model_->MaxBandwidth()) + << congestion_event.bytes_in_flight << ", bdp:" << model_->BDP() << ", drain_target:" << drain_target << " @ " << congestion_event.event_time; return Bbr2Mode::DRAIN; } QuicByteCount Bbr2DrainMode::DrainTarget() const { - QuicByteCount bdp = model_->BDP(model_->MaxBandwidth()); + QuicByteCount bdp = model_->BDP(); return std::max<QuicByteCount>(bdp, sender_->GetMinimumCongestionWindow()); } diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_drain.h b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_drain.h index 548db8b07d4..3026320f72d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_drain.h +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_drain.h @@ -5,10 +5,10 @@ #ifndef QUICHE_QUIC_CORE_CONGESTION_CONTROL_BBR2_DRAIN_H_ #define QUICHE_QUIC_CORE_CONGESTION_CONTROL_BBR2_DRAIN_H_ -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_misc.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/congestion_control/bbr2_misc.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_misc.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_misc.cc index 3e3937a4e52..dfb834cd05b 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_misc.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_misc.cc @@ -2,21 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_misc.h" +#include "quic/core/congestion_control/bbr2_misc.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bandwidth_sampler.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/congestion_control/bandwidth_sampler.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_logging.h" namespace quic { RoundTripCounter::RoundTripCounter() : round_trip_count_(0) {} void RoundTripCounter::OnPacketSent(QuicPacketNumber packet_number) { - DCHECK(!last_sent_packet_.IsInitialized() || - last_sent_packet_ < packet_number); + QUICHE_DCHECK(!last_sent_packet_.IsInitialized() || + last_sent_packet_ < packet_number); last_sent_packet_ = packet_number; } @@ -148,8 +149,7 @@ void Bbr2NetworkModel::OnCongestionEventStart( loss_events_in_round_++; } - if (GetQuicReloadableFlag(quic_bbr2_startup_loss_exit_use_max_delivered) && - congestion_event->bytes_acked > 0 && + if (congestion_event->bytes_acked > 0 && congestion_event->last_packet_send_state.is_valid && total_bytes_acked() > congestion_event->last_packet_send_state.total_bytes_acked) { @@ -169,13 +169,13 @@ void Bbr2NetworkModel::OnCongestionEventStart( inflight_latest_ = sample.sample_max_inflight; } + // Adapt lower bounds(bandwidth_lo and inflight_lo). + AdaptLowerBounds(*congestion_event); + if (!congestion_event->end_of_round_trip) { return; } - // Per round-trip updates. - AdaptLowerBounds(*congestion_event); - if (!sample.sample_max_bandwidth.IsZero()) { bandwidth_latest_ = sample.sample_max_bandwidth; } @@ -187,6 +187,63 @@ void Bbr2NetworkModel::OnCongestionEventStart( void Bbr2NetworkModel::AdaptLowerBounds( const Bbr2CongestionEvent& congestion_event) { + if (Params().bw_lo_mode_ != Bbr2Params::DEFAULT) { + QUICHE_DCHECK(Params().bw_startup); + if (congestion_event.bytes_lost == 0) { + return; + } + // Ignore losses from packets sent when probing for more bandwidth in + // STARTUP or PROBE_UP when they're lost in DRAIN or PROBE_DOWN. + if (pacing_gain_ < 1) { + return; + } + // Decrease bandwidth_lo whenever there is loss. + // Set bandwidth_lo_ if it is not yet set. + if (bandwidth_lo_.IsInfinite()) { + bandwidth_lo_ = MaxBandwidth(); + } + switch (Params().bw_lo_mode_) { + case Bbr2Params::MIN_RTT_REDUCTION: + bandwidth_lo_ = + bandwidth_lo_ - QuicBandwidth::FromBytesAndTimeDelta( + congestion_event.bytes_lost, MinRtt()); + break; + case Bbr2Params::INFLIGHT_REDUCTION: { + // Use a max of BDP and inflight to avoid starving app-limited flows. + const QuicByteCount effective_inflight = + std::max(BDP(), congestion_event.prior_bytes_in_flight); + // This could use bytes_lost_in_round if the bandwidth_lo_ was saved + // when entering 'recovery', but this BBRv2 implementation doesn't have + // recovery defined. + bandwidth_lo_ = bandwidth_lo_ * + ((effective_inflight - congestion_event.bytes_lost) / + static_cast<double>(effective_inflight)); + break; + } + case Bbr2Params::CWND_REDUCTION: + bandwidth_lo_ = + bandwidth_lo_ * + ((congestion_event.prior_cwnd - congestion_event.bytes_lost) / + static_cast<double>(congestion_event.prior_cwnd)); + break; + case Bbr2Params::DEFAULT: + QUIC_BUG << "Unreachable case DEFAULT."; + } + if (pacing_gain_ > Params().startup_full_bw_threshold) { + // In STARTUP, pacing_gain_ is applied to bandwidth_lo_, so this backs + // that multiplication out to allow the pacing rate to decrease, + // but not below bandwidth_latest_ * startup_full_bw_threshold. + bandwidth_lo_ = + std::max(bandwidth_lo_, + bandwidth_latest_ * + (Params().startup_full_bw_threshold / pacing_gain_)); + } else { + // Ensure bandwidth_lo isn't lower than bandwidth_latest_. + bandwidth_lo_ = std::max(bandwidth_lo_, bandwidth_latest_); + } + // This early return ignores inflight_lo as well. + return; + } if (!congestion_event.end_of_round_trip || congestion_event.is_probing_for_bandwidth) { return; @@ -216,8 +273,13 @@ void Bbr2NetworkModel::OnCongestionEventFinish( QuicPacketNumber least_unacked_packet, const Bbr2CongestionEvent& congestion_event) { if (congestion_event.end_of_round_trip) { - bytes_lost_in_round_ = 0; - loss_events_in_round_ = 0; + if (!reset_max_bytes_delivered_) { + bytes_lost_in_round_ = 0; + loss_events_in_round_ = 0; + } else { + QUIC_RELOADABLE_FLAG_COUNT_N(quic_bbr2_reset_max_bytes_delivered, 1, 2); + OnNewRound(); + } } bandwidth_sampler_.RemoveObsoletePackets(least_unacked_packet); @@ -291,15 +353,25 @@ bool Bbr2NetworkModel::IsInflightTooHigh( return false; } -void Bbr2NetworkModel::RestartRound() { - bytes_lost_in_round_ = 0; - loss_events_in_round_ = 0; - if (GetQuicReloadableFlag(quic_bbr2_startup_loss_exit_use_max_delivered)) { +void Bbr2NetworkModel::RestartRoundEarly() { + if (!reset_max_bytes_delivered_) { + bytes_lost_in_round_ = 0; + loss_events_in_round_ = 0; max_bytes_delivered_in_round_ = 0; + } else { + QUIC_RELOADABLE_FLAG_COUNT_N(quic_bbr2_reset_max_bytes_delivered, 2, 2); + OnNewRound(); } round_trip_counter_.RestartRound(); } +void Bbr2NetworkModel::OnNewRound() { + QUICHE_DCHECK(reset_max_bytes_delivered_); + bytes_lost_in_round_ = 0; + loss_events_in_round_ = 0; + max_bytes_delivered_in_round_ = 0; +} + void Bbr2NetworkModel::cap_inflight_lo(QuicByteCount cap) { if (Params().ignore_inflight_lo) { return; @@ -315,4 +387,39 @@ QuicByteCount Bbr2NetworkModel::inflight_hi_with_headroom() const { return inflight_hi_ > headroom ? inflight_hi_ - headroom : 0; } +Bbr2NetworkModel::BandwidthGrowth Bbr2NetworkModel::CheckBandwidthGrowth( + const Bbr2CongestionEvent& congestion_event) { + QUICHE_DCHECK(!full_bandwidth_reached_); + QUICHE_DCHECK(congestion_event.end_of_round_trip); + if (congestion_event.last_sample_is_app_limited) { + return APP_LIMITED; + } + + QuicBandwidth threshold = + full_bandwidth_baseline_ * Params().startup_full_bw_threshold; + + if (MaxBandwidth() >= threshold) { + QUIC_DVLOG(3) << " CheckBandwidthGrowth at end of round. max_bandwidth:" + << MaxBandwidth() << ", threshold:" << threshold + << " (Still growing) @ " << congestion_event.event_time; + full_bandwidth_baseline_ = MaxBandwidth(); + rounds_without_bandwidth_growth_ = 0; + return GROWTH; + } + + ++rounds_without_bandwidth_growth_; + BandwidthGrowth return_value = NO_GROWTH; + if (rounds_without_bandwidth_growth_ >= Params().startup_full_bw_rounds) { + full_bandwidth_reached_ = true; + return_value = EXIT; + } + QUIC_DVLOG(3) << " CheckBandwidthGrowth at end of round. max_bandwidth:" + << MaxBandwidth() << ", threshold:" << threshold + << " rounds_without_growth:" << rounds_without_bandwidth_growth_ + << " full_bw_reached:" << full_bandwidth_reached_ << " @ " + << congestion_event.event_time; + + return return_value; +} + } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_misc.h b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_misc.h index 1109e08c673..8b53c1b741d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_misc.h +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_misc.h @@ -8,15 +8,14 @@ #include <algorithm> #include <limits> -#include "net/third_party/quiche/src/quic/core/congestion_control/bandwidth_sampler.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/windowed_filter.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_number.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/quic/platform/impl/quic_export_impl.h" +#include "quic/core/congestion_control/bandwidth_sampler.h" +#include "quic/core/congestion_control/windowed_filter.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_packet_number.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_flags.h" namespace quic { @@ -187,8 +186,31 @@ struct QUIC_EXPORT_PRIVATE Bbr2Params { // Can be enabled by connection option 'B2H2'. bool limit_inflight_hi_by_max_delivered = false; - // Can be enabled by connection option 'B2SL'. - bool startup_loss_exit_use_max_delivered_for_inflight_hi = false; + // Can be disabled by connection option 'B2SL'. + bool startup_loss_exit_use_max_delivered_for_inflight_hi = true; + + // Can be enabled by connection option 'B2DL'. + bool use_bytes_delivered_for_inflight_hi = false; + + // Can be disabled by connection option 'B2RC'. + bool enable_reno_coexistence = true; + + // For experimentation to improve fast convergence upon loss. + enum QuicBandwidthLoMode : uint8_t { + DEFAULT = 0, + MIN_RTT_REDUCTION = 1, // 'BBQ7' + INFLIGHT_REDUCTION = 2, // 'BBQ8' + CWND_REDUCTION = 3, // 'BBQ9' + }; + + // Different modes change bandwidth_lo_ differently upon loss. + QuicBandwidthLoMode bw_lo_mode_ = QuicBandwidthLoMode::DEFAULT; + + // Set the pacing gain to 25% larger than the recent BW increase in STARTUP. + bool decrease_startup_pacing_at_end_of_round = false; + + // Latch the flag for quic_bbr2_bw_startup. + const bool bw_startup = GetQuicReloadableFlag(quic_bbr2_bw_startup); }; class QUIC_EXPORT_PRIVATE RoundTripCounter { @@ -336,12 +358,15 @@ class QUIC_EXPORT_PRIVATE Bbr2NetworkModel { void AdaptLowerBounds(const Bbr2CongestionEvent& congestion_event); // Restart the current round trip as if it is starting now. - void RestartRound(); + void RestartRoundEarly(); void AdvanceMaxBandwidthFilter() { max_bandwidth_filter_.Advance(); } void OnApplicationLimited() { bandwidth_sampler_.OnAppLimited(); } + // Calculates BDP using the current MaxBandwidth. + QuicByteCount BDP() const { return BDP(MaxBandwidth()); } + QuicByteCount BDP(QuicBandwidth bandwidth) const { return bandwidth * MinRtt(); } @@ -400,6 +425,23 @@ class QUIC_EXPORT_PRIVATE Bbr2NetworkModel { bool IsInflightTooHigh(const Bbr2CongestionEvent& congestion_event, int64_t max_loss_events) const; + enum BandwidthGrowth { + APP_LIMITED = 0, + NO_GROWTH = 1, + GROWTH = 2, + EXIT = 3, // Too many rounds without bandwidth growth. + }; + + // Check bandwidth growth in the past round. Must be called at the end of a + // round. + // Return APP_LIMITED if the bandwidth sample was app-limited. + // Return GROWTH if the bandwidth grew as expected. + // Return NO_GROWTH if the bandwidth didn't increase enough. + // Return TOO_MANY_ROUNDS_WITH_NO_GROWTH if enough rounds have elapsed without + // growth, also sets |full_bandwidth_reached_| to true. + BandwidthGrowth CheckBandwidthGrowth( + const Bbr2CongestionEvent& congestion_event); + QuicPacketNumber last_sent_packet() const { return round_trip_counter_.last_sent_packet(); } @@ -456,7 +498,19 @@ class QUIC_EXPORT_PRIVATE Bbr2NetworkModel { float pacing_gain() const { return pacing_gain_; } void set_pacing_gain(float pacing_gain) { pacing_gain_ = pacing_gain; } + bool full_bandwidth_reached() const { return full_bandwidth_reached_; } + void set_full_bandwidth_reached() { full_bandwidth_reached_ = true; } + QuicBandwidth full_bandwidth_baseline() const { + return full_bandwidth_baseline_; + } + QuicRoundTripCount rounds_without_bandwidth_growth() const { + return rounds_without_bandwidth_growth_; + } + private: + // Called when a new round trip starts. + void OnNewRound(); + const Bbr2Params& Params() const { return *params_; } const Bbr2Params* const params_; RoundTripCounter round_trip_counter_; @@ -493,6 +547,13 @@ class QUIC_EXPORT_PRIVATE Bbr2NetworkModel { float cwnd_gain_; float pacing_gain_; + + // STARTUP-centric fields which experimentally used by PROBE_UP. + bool full_bandwidth_reached_ = false; + QuicBandwidth full_bandwidth_baseline_ = QuicBandwidth::Zero(); + QuicRoundTripCount rounds_without_bandwidth_growth_ = 0; + const bool reset_max_bytes_delivered_ = + GetQuicReloadableFlag(quic_bbr2_reset_max_bytes_delivered); }; enum class Bbr2Mode : uint8_t { @@ -562,7 +623,7 @@ class QUIC_EXPORT_PRIVATE Bbr2ModeBase { QUIC_EXPORT_PRIVATE inline QuicByteCount BytesInFlight( const SendTimeState& send_state) { - DCHECK(send_state.is_valid); + QUICHE_DCHECK(send_state.is_valid); if (send_state.bytes_in_flight != 0) { return send_state.bytes_in_flight; } diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_bw.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_bw.cc index 0b8991cb86b..78bd06d4b24 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_bw.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_bw.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_bw.h" +#include "quic/core/congestion_control/bbr2_probe_bw.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_misc.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_sender.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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 "quic/core/congestion_control/bbr2_misc.h" +#include "quic/core/congestion_control/bbr2_sender.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -24,8 +24,8 @@ void Bbr2ProbeBwMode::Enter(QuicTime now, } else { // Transitioning from PROBE_RTT to PROBE_BW. Re-enter the last phase before // PROBE_RTT. - DCHECK(cycle_.phase == CyclePhase::PROBE_CRUISE || - cycle_.phase == CyclePhase::PROBE_REFILL); + QUICHE_DCHECK(cycle_.phase == CyclePhase::PROBE_CRUISE || + cycle_.phase == CyclePhase::PROBE_REFILL); cycle_.cycle_start_time = now; if (cycle_.phase == CyclePhase::PROBE_CRUISE) { EnterProbeCruise(now); @@ -41,7 +41,7 @@ Bbr2Mode Bbr2ProbeBwMode::OnCongestionEvent( const AckedPacketVector& /*acked_packets*/, const LostPacketVector& /*lost_packets*/, const Bbr2CongestionEvent& congestion_event) { - DCHECK_NE(cycle_.phase, CyclePhase::PROBE_NOT_STARTED); + QUICHE_DCHECK_NE(cycle_.phase, CyclePhase::PROBE_NOT_STARTED); if (congestion_event.end_of_round_trip) { if (cycle_.cycle_start_time != event_time) { @@ -126,10 +126,11 @@ Bbr2Mode Bbr2ProbeBwMode::OnExitQuiescence(QuicTime now, return Bbr2Mode::PROBE_BW; } +// TODO(ianswett): Remove prior_in_flight from UpdateProbeDown. void Bbr2ProbeBwMode::UpdateProbeDown( QuicByteCount prior_in_flight, const Bbr2CongestionEvent& congestion_event) { - DCHECK_EQ(cycle_.phase, CyclePhase::PROBE_DOWN); + QUICHE_DCHECK_EQ(cycle_.phase, CyclePhase::PROBE_DOWN); if (cycle_.rounds_in_phase == 1 && congestion_event.end_of_round_trip) { cycle_.is_sample_from_probing = false; @@ -169,20 +170,15 @@ void Bbr2ProbeBwMode::UpdateProbeDown( << prior_in_flight << " congestion_event.bytes_in_flight:" << congestion_event.bytes_in_flight << ", inflight_with_headroom:" << inflight_with_headroom; - QuicByteCount bytes_in_flight = prior_in_flight; - if (GetQuicReloadableFlag(quic_bbr2_use_post_inflight_to_detect_queuing)) { - // TODO(ianswett): Remove prior_in_flight from UpdateProbeDown. - QUIC_RELOADABLE_FLAG_COUNT_N(quic_bbr2_use_post_inflight_to_detect_queuing, - 2, 2); - bytes_in_flight = congestion_event.bytes_in_flight; - } + QuicByteCount bytes_in_flight = congestion_event.bytes_in_flight; + if (bytes_in_flight > inflight_with_headroom) { // Stay in PROBE_DOWN. return; } // Transition to PROBE_CRUISE iff we've drained to target. - QuicByteCount bdp = model_->BDP(model_->MaxBandwidth()); + QuicByteCount bdp = model_->BDP(); QUIC_DVLOG(3) << sender_ << " Checking if drained to target. bytes_in_flight:" << bytes_in_flight << ", bdp:" << bdp; if (bytes_in_flight < bdp) { @@ -199,14 +195,28 @@ Bbr2ProbeBwMode::AdaptUpperBoundsResult Bbr2ProbeBwMode::MaybeAdaptUpperBounds( return NOT_ADAPTED_INVALID_SAMPLE; } + // TODO(ianswett): Rename to bytes_delivered if + // use_bytes_delivered_for_inflight_hi is default enabled. + QuicByteCount inflight_at_send = BytesInFlight(send_state); + if (Params().use_bytes_delivered_for_inflight_hi) { + if (congestion_event.last_packet_send_state.total_bytes_acked <= + model_->total_bytes_acked()) { + inflight_at_send = + model_->total_bytes_acked() - + congestion_event.last_packet_send_state.total_bytes_acked; + } else { + QUIC_BUG << "Total_bytes_acked(" << model_->total_bytes_acked() + << ") < send_state.total_bytes_acked(" + << congestion_event.last_packet_send_state.total_bytes_acked + << ")"; + } + } if (model_->IsInflightTooHigh(congestion_event, Params().probe_bw_full_loss_count)) { if (cycle_.is_sample_from_probing) { cycle_.is_sample_from_probing = false; if (!send_state.is_app_limited) { - const QuicByteCount inflight_at_send = BytesInFlight(send_state); - const QuicByteCount inflight_target = sender_->GetTargetBytesInflight() * (1.0 - Params().beta); if (inflight_at_send >= inflight_target) { @@ -252,8 +262,6 @@ Bbr2ProbeBwMode::AdaptUpperBoundsResult Bbr2ProbeBwMode::MaybeAdaptUpperBounds( return NOT_ADAPTED_INFLIGHT_HIGH_NOT_SET; } - const QuicByteCount inflight_at_send = BytesInFlight(send_state); - // Raise the upper bound for inflight. if (inflight_at_send > model_->inflight_hi()) { QUIC_DVLOG(3) @@ -317,6 +325,10 @@ bool Bbr2ProbeBwMode::HasPhaseLasted( bool Bbr2ProbeBwMode::IsTimeToProbeForRenoCoexistence( double probe_wait_fraction, const Bbr2CongestionEvent& /*congestion_event*/) const { + if (!Params().enable_reno_coexistence) { + return false; + } + uint64_t rounds = Params().probe_bw_probe_max_rounds; if (Params().probe_bw_probe_reno_gain > 0.0) { QuicByteCount target_bytes_inflight = sender_->GetTargetBytesInflight(); @@ -334,7 +346,7 @@ bool Bbr2ProbeBwMode::IsTimeToProbeForRenoCoexistence( } void Bbr2ProbeBwMode::RaiseInflightHighSlope() { - DCHECK_EQ(cycle_.phase, CyclePhase::PROBE_UP); + QUICHE_DCHECK_EQ(cycle_.phase, CyclePhase::PROBE_UP); uint64_t growth_this_round = 1 << cycle_.probe_up_rounds; // The number 30 below means |growth_this_round| is capped at 1G and the lower // bound of |probe_up_bytes| is (practically) 1 mss, at this speed inflight_hi @@ -350,7 +362,7 @@ void Bbr2ProbeBwMode::RaiseInflightHighSlope() { void Bbr2ProbeBwMode::ProbeInflightHighUpward( const Bbr2CongestionEvent& congestion_event) { - DCHECK_EQ(cycle_.phase, CyclePhase::PROBE_UP); + QUICHE_DCHECK_EQ(cycle_.phase, CyclePhase::PROBE_UP); if (!model_->IsCongestionWindowLimited(congestion_event)) { QUIC_DVLOG(3) << sender_ << " Raising inflight_hi early return: Not cwnd limited."; @@ -394,9 +406,9 @@ void Bbr2ProbeBwMode::ProbeInflightHighUpward( void Bbr2ProbeBwMode::UpdateProbeCruise( const Bbr2CongestionEvent& congestion_event) { - DCHECK_EQ(cycle_.phase, CyclePhase::PROBE_CRUISE); + QUICHE_DCHECK_EQ(cycle_.phase, CyclePhase::PROBE_CRUISE); MaybeAdaptUpperBounds(congestion_event); - DCHECK(!cycle_.is_sample_from_probing); + QUICHE_DCHECK(!cycle_.is_sample_from_probing); if (IsTimeToProbeBandwidth(congestion_event)) { EnterProbeRefill(/*probe_up_rounds=*/0, congestion_event.event_time); @@ -406,9 +418,9 @@ void Bbr2ProbeBwMode::UpdateProbeCruise( void Bbr2ProbeBwMode::UpdateProbeRefill( const Bbr2CongestionEvent& congestion_event) { - DCHECK_EQ(cycle_.phase, CyclePhase::PROBE_REFILL); + QUICHE_DCHECK_EQ(cycle_.phase, CyclePhase::PROBE_REFILL); MaybeAdaptUpperBounds(congestion_event); - DCHECK(!cycle_.is_sample_from_probing); + QUICHE_DCHECK(!cycle_.is_sample_from_probing); if (cycle_.rounds_in_phase > 0 && congestion_event.end_of_round_trip) { EnterProbeUp(congestion_event.event_time); @@ -419,7 +431,7 @@ void Bbr2ProbeBwMode::UpdateProbeRefill( void Bbr2ProbeBwMode::UpdateProbeUp( QuicByteCount prior_in_flight, const Bbr2CongestionEvent& congestion_event) { - DCHECK_EQ(cycle_.phase, CyclePhase::PROBE_UP); + QUICHE_DCHECK_EQ(cycle_.phase, CyclePhase::PROBE_UP); if (MaybeAdaptUpperBounds(congestion_event) == ADAPTED_PROBED_TOO_HIGH) { EnterProbeDown(/*probed_too_high=*/true, /*stopped_risky_probe=*/false, congestion_event.event_time); @@ -442,7 +454,7 @@ void Bbr2ProbeBwMode::UpdateProbeUp( // TCP uses min_rtt instead of a full round: // HasPhaseLasted(model_->MinRtt(), congestion_event) } else if (cycle_.rounds_in_phase > 0) { - const QuicByteCount bdp = model_->BDP(model_->MaxBandwidth()); + const QuicByteCount bdp = model_->BDP(); QuicByteCount queuing_threshold_extra_bytes = 2 * kDefaultTCPMSS; if (Params().add_ack_height_to_queueing_threshold) { queuing_threshold_extra_bytes += model_->MaxAckHeight(); @@ -450,13 +462,9 @@ void Bbr2ProbeBwMode::UpdateProbeUp( QuicByteCount queuing_threshold = (Params().probe_bw_probe_inflight_gain * bdp) + queuing_threshold_extra_bytes; - if (GetQuicReloadableFlag(quic_bbr2_use_post_inflight_to_detect_queuing)) { - QUIC_RELOADABLE_FLAG_COUNT_N( - quic_bbr2_use_post_inflight_to_detect_queuing, 1, 2); - is_queuing = congestion_event.bytes_in_flight >= queuing_threshold; - } else { - is_queuing = prior_in_flight >= queuing_threshold; - } + + is_queuing = congestion_event.bytes_in_flight >= queuing_threshold; + QUIC_DVLOG(3) << sender_ << " Checking if building up a queue. prior_in_flight:" << prior_in_flight @@ -502,7 +510,7 @@ void Bbr2ProbeBwMode::EnterProbeDown(bool probed_too_high, cycle_.probe_up_bytes = std::numeric_limits<QuicByteCount>::max(); cycle_.has_advanced_max_bw = false; - model_->RestartRound(); + model_->RestartRoundEarly(); } void Bbr2ProbeBwMode::EnterProbeCruise(QuicTime now) { @@ -541,11 +549,11 @@ void Bbr2ProbeBwMode::EnterProbeRefill(uint64_t probe_up_rounds, QuicTime now) { model_->clear_inflight_lo(); cycle_.probe_up_rounds = probe_up_rounds; cycle_.probe_up_acked = 0; - model_->RestartRound(); + model_->RestartRoundEarly(); } void Bbr2ProbeBwMode::EnterProbeUp(QuicTime now) { - DCHECK_EQ(cycle_.phase, CyclePhase::PROBE_REFILL); + QUICHE_DCHECK_EQ(cycle_.phase, CyclePhase::PROBE_REFILL); QUIC_DVLOG(2) << sender_ << " Phase change: " << cycle_.phase << " ==> " << CyclePhase::PROBE_UP << " after " << now - cycle_.phase_start_time << ", or " @@ -556,11 +564,11 @@ void Bbr2ProbeBwMode::EnterProbeUp(QuicTime now) { cycle_.is_sample_from_probing = true; RaiseInflightHighSlope(); - model_->RestartRound(); + model_->RestartRoundEarly(); } void Bbr2ProbeBwMode::ExitProbeDown() { - DCHECK_EQ(cycle_.phase, CyclePhase::PROBE_DOWN); + QUICHE_DCHECK_EQ(cycle_.phase, CyclePhase::PROBE_DOWN); if (!cycle_.has_advanced_max_bw) { QUIC_DVLOG(2) << sender_ << " Advancing max bw filter at end of cycle."; model_->AdvanceMaxBandwidthFilter(); diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_bw.h b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_bw.h index 5c0224ff974..45b1df70c5c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_bw.h +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_bw.h @@ -7,11 +7,11 @@ #include <cstdint> -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_misc.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "quic/core/congestion_control/bbr2_misc.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_flags.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_rtt.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_rtt.cc index ec5cf7c700d..d83e5e67739 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_rtt.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_rtt.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_rtt.h" +#include "quic/core/congestion_control/bbr2_probe_rtt.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_sender.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/congestion_control/bbr2_sender.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_logging.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_rtt.h b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_rtt.h index 156fda52fd6..7d3873d47b4 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_rtt.h +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_rtt.h @@ -5,10 +5,10 @@ #ifndef QUICHE_QUIC_CORE_CONGESTION_CONTROL_BBR2_PROBE_RTT_H_ #define QUICHE_QUIC_CORE_CONGESTION_CONTROL_BBR2_PROBE_RTT_H_ -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_misc.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/congestion_control/bbr2_misc.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_sender.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_sender.cc index c3abffec147..a29d7aea3c2 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_sender.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_sender.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_sender.h" +#include "quic/core/congestion_control/bbr2_sender.h" #include <cstddef> -#include "net/third_party/quiche/src/quic/core/congestion_control/bandwidth_sampler.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_drain.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_misc.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_tag.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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 "quic/core/congestion_control/bandwidth_sampler.h" +#include "quic/core/congestion_control/bbr2_drain.h" +#include "quic/core/congestion_control/bbr2_misc.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_tag.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -76,9 +76,8 @@ Bbr2Sender::Bbr2Sender(QuicTime now, /*pacing_gain=*/kInitialPacingGain, old_sender ? &old_sender->sampler_ : nullptr), initial_cwnd_(cwnd_limits().ApplyLimits( - (GetQuicReloadableFlag(quic_copy_bbr_cwnd_to_bbr2) && old_sender) - ? old_sender->GetCongestionWindow() - : (initial_cwnd_in_packets * kDefaultTCPMSS))), + (old_sender) ? old_sender->GetCongestionWindow() + : (initial_cwnd_in_packets * kDefaultTCPMSS))), cwnd_(initial_cwnd_), pacing_rate_(kInitialPacingGain * QuicBandwidth::FromBytesAndTimeDelta( cwnd_, @@ -88,14 +87,10 @@ Bbr2Sender::Bbr2Sender(QuicTime now, probe_bw_(this, &model_), probe_rtt_(this, &model_), last_sample_is_app_limited_(false) { - if (GetQuicReloadableFlag(quic_copy_bbr_cwnd_to_bbr2) && old_sender) { - QUIC_RELOADABLE_FLAG_COUNT(quic_copy_bbr_cwnd_to_bbr2); - } - QUIC_DVLOG(2) << this << " Initializing Bbr2Sender. mode:" << mode_ << ", PacingRate:" << pacing_rate_ << ", Cwnd:" << cwnd_ << ", CwndLimits:" << cwnd_limits() << " @ " << now; - DCHECK_EQ(mode_, Bbr2Mode::STARTUP); + QUICHE_DCHECK_EQ(mode_, Bbr2Mode::STARTUP); } void Bbr2Sender::SetFromConfig(const QuicConfig& config, @@ -123,14 +118,10 @@ void Bbr2Sender::SetFromConfig(const QuicConfig& config, if (config.HasClientRequestedIndependentOption(kB2LO, perspective)) { params_.ignore_inflight_lo = true; } - if (GetQuicReloadableFlag(quic_bbr2_use_tcp_inflight_hi_headroom) && - config.HasClientRequestedIndependentOption(kB2HR, perspective)) { - QUIC_RELOADABLE_FLAG_COUNT(quic_bbr2_use_tcp_inflight_hi_headroom); + if (config.HasClientRequestedIndependentOption(kB2HR, perspective)) { params_.inflight_hi_headroom = 0.15; } - if (GetQuicReloadableFlag(quic_bbr2_support_max_bootstrap_cwnd) && - config.HasClientRequestedIndependentOption(kICW1, perspective)) { - QUIC_RELOADABLE_FLAG_COUNT_N(quic_bbr2_support_max_bootstrap_cwnd, 1, 4); + if (config.HasClientRequestedIndependentOption(kICW1, perspective)) { max_cwnd_when_network_parameters_adjusted_ = 100 * kDefaultTCPMSS; } @@ -142,24 +133,46 @@ void Bbr2Sender::ApplyConnectionOptions( if (ContainsQuicTag(connection_options, kBBQ2)) { params_.startup_cwnd_gain = 2.885; params_.drain_cwnd_gain = 2.885; + if (params_.bw_startup) { + model_.set_cwnd_gain(params_.startup_cwnd_gain); + } } - if (GetQuicReloadableFlag(quic_bbr2_no_exit_startup_on_loss_with_bw_growth) && - ContainsQuicTag(connection_options, kB2NE)) { - QUIC_RELOADABLE_FLAG_COUNT( - quic_bbr2_no_exit_startup_on_loss_with_bw_growth); + if (ContainsQuicTag(connection_options, kB2NE)) { params_.always_exit_startup_on_excess_loss = false; } - if (GetQuicReloadableFlag(quic_bbr2_startup_loss_exit_use_max_delivered) && - ContainsQuicTag(connection_options, kB2SL)) { - params_.startup_loss_exit_use_max_delivered_for_inflight_hi = true; + if (ContainsQuicTag(connection_options, kB2SL)) { + params_.startup_loss_exit_use_max_delivered_for_inflight_hi = false; } - if (GetQuicReloadableFlag(quic_bbr2_startup_loss_exit_use_max_delivered) && - ContainsQuicTag(connection_options, kB2H2)) { + if (ContainsQuicTag(connection_options, kB2H2)) { params_.limit_inflight_hi_by_max_delivered = true; } + if (GetQuicReloadableFlag(quic_bbr2_use_bytes_delivered) && + ContainsQuicTag(connection_options, kB2DL)) { + QUIC_RELOADABLE_FLAG_COUNT(quic_bbr2_use_bytes_delivered); + params_.use_bytes_delivered_for_inflight_hi = true; + } + if (ContainsQuicTag(connection_options, kB2RC)) { + params_.enable_reno_coexistence = false; + } if (ContainsQuicTag(connection_options, kBSAO)) { model_.EnableOverestimateAvoidance(); } + if (params_.bw_startup && ContainsQuicTag(connection_options, kBBQ6)) { + QUIC_RELOADABLE_FLAG_COUNT_N(quic_bbr2_bw_startup, 1, 4); + params_.decrease_startup_pacing_at_end_of_round = true; + } + if (params_.bw_startup && ContainsQuicTag(connection_options, kBBQ7)) { + QUIC_RELOADABLE_FLAG_COUNT_N(quic_bbr2_bw_startup, 2, 4); + params_.bw_lo_mode_ = Bbr2Params::QuicBandwidthLoMode::MIN_RTT_REDUCTION; + } + if (params_.bw_startup && ContainsQuicTag(connection_options, kBBQ8)) { + QUIC_RELOADABLE_FLAG_COUNT_N(quic_bbr2_bw_startup, 3, 4); + params_.bw_lo_mode_ = Bbr2Params::QuicBandwidthLoMode::INFLIGHT_REDUCTION; + } + if (params_.bw_startup && ContainsQuicTag(connection_options, kBBQ9)) { + QUIC_RELOADABLE_FLAG_COUNT_N(quic_bbr2_bw_startup, 4, 4); + params_.bw_lo_mode_ = Bbr2Params::QuicBandwidthLoMode::CWND_REDUCTION; + } } Limits<QuicByteCount> Bbr2Sender::GetCwndLimitsByMode() const { @@ -192,22 +205,14 @@ void Bbr2Sender::AdjustNetworkParameters(const NetworkParams& params) { std::max(params.bandwidth, model_.BandwidthEstimate()); connection_stats_->cwnd_bootstrapping_rtt_us = model_.MinRtt().ToMicroseconds(); - if (GetQuicReloadableFlag(quic_bbr2_support_max_bootstrap_cwnd)) { - if (params.max_initial_congestion_window > 0) { - QUIC_RELOADABLE_FLAG_COUNT_N(quic_bbr2_support_max_bootstrap_cwnd, 2, - 4); - max_cwnd_when_network_parameters_adjusted_ = - params.max_initial_congestion_window * kDefaultTCPMSS; - } else { - QUIC_RELOADABLE_FLAG_COUNT_N(quic_bbr2_support_max_bootstrap_cwnd, 3, - 4); - } - cwnd_ = cwnd_limits().ApplyLimits( - std::min(max_cwnd_when_network_parameters_adjusted_, - model_.BDP(effective_bandwidth))); - } else { - cwnd_ = cwnd_limits().ApplyLimits(model_.BDP(effective_bandwidth)); + + if (params.max_initial_congestion_window > 0) { + max_cwnd_when_network_parameters_adjusted_ = + params.max_initial_congestion_window * kDefaultTCPMSS; } + cwnd_ = cwnd_limits().ApplyLimits( + std::min(max_cwnd_when_network_parameters_adjusted_, + model_.BDP(effective_bandwidth))); if (!params.allow_cwnd_to_decrease) { cwnd_ = std::max(cwnd_, prior_cwnd); @@ -315,11 +320,14 @@ void Bbr2Sender::UpdatePacingRate(QuicByteCount bytes_acked) { } QuicBandwidth target_rate = model_.pacing_gain() * model_.BandwidthEstimate(); - if (startup_.FullBandwidthReached()) { + if (model_.full_bandwidth_reached() || + params_.decrease_startup_pacing_at_end_of_round || + params_.bw_lo_mode_ != Bbr2Params::DEFAULT) { pacing_rate_ = target_rate; return; } + // By default, the pacing rate never decreases in STARTUP. if (target_rate > pacing_rate_) { pacing_rate_ = target_rate; } @@ -329,7 +337,7 @@ void Bbr2Sender::UpdateCongestionWindow(QuicByteCount bytes_acked) { QuicByteCount target_cwnd = GetTargetCongestionWindow(model_.cwnd_gain()); const QuicByteCount prior_cwnd = cwnd_; - if (startup_.FullBandwidthReached()) { + if (model_.full_bandwidth_reached()) { target_cwnd += model_.MaxAckHeight(); cwnd_ = std::min(prior_cwnd + bytes_acked, target_cwnd); } else if (prior_cwnd < target_cwnd || prior_cwnd < 2 * initial_cwnd_) { @@ -344,7 +352,7 @@ void Bbr2Sender::UpdateCongestionWindow(QuicByteCount bytes_acked) { QUIC_DVLOG(3) << this << " Updating CWND. target_cwnd:" << target_cwnd << ", max_ack_height:" << model_.MaxAckHeight() - << ", full_bw:" << startup_.FullBandwidthReached() + << ", full_bw:" << model_.full_bandwidth_reached() << ", bytes_acked:" << bytes_acked << ", inflight_lo:" << model_.inflight_lo() << ", inflight_hi:" << model_.inflight_hi() << ". (prior_cwnd) " diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_sender.h b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_sender.h index 6a83184cc93..a0b5199b254 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_sender.h +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_sender.h @@ -7,20 +7,20 @@ #include <cstdint> -#include "net/third_party/quiche/src/quic/core/congestion_control/bandwidth_sampler.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_drain.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_misc.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_bw.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_probe_rtt.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_startup.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr_sender.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/windowed_filter.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "quic/core/congestion_control/bandwidth_sampler.h" +#include "quic/core/congestion_control/bbr2_drain.h" +#include "quic/core/congestion_control/bbr2_misc.h" +#include "quic/core/congestion_control/bbr2_probe_bw.h" +#include "quic/core/congestion_control/bbr2_probe_rtt.h" +#include "quic/core/congestion_control/bbr2_startup.h" +#include "quic/core/congestion_control/bbr_sender.h" +#include "quic/core/congestion_control/rtt_stats.h" +#include "quic/core/congestion_control/send_algorithm_interface.h" +#include "quic/core/congestion_control/windowed_filter.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_flags.h" namespace quic { @@ -147,12 +147,12 @@ class QUIC_EXPORT_PRIVATE Bbr2Sender final : public SendAlgorithmInterface { // Helper function for BBR2_MODE_DISPATCH. Bbr2ProbeRttMode& probe_rtt_or_die() { - DCHECK_EQ(mode_, Bbr2Mode::PROBE_RTT); + QUICHE_DCHECK_EQ(mode_, Bbr2Mode::PROBE_RTT); return probe_rtt_; } const Bbr2ProbeRttMode& probe_rtt_or_die() const { - DCHECK_EQ(mode_, Bbr2Mode::PROBE_RTT); + QUICHE_DCHECK_EQ(mode_, Bbr2Mode::PROBE_RTT); return probe_rtt_; } diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_simulator_test.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_simulator_test.cc index f446ab577df..9cd5966e91f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_simulator_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_simulator_test.cc @@ -6,29 +6,29 @@ #include <sstream> #include <utility> +#include "absl/strings/str_cat.h" #include "absl/types/optional.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_misc.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_sender.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr_sender.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/tcp_cubic_sender_bytes.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_number.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#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_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/send_algorithm_test_result.pb.h" -#include "net/third_party/quiche/src/quic/test_tools/send_algorithm_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/link.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/simulator.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/switch.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/traffic_policer.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "quic/core/congestion_control/bbr2_misc.h" +#include "quic/core/congestion_control/bbr2_sender.h" +#include "quic/core/congestion_control/bbr_sender.h" +#include "quic/core/congestion_control/tcp_cubic_sender_bytes.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_packet_number.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_sent_packet_manager_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/send_algorithm_test_result.pb.h" +#include "quic/test_tools/send_algorithm_test_utils.h" +#include "quic/test_tools/simulator/link.h" +#include "quic/test_tools/simulator/quic_endpoint.h" +#include "quic/test_tools/simulator/simulator.h" +#include "quic/test_tools/simulator/switch.h" +#include "quic/test_tools/simulator/traffic_policer.h" using testing::AllOf; using testing::Ge; @@ -121,7 +121,14 @@ class DefaultTopologyParams { class Bbr2SimulatorTest : public QuicTest { protected: - Bbr2SimulatorTest() : simulator_(&random_) {} + Bbr2SimulatorTest() : simulator_(&random_) { + // Enable this for all tests because it moves where cwnd and pacing gain + // are initialized. + SetQuicReloadableFlag(quic_bbr2_bw_startup, true); + // Prevent the server(receiver), which only sends acks, from closing + // connection due to too many outstanding packets. + SetQuicFlag(FLAGS_quic_max_tracked_packet_count, 1000000); + } void SetUp() override { if (GetQuicFlag(FLAGS_quic_bbr2_test_regression_mode) == "regress") { @@ -432,6 +439,25 @@ TEST_F(Bbr2DefaultTopologyTest, SimpleTransferB2NE) { EXPECT_APPROX_EQ(params.RTT(), rtt_stats()->min_rtt(), 0.2f); } +TEST_F(Bbr2DefaultTopologyTest, SimpleTransferB2RC) { + SetConnectionOption(kB2RC); + DefaultTopologyParams params; + CreateNetwork(params); + + // Transfer 12MB. + DoSimpleTransfer(12 * 1024 * 1024, QuicTime::Delta::FromSeconds(35)); + EXPECT_TRUE(Bbr2ModeIsOneOf({Bbr2Mode::PROBE_BW, Bbr2Mode::PROBE_RTT})); + + EXPECT_APPROX_EQ(params.BottleneckBandwidth(), + sender_->ExportDebugState().bandwidth_hi, 0.01f); + + EXPECT_LE(sender_loss_rate_in_packets(), 0.05); + // The margin here is high, because the aggregation greatly increases + // smoothed rtt. + EXPECT_GE(params.RTT() * 4, rtt_stats()->smoothed_rtt()); + EXPECT_APPROX_EQ(params.RTT(), rtt_stats()->min_rtt(), 0.2f); +} + TEST_F(Bbr2DefaultTopologyTest, SimpleTransferSmallBuffer) { DefaultTopologyParams params; params.switch_queue_capacity_in_bdp = 0.5; @@ -564,7 +590,72 @@ TEST_F(Bbr2DefaultTopologyTest, PacketLossOnSmallBufferStartup) { CreateNetwork(params); DriveOutOfStartup(params); - EXPECT_LE(sender_loss_rate_in_packets(), 0.20); + // Packet loss is smaller with a CWND gain of 2 than 2.889. + EXPECT_LE(sender_loss_rate_in_packets(), 0.05); +} + +// Test the number of losses decreases with packet-conservation pacing. +TEST_F(Bbr2DefaultTopologyTest, PacketLossBBQ6SmallBufferStartup) { + SetQuicReloadableFlag(quic_bbr2_bw_startup, true); + SetConnectionOption(kBBQ2); // Increase CWND gain. + SetConnectionOption(kBBQ6); + DefaultTopologyParams params; + params.switch_queue_capacity_in_bdp = 0.5; + CreateNetwork(params); + + DriveOutOfStartup(params); + EXPECT_LE(sender_loss_rate_in_packets(), 0.0575); + // bandwidth_lo is cleared exiting STARTUP. + EXPECT_EQ(sender_->ExportDebugState().bandwidth_lo, + QuicBandwidth::Infinite()); +} + +// Test the number of losses decreases with min_rtt packet-conservation pacing. +TEST_F(Bbr2DefaultTopologyTest, PacketLossBBQ7SmallBufferStartup) { + SetQuicReloadableFlag(quic_bbr2_bw_startup, true); + SetConnectionOption(kBBQ2); // Increase CWND gain. + SetConnectionOption(kBBQ7); + DefaultTopologyParams params; + params.switch_queue_capacity_in_bdp = 0.5; + CreateNetwork(params); + + DriveOutOfStartup(params); + EXPECT_LE(sender_loss_rate_in_packets(), 0.06); + // bandwidth_lo is cleared exiting STARTUP. + EXPECT_EQ(sender_->ExportDebugState().bandwidth_lo, + QuicBandwidth::Infinite()); +} + +// Test the number of losses decreases with Inflight packet-conservation pacing. +TEST_F(Bbr2DefaultTopologyTest, PacketLossBBQ8SmallBufferStartup) { + SetQuicReloadableFlag(quic_bbr2_bw_startup, true); + SetConnectionOption(kBBQ2); // Increase CWND gain. + SetConnectionOption(kBBQ8); + DefaultTopologyParams params; + params.switch_queue_capacity_in_bdp = 0.5; + CreateNetwork(params); + + DriveOutOfStartup(params); + EXPECT_LE(sender_loss_rate_in_packets(), 0.065); + // bandwidth_lo is cleared exiting STARTUP. + EXPECT_EQ(sender_->ExportDebugState().bandwidth_lo, + QuicBandwidth::Infinite()); +} + +// Test the number of losses decreases with CWND packet-conservation pacing. +TEST_F(Bbr2DefaultTopologyTest, PacketLossBBQ9SmallBufferStartup) { + SetQuicReloadableFlag(quic_bbr2_bw_startup, true); + SetConnectionOption(kBBQ2); // Increase CWND gain. + SetConnectionOption(kBBQ9); + DefaultTopologyParams params; + params.switch_queue_capacity_in_bdp = 0.5; + CreateNetwork(params); + + DriveOutOfStartup(params); + EXPECT_LE(sender_loss_rate_in_packets(), 0.065); + // bandwidth_lo is cleared exiting STARTUP. + EXPECT_EQ(sender_->ExportDebugState().bandwidth_lo, + QuicBandwidth::Infinite()); } // Verify the behavior of the algorithm in the case when the connection sends @@ -738,6 +829,8 @@ TEST_F(Bbr2DefaultTopologyTest, ExitStartupDueToLoss) { sender_->ExportDebugState().startup.round_trips_without_bandwidth_growth); EXPECT_NE(0u, sender_connection_stats().packets_lost); EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited); + + EXPECT_GT(sender_->ExportDebugState().inflight_hi, 1.2f * params.BDP()); } // Test exiting STARTUP earlier upon loss due to loss when connection option @@ -770,12 +863,7 @@ TEST_F(Bbr2DefaultTopologyTest, ExitStartupDueToLossB2SL) { EXPECT_NE(0u, sender_connection_stats().packets_lost); EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited); - if (GetQuicReloadableFlag(quic_bbr2_startup_loss_exit_use_max_delivered)) { - EXPECT_GT(sender_->ExportDebugState().inflight_hi, 1.2f * params.BDP()); - } else { - EXPECT_APPROX_EQ(sender_->ExportDebugState().inflight_hi, params.BDP(), - 0.1f); - } + EXPECT_APPROX_EQ(sender_->ExportDebugState().inflight_hi, params.BDP(), 0.1f); } TEST_F(Bbr2DefaultTopologyTest, SenderPoliced) { @@ -1000,9 +1088,7 @@ TEST_F(Bbr2DefaultTopologyTest, SwitchToBbr2MidConnection) { // Switch from |old_sender| to |sender_|. const QuicByteCount old_sender_cwnd = old_sender.GetCongestionWindow(); sender_ = SetupBbr2Sender(&sender_endpoint_, &old_sender); - if (GetQuicReloadableFlag(quic_copy_bbr_cwnd_to_bbr2)) { - EXPECT_EQ(old_sender_cwnd, sender_->GetCongestionWindow()); - } + EXPECT_EQ(old_sender_cwnd, sender_->GetCongestionWindow()); // Send packets 5-7. now = now + QuicTime::Delta::FromMilliseconds(10); @@ -1107,12 +1193,10 @@ TEST_F(Bbr2DefaultTopologyTest, SendAlgorithmInterface::NetworkParams(1024 * params.BottleneckBandwidth(), QuicTime::Delta::Zero(), false)); - if (GetQuicReloadableFlag(quic_bbr2_support_max_bootstrap_cwnd)) { - // Verify cwnd is capped at 200. - EXPECT_EQ(200 * kDefaultTCPMSS, - sender_->ExportDebugState().congestion_window); - EXPECT_GT(1024 * params.BottleneckBandwidth(), sender_->PacingRate(0)); - } + // Verify cwnd is capped at 200. + EXPECT_EQ(200 * kDefaultTCPMSS, + sender_->ExportDebugState().congestion_window); + EXPECT_GT(1024 * params.BottleneckBandwidth(), sender_->PacingRate(0)); } TEST_F(Bbr2DefaultTopologyTest, @@ -1134,12 +1218,10 @@ TEST_F(Bbr2DefaultTopologyTest, network_params.max_initial_congestion_window = 100; sender_connection()->AdjustNetworkParameters(network_params); - if (GetQuicReloadableFlag(quic_bbr2_support_max_bootstrap_cwnd)) { - // Verify cwnd is capped at 100. - EXPECT_EQ(100 * kDefaultTCPMSS, - sender_->ExportDebugState().congestion_window); - EXPECT_GT(1024 * params.BottleneckBandwidth(), sender_->PacingRate(0)); - } + // Verify cwnd is capped at 100. + EXPECT_EQ(100 * kDefaultTCPMSS, + sender_->ExportDebugState().congestion_window); + EXPECT_GT(1024 * params.BottleneckBandwidth(), sender_->PacingRate(0)); } TEST_F(Bbr2DefaultTopologyTest, @@ -1161,12 +1243,10 @@ TEST_F(Bbr2DefaultTopologyTest, SendAlgorithmInterface::NetworkParams(1024 * params.BottleneckBandwidth(), QuicTime::Delta::Zero(), false)); - if (GetQuicReloadableFlag(quic_bbr2_support_max_bootstrap_cwnd)) { - // Verify cwnd is capped at 100. - EXPECT_EQ(100 * kDefaultTCPMSS, - sender_->ExportDebugState().congestion_window); - EXPECT_GT(1024 * params.BottleneckBandwidth(), sender_->PacingRate(0)); - } + // Verify cwnd is capped at 100. + EXPECT_EQ(100 * kDefaultTCPMSS, + sender_->ExportDebugState().congestion_window); + EXPECT_GT(1024 * params.BottleneckBandwidth(), sender_->PacingRate(0)); } // All Bbr2MultiSenderTests uses the following network topology: @@ -1206,7 +1286,7 @@ class MultiSenderTopologyParams { QuicBandwidth BottleneckBandwidth() const { // Make sure all local links have a higher bandwidth than the test link. for (size_t i = 0; i < local_links.size(); ++i) { - CHECK_GT(local_links[i].bandwidth, test_link.bandwidth); + QUICHE_CHECK_GT(local_links[i].bandwidth, test_link.bandwidth); } return test_link.bandwidth; } @@ -1241,8 +1321,8 @@ class Bbr2MultiSenderTest : public Bbr2SimulatorTest { uint64_t first_connection_id = 42; std::vector<simulator::QuicEndpointBase*> receiver_endpoint_pointers; for (size_t i = 0; i < MultiSenderTopologyParams::kNumLocalLinks; ++i) { - std::string sender_name = quiche::QuicheStrCat("Sender", i + 1); - std::string receiver_name = quiche::QuicheStrCat("Receiver", i + 1); + std::string sender_name = absl::StrCat("Sender", i + 1); + std::string receiver_name = absl::StrCat("Receiver", i + 1); sender_endpoints_.push_back(std::make_unique<simulator::QuicEndpoint>( &simulator_, sender_name, receiver_name, Perspective::IS_CLIENT, TestConnectionId(first_connection_id + i))); @@ -1254,7 +1334,7 @@ class Bbr2MultiSenderTest : public Bbr2SimulatorTest { receiver_multiplexer_ = std::make_unique<simulator::QuicEndpointMultiplexer>( "Receiver multiplexer", receiver_endpoint_pointers); - sender_1_ = SetupBbr2Sender(sender_endpoints_[0].get()); + sender_0_ = SetupBbr2Sender(sender_endpoints_[0].get()); } ~Bbr2MultiSenderTest() { @@ -1320,6 +1400,14 @@ class Bbr2MultiSenderTest : public Bbr2SimulatorTest { return sender; } + void SetConnectionOption(SendAlgorithmInterface* sender, QuicTag option) { + QuicConfig config; + QuicTagVector options; + options.push_back(option); + QuicConfigPeer::SetReceivedConnectionOptions(&config, options); + sender->SetFromConfig(config, Perspective::IS_SERVER); + } + void CreateNetwork(const MultiSenderTopologyParams& params) { QUIC_LOG(INFO) << "CreateNetwork with parameters: " << params.ToString(); switch_ = std::make_unique<simulator::Switch>(&simulator_, "Switch", @@ -1353,7 +1441,7 @@ class Bbr2MultiSenderTest : public Bbr2SimulatorTest { std::vector<std::unique_ptr<simulator::QuicEndpoint>> sender_endpoints_; std::vector<std::unique_ptr<simulator::QuicEndpoint>> receiver_endpoints_; std::unique_ptr<simulator::QuicEndpointMultiplexer> receiver_multiplexer_; - Bbr2Sender* sender_1_; + Bbr2Sender* sender_0_; std::unique_ptr<simulator::Switch> switch_; std::vector<std::unique_ptr<simulator::SymmetricLink>> network_links_; @@ -1512,7 +1600,39 @@ TEST_F(Bbr2MultiSenderTest, QUIC_SLOW_TEST(Bbr2VsReno)) { MultiSenderTopologyParams params; CreateNetwork(params); - const QuicByteCount transfer_size = 50 * 1024 * 1024; + const QuicByteCount transfer_size = 10 * 1024 * 1024; + const QuicTime::Delta transfer_time = + params.BottleneckBandwidth().TransferTime(transfer_size); + QUIC_LOG(INFO) << "Single flow transfer time: " << transfer_time; + + // Transfer 10% of data in first transfer. + sender_endpoints_[0]->AddBytesToTransfer(transfer_size); + bool simulator_result = simulator_.RunUntilOrTimeout( + [this]() { + return receiver_endpoints_[0]->bytes_received() >= 0.1 * transfer_size; + }, + transfer_time); + ASSERT_TRUE(simulator_result); + + // Start the second transfer and wait until both finish. + sender_endpoints_[1]->AddBytesToTransfer(transfer_size); + simulator_result = simulator_.RunUntilOrTimeout( + [this]() { + return receiver_endpoints_[0]->bytes_received() == transfer_size && + receiver_endpoints_[1]->bytes_received() == transfer_size; + }, + 3 * transfer_time); + ASSERT_TRUE(simulator_result); +} + +TEST_F(Bbr2MultiSenderTest, QUIC_SLOW_TEST(Bbr2VsRenoB2RC)) { + SetConnectionOption(sender_0_, kB2RC); + SetupTcpSender(sender_endpoints_[1].get(), /*reno=*/true); + + MultiSenderTopologyParams params; + CreateNetwork(params); + + const QuicByteCount transfer_size = 10 * 1024 * 1024; const QuicTime::Delta transfer_time = params.BottleneckBandwidth().TransferTime(transfer_size); QUIC_LOG(INFO) << "Single flow transfer time: " << transfer_time; diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_startup.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_startup.cc index 5c47adb8426..0f6b80ff233 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_startup.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_startup.cc @@ -2,29 +2,32 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_startup.h" +#include "quic/core/congestion_control/bbr2_startup.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_misc.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_sender.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/congestion_control/bbr2_misc.h" +#include "quic/core/congestion_control/bbr2_sender.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { Bbr2StartupMode::Bbr2StartupMode(const Bbr2Sender* sender, Bbr2NetworkModel* model, QuicTime now) - : Bbr2ModeBase(sender, model), - full_bandwidth_reached_(false), - full_bandwidth_baseline_(QuicBandwidth::Zero()), - rounds_without_bandwidth_growth_(0) { + : Bbr2ModeBase(sender, model) { // Clear some startup stats if |sender_->connection_stats_| has been used by // another sender, which happens e.g. when QuicConnection switch send // algorithms. sender_->connection_stats_->slowstart_count = 1; sender_->connection_stats_->slowstart_duration = QuicTimeAccumulator(); sender_->connection_stats_->slowstart_duration.Start(now); + if (sender->Params().bw_startup) { + // Enter() is never called for Startup, so the gains needs to be set here. + model_->set_pacing_gain(Params().startup_pacing_gain); + model_->set_cwnd_gain(Params().startup_cwnd_gain); + } } void Bbr2StartupMode::Enter(QuicTime /*now*/, @@ -35,6 +38,8 @@ void Bbr2StartupMode::Enter(QuicTime /*now*/, void Bbr2StartupMode::Leave(QuicTime now, const Bbr2CongestionEvent* /*congestion_event*/) { sender_->connection_stats_->slowstart_duration.Stop(now); + // Clear bandwidth_lo if it's set during STARTUP. + model_->clear_bandwidth_lo(); } Bbr2Mode Bbr2StartupMode::OnCongestionEvent( @@ -43,96 +48,92 @@ Bbr2Mode Bbr2StartupMode::OnCongestionEvent( const AckedPacketVector& /*acked_packets*/, const LostPacketVector& /*lost_packets*/, const Bbr2CongestionEvent& congestion_event) { - if (!full_bandwidth_reached_ && congestion_event.end_of_round_trip) { + if (!model_->full_bandwidth_reached() && congestion_event.end_of_round_trip) { // TCP BBR always exits upon excessive losses. QUIC BBRv1 does not exits // upon excessive losses, if enough bandwidth growth is observed. - bool has_enough_bw_growth = CheckBandwidthGrowth(congestion_event); + Bbr2NetworkModel::BandwidthGrowth bw_growth = + model_->CheckBandwidthGrowth(congestion_event); - if (Params().always_exit_startup_on_excess_loss || !has_enough_bw_growth) { + if (Params().always_exit_startup_on_excess_loss || + (bw_growth == Bbr2NetworkModel::NO_GROWTH || + bw_growth == Bbr2NetworkModel::EXIT)) { CheckExcessiveLosses(congestion_event); } } - model_->set_pacing_gain(Params().startup_pacing_gain); - model_->set_cwnd_gain(Params().startup_cwnd_gain); - - // TODO(wub): Maybe implement STARTUP => PROBE_RTT. - return full_bandwidth_reached_ ? Bbr2Mode::DRAIN : Bbr2Mode::STARTUP; -} - -bool Bbr2StartupMode::CheckBandwidthGrowth( - const Bbr2CongestionEvent& congestion_event) { - DCHECK(!full_bandwidth_reached_); - DCHECK(congestion_event.end_of_round_trip); - if (congestion_event.last_sample_is_app_limited) { - // Return true such that when Params().always_exit_startup_on_excess_loss is - // false, we'll not check excess loss, which is the behavior of QUIC BBRv1. - return true; - } - - QuicBandwidth threshold = - full_bandwidth_baseline_ * Params().startup_full_bw_threshold; - - if (model_->MaxBandwidth() >= threshold) { - QUIC_DVLOG(3) << sender_ - << " CheckBandwidthGrowth at end of round. max_bandwidth:" - << model_->MaxBandwidth() << ", threshold:" << threshold - << " (Still growing) @ " << congestion_event.event_time; - full_bandwidth_baseline_ = model_->MaxBandwidth(); - rounds_without_bandwidth_growth_ = 0; - return true; + if (Params().decrease_startup_pacing_at_end_of_round) { + QUICHE_DCHECK_GT(model_->pacing_gain(), 0); + QUICHE_DCHECK(Params().bw_startup); + if (congestion_event.end_of_round_trip && + !congestion_event.last_sample_is_app_limited) { + // Multiply by startup_pacing_gain, so if the bandwidth doubles, + // the pacing gain will be the full startup_pacing_gain. + if (max_bw_at_round_beginning_ > QuicBandwidth::Zero()) { + const float bandwidth_ratio = + std::max(1., model_->MaxBandwidth().ToBitsPerSecond() / + static_cast<double>( + max_bw_at_round_beginning_.ToBitsPerSecond())); + // Even when bandwidth isn't increasing, use a gain large enough to + // cause a startup_full_bw_threshold increase. + const float new_gain = + ((bandwidth_ratio - 1) * (Params().startup_pacing_gain - + Params().startup_full_bw_threshold)) + + Params().startup_full_bw_threshold; + // Allow the pacing gain to decrease. + model_->set_pacing_gain( + std::min(Params().startup_pacing_gain, new_gain)); + // Clear bandwidth_lo if it's less than the pacing rate. + // This avoids a constantly app-limited flow from having it's pacing + // gain effectively decreased below 1.25. + if (model_->bandwidth_lo() < + model_->MaxBandwidth() * model_->pacing_gain()) { + model_->clear_bandwidth_lo(); + } + } + max_bw_at_round_beginning_ = model_->MaxBandwidth(); + } + } else if (!Params().bw_startup) { + // When the flag is enabled, set these in the constructor. + model_->set_pacing_gain(Params().startup_pacing_gain); + model_->set_cwnd_gain(Params().startup_cwnd_gain); } - ++rounds_without_bandwidth_growth_; - full_bandwidth_reached_ = - rounds_without_bandwidth_growth_ >= Params().startup_full_bw_rounds; - QUIC_DVLOG(3) << sender_ - << " CheckBandwidthGrowth at end of round. max_bandwidth:" - << model_->MaxBandwidth() << ", threshold:" << threshold - << " rounds_without_growth:" << rounds_without_bandwidth_growth_ - << " full_bw_reached:" << full_bandwidth_reached_ << " @ " - << congestion_event.event_time; - - return false; + // TODO(wub): Maybe implement STARTUP => PROBE_RTT. + return model_->full_bandwidth_reached() ? Bbr2Mode::DRAIN : Bbr2Mode::STARTUP; } void Bbr2StartupMode::CheckExcessiveLosses( const Bbr2CongestionEvent& congestion_event) { - DCHECK(congestion_event.end_of_round_trip); + QUICHE_DCHECK(congestion_event.end_of_round_trip); - if (full_bandwidth_reached_) { + if (model_->full_bandwidth_reached()) { return; } // At the end of a round trip. Check if loss is too high in this round. if (model_->IsInflightTooHigh(congestion_event, Params().startup_full_loss_count)) { - QuicByteCount new_inflight_hi = model_->BDP(model_->MaxBandwidth()); + QuicByteCount new_inflight_hi = model_->BDP(); if (Params().startup_loss_exit_use_max_delivered_for_inflight_hi) { if (new_inflight_hi < model_->max_bytes_delivered_in_round()) { - QUIC_RELOADABLE_FLAG_COUNT_N( - quic_bbr2_startup_loss_exit_use_max_delivered, 1, 2); new_inflight_hi = model_->max_bytes_delivered_in_round(); - } else { - QUIC_RELOADABLE_FLAG_COUNT_N( - quic_bbr2_startup_loss_exit_use_max_delivered, 2, 2); } } QUIC_DVLOG(3) << sender_ << " Exiting STARTUP due to loss. inflight_hi:" << new_inflight_hi; // TODO(ianswett): Add a shared method to set inflight_hi in the model. model_->set_inflight_hi(new_inflight_hi); - - full_bandwidth_reached_ = true; + model_->set_full_bandwidth_reached(); sender_->connection_stats_->bbr_exit_startup_due_to_loss = true; } } Bbr2StartupMode::DebugState Bbr2StartupMode::ExportDebugState() const { DebugState s; - s.full_bandwidth_reached = full_bandwidth_reached_; - s.full_bandwidth_baseline = full_bandwidth_baseline_; - s.round_trips_without_bandwidth_growth = rounds_without_bandwidth_growth_; + s.full_bandwidth_reached = model_->full_bandwidth_reached(); + s.full_bandwidth_baseline = model_->full_bandwidth_baseline(); + s.round_trips_without_bandwidth_growth = + model_->rounds_without_bandwidth_growth(); return s; } diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_startup.h b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_startup.h index 75ec71ecd25..a05bac28216 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_startup.h +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr2_startup.h @@ -5,11 +5,11 @@ #ifndef QUICHE_QUIC_CORE_CONGESTION_CONTROL_BBR2_STARTUP_H_ #define QUICHE_QUIC_CORE_CONGESTION_CONTROL_BBR2_STARTUP_H_ -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_misc.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/congestion_control/bbr2_misc.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -34,7 +34,8 @@ class QUIC_EXPORT_PRIVATE Bbr2StartupMode final : public Bbr2ModeBase { Limits<QuicByteCount> GetCwndLimits() const override { // Inflight_lo is never set in STARTUP. - DCHECK_EQ(Bbr2NetworkModel::inflight_lo_default(), model_->inflight_lo()); + QUICHE_DCHECK_EQ(Bbr2NetworkModel::inflight_lo_default(), + model_->inflight_lo()); return NoGreaterThan(model_->inflight_lo()); } @@ -45,8 +46,6 @@ class QUIC_EXPORT_PRIVATE Bbr2StartupMode final : public Bbr2ModeBase { return Bbr2Mode::STARTUP; } - bool FullBandwidthReached() const { return full_bandwidth_reached_; } - struct QUIC_EXPORT_PRIVATE DebugState { bool full_bandwidth_reached; QuicBandwidth full_bandwidth_baseline = QuicBandwidth::Zero(); @@ -58,18 +57,9 @@ class QUIC_EXPORT_PRIVATE Bbr2StartupMode final : public Bbr2ModeBase { private: const Bbr2Params& Params() const; - // Check bandwidth growth in the past round. Must be called at the end of a - // round. - // Return true if the bandwidth growed as expected. - // Return false otherwise, if enough rounds have elapsed without expected - // growth, also sets |full_bandwidth_reached_| to true. - bool CheckBandwidthGrowth(const Bbr2CongestionEvent& congestion_event); - void CheckExcessiveLosses(const Bbr2CongestionEvent& congestion_event); - - bool full_bandwidth_reached_; - QuicBandwidth full_bandwidth_baseline_; - QuicRoundTripCount rounds_without_bandwidth_growth_; + // Used when the pacing gain can decrease in STARTUP. + QuicBandwidth max_bw_at_round_beginning_ = QuicBandwidth::Zero(); }; QUIC_EXPORT_PRIVATE std::ostream& operator<<( diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr_sender.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr_sender.cc index 7ce3ab586af..940fe260731 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr_sender.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr_sender.cc @@ -2,21 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr_sender.h" +#include "quic/core/congestion_control/bbr_sender.h" #include <algorithm> #include <sstream> #include <string> #include "absl/base/attributes.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_time_accumulator.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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 "quic/core/congestion_control/rtt_stats.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_time_accumulator.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -284,22 +284,17 @@ void BbrSender::AdjustNetworkParameters(const NetworkParams& params) { const QuicBandwidth& bandwidth = params.bandwidth; const QuicTime::Delta& rtt = params.rtt; - if (!params.quic_bbr_donot_inject_bandwidth && !bandwidth.IsZero()) { - max_bandwidth_.Update(bandwidth, round_trip_count_); - } if (!rtt.IsZero() && (min_rtt_ > rtt || min_rtt_.IsZero())) { min_rtt_ = rtt; } - if (params.quic_fix_bbr_cwnd_in_bandwidth_resumption && mode_ == STARTUP) { + if (mode_ == STARTUP) { if (bandwidth.IsZero()) { // Ignore bad bandwidth samples. return; } - auto cwnd_bootstrapping_rtt = params.quic_bbr_donot_inject_bandwidth - ? GetMinRtt() - : rtt_stats_->SmoothedOrInitialRtt(); + auto cwnd_bootstrapping_rtt = GetMinRtt(); if (params.max_initial_congestion_window > 0) { max_congestion_window_with_network_parameters_adjusted_ = params.max_initial_congestion_window * kDefaultTCPMSS; @@ -330,13 +325,12 @@ void BbrSender::AdjustNetworkParameters(const NetworkParams& params) { set_high_cwnd_gain(kDerivedHighCWNDGain); } congestion_window_ = new_cwnd; - if (params.quic_bbr_fix_pacing_rate) { - // Pace at the rate of new_cwnd / RTT. - QuicBandwidth new_pacing_rate = - QuicBandwidth::FromBytesAndTimeDelta(congestion_window_, GetMinRtt()); - pacing_rate_ = std::max(pacing_rate_, new_pacing_rate); - detect_overshooting_ = true; - } + + // Pace at the rate of new_cwnd / RTT. + QuicBandwidth new_pacing_rate = + QuicBandwidth::FromBytesAndTimeDelta(congestion_window_, GetMinRtt()); + pacing_rate_ = std::max(pacing_rate_, new_pacing_rate); + detect_overshooting_ = true; } } @@ -525,7 +519,7 @@ bool BbrSender::MaybeUpdateMinRtt(QuicTime now, min_rtt_ = sample_min_rtt; min_rtt_timestamp_ = now; } - DCHECK(!min_rtt_.IsZero()); + QUICHE_DCHECK(!min_rtt_.IsZero()); return min_rtt_expired; } @@ -592,7 +586,7 @@ void BbrSender::CheckIfFullBandwidthReached( rounds_without_bandwidth_gain_++; if ((rounds_without_bandwidth_gain_ >= num_startup_rtts_) || ShouldExitStartupDueToLoss(last_packet_send_state)) { - DCHECK(has_non_app_limited_sample_); + QUICHE_DCHECK(has_non_app_limited_sample_); is_at_full_bandwidth_ = true; } } @@ -611,7 +605,7 @@ void BbrSender::MaybeExitStartupOrDrain(QuicTime now) { } void BbrSender::OnExitStartup(QuicTime now) { - DCHECK_EQ(mode_, STARTUP); + QUICHE_DCHECK_EQ(mode_, STARTUP); if (stats_) { stats_->slowstart_duration.Stop(now); } diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr_sender.h b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr_sender.h index 586ef1afc2e..c1dbd22216e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr_sender.h +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr_sender.h @@ -11,17 +11,17 @@ #include <ostream> #include <string> -#include "net/third_party/quiche/src/quic/core/congestion_control/bandwidth_sampler.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/windowed_filter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_number.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_unacked_packet_map.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "quic/core/congestion_control/bandwidth_sampler.h" +#include "quic/core/congestion_control/send_algorithm_interface.h" +#include "quic/core/congestion_control/windowed_filter.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_packet_number.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_unacked_packet_map.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_flags.h" namespace quic { @@ -143,7 +143,7 @@ class QUIC_EXPORT_PRIVATE BbrSender : public SendAlgorithmInterface { // Sets the pacing gain used in STARTUP. Must be greater than 1. void set_high_gain(float high_gain) { - DCHECK_LT(1.0f, high_gain); + QUICHE_DCHECK_LT(1.0f, high_gain); high_gain_ = high_gain; if (mode_ == STARTUP) { pacing_gain_ = high_gain; @@ -152,7 +152,7 @@ class QUIC_EXPORT_PRIVATE BbrSender : public SendAlgorithmInterface { // Sets the CWND gain used in STARTUP. Must be greater than 1. void set_high_cwnd_gain(float high_cwnd_gain) { - DCHECK_LT(1.0f, high_cwnd_gain); + QUICHE_DCHECK_LT(1.0f, high_cwnd_gain); high_cwnd_gain_ = high_cwnd_gain; if (mode_ == STARTUP) { congestion_window_gain_ = high_cwnd_gain; @@ -161,7 +161,7 @@ class QUIC_EXPORT_PRIVATE BbrSender : public SendAlgorithmInterface { // Sets the gain used in DRAIN. Must be less than 1. void set_drain_gain(float drain_gain) { - DCHECK_GT(1.0f, drain_gain); + QUICHE_DCHECK_GT(1.0f, drain_gain); drain_gain_ = drain_gain; } diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr_sender_test.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr_sender_test.cc index c0000e78699..4a5cb0f0092 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr_sender_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/bbr_sender_test.cc @@ -2,31 +2,31 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr_sender.h" +#include "quic/core/congestion_control/bbr_sender.h" #include <algorithm> #include <map> #include <memory> #include <utility> -#include "net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#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_test.h" -#include "net/third_party/quiche/src/quic/test_tools/mock_clock.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/send_algorithm_test_result.pb.h" -#include "net/third_party/quiche/src/quic/test_tools/send_algorithm_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/simulator.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/switch.h" +#include "quic/core/congestion_control/rtt_stats.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_sent_packet_manager_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/send_algorithm_test_result.pb.h" +#include "quic/test_tools/send_algorithm_test_utils.h" +#include "quic/test_tools/simulator/quic_endpoint.h" +#include "quic/test_tools/simulator/simulator.h" +#include "quic/test_tools/simulator/switch.h" using testing::AllOf; using testing::Ge; diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/cubic_bytes.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/cubic_bytes.cc index 9300a790eb1..854d6a75433 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/cubic_bytes.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/cubic_bytes.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/cubic_bytes.h" +#include "quic/core/congestion_control/cubic_bytes.h" #include <algorithm> #include <cmath> #include <cstdint> -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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 "quic/core/quic_constants.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -153,8 +153,8 @@ QuicByteCount CubicBytes::CongestionWindowAfterAck( kCubeScale; const bool add_delta = elapsed_time > time_to_origin_point_; - DCHECK(add_delta || - (origin_point_congestion_window_ > delta_congestion_window)); + QUICHE_DCHECK(add_delta || + (origin_point_congestion_window_ > delta_congestion_window)); QuicByteCount target_congestion_window = add_delta ? origin_point_congestion_window_ + delta_congestion_window : origin_point_congestion_window_ - delta_congestion_window; @@ -163,7 +163,7 @@ QuicByteCount CubicBytes::CongestionWindowAfterAck( std::min(target_congestion_window, current_congestion_window + acked_bytes_count_ / 2); - DCHECK_LT(0u, estimated_tcp_congestion_window_); + QUICHE_DCHECK_LT(0u, estimated_tcp_congestion_window_); // Increase the window by approximately Alpha * 1 MSS of bytes every // time we ack an estimated tcp window of bytes. For small // congestion windows (less than 25), the formula below will diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/cubic_bytes.h b/chromium/net/third_party/quiche/src/quic/core/congestion_control/cubic_bytes.h index 0e174a84af4..75a3bcdc3e0 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/cubic_bytes.h +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/cubic_bytes.h @@ -10,11 +10,11 @@ #include <cstdint> -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_clock.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_stats.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_clock.h" +#include "quic/core/quic_connection_stats.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/cubic_bytes_test.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/cubic_bytes_test.cc index 7a48ddf9165..edbe18dbea5 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/cubic_bytes_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/cubic_bytes_test.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/cubic_bytes.h" +#include "quic/core/congestion_control/cubic_bytes.h" #include <cstdint> -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.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 "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/general_loss_algorithm.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/general_loss_algorithm.cc index 504a16371a0..521aa4a7a10 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/general_loss_algorithm.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/general_loss_algorithm.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/general_loss_algorithm.h" +#include "quic/core/congestion_control/general_loss_algorithm.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "quic/core/congestion_control/rtt_stats.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" namespace quic { @@ -79,8 +79,8 @@ LossDetectionInterface::DetectionStats GeneralLossAlgorithm::DetectLosses( } // Clear least_in_flight_. least_in_flight_.Clear(); - DCHECK_EQ(packet_number_space_, - unacked_packets.GetPacketNumberSpace(largest_newly_acked)); + QUICHE_DCHECK_EQ(packet_number_space_, + unacked_packets.GetPacketNumberSpace(largest_newly_acked)); for (; it != unacked_packets.end() && packet_number <= largest_newly_acked; ++it, ++packet_number) { if (unacked_packets.GetPacketNumberSpace(it->encryption_level) != @@ -169,7 +169,7 @@ void GeneralLossAlgorithm::SpuriousLossDetected( } if (use_adaptive_reordering_threshold_) { - DCHECK_LT(packet_number, previous_largest_acked); + QUICHE_DCHECK_LT(packet_number, previous_largest_acked); // Increase reordering_threshold_ such that packet_number would not have // been declared lost. reordering_threshold_ = std::max( diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/general_loss_algorithm.h b/chromium/net/third_party/quiche/src/quic/core/congestion_control/general_loss_algorithm.h index b2ec008747b..6a3c5dd3515 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/general_loss_algorithm.h +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/general_loss_algorithm.h @@ -8,12 +8,12 @@ #include <algorithm> #include <map> -#include "net/third_party/quiche/src/quic/core/congestion_control/loss_detection_interface.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_unacked_packet_map.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/congestion_control/loss_detection_interface.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_unacked_packet_map.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -49,27 +49,27 @@ class QUIC_EXPORT_PRIVATE GeneralLossAlgorithm : public LossDetectionInterface { QuicPacketNumber previous_largest_acked) override; void OnConfigNegotiated() override { - DCHECK(false) + QUICHE_DCHECK(false) << "Unexpected call to GeneralLossAlgorithm::OnConfigNegotiated"; } void OnMinRttAvailable() override { - DCHECK(false) + QUICHE_DCHECK(false) << "Unexpected call to GeneralLossAlgorithm::OnMinRttAvailable"; } void OnUserAgentIdKnown() override { - DCHECK(false) + QUICHE_DCHECK(false) << "Unexpected call to GeneralLossAlgorithm::OnUserAgentIdKnown"; } void OnConnectionClosed() override { - DCHECK(false) + QUICHE_DCHECK(false) << "Unexpected call to GeneralLossAlgorithm::OnConnectionClosed"; } void OnReorderingDetected() override { - DCHECK(false) + QUICHE_DCHECK(false) << "Unexpected call to GeneralLossAlgorithm::OnReorderingDetected"; } diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/general_loss_algorithm_test.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/general_loss_algorithm_test.cc index 6d89cb93f06..b8cffab6529 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/general_loss_algorithm_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/general_loss_algorithm_test.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/general_loss_algorithm.h" +#include "quic/core/congestion_control/general_loss_algorithm.h" #include <algorithm> #include <cstdint> -#include "net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h" -#include "net/third_party/quiche/src/quic/core/quic_unacked_packet_map.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.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 "quic/core/congestion_control/rtt_stats.h" +#include "quic/core/quic_unacked_packet_map.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/hybrid_slow_start.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/hybrid_slow_start.cc index 28963b11105..1e567faa8be 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/hybrid_slow_start.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/hybrid_slow_start.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/hybrid_slow_start.h" +#include "quic/core/congestion_control/hybrid_slow_start.h" #include <algorithm> -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_logging.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/hybrid_slow_start.h b/chromium/net/third_party/quiche/src/quic/core/congestion_control/hybrid_slow_start.h index 0017500482e..bd1292ae9c2 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/hybrid_slow_start.h +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/hybrid_slow_start.h @@ -18,9 +18,9 @@ #include <cstdint> -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/hybrid_slow_start_test.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/hybrid_slow_start_test.cc index 05d771af944..caa07812e48 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/hybrid_slow_start_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/hybrid_slow_start_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/hybrid_slow_start.h" +#include "quic/core/congestion_control/hybrid_slow_start.h" #include <memory> #include <utility> -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/loss_detection_interface.h b/chromium/net/third_party/quiche/src/quic/core/congestion_control/loss_detection_interface.h index 8e7bbc35d1e..77c8913e6aa 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/loss_detection_interface.h +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/loss_detection_interface.h @@ -7,12 +7,12 @@ #ifndef QUICHE_QUIC_CORE_CONGESTION_CONTROL_LOSS_DETECTION_INTERFACE_H_ #define QUICHE_QUIC_CORE_CONGESTION_CONTROL_LOSS_DETECTION_INTERFACE_H_ -#include "net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/congestion_control/send_algorithm_interface.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/pacing_sender.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/pacing_sender.cc index 2ba07ab67d1..a43601eae0d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/pacing_sender.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/pacing_sender.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/pacing_sender.h" +#include "quic/core/congestion_control/pacing_sender.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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 "quic/core/quic_bandwidth.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { namespace { @@ -35,7 +35,7 @@ PacingSender::PacingSender() PacingSender::~PacingSender() {} void PacingSender::set_sender(SendAlgorithmInterface* sender) { - DCHECK(sender != nullptr); + QUICHE_DCHECK(sender != nullptr); sender_ = sender; } @@ -44,7 +44,7 @@ void PacingSender::OnCongestionEvent(bool rtt_updated, QuicTime event_time, const AckedPacketVector& acked_packets, const LostPacketVector& lost_packets) { - DCHECK(sender_ != nullptr); + QUICHE_DCHECK(sender_ != nullptr); if (!lost_packets.empty()) { // Clear any burst tokens when entering recovery. burst_tokens_ = 0; @@ -59,7 +59,7 @@ void PacingSender::OnPacketSent( QuicPacketNumber packet_number, QuicByteCount bytes, HasRetransmittableData has_retransmittable_data) { - DCHECK(sender_ != nullptr); + QUICHE_DCHECK(sender_ != nullptr); sender_->OnPacketSent(sent_time, bytes_in_flight, packet_number, bytes, has_retransmittable_data); if (has_retransmittable_data != HAS_RETRANSMITTABLE_DATA) { @@ -130,7 +130,7 @@ void PacingSender::SetBurstTokens(uint32_t burst_tokens) { QuicTime::Delta PacingSender::TimeUntilSend( QuicTime now, QuicByteCount bytes_in_flight) const { - DCHECK(sender_ != nullptr); + QUICHE_DCHECK(sender_ != nullptr); if (!sender_->CanSend(bytes_in_flight)) { // The underlying sender prevents sending. @@ -158,7 +158,7 @@ QuicTime::Delta PacingSender::TimeUntilSend( } QuicBandwidth PacingSender::PacingRate(QuicByteCount bytes_in_flight) const { - DCHECK(sender_ != nullptr); + QUICHE_DCHECK(sender_ != nullptr); if (!max_pacing_rate_.IsZero()) { return QuicBandwidth::FromBitsPerSecond( std::min(max_pacing_rate_.ToBitsPerSecond(), diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/pacing_sender.h b/chromium/net/third_party/quiche/src/quic/core/congestion_control/pacing_sender.h index a8436f8fc7d..d473a38cd91 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/pacing_sender.h +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/pacing_sender.h @@ -15,12 +15,12 @@ #include <map> #include <memory> -#include "net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/congestion_control/send_algorithm_interface.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/pacing_sender_test.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/pacing_sender_test.cc index 8c298d9ccfb..b7513576cca 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/pacing_sender_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/pacing_sender_test.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/pacing_sender.h" +#include "quic/core/congestion_control/pacing_sender.h" #include <memory> #include <utility> -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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_test.h" -#include "net/third_party/quiche/src/quic/test_tools/mock_clock.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" +#include "quic/test_tools/quic_test_utils.h" using testing::_; using testing::AtMost; diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/prr_sender.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/prr_sender.cc index c09b312eb75..ed969534bc6 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/prr_sender.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/prr_sender.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/prr_sender.h" +#include "quic/core/congestion_control/prr_sender.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" +#include "quic/core/quic_packets.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/prr_sender.h b/chromium/net/third_party/quiche/src/quic/core/congestion_control/prr_sender.h index 21909129dae..a403dcf7295 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/prr_sender.h +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/prr_sender.h @@ -7,9 +7,9 @@ #ifndef QUICHE_QUIC_CORE_CONGESTION_CONTROL_PRR_SENDER_H_ #define QUICHE_QUIC_CORE_CONGESTION_CONTROL_PRR_SENDER_H_ -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/prr_sender_test.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/prr_sender_test.cc index 45910659880..80e9b4132c8 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/prr_sender_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/prr_sender_test.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/prr_sender.h" +#include "quic/core/congestion_control/prr_sender.h" #include <algorithm> -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/quic_constants.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.cc index f4cd2d01ec9..2be6fa44b2a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h" +#include "quic/core/congestion_control/rtt_stats.h" #include <cstdlib> // std::abs -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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 "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -103,7 +103,7 @@ void RttStats::OnConnectionMigration() { } QuicTime::Delta RttStats::GetStandardOrMeanDeviation() const { - DCHECK(calculate_standard_deviation_); + QUICHE_DCHECK(calculate_standard_deviation_); if (!standard_deviation_calculator_.has_valid_standard_deviation) { return mean_deviation_; } @@ -124,8 +124,21 @@ void RttStats::StandardDeviationCaculator::OnNewRttSample( QuicTime::Delta RttStats::StandardDeviationCaculator::CalculateStandardDeviation() const { - DCHECK(has_valid_standard_deviation); + QUICHE_DCHECK(has_valid_standard_deviation); return QuicTime::Delta::FromMicroseconds(sqrt(m2)); } +void RttStats::CloneFrom(const RttStats& stats) { + latest_rtt_ = stats.latest_rtt_; + min_rtt_ = stats.min_rtt_; + smoothed_rtt_ = stats.smoothed_rtt_; + previous_srtt_ = stats.previous_srtt_; + mean_deviation_ = stats.mean_deviation_; + standard_deviation_calculator_ = stats.standard_deviation_calculator_; + calculate_standard_deviation_ = stats.calculate_standard_deviation_; + initial_rtt_ = stats.initial_rtt_; + last_update_time_ = stats.last_update_time_; + ignore_max_ack_delay_ = stats.ignore_max_ack_delay_; +} + } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h b/chromium/net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h index 60549032b22..1911e385348 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h @@ -10,10 +10,10 @@ #include <algorithm> #include <cstdint> -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -111,6 +111,8 @@ class QUIC_EXPORT_PRIVATE RttStats { calculate_standard_deviation_ = true; } + void CloneFrom(const RttStats& stats); + private: friend class test::RttStatsPeer; diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/rtt_stats_test.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/rtt_stats_test.cc index 1b0e545af2c..bdf54c611fc 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/rtt_stats_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/rtt_stats_test.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h" +#include "quic/core/congestion_control/rtt_stats.h" #include <cmath> -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_mock_log.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/rtt_stats_peer.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_mock_log.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/rtt_stats_peer.h" using testing::_; using testing::Message; diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.cc index 4b36e4a378e..22f164cd3b7 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.cc @@ -2,17 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h" +#include "quic/core/congestion_control/send_algorithm_interface.h" #include "absl/base/attributes.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr2_sender.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/bbr_sender.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/tcp_cubic_sender_bytes.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_pcc_sender.h" +#include "quic/core/congestion_control/bbr2_sender.h" +#include "quic/core/congestion_control/bbr_sender.h" +#include "quic/core/congestion_control/tcp_cubic_sender_bytes.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" namespace quic { @@ -45,7 +44,7 @@ SendAlgorithmInterface* SendAlgorithmInterface::Create( ? static_cast<BbrSender*>(old_send_algorithm) : nullptr); case kPCC: - // PCC is work has stalled, fall back to CUBIC instead. + // PCC is currently not supported, fall back to CUBIC instead. ABSL_FALLTHROUGH_INTENDED; case kCubicBytes: return new TcpCubicSenderBytes( diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h b/chromium/net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h index 533bf4cc14d..2fa1217a9ea 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h @@ -11,16 +11,16 @@ #include <map> #include <string> -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_clock.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_stats.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_unacked_packet_map.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_clock.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_connection_stats.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_unacked_packet_map.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -47,25 +47,13 @@ class QUIC_EXPORT_PRIVATE SendAlgorithmInterface { return bandwidth == other.bandwidth && rtt == other.rtt && max_initial_congestion_window == other.max_initial_congestion_window && - allow_cwnd_to_decrease == other.allow_cwnd_to_decrease && - quic_fix_bbr_cwnd_in_bandwidth_resumption == - other.quic_fix_bbr_cwnd_in_bandwidth_resumption && - quic_bbr_fix_pacing_rate == other.quic_bbr_fix_pacing_rate && - quic_bbr_donot_inject_bandwidth == - other.quic_bbr_donot_inject_bandwidth; + allow_cwnd_to_decrease == other.allow_cwnd_to_decrease; } QuicBandwidth bandwidth; QuicTime::Delta rtt; int max_initial_congestion_window = 0; bool allow_cwnd_to_decrease; - // Code changes that are controlled by flags. - // TODO(b/131899599): Remove after impact of fix is measured. - bool quic_fix_bbr_cwnd_in_bandwidth_resumption = true; - // TODO(b/143540157): Remove after impact of fix is measured. - bool quic_bbr_fix_pacing_rate = true; - // TODO(b/72089315, b/143891040): Remove after impact of fix is measured. - bool quic_bbr_donot_inject_bandwidth = true; }; static SendAlgorithmInterface* Create( diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_test.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_test.cc index 9937cf89a37..4272c0bb173 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_test.cc @@ -8,21 +8,21 @@ #include <string> #include <utility> -#include "net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.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/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/simulator.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/switch.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_cat.h" +#include "quic/core/congestion_control/rtt_stats.h" +#include "quic/core/congestion_control/send_algorithm_interface.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_sent_packet_manager_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/simulator/quic_endpoint.h" +#include "quic/test_tools/simulator/simulator.h" +#include "quic/test_tools/simulator/switch.h" namespace quic { namespace test { @@ -134,7 +134,7 @@ struct TestParams { std::string TestParamToString( const testing::TestParamInfo<TestParams>& params) { - return quiche::QuicheStrCat( + return absl::StrCat( CongestionControlTypeToString(params.param.congestion_control_type), "_"); } diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/tcp_cubic_sender_bytes.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/tcp_cubic_sender_bytes.cc index bd2e24ec202..77691fdcf09 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/tcp_cubic_sender_bytes.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/tcp_cubic_sender_bytes.cc @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/tcp_cubic_sender_bytes.h" +#include "quic/core/congestion_control/tcp_cubic_sender_bytes.h" #include <algorithm> #include <cstdint> #include <string> -#include "net/third_party/quiche/src/quic/core/congestion_control/prr_sender.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#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 "quic/core/congestion_control/prr_sender.h" +#include "quic/core/congestion_control/rtt_stats.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/quic_constants.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -178,8 +178,8 @@ void TcpCubicSenderBytes::OnPacketSent( // PRR is used when in recovery. prr_.OnPacketSent(bytes); } - DCHECK(!largest_sent_packet_number_.IsInitialized() || - largest_sent_packet_number_ < packet_number); + QUICHE_DCHECK(!largest_sent_packet_number_.IsInitialized() || + largest_sent_packet_number_ < packet_number); largest_sent_packet_number_ = packet_number; hybrid_slow_start_.OnPacketSent(packet_number); } @@ -323,7 +323,7 @@ void TcpCubicSenderBytes::OnPacketLost(QuicPacketNumber packet_number, // TODO(b/77268641): Separate out all of slow start into a separate class. if (slow_start_large_reduction_ && InSlowStart()) { - DCHECK_LT(kDefaultTCPMSS, congestion_window_); + QUICHE_DCHECK_LT(kDefaultTCPMSS, congestion_window_); if (congestion_window_ >= 2 * initial_tcp_congestion_window_) { min_slow_start_exit_window_ = congestion_window_ / 2; } diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/tcp_cubic_sender_bytes.h b/chromium/net/third_party/quiche/src/quic/core/congestion_control/tcp_cubic_sender_bytes.h index 59ca7f875be..cf2a532e463 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/tcp_cubic_sender_bytes.h +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/tcp_cubic_sender_bytes.h @@ -10,15 +10,15 @@ #include <cstdint> #include <string> -#include "net/third_party/quiche/src/quic/core/congestion_control/cubic_bytes.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/hybrid_slow_start.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/prr_sender.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_stats.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/congestion_control/cubic_bytes.h" +#include "quic/core/congestion_control/hybrid_slow_start.h" +#include "quic/core/congestion_control/prr_sender.h" +#include "quic/core/congestion_control/send_algorithm_interface.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_connection_stats.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/tcp_cubic_sender_bytes_test.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/tcp_cubic_sender_bytes_test.cc index 13a253b97d0..6ef746d0a33 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/tcp_cubic_sender_bytes_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/tcp_cubic_sender_bytes_test.cc @@ -2,22 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/tcp_cubic_sender_bytes.h" +#include "quic/core/congestion_control/tcp_cubic_sender_bytes.h" #include <algorithm> #include <cstdint> #include <memory> #include <utility> -#include "net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.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/quic_config_peer.h" +#include "quic/core/congestion_control/rtt_stats.h" +#include "quic/core/congestion_control/send_algorithm_interface.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" +#include "quic/test_tools/quic_config_peer.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/uber_loss_algorithm.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/uber_loss_algorithm.cc index 2a1cbabea6e..3668487eac9 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/uber_loss_algorithm.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/uber_loss_algorithm.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/uber_loss_algorithm.h" +#include "quic/core/congestion_control/uber_loss_algorithm.h" #include <algorithm> -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/platform/api/quic_bug_tracker.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/uber_loss_algorithm.h b/chromium/net/third_party/quiche/src/quic/core/congestion_control/uber_loss_algorithm.h index 169972e1439..58cb53e3843 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/uber_loss_algorithm.h +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/uber_loss_algorithm.h @@ -6,9 +6,9 @@ #define QUICHE_QUIC_CORE_CONGESTION_CONTROL_UBER_LOSS_ALGORITHM_H_ #include "absl/types/optional.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/general_loss_algorithm.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "quic/core/congestion_control/general_loss_algorithm.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_flags.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/uber_loss_algorithm_test.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/uber_loss_algorithm_test.cc index 788d1013439..a24b444026a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/uber_loss_algorithm_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/uber_loss_algorithm_test.cc @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/uber_loss_algorithm.h" +#include "quic/core/congestion_control/uber_loss_algorithm.h" #include <memory> #include <utility> #include "absl/types/optional.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.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/quic_unacked_packet_map_peer.h" +#include "quic/core/congestion_control/rtt_stats.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" +#include "quic/test_tools/quic_unacked_packet_map_peer.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/windowed_filter.h b/chromium/net/third_party/quiche/src/quic/core/congestion_control/windowed_filter.h index 4176d730536..8949a9cab9a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/windowed_filter.h +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/windowed_filter.h @@ -31,7 +31,7 @@ // turn is replaced by the third best. The newest sample replaces the third // best. -#include "net/third_party/quiche/src/quic/core/quic_time.h" +#include "quic/core/quic_time.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/congestion_control/windowed_filter_test.cc b/chromium/net/third_party/quiche/src/quic/core/congestion_control/windowed_filter_test.cc index d91e80e4b82..bb0e8fb793c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/congestion_control/windowed_filter_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/congestion_control/windowed_filter_test.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/congestion_control/windowed_filter.h" +#include "quic/core/congestion_control/windowed_filter.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/congestion_control/rtt_stats.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aead_base_decrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/aead_base_decrypter.cc index f31720a82a8..32a2ebfc0e0 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aead_base_decrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aead_base_decrypter.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/aead_base_decrypter.h" +#include "quic/core/crypto/aead_base_decrypter.h" #include <cstdint> #include <string> @@ -12,9 +12,9 @@ #include "third_party/boringssl/src/include/openssl/crypto.h" #include "third_party/boringssl/src/include/openssl/err.h" #include "third_party/boringssl/src/include/openssl/evp.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -60,17 +60,17 @@ AeadBaseDecrypter::AeadBaseDecrypter(const EVP_AEAD* (*aead_getter)(), nonce_size_(nonce_size), use_ietf_nonce_construction_(use_ietf_nonce_construction), have_preliminary_key_(false) { - DCHECK_GT(256u, key_size); - DCHECK_GT(256u, auth_tag_size); - DCHECK_GT(256u, nonce_size); - DCHECK_LE(key_size_, sizeof(key_)); - DCHECK_LE(nonce_size_, sizeof(iv_)); + QUICHE_DCHECK_GT(256u, key_size); + QUICHE_DCHECK_GT(256u, auth_tag_size); + QUICHE_DCHECK_GT(256u, nonce_size); + QUICHE_DCHECK_LE(key_size_, sizeof(key_)); + QUICHE_DCHECK_LE(nonce_size_, sizeof(iv_)); } AeadBaseDecrypter::~AeadBaseDecrypter() {} bool AeadBaseDecrypter::SetKey(absl::string_view key) { - DCHECK_EQ(key.size(), key_size_); + QUICHE_DCHECK_EQ(key.size(), key_size_); if (key.size() != key_size_) { return false; } @@ -91,7 +91,7 @@ bool AeadBaseDecrypter::SetNoncePrefix(absl::string_view nonce_prefix) { QUIC_BUG << "Attempted to set nonce prefix on IETF QUIC crypter"; return false; } - DCHECK_EQ(nonce_prefix.size(), nonce_size_ - sizeof(QuicPacketNumber)); + QUICHE_DCHECK_EQ(nonce_prefix.size(), nonce_size_ - sizeof(QuicPacketNumber)); if (nonce_prefix.size() != nonce_size_ - sizeof(QuicPacketNumber)) { return false; } @@ -104,7 +104,7 @@ bool AeadBaseDecrypter::SetIV(absl::string_view iv) { QUIC_BUG << "Attempted to set IV on Google QUIC crypter"; return false; } - DCHECK_EQ(iv.size(), nonce_size_); + QUICHE_DCHECK_EQ(iv.size(), nonce_size_); if (iv.size() != nonce_size_) { return false; } @@ -113,7 +113,7 @@ bool AeadBaseDecrypter::SetIV(absl::string_view iv) { } bool AeadBaseDecrypter::SetPreliminaryKey(absl::string_view key) { - DCHECK(!have_preliminary_key_); + QUICHE_DCHECK(!have_preliminary_key_); SetKey(key); have_preliminary_key_ = true; @@ -139,7 +139,7 @@ bool AeadBaseDecrypter::SetDiversificationNonce( if (!SetKey(key) || (!use_ietf_nonce_construction_ && !SetNoncePrefix(nonce_prefix)) || (use_ietf_nonce_construction_ && !SetIV(nonce_prefix))) { - DCHECK(false); + QUICHE_DCHECK(false); return false; } diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aead_base_decrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/aead_base_decrypter.h index c4c04fe8f1b..1d4598b38ca 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aead_base_decrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aead_base_decrypter.h @@ -9,8 +9,8 @@ #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/aead.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aead_base_encrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/aead_base_encrypter.cc index b87ea50aede..a7100c5fa24 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aead_base_encrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aead_base_encrypter.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/aead_base_encrypter.h" +#include "quic/core/crypto/aead_base_encrypter.h" #include "absl/base/macros.h" #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/crypto.h" #include "third_party/boringssl/src/include/openssl/err.h" #include "third_party/boringssl/src/include/openssl/evp.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -51,15 +51,15 @@ AeadBaseEncrypter::AeadBaseEncrypter(const EVP_AEAD* (*aead_getter)(), auth_tag_size_(auth_tag_size), nonce_size_(nonce_size), use_ietf_nonce_construction_(use_ietf_nonce_construction) { - DCHECK_LE(key_size_, sizeof(key_)); - DCHECK_LE(nonce_size_, sizeof(iv_)); - DCHECK_GE(kMaxNonceSize, nonce_size_); + QUICHE_DCHECK_LE(key_size_, sizeof(key_)); + QUICHE_DCHECK_LE(nonce_size_, sizeof(iv_)); + QUICHE_DCHECK_GE(kMaxNonceSize, nonce_size_); } AeadBaseEncrypter::~AeadBaseEncrypter() {} bool AeadBaseEncrypter::SetKey(absl::string_view key) { - DCHECK_EQ(key.size(), key_size_); + QUICHE_DCHECK_EQ(key.size(), key_size_); if (key.size() != key_size_) { return false; } @@ -81,7 +81,7 @@ bool AeadBaseEncrypter::SetNoncePrefix(absl::string_view nonce_prefix) { QUIC_BUG << "Attempted to set nonce prefix on IETF QUIC crypter"; return false; } - DCHECK_EQ(nonce_prefix.size(), nonce_size_ - sizeof(QuicPacketNumber)); + QUICHE_DCHECK_EQ(nonce_prefix.size(), nonce_size_ - sizeof(QuicPacketNumber)); if (nonce_prefix.size() != nonce_size_ - sizeof(QuicPacketNumber)) { return false; } @@ -94,7 +94,7 @@ bool AeadBaseEncrypter::SetIV(absl::string_view iv) { QUIC_BUG << "Attempted to set IV on Google QUIC crypter"; return false; } - DCHECK_EQ(iv.size(), nonce_size_); + QUICHE_DCHECK_EQ(iv.size(), nonce_size_); if (iv.size() != nonce_size_) { return false; } @@ -106,7 +106,7 @@ bool AeadBaseEncrypter::Encrypt(absl::string_view nonce, absl::string_view associated_data, absl::string_view plaintext, unsigned char* output) { - DCHECK_EQ(nonce.size(), nonce_size_); + QUICHE_DCHECK_EQ(nonce.size(), nonce_size_); size_t ciphertext_len; if (!EVP_AEAD_CTX_seal( diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aead_base_encrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/aead_base_encrypter.h index 5ef8b96d11a..7571a651d7c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aead_base_encrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aead_base_encrypter.h @@ -9,8 +9,8 @@ #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/aead.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_decrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_decrypter.cc index 344280771f1..579ff923d56 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_decrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_decrypter.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_decrypter.h" +#include "quic/core/crypto/aes_128_gcm_12_decrypter.h" #include "third_party/boringssl/src/include/openssl/aead.h" #include "third_party/boringssl/src/include/openssl/tls1.h" diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_decrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_decrypter.h index d5686e81807..fbd8d51fb04 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_decrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_decrypter.h @@ -7,8 +7,8 @@ #include <cstdint> -#include "net/third_party/quiche/src/quic/core/crypto/aes_base_decrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/aes_base_decrypter.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_decrypter_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_decrypter_test.cc index aba1001b6ea..c16668b2fdd 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_decrypter_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_decrypter_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_decrypter.h" +#include "quic/core/crypto/aes_128_gcm_12_decrypter.h" #include <memory> #include <string> @@ -10,11 +10,11 @@ #include "absl/base/macros.h" #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/test_tools/quiche_test_utils.h" namespace { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_encrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_encrypter.cc index d48d5a583f2..075a21b9ef5 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_encrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_encrypter.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_encrypter.h" +#include "quic/core/crypto/aes_128_gcm_12_encrypter.h" #include "third_party/boringssl/src/include/openssl/evp.h" diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_encrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_encrypter.h index cd80fbfc9f5..f457336c00e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_encrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_encrypter.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_CORE_CRYPTO_AES_128_GCM_12_ENCRYPTER_H_ #define QUICHE_QUIC_CORE_CRYPTO_AES_128_GCM_12_ENCRYPTER_H_ -#include "net/third_party/quiche/src/quic/core/crypto/aes_base_encrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/aes_base_encrypter.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_encrypter_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_encrypter_test.cc index 1495fd08be1..5c093ad4ee0 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_encrypter_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_encrypter_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_encrypter.h" +#include "quic/core/crypto/aes_128_gcm_12_encrypter.h" #include <memory> #include <string> @@ -10,11 +10,11 @@ #include "absl/base/macros.h" #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/test_tools/quiche_test_utils.h" namespace { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_decrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_decrypter.cc index 650b245e7b6..d1def92811d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_decrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_decrypter.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_decrypter.h" +#include "quic/core/crypto/aes_128_gcm_decrypter.h" #include "third_party/boringssl/src/include/openssl/aead.h" #include "third_party/boringssl/src/include/openssl/tls1.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_decrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_decrypter.h index 6ddbe01e5aa..b9b3c68d8a7 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_decrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_decrypter.h @@ -7,8 +7,8 @@ #include <cstdint> -#include "net/third_party/quiche/src/quic/core/crypto/aes_base_decrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/aes_base_decrypter.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_decrypter_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_decrypter_test.cc index d4f38b90019..6877d9de48f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_decrypter_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_decrypter_test.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_decrypter.h" +#include "quic/core/crypto/aes_128_gcm_decrypter.h" #include <memory> #include <string> #include "absl/base/macros.h" #include "absl/strings/escaping.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/test_tools/quiche_test_utils.h" namespace { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_encrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_encrypter.cc index 71265782fdc..1cf28178581 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_encrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_encrypter.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_encrypter.h" +#include "quic/core/crypto/aes_128_gcm_encrypter.h" #include "third_party/boringssl/src/include/openssl/evp.h" diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_encrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_encrypter.h index 0610eac2638..c385de3b1b8 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_encrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_encrypter.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_CORE_CRYPTO_AES_128_GCM_ENCRYPTER_H_ #define QUICHE_QUIC_CORE_CRYPTO_AES_128_GCM_ENCRYPTER_H_ -#include "net/third_party/quiche/src/quic/core/crypto/aes_base_encrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/aes_base_encrypter.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_encrypter_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_encrypter_test.cc index c7c096f2b88..d51c5deb0ea 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_encrypter_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_encrypter_test.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_encrypter.h" +#include "quic/core/crypto/aes_128_gcm_encrypter.h" #include <memory> #include <string> #include "absl/base/macros.h" #include "absl/strings/escaping.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/test_tools/quiche_test_utils.h" namespace { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_decrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_decrypter.cc index a5f09e5d617..50980b731d2 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_decrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_decrypter.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_decrypter.h" +#include "quic/core/crypto/aes_256_gcm_decrypter.h" #include "third_party/boringssl/src/include/openssl/aead.h" #include "third_party/boringssl/src/include/openssl/tls1.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_decrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_decrypter.h index 260fecef7d9..6cc451ba186 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_decrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_decrypter.h @@ -7,8 +7,8 @@ #include <cstdint> -#include "net/third_party/quiche/src/quic/core/crypto/aes_base_decrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/aes_base_decrypter.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_decrypter_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_decrypter_test.cc index c688ce45ca8..bfafd2cb513 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_decrypter_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_decrypter_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_decrypter.h" +#include "quic/core/crypto/aes_256_gcm_decrypter.h" #include <memory> #include <string> @@ -10,11 +10,11 @@ #include "absl/base/macros.h" #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/test_tools/quiche_test_utils.h" namespace { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_encrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_encrypter.cc index 146e3de8519..06324967984 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_encrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_encrypter.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_encrypter.h" +#include "quic/core/crypto/aes_256_gcm_encrypter.h" #include "third_party/boringssl/src/include/openssl/evp.h" diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_encrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_encrypter.h index 0e458226375..7183fb764fa 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_encrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_encrypter.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_CORE_CRYPTO_AES_256_GCM_ENCRYPTER_H_ #define QUICHE_QUIC_CORE_CRYPTO_AES_256_GCM_ENCRYPTER_H_ -#include "net/third_party/quiche/src/quic/core/crypto/aes_base_encrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/aes_base_encrypter.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_encrypter_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_encrypter_test.cc index c09f8a84638..8d4c1de8e16 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_encrypter_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_encrypter_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_encrypter.h" +#include "quic/core/crypto/aes_256_gcm_encrypter.h" #include <memory> #include <string> @@ -10,11 +10,11 @@ #include "absl/base/macros.h" #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/test_tools/quiche_test_utils.h" namespace { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_base_decrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_base_decrypter.cc index 464e7656783..95cd509267a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_base_decrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_base_decrypter.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/aes_base_decrypter.h" +#include "quic/core/crypto/aes_base_decrypter.h" #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/aes.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_bug_tracker.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_base_decrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_base_decrypter.h index ced98103b90..a826f41b406 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_base_decrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_base_decrypter.h @@ -9,8 +9,8 @@ #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/aes.h" -#include "net/third_party/quiche/src/quic/core/crypto/aead_base_decrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/aead_base_decrypter.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_base_encrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_base_encrypter.cc index 6e998f8451e..663056dd41e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_base_encrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_base_encrypter.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/aes_base_encrypter.h" +#include "quic/core/crypto/aes_base_encrypter.h" #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/aes.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_bug_tracker.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_base_encrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_base_encrypter.h index 6b1c98c7566..8ea3787a911 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/aes_base_encrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/aes_base_encrypter.h @@ -9,8 +9,8 @@ #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/aes.h" -#include "net/third_party/quiche/src/quic/core/crypto/aead_base_encrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/aead_base_encrypter.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/boring_utils.h b/chromium/net/third_party/quiche/src/quic/core/crypto/boring_utils.h index 9de61f4d896..2927b891f98 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/boring_utils.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/boring_utils.h @@ -7,7 +7,7 @@ #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/bytestring.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/cert_compressor.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/cert_compressor.cc index ec5ebacbb08..e2a352d9d47 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/cert_compressor.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/cert_compressor.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/cert_compressor.h" +#include "quic/core/crypto/cert_compressor.h" #include <cstdint> #include <memory> @@ -10,7 +10,7 @@ #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" +#include "quic/core/quic_utils.h" #include "third_party/zlib/zlib.h" namespace quic { @@ -308,7 +308,7 @@ std::string ZlibDictForEntries(const std::vector<CertEntry>& entries, zlib_dict += std::string(reinterpret_cast<const char*>(kCommonCertSubstrings), sizeof(kCommonCertSubstrings)); - DCHECK_EQ(zlib_dict.size(), zlib_dict_size); + QUICHE_DCHECK_EQ(zlib_dict.size(), zlib_dict_size); return zlib_dict; } @@ -456,7 +456,7 @@ std::string CertCompressor::CompressChain( const CommonCertSets* common_sets) { const std::vector<CertEntry> entries = MatchCerts( certs, client_common_set_hashes, client_cached_cert_hashes, common_sets); - DCHECK_EQ(entries.size(), certs.size()); + QUICHE_DCHECK_EQ(entries.size(), certs.size()); size_t uncompressed_size = 0; for (size_t i = 0; i < entries.size(); i++) { @@ -472,7 +472,7 @@ std::string CertCompressor::CompressChain( if (uncompressed_size > 0) { memset(&z, 0, sizeof(z)); int rv = deflateInit(&z, Z_DEFAULT_COMPRESSION); - DCHECK_EQ(Z_OK, rv); + QUICHE_DCHECK_EQ(Z_OK, rv); if (rv != Z_OK) { return ""; } @@ -482,7 +482,7 @@ std::string CertCompressor::CompressChain( rv = deflateSetDictionary( &z, reinterpret_cast<const uint8_t*>(&zlib_dict[0]), zlib_dict.size()); - DCHECK_EQ(Z_OK, rv); + QUICHE_DCHECK_EQ(Z_OK, rv); if (rv != Z_OK) { return ""; } @@ -522,8 +522,8 @@ std::string CertCompressor::CompressChain( z.next_in = reinterpret_cast<uint8_t*>(&length32); z.avail_in = sizeof(length32); rv = deflate(&z, Z_NO_FLUSH); - DCHECK_EQ(Z_OK, rv); - DCHECK_EQ(0u, z.avail_in); + QUICHE_DCHECK_EQ(Z_OK, rv); + QUICHE_DCHECK_EQ(0u, z.avail_in); if (rv != Z_OK || z.avail_in) { return ""; } @@ -532,8 +532,8 @@ std::string CertCompressor::CompressChain( const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(certs[i].data())); z.avail_in = certs[i].size(); rv = deflate(&z, Z_NO_FLUSH); - DCHECK_EQ(Z_OK, rv); - DCHECK_EQ(0u, z.avail_in); + QUICHE_DCHECK_EQ(Z_OK, rv); + QUICHE_DCHECK_EQ(0u, z.avail_in); if (rv != Z_OK || z.avail_in) { return ""; } @@ -541,7 +541,7 @@ std::string CertCompressor::CompressChain( z.avail_in = 0; rv = deflate(&z, Z_FINISH); - DCHECK_EQ(Z_STREAM_END, rv); + QUICHE_DCHECK_EQ(Z_STREAM_END, rv); if (rv != Z_STREAM_END) { return ""; } @@ -560,7 +560,7 @@ bool CertCompressor::DecompressChain( if (!ParseEntries(&in, cached_certs, common_sets, &entries, out_certs)) { return false; } - DCHECK_EQ(entries.size(), out_certs->size()); + QUICHE_DCHECK_EQ(entries.size(), out_certs->size()); std::unique_ptr<uint8_t[]> uncompressed_data; absl::string_view uncompressed; diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/cert_compressor.h b/chromium/net/third_party/quiche/src/quic/core/crypto/cert_compressor.h index a9e9ec90520..85542228fbb 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/cert_compressor.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/cert_compressor.h @@ -9,9 +9,9 @@ #include <vector> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/common_cert_set.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/common_cert_set.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/cert_compressor_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/cert_compressor_test.cc index 87446acf86a..b76ee7bf8d4 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/cert_compressor_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/cert_compressor_test.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/cert_compressor.h" +#include "quic/core/crypto/cert_compressor.h" #include <memory> #include <string> #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view.cc index 6042b9e7cc4..7a20602337d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/certificate_view.h" +#include "quic/core/crypto/certificate_view.h" #include <algorithm> #include <cstdint> @@ -11,6 +11,7 @@ #include "absl/strings/escaping.h" #include "absl/strings/match.h" +#include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" @@ -23,16 +24,15 @@ #include "third_party/boringssl/src/include/openssl/nid.h" #include "third_party/boringssl/src/include/openssl/rsa.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/crypto/boring_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_time_utils.h" -#include "net/third_party/quiche/src/common/quiche_data_reader.h" +#include "quic/core/crypto/boring_utils.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_logging.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/platform/api/quiche_time_utils.h" +#include "common/quiche_data_reader.h" namespace quic { namespace { @@ -123,7 +123,7 @@ std::string AttributeNameToString(const CBS& oid_cbs) { bssl::UniquePtr<char> oid_representation(CBS_asn1_oid_to_text(&oid_cbs)); if (oid_representation == nullptr) { - return quiche::QuicheStrCat("(", absl::BytesToHexString(oid), ")"); + return absl::StrCat("(", absl::BytesToHexString(oid), ")"); } return std::string(oid_representation.get()); } @@ -139,8 +139,8 @@ absl::optional<std::string> X509NameAttributeToString(CBS input) { } // Note that this does not process encoding of |input| in any way. This works // fine for the most cases. - return quiche::QuicheStrCat(AttributeNameToString(name), "=", - absl::CHexEscape(CbsToStringPiece(value))); + return absl::StrCat(AttributeNameToString(name), "=", + absl::CHexEscape(CbsToStringPiece(value))); } namespace { @@ -196,7 +196,7 @@ absl::optional<quic::QuicWallTime> ParseDerTime(unsigned tag, } if (tag == CBS_ASN1_UTCTIME) { - DCHECK_LE(year, 100u); + QUICHE_DCHECK_LE(year, 100u); year += (year >= 50) ? 1900 : 2000; } @@ -227,7 +227,7 @@ PemReadResult ReadNextPemMessage(std::istream* input) { result.type = std::string( line.substr(kPemBegin.size(), line.size() - kPemDashes.size() - kPemBegin.size())); - expected_end = quiche::QuicheStrCat(kPemEnd, result.type, kPemDashes); + expected_end = absl::StrCat(kPemEnd, result.type, kPemDashes); pending_message = true; continue; } diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view.h b/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view.h index 7439ee64401..0f881654f5b 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view.h @@ -14,11 +14,11 @@ #include "third_party/boringssl/src/include/openssl/base.h" #include "third_party/boringssl/src/include/openssl/bytestring.h" #include "third_party/boringssl/src/include/openssl/evp.h" -#include "net/third_party/quiche/src/quic/core/crypto/boring_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" +#include "quic/core/crypto/boring_utils.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_ip_address.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view_der_fuzzer.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view_der_fuzzer.cc index e66f4f917bc..da931a26ecf 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view_der_fuzzer.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view_der_fuzzer.cc @@ -4,7 +4,7 @@ #include <string> -#include "net/third_party/quiche/src/quic/core/crypto/certificate_view.h" +#include "quic/core/crypto/certificate_view.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { std::string input(reinterpret_cast<const char*>(data), size); diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view_pem_fuzzer.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view_pem_fuzzer.cc index e1efd988bb9..b317bef0041 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view_pem_fuzzer.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view_pem_fuzzer.cc @@ -5,7 +5,7 @@ #include <sstream> #include <string> -#include "net/third_party/quiche/src/quic/core/crypto/certificate_view.h" +#include "quic/core/crypto/certificate_view.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { std::string input(reinterpret_cast<const char*>(data), size); diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view_test.cc index 46e30f1285f..5d743b2114c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/certificate_view_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/certificate_view.h" +#include "quic/core/crypto/certificate_view.h" #include <memory> #include <sstream> @@ -13,12 +13,12 @@ #include "third_party/boringssl/src/include/openssl/bytestring.h" #include "third_party/boringssl/src/include/openssl/evp.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/crypto/boring_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/test_certificates.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_time_utils.h" +#include "quic/core/crypto/boring_utils.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/test_certificates.h" +#include "common/platform/api/quiche_time_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_decrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_decrypter.cc index b860348b13f..8a4571b7da4 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_decrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_decrypter.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_decrypter.h" +#include "quic/core/crypto/chacha20_poly1305_decrypter.h" #include "third_party/boringssl/src/include/openssl/aead.h" #include "third_party/boringssl/src/include/openssl/tls1.h" diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_decrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_decrypter.h index 2e4b32b36f4..f6af33d7902 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_decrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_decrypter.h @@ -7,8 +7,8 @@ #include <cstdint> -#include "net/third_party/quiche/src/quic/core/crypto/chacha_base_decrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/chacha_base_decrypter.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_decrypter_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_decrypter_test.cc index 3711104fc4f..42d8899a781 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_decrypter_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_decrypter_test.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_decrypter.h" +#include "quic/core/crypto/chacha20_poly1305_decrypter.h" #include <memory> #include <string> #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/test_tools/quiche_test_utils.h" namespace { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter.cc index f66f31c46b5..09be04ff79f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter.h" +#include "quic/core/crypto/chacha20_poly1305_encrypter.h" #include "third_party/boringssl/src/include/openssl/evp.h" diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter.h index 98f6ff042bd..3f58b592433 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_CORE_CRYPTO_CHACHA20_POLY1305_ENCRYPTER_H_ #define QUICHE_QUIC_CORE_CRYPTO_CHACHA20_POLY1305_ENCRYPTER_H_ -#include "net/third_party/quiche/src/quic/core/crypto/chacha_base_encrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/chacha_base_encrypter.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter_test.cc index 91b32ef5c3c..8c403fede35 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter_test.cc @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter.h" +#include "quic/core/crypto/chacha20_poly1305_encrypter.h" #include <memory> #include <string> #include "absl/base/macros.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_decrypter.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/core/crypto/chacha20_poly1305_decrypter.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/test_tools/quiche_test_utils.h" namespace { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_decrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_decrypter.cc index 7bf84785127..92cb1320f69 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_decrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_decrypter.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_decrypter.h" +#include "quic/core/crypto/chacha20_poly1305_tls_decrypter.h" #include "third_party/boringssl/src/include/openssl/aead.h" #include "third_party/boringssl/src/include/openssl/tls1.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_decrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_decrypter.h index 04ee5b8b865..69abd89f873 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_decrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_decrypter.h @@ -7,8 +7,8 @@ #include <cstdint> -#include "net/third_party/quiche/src/quic/core/crypto/chacha_base_decrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/chacha_base_decrypter.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_decrypter_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_decrypter_test.cc index 431f0121c7d..4b0f10bcd0d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_decrypter_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_decrypter_test.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_decrypter.h" +#include "quic/core/crypto/chacha20_poly1305_tls_decrypter.h" #include <memory> #include <string> #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/test_tools/quiche_test_utils.h" namespace { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_encrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_encrypter.cc index a03a14c065e..bbcb332799c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_encrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_encrypter.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_encrypter.h" +#include "quic/core/crypto/chacha20_poly1305_tls_encrypter.h" #include "third_party/boringssl/src/include/openssl/evp.h" diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_encrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_encrypter.h index f83141fd626..81a750fddb0 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_encrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_encrypter.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_CORE_CRYPTO_CHACHA20_POLY1305_TLS_ENCRYPTER_H_ #define QUICHE_QUIC_CORE_CRYPTO_CHACHA20_POLY1305_TLS_ENCRYPTER_H_ -#include "net/third_party/quiche/src/quic/core/crypto/chacha_base_encrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/chacha_base_encrypter.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_encrypter_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_encrypter_test.cc index 1918d2ab878..7bca425a708 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_encrypter_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_encrypter_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_encrypter.h" +#include "quic/core/crypto/chacha20_poly1305_tls_encrypter.h" #include <memory> #include <string> @@ -10,12 +10,12 @@ #include "absl/base/macros.h" #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_decrypter.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/core/crypto/chacha20_poly1305_tls_decrypter.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/test_tools/quiche_test_utils.h" namespace { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha_base_decrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha_base_decrypter.cc index 1fccc5d1b9d..1b8af25c451 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha_base_decrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha_base_decrypter.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/chacha_base_decrypter.h" +#include "quic/core/crypto/chacha_base_decrypter.h" #include <cstdint> #include "absl/base/macros.h" #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/chacha.h" -#include "net/third_party/quiche/src/quic/core/quic_data_reader.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/core/quic_data_reader.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "common/quiche_endian.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha_base_decrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha_base_decrypter.h index 610bc594b77..4348cacee7d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha_base_decrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha_base_decrypter.h @@ -8,8 +8,8 @@ #include <cstddef> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/aead_base_decrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/aead_base_decrypter.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha_base_encrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha_base_encrypter.cc index 0b9d3444d2b..f667f1cdc8a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha_base_encrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha_base_encrypter.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/chacha_base_encrypter.h" +#include "quic/core/crypto/chacha_base_encrypter.h" #include "absl/base/macros.h" #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/chacha.h" -#include "net/third_party/quiche/src/quic/core/quic_data_reader.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/core/quic_data_reader.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "common/quiche_endian.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha_base_encrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha_base_encrypter.h index 97385c31364..4b48963d0ac 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/chacha_base_encrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/chacha_base_encrypter.h @@ -8,8 +8,8 @@ #include <cstddef> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/aead_base_encrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/aead_base_encrypter.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/channel_id.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/channel_id.cc index 2d30147ef82..2d6f825a481 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/channel_id.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/channel_id.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/channel_id.h" +#include "quic/core/crypto/channel_id.h" #include <cstdint> diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/channel_id.h b/chromium/net/third_party/quiche/src/quic/core/crypto/channel_id.h index e176cdb0676..11759d23601 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/channel_id.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/channel_id.h @@ -9,8 +9,8 @@ #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/channel_id_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/channel_id_test.cc index cd95539d541..cf89fe5d891 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/channel_id_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/channel_id_test.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/channel_id.h" +#include "quic/core/crypto/channel_id.h" #include <memory> #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set.cc index fa66c7292cb..aa057538948 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set.cc @@ -2,22 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/common_cert_set.h" +#include "quic/core/crypto/common_cert_set.h" #include <cstddef> #include "absl/base/macros.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" +#include "quic/core/quic_utils.h" namespace quic { namespace common_cert_set_2 { -#include "net/third_party/quiche/src/quic/core/crypto/common_cert_set_2.c" +#include "quic/core/crypto/common_cert_set_2.c" } namespace common_cert_set_3 { -#include "net/third_party/quiche/src/quic/core/crypto/common_cert_set_3.c" +#include "quic/core/crypto/common_cert_set_3.c" } namespace { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set.h b/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set.h index ae83e1ddbf5..6bcd87d7844 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set.h @@ -8,8 +8,8 @@ #include <cstdint> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set_2.c b/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set_2.c index ec205fc7fb1..6392e67d387 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set_2.c +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set_2.c @@ -1,8 +1,8 @@ /* This file contains common certificates. It's designed to be #included in * another file, in a namespace. */ -#include "net/third_party/quiche/src/quic/core/crypto/common_cert_set_2a.inc" -#include "net/third_party/quiche/src/quic/core/crypto/common_cert_set_2b.inc" +#include "quic/core/crypto/common_cert_set_2a.inc" +#include "quic/core/crypto/common_cert_set_2b.inc" static const size_t kNumCerts = 54; static const unsigned char* const kCerts[] = { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set_3.c b/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set_3.c index 876d00c837a..e387b1b20b8 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set_3.c +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set_3.c @@ -1,8 +1,8 @@ /* This file contains common certificates. It's designed to be #included in * another file, in a namespace. */ -#include "net/third_party/quiche/src/quic/core/crypto/common_cert_set_3a.inc" -#include "net/third_party/quiche/src/quic/core/crypto/common_cert_set_3b.inc" +#include "quic/core/crypto/common_cert_set_3a.inc" +#include "quic/core/crypto/common_cert_set_3b.inc" static const size_t kNumCerts = 52; static const unsigned char* const kCerts[] = { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set_empty.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set_empty.cc index 8c9a67bafe8..f5d246dd768 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set_empty.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set_empty.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/common_cert_set.h" +#include "quic/core/crypto/common_cert_set.h" #include <cstddef> #include "absl/base/macros.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" +#include "quic/core/quic_utils.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set_test.cc index 01996c33e15..b5f91f38b8c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/common_cert_set_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/common_cert_set.h" +#include "quic/core/crypto/common_cert_set.h" #include <cstdint> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_framer.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_framer.cc index 2a3f7958034..cf6e123d833 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_framer.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_framer.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/crypto_framer.h" +#include "quic/core/crypto/crypto_framer.h" #include <string> #include <utility> #include "absl/base/attributes.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/quic_data_reader.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/quic_data_reader.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_logging.h" +#include "common/quiche_endian.h" namespace quic { @@ -87,13 +87,13 @@ bool CryptoFramer::ProcessInput(absl::string_view input, } bool CryptoFramer::ProcessInput(absl::string_view input) { - DCHECK_EQ(QUIC_NO_ERROR, error_); + QUICHE_DCHECK_EQ(QUIC_NO_ERROR, error_); if (error_ != QUIC_NO_ERROR) { return false; } error_ = Process(input); if (error_ != QUIC_NO_ERROR) { - DCHECK(!error_detail_.empty()); + QUICHE_DCHECK(!error_detail_.empty()); visitor_->OnError(this); return false; } @@ -160,15 +160,15 @@ std::unique_ptr<QuicData> CryptoFramer::ConstructHandshakeMessage( std::unique_ptr<char[]> buffer(new char[len]); QuicDataWriter writer(len, buffer.get(), quiche::HOST_BYTE_ORDER); if (!writer.WriteTag(message.tag())) { - DCHECK(false) << "Failed to write message tag."; + QUICHE_DCHECK(false) << "Failed to write message tag."; return nullptr; } if (!writer.WriteUInt16(static_cast<uint16_t>(num_entries))) { - DCHECK(false) << "Failed to write size."; + QUICHE_DCHECK(false) << "Failed to write size."; return nullptr; } if (!writer.WriteUInt16(0)) { - DCHECK(false) << "Failed to write padding."; + QUICHE_DCHECK(false) << "Failed to write padding."; return nullptr; } @@ -180,7 +180,8 @@ std::unique_ptr<QuicData> CryptoFramer::ConstructHandshakeMessage( // Existing PAD tags are only checked when padding needs to be added // because parts of the code may need to reserialize received messages // and those messages may, legitimately include padding. - DCHECK(false) << "Message needed padding but already contained a PAD tag"; + QUICHE_DCHECK(false) + << "Message needed padding but already contained a PAD tag"; return nullptr; } @@ -192,12 +193,12 @@ std::unique_ptr<QuicData> CryptoFramer::ConstructHandshakeMessage( } if (!writer.WriteTag(it->first)) { - DCHECK(false) << "Failed to write tag."; + QUICHE_DCHECK(false) << "Failed to write tag."; return nullptr; } end_offset += it->second.length(); if (!writer.WriteUInt32(end_offset)) { - DCHECK(false) << "Failed to write end offset."; + QUICHE_DCHECK(false) << "Failed to write end offset."; return nullptr; } } @@ -214,20 +215,20 @@ std::unique_ptr<QuicData> CryptoFramer::ConstructHandshakeMessage( if (it->first > kPAD && need_pad_value) { need_pad_value = false; if (!writer.WriteRepeatedByte('-', pad_length)) { - DCHECK(false) << "Failed to write padding."; + QUICHE_DCHECK(false) << "Failed to write padding."; return nullptr; } } if (!writer.WriteBytes(it->second.data(), it->second.length())) { - DCHECK(false) << "Failed to write value."; + QUICHE_DCHECK(false) << "Failed to write value."; return nullptr; } } if (need_pad_value) { if (!writer.WriteRepeatedByte('-', pad_length)) { - DCHECK(false) << "Failed to write padding."; + QUICHE_DCHECK(false) << "Failed to write padding."; return nullptr; } } @@ -265,7 +266,7 @@ QuicErrorCode CryptoFramer::Process(absl::string_view input) { } reader.ReadUInt16(&num_entries_); if (num_entries_ > kMaxEntries) { - error_detail_ = quiche::QuicheStrCat(num_entries_, " entries"); + error_detail_ = absl::StrCat(num_entries_, " entries"); return QUIC_CRYPTO_TOO_MANY_ENTRIES; } uint16_t padding; @@ -287,10 +288,10 @@ QuicErrorCode CryptoFramer::Process(absl::string_view input) { reader.ReadTag(&tag); if (i > 0 && tag <= tags_and_lengths_[i - 1].first) { if (tag == tags_and_lengths_[i - 1].first) { - error_detail_ = quiche::QuicheStrCat("Duplicate tag:", tag); + error_detail_ = absl::StrCat("Duplicate tag:", tag); return QUIC_CRYPTO_DUPLICATE_TAG; } - error_detail_ = quiche::QuicheStrCat("Tag ", tag, " out of order"); + error_detail_ = absl::StrCat("Tag ", tag, " out of order"); return QUIC_CRYPTO_TAGS_OUT_OF_ORDER; } @@ -298,8 +299,8 @@ QuicErrorCode CryptoFramer::Process(absl::string_view input) { reader.ReadUInt32(&end_offset); if (end_offset < last_end_offset) { - error_detail_ = quiche::QuicheStrCat("End offset: ", end_offset, - " vs ", last_end_offset); + error_detail_ = + absl::StrCat("End offset: ", end_offset, " vs ", last_end_offset); return QUIC_CRYPTO_TAGS_OUT_OF_ORDER; } tags_and_lengths_.push_back(std::make_pair( @@ -321,7 +322,7 @@ QuicErrorCode CryptoFramer::Process(absl::string_view input) { for (const std::pair<QuicTag, size_t>& item : tags_and_lengths_) { absl::string_view value; if (!reader.ReadStringPiece(&value, item.second)) { - DCHECK(process_truncated_messages_); + QUICHE_DCHECK(process_truncated_messages_); // Store an empty value. message_.SetStringPiece(item.first, ""); continue; @@ -343,12 +344,12 @@ bool CryptoFramer::WritePadTag(QuicDataWriter* writer, size_t pad_length, uint32_t* end_offset) { if (!writer->WriteTag(kPAD)) { - DCHECK(false) << "Failed to write tag."; + QUICHE_DCHECK(false) << "Failed to write tag."; return false; } *end_offset += pad_length; if (!writer->WriteUInt32(*end_offset)) { - DCHECK(false) << "Failed to write end offset."; + QUICHE_DCHECK(false) << "Failed to write end offset."; return false; } return true; diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_framer.h b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_framer.h index e7289ebed2f..e3c6c63c746 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_framer.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_framer.h @@ -13,9 +13,9 @@ #include <vector> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_message_parser.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/crypto_handshake_message.h" +#include "quic/core/crypto/crypto_message_parser.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_framer_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_framer_test.cc index 033e6248b90..656a00a6ced 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_framer_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_framer_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/crypto_framer.h" +#include "quic/core/crypto/crypto_framer.h" #include <map> #include <memory> @@ -10,14 +10,14 @@ #include "absl/base/macros.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/test_tools/quiche_test_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake.cc index 3d6baac26d6..05194a5cc3b 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/common_cert_set.h" -#include "net/third_party/quiche/src/quic/core/crypto/key_exchange.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" +#include "quic/core/crypto/common_cert_set.h" +#include "quic/core/crypto/key_exchange.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h index 040fe9ece83..2c5c588ba51 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h @@ -9,8 +9,8 @@ #include <string> #include <vector> -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.cc index 75bd3feac4f..9628ed904fe 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.cc @@ -2,22 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" +#include "quic/core/crypto/crypto_handshake_message.h" #include <memory> #include <string> #include "absl/strings/escaping.h" +#include "absl/strings/str_format.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_framer.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_socket_address_coder.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/core/crypto/crypto_framer.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/crypto_utils.h" +#include "quic/core/quic_socket_address_coder.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_map_util.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/quiche_endian.h" namespace quic { @@ -357,8 +357,7 @@ std::string CryptoHandshakeMessage::DebugStringInternal(size_t indent) const { } break; case kPAD: - ret += quiche::QuicheStringPrintf("(%d bytes of padding)", - static_cast<int>(it->second.size())); + ret += absl::StrFormat("(%d bytes of padding)", it->second.size()); done = true; break; case kSNI: diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h index 5c501277112..61fb75735c6 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h @@ -12,9 +12,9 @@ #include <vector> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_uint128.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message_test.cc index b006572238b..4ace2e36b77 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" +#include "quic/core/crypto/crypto_handshake_message.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/platform/api/quic_test.h" +#include "common/quiche_endian.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_message_parser.h b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_message_parser.h index b5e6a9d4764..5b29dbf7364 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_message_parser.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_message_parser.h @@ -8,8 +8,8 @@ #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_types.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_message_printer_bin.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_message_printer_bin.cc index 9a4e223fae9..3109924d59e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_message_printer_bin.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_message_printer_bin.cc @@ -11,9 +11,9 @@ #include <string> #include "absl/strings/escaping.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/crypto_framer.h" +#include "quic/core/quic_utils.h" +#include "common/platform/api/quiche_text_utils.h" using std::cerr; using std::cout; diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h index 5372f3fdb50..99f537213b7 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h @@ -8,7 +8,7 @@ #include <cstddef> #include <string> -#include "net/third_party/quiche/src/quic/core/quic_tag.h" +#include "quic/core/quic_tag.h" // Version and Crypto tags are written to the wire with a big-endian // representation of the name of the tag. For example @@ -28,7 +28,7 @@ using ServerConfigID = std::string; // The following tags have been deprecated and should not be reused: // "1CON", "BBQ4", "NCON", "RCID", "SREJ", "TBKP", "TB10", "SCLS", "SMHL", -// "QNZR", "B2HI" +// "QNZR", "B2HI", "H2PR", "FIFO", "LIFO", "RRWS" // clang-format off const QuicTag kCHLO = TAG('C', 'H', 'L', 'O'); // Client hello @@ -108,6 +108,14 @@ const QuicTag kBBQ3 = TAG('B', 'B', 'Q', '3'); // BBR with ack aggregation const QuicTag kBBQ5 = TAG('B', 'B', 'Q', '5'); // Expire ack aggregation upon // bandwidth increase in // STARTUP. +const QuicTag kBBQ6 = TAG('B', 'B', 'Q', '6'); // Reduce STARTUP gain to 25% + // more than BW increase. +const QuicTag kBBQ7 = TAG('B', 'B', 'Q', '7'); // Reduce bw_lo by + // bytes_lost/min_rtt. +const QuicTag kBBQ8 = TAG('B', 'B', 'Q', '8'); // Reduce bw_lo by + // bw_lo * bytes_lost/inflight +const QuicTag kBBQ9 = TAG('B', 'B', 'Q', '9'); // Reduce bw_lo by + // bw_lo * bytes_lost/cwnd const QuicTag kRENO = TAG('R', 'E', 'N', 'O'); // Reno Congestion Control const QuicTag kTPCC = TAG('P', 'C', 'C', '\0'); // Performance-Oriented // Congestion Control @@ -137,9 +145,13 @@ const QuicTag kB2H2 = TAG('B', '2', 'H', '2'); // When exiting PROBE_UP due to // loss, set inflight_hi to the // max of inflight@send and max // bytes delivered in round. +const QuicTag kB2RC = TAG('B', '2', 'R', 'C'); // Disable Reno-coexistence for + // BBR2. const QuicTag kBSAO = TAG('B', 'S', 'A', 'O'); // Avoid Overestimation in // Bandwidth Sampler with ack // aggregation +const QuicTag kB2DL = TAG('B', '2', 'D', 'L'); // Increase inflight_hi based + // on delievered, not inflight. const QuicTag kNTLP = TAG('N', 'T', 'L', 'P'); // No tail loss probe const QuicTag k1TLP = TAG('1', 'T', 'L', 'P'); // 1 tail loss probe const QuicTag k1RTO = TAG('1', 'R', 'T', 'O'); // Send 1 packet upon RTO @@ -266,6 +278,9 @@ const QuicTag kMPTH = TAG('M', 'P', 'T', 'H'); // Enable multipath. const QuicTag kNCMR = TAG('N', 'C', 'M', 'R'); // Do not attempt connection // migration. +// Allows disabling defer_send_in_response_to_packets in QuicConnection. +const QuicTag kDFER = TAG('D', 'F', 'E', 'R'); // Do not defer sending. + // Disable Pacing offload option. const QuicTag kNPCO = TAG('N', 'P', 'C', 'O'); // No pacing offload. @@ -322,14 +337,6 @@ const QuicTag k10AF = TAG('1', '0', 'A', 'F'); // 10 anti amplification factor. const QuicTag kMTUH = TAG('M', 'T', 'U', 'H'); // High-target MTU discovery. const QuicTag kMTUL = TAG('M', 'T', 'U', 'L'); // Low-target MTU discovery. -// Enable Priority scheme experiment. -const QuicTag kH2PR = TAG('H', '2', 'P', 'R'); // HTTP2 priorities. -const QuicTag kFIFO = TAG('F', 'I', 'F', 'O'); // Stream with the smallest ID - // has the highest priority. -const QuicTag kLIFO = TAG('L', 'I', 'F', 'O'); // Stream with the largest ID - // has the highest priority. -const QuicTag kRRWS = TAG('R', 'R', 'W', 'S'); // Round robin write scheduling. - const QuicTag kNSLC = TAG('N', 'S', 'L', 'C'); // Always send connection close // for idle timeout. @@ -377,6 +384,18 @@ const QuicTag kXLCT = TAG('X', 'L', 'C', 'T'); // Expected leaf certificate. const QuicTag kQLVE = TAG('Q', 'L', 'V', 'E'); // Legacy Version // Encapsulation. +const QuicTag kPDP2 = TAG('P', 'D', 'P', '2'); // Path degrading triggered + // at 2PTO. + +const QuicTag kPDP3 = TAG('P', 'D', 'P', '3'); // Path degrading triggered + // at 3PTO. + +const QuicTag kPDP4 = TAG('P', 'D', 'P', '4'); // Path degrading triggered + // at 4PTO. + +const QuicTag kPDP5 = TAG('P', 'D', 'P', '5'); // Path degrading triggered + // at 5PTO. + const QuicTag kQNZ2 = TAG('Q', 'N', 'Z', '2'); // Turn off QUIC crypto 0-RTT. const QuicTag kQNSP = TAG('Q', 'N', 'S', 'P'); // Turn off server push in @@ -384,6 +403,14 @@ const QuicTag kQNSP = TAG('Q', 'N', 'S', 'P'); // Turn off server push in const QuicTag kMAD = TAG('M', 'A', 'D', 0); // Max Ack Delay (IETF QUIC) +const QuicTag kIGNP = TAG('I', 'G', 'N', 'P'); // Do not use PING only packet + // for RTT measure or + // congestion control. + +const QuicTag kSRWP = TAG('S', 'R', 'W', 'P'); // Enable retransmittable on + // wire PING (ROWP) on the + // server side. + // Rejection tags const QuicTag kRREJ = TAG('R', 'R', 'E', 'J'); // Reasons for server sending diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_secret_boxer.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_secret_boxer.cc index 1f75e0c7157..1826212d83c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_secret_boxer.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_secret_boxer.cc @@ -5,13 +5,13 @@ #include <cstdint> #include <string> -#include "net/third_party/quiche/src/quic/core/crypto/crypto_secret_boxer.h" +#include "quic/core/crypto/crypto_secret_boxer.h" #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/aead.h" #include "third_party/boringssl/src/include/openssl/err.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -45,12 +45,12 @@ size_t CryptoSecretBoxer::GetKeySize() { static const EVP_AEAD* (*const kAEAD)() = EVP_aead_aes_256_gcm_siv; void CryptoSecretBoxer::SetKeys(const std::vector<std::string>& keys) { - DCHECK(!keys.empty()); + QUICHE_DCHECK(!keys.empty()); const EVP_AEAD* const aead = kAEAD(); std::unique_ptr<State> new_state(new State); for (const std::string& key : keys) { - DCHECK_EQ(kBoxKeySize, key.size()); + QUICHE_DCHECK_EQ(kBoxKeySize, key.size()); bssl::UniquePtr<EVP_AEAD_CTX> ctx( EVP_AEAD_CTX_new(aead, reinterpret_cast<const uint8_t*>(key.data()), key.size(), EVP_AEAD_DEFAULT_TAG_LENGTH)); @@ -100,7 +100,7 @@ std::string CryptoSecretBoxer::Box(QuicRandom* rand, } } - DCHECK_EQ(out_len, bytes_written); + QUICHE_DCHECK_EQ(out_len, bytes_written); return ret; } diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_secret_boxer.h b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_secret_boxer.h index 6cf61b41c8d..5dd5cb24985 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_secret_boxer.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_secret_boxer.h @@ -11,8 +11,8 @@ #include <vector> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_mutex.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_mutex.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_secret_boxer_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_secret_boxer_test.cc index b63d081031f..225bfc8b14e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_secret_boxer_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_secret_boxer_test.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/crypto_secret_boxer.h" +#include "quic/core/crypto/crypto_secret_boxer.h" #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_server_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_server_test.cc index 51dc4181002..323aec10316 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_server_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_server_test.cc @@ -14,26 +14,26 @@ #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/sha.h" -#include "net/third_party/quiche/src/quic/core/crypto/cert_compressor.h" -#include "net/third_party/quiche/src/quic/core/crypto/common_cert_set.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/proto/crypto_server_config_proto.h" -#include "net/third_party/quiche/src/quic/core/quic_socket_address_coder.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/failing_proof_source.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" -#include "net/third_party/quiche/src/quic/test_tools/quic_crypto_server_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/core/crypto/cert_compressor.h" +#include "quic/core/crypto/common_cert_set.h" +#include "quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/crypto_utils.h" +#include "quic/core/crypto/proof_source.h" +#include "quic/core/crypto/quic_crypto_server_config.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/proto/crypto_server_config_proto.h" +#include "quic/core/quic_socket_address_coder.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/failing_proof_source.h" +#include "quic/test_tools/mock_clock.h" +#include "quic/test_tools/mock_random.h" +#include "quic/test_tools/quic_crypto_server_config_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/quiche_endian.h" namespace quic { namespace test { @@ -48,7 +48,7 @@ class DummyProofVerifierCallback : public ProofVerifierCallback { void Run(bool /*ok*/, const std::string& /*error_details*/, std::unique_ptr<ProofVerifyDetails>* /*details*/) override { - DCHECK(false); + QUICHE_DCHECK(false); } }; @@ -129,8 +129,8 @@ class CryptoServerTest : public QuicTestWithParam<TestParams> { config_.AddConfig(primary_config, clock_.WallNow())); absl::string_view orbit; - CHECK(msg->GetStringPiece(kORBT, &orbit)); - CHECK_EQ(sizeof(orbit_), orbit.size()); + QUICHE_CHECK(msg->GetStringPiece(kORBT, &orbit)); + QUICHE_CHECK_EQ(sizeof(orbit_), orbit.size()); memcpy(orbit_, orbit.data(), orbit.size()); char public_value[32]; @@ -171,7 +171,7 @@ class CryptoServerTest : public QuicTestWithParam<TestParams> { signed_config_ = QuicReferenceCountedPointer<QuicSignedServerConfig>( new QuicSignedServerConfig()); - DCHECK(signed_config_->chain.get() == nullptr); + QUICHE_DCHECK(signed_config_->chain.get() == nullptr); } // Helper used to accept the result of ValidateClientHello and pass @@ -454,7 +454,7 @@ TEST_P(CryptoServerTest, RejectTooLarge) { TEST_P(CryptoServerTest, RejectNotTooLarge) { // When the CHLO packet is large enough, ensure that a full REJ is sent. - chlo_packet_size_ *= 2; + chlo_packet_size_ *= 5; CryptoHandshakeMessage msg = crypto_test_utils::CreateCHLO({{"PDMD", "X509"}, diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_utils.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_utils.cc index efb7b665744..a2e205bbbb2 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_utils.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_utils.cc @@ -2,40 +2,40 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" +#include "quic/core/crypto/crypto_utils.h" #include <memory> #include <string> #include <utility> #include "absl/base/macros.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/bytestring.h" #include "third_party/boringssl/src/include/openssl/hkdf.h" #include "third_party/boringssl/src/include/openssl/mem.h" #include "third_party/boringssl/src/include/openssl/sha.h" -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_hkdf.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/core/crypto/aes_128_gcm_12_decrypter.h" +#include "quic/core/crypto/aes_128_gcm_12_encrypter.h" +#include "quic/core/crypto/aes_128_gcm_decrypter.h" +#include "quic/core/crypto/aes_128_gcm_encrypter.h" +#include "quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/null_decrypter.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/crypto/quic_hkdf.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_logging.h" +#include "common/quiche_endian.h" namespace quic { @@ -55,11 +55,6 @@ namespace { // The implicit PRF is explicitly passed into HkdfExpandLabel as |prf|; the // Secret, Label, and Length are passed in as |secret|, |label|, and // |out_len|, respectively. The resulting expanded secret is returned. -// -// TODO(nharper): HkdfExpandLabel and SetKeyAndIV (below) implement what is -// specified in draft-ietf-quic-tls-16. The latest editors' draft has changed -// derivation again, and this will need to be updated to reflect those (and any -// other future) changes. std::vector<uint8_t> HkdfExpandLabel(const EVP_MD* prf, const std::vector<uint8_t>& secret, const std::string& label, @@ -136,15 +131,13 @@ std::vector<uint8_t> CryptoUtils::GenerateNextKeyPhaseSecret( namespace { -// Salt from https://tools.ietf.org/html/draft-ietf-quic-tls-27#section-5.2 -const uint8_t kDraft27InitialSalt[] = {0xc3, 0xee, 0xf7, 0x12, 0xc7, 0x2e, 0xbb, - 0x5a, 0x11, 0xa7, 0xd2, 0x43, 0x2b, 0xb4, - 0x63, 0x65, 0xbe, 0xf9, 0xf5, 0x02}; - // Salt from https://tools.ietf.org/html/draft-ietf-quic-tls-29#section-5.2 const uint8_t kDraft29InitialSalt[] = {0xaf, 0xbf, 0xec, 0x28, 0x99, 0x93, 0xd2, 0x4c, 0x9e, 0x97, 0x86, 0xf1, 0x9c, 0x61, 0x11, 0xe0, 0x43, 0x90, 0xa8, 0x99}; +const uint8_t kRFCv1InitialSalt[] = {0x38, 0x76, 0x2c, 0xf7, 0xf5, 0x59, 0x34, + 0xb3, 0x4d, 0x17, 0x9a, 0xe6, 0xa4, 0xc8, + 0x0c, 0xad, 0xcc, 0xbb, 0x7f, 0x0a}; // Salts used by deployed versions of QUIC. When introducing a new version, // generate a new salt by running `openssl rand -hex 20`. @@ -153,10 +146,6 @@ const uint8_t kDraft29InitialSalt[] = {0xaf, 0xbf, 0xec, 0x28, 0x99, 0x93, 0xd2, const uint8_t kQ050Salt[] = {0x50, 0x45, 0x74, 0xef, 0xd0, 0x66, 0xfe, 0x2f, 0x9d, 0x94, 0x5c, 0xfc, 0xdb, 0xd3, 0xa7, 0xf0, 0xd3, 0xb5, 0x6b, 0x45}; -// Salt to use for initial obfuscators in version T050. -const uint8_t kT050Salt[] = {0x7f, 0xf5, 0x79, 0xe5, 0xac, 0xd0, 0x72, - 0x91, 0x55, 0x80, 0x30, 0x4c, 0x43, 0xa2, - 0x36, 0x7c, 0x60, 0x48, 0x83, 0x10}; // Salt to use for initial obfuscators in version T051. const uint8_t kT051Salt[] = {0x7a, 0x4e, 0xde, 0xf4, 0xe7, 0xcc, 0xee, 0x5f, 0xa4, 0x50, 0x6c, 0x19, 0x12, 0x4f, @@ -169,20 +158,17 @@ const uint8_t kReservedForNegotiationSalt[] = { const uint8_t* InitialSaltForVersion(const ParsedQuicVersion& version, size_t* out_len) { - static_assert(SupportedVersions().size() == 7u, + static_assert(SupportedVersions().size() == 6u, "Supported versions out of sync with initial encryption salts"); - if (version == ParsedQuicVersion::Draft29()) { + if (version == ParsedQuicVersion::RFCv1()) { + *out_len = ABSL_ARRAYSIZE(kRFCv1InitialSalt); + return kRFCv1InitialSalt; + } else if (version == ParsedQuicVersion::Draft29()) { *out_len = ABSL_ARRAYSIZE(kDraft29InitialSalt); return kDraft29InitialSalt; - } else if (version == ParsedQuicVersion::Draft27()) { - *out_len = ABSL_ARRAYSIZE(kDraft27InitialSalt); - return kDraft27InitialSalt; } else if (version == ParsedQuicVersion::T051()) { *out_len = ABSL_ARRAYSIZE(kT051Salt); return kT051Salt; - } else if (version == ParsedQuicVersion::T050()) { - *out_len = ABSL_ARRAYSIZE(kT050Salt); - return kT050Salt; } else if (version == ParsedQuicVersion::Q050()) { *out_len = ABSL_ARRAYSIZE(kQ050Salt); return kQ050Salt; @@ -191,32 +177,27 @@ const uint8_t* InitialSaltForVersion(const ParsedQuicVersion& version, return kReservedForNegotiationSalt; } QUIC_BUG << "No initial obfuscation salt for version " << version; - *out_len = ABSL_ARRAYSIZE(kDraft27InitialSalt); - return kDraft27InitialSalt; + *out_len = ABSL_ARRAYSIZE(kReservedForNegotiationSalt); + return kReservedForNegotiationSalt; } const char kPreSharedKeyLabel[] = "QUIC PSK"; // Retry Integrity Protection Keys and Nonces. -// https://tools.ietf.org/html/draft-ietf-quic-tls-27#section-5.8 -const uint8_t kDraft27RetryIntegrityKey[] = {0x4d, 0x32, 0xec, 0xdb, 0x2a, 0x21, - 0x33, 0xc8, 0x41, 0xe4, 0x04, 0x3d, - 0xf2, 0x7d, 0x44, 0x30}; -const uint8_t kDraft27RetryIntegrityNonce[] = { - 0x4d, 0x16, 0x11, 0xd0, 0x55, 0x13, 0xa5, 0x52, 0xc5, 0x87, 0xd5, 0x75}; - // https://tools.ietf.org/html/draft-ietf-quic-tls-29#section-5.8 const uint8_t kDraft29RetryIntegrityKey[] = {0xcc, 0xce, 0x18, 0x7e, 0xd0, 0x9a, 0x09, 0xd0, 0x57, 0x28, 0x15, 0x5a, 0x6c, 0xb9, 0x6b, 0xe1}; const uint8_t kDraft29RetryIntegrityNonce[] = { 0xe5, 0x49, 0x30, 0xf9, 0x7f, 0x21, 0x36, 0xf0, 0x53, 0x0a, 0x8c, 0x1c}; +const uint8_t kRFCv1RetryIntegrityKey[] = {0xbe, 0x0c, 0x69, 0x0b, 0x9f, 0x66, + 0x57, 0x5a, 0x1d, 0x76, 0x6b, 0x54, + 0xe3, 0x68, 0xc8, 0x4e}; +const uint8_t kRFCv1RetryIntegrityNonce[] = { + 0x46, 0x15, 0x99, 0xd3, 0x5d, 0x63, 0x2b, 0xf2, 0x23, 0x98, 0x25, 0xbb}; // Keys used by Google versions of QUIC. When introducing a new version, // generate a new key by running `openssl rand -hex 16`. -const uint8_t kT050RetryIntegrityKey[] = {0xc9, 0x2d, 0x32, 0x3d, 0x9c, 0xe3, - 0x0d, 0xa0, 0x88, 0xb9, 0xb7, 0xbb, - 0xdc, 0xcd, 0x50, 0xc8}; const uint8_t kT051RetryIntegrityKey[] = {0x2e, 0xb9, 0x61, 0xa6, 0x79, 0x56, 0xf8, 0x79, 0x53, 0x14, 0xda, 0xfb, 0x2e, 0xbc, 0x83, 0xd7}; @@ -226,8 +207,6 @@ const uint8_t kReservedForNegotiationRetryIntegrityKey[] = { 0x03, 0xe6, 0x7c, 0x7b, 0xd2, 0x44, 0xca, 0xd9}; // Nonces used by Google versions of QUIC. When introducing a new version, // generate a new nonce by running `openssl rand -hex 12`. -const uint8_t kT050RetryIntegrityNonce[] = {0x26, 0xe4, 0xd6, 0x23, 0x83, 0xd5, - 0xc7, 0x60, 0xea, 0x02, 0xb4, 0x1f}; const uint8_t kT051RetryIntegrityNonce[] = {0xb5, 0x0e, 0x4e, 0x53, 0x4c, 0xfc, 0x0b, 0xbb, 0x85, 0xf2, 0xf9, 0xca}; // Retry integrity nonce used by ParsedQuicVersion::ReservedForNegotiation(). @@ -237,12 +216,20 @@ const uint8_t kReservedForNegotiationRetryIntegrityNonce[] = { bool RetryIntegrityKeysForVersion(const ParsedQuicVersion& version, absl::string_view* key, absl::string_view* nonce) { - static_assert(SupportedVersions().size() == 7u, + static_assert(SupportedVersions().size() == 6u, "Supported versions out of sync with retry integrity keys"); - if (!version.HasRetryIntegrityTag()) { + if (!version.UsesTls()) { QUIC_BUG << "Attempted to get retry integrity keys for invalid version " << version; return false; + } else if (version == ParsedQuicVersion::RFCv1()) { + *key = absl::string_view( + reinterpret_cast<const char*>(kRFCv1RetryIntegrityKey), + ABSL_ARRAYSIZE(kRFCv1RetryIntegrityKey)); + *nonce = absl::string_view( + reinterpret_cast<const char*>(kRFCv1RetryIntegrityNonce), + ABSL_ARRAYSIZE(kRFCv1RetryIntegrityNonce)); + return true; } else if (version == ParsedQuicVersion::Draft29()) { *key = absl::string_view( reinterpret_cast<const char*>(kDraft29RetryIntegrityKey), @@ -251,14 +238,6 @@ bool RetryIntegrityKeysForVersion(const ParsedQuicVersion& version, reinterpret_cast<const char*>(kDraft29RetryIntegrityNonce), ABSL_ARRAYSIZE(kDraft29RetryIntegrityNonce)); return true; - } else if (version == ParsedQuicVersion::Draft27()) { - *key = absl::string_view( - reinterpret_cast<const char*>(kDraft27RetryIntegrityKey), - ABSL_ARRAYSIZE(kDraft27RetryIntegrityKey)); - *nonce = absl::string_view( - reinterpret_cast<const char*>(kDraft27RetryIntegrityNonce), - ABSL_ARRAYSIZE(kDraft27RetryIntegrityNonce)); - return true; } else if (version == ParsedQuicVersion::T051()) { *key = absl::string_view(reinterpret_cast<const char*>(kT051RetryIntegrityKey), @@ -267,14 +246,6 @@ bool RetryIntegrityKeysForVersion(const ParsedQuicVersion& version, reinterpret_cast<const char*>(kT051RetryIntegrityNonce), ABSL_ARRAYSIZE(kT051RetryIntegrityNonce)); return true; - } else if (version == ParsedQuicVersion::T050()) { - *key = - absl::string_view(reinterpret_cast<const char*>(kT050RetryIntegrityKey), - ABSL_ARRAYSIZE(kT050RetryIntegrityKey)); - *nonce = absl::string_view( - reinterpret_cast<const char*>(kT050RetryIntegrityNonce), - ABSL_ARRAYSIZE(kT050RetryIntegrityNonce)); - return true; } else if (version == ParsedQuicVersion::ReservedForNegotiation()) { *key = absl::string_view( reinterpret_cast<const char*>(kReservedForNegotiationRetryIntegrityKey), @@ -552,7 +523,7 @@ bool CryptoUtils::DeriveKeys(const ParsedQuicVersion& version, break; } default: - DCHECK(false); + QUICHE_DCHECK(false); } if (subkey_secret != nullptr) { @@ -600,7 +571,7 @@ QuicErrorCode CryptoUtils::ValidateServerHello( const CryptoHandshakeMessage& server_hello, const ParsedQuicVersionVector& negotiated_versions, std::string* error_details) { - DCHECK(error_details != nullptr); + QUICHE_DCHECK(error_details != nullptr); if (server_hello.tag() != kSHLO) { *error_details = "Bad tag"; @@ -632,7 +603,7 @@ QuicErrorCode CryptoUtils::ValidateServerHelloVersions( // reports that there was a version negotiation during the handshake. // Ensure that these two lists are identical. if (mismatch) { - *error_details = quiche::QuicheStrCat( + *error_details = absl::StrCat( "Downgrade attack detected: ServerVersions(", server_versions.size(), ")[", QuicVersionLabelVectorToString(server_versions, ",", 30), "] NegotiatedVersions(", negotiated_versions.size(), ")[", @@ -678,7 +649,7 @@ QuicErrorCode CryptoUtils::ValidateClientHelloVersion( // downgrade attack. for (size_t i = 0; i < supported_versions.size(); ++i) { if (client_version == CreateQuicVersionLabel(supported_versions[i])) { - *error_details = quiche::QuicheStrCat( + *error_details = absl::StrCat( "Downgrade attack detected: ClientVersion[", QuicVersionLabelToString(client_version), "] ConnectionVersion[", ParsedQuicVersionToString(connection_version), diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_utils.h b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_utils.h index 9195e3add82..ec68c6580f4 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_utils.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_utils.h @@ -14,15 +14,15 @@ #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/evp.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypter.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/crypto_handshake_message.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/quic_crypter.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -62,7 +62,7 @@ class QUIC_EXPORT_PRIVATE CryptoUtils { Mode mode() const { return mode_; } DiversificationNonce* nonce() const { - DCHECK_EQ(mode_, NOW); + QUICHE_DCHECK_EQ(mode_, NOW); return nonce_; } diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_utils_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_utils_test.cc index e0d1165ff5f..4586b9bbb4a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_utils_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/crypto_utils_test.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" +#include "quic/core/crypto/crypto_utils.h" #include <string> #include "absl/base/macros.h" #include "absl/strings/escaping.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/test_tools/quiche_test_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/curve25519_key_exchange.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/curve25519_key_exchange.cc index acdf9a8394b..aefbcf5817a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/curve25519_key_exchange.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/curve25519_key_exchange.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/curve25519_key_exchange.h" +#include "quic/core/crypto/curve25519_key_exchange.h" #include <cstdint> #include <cstring> @@ -10,9 +10,9 @@ #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/curve25519.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_ptr_util.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/curve25519_key_exchange.h b/chromium/net/third_party/quiche/src/quic/core/crypto/curve25519_key_exchange.h index e6703ec2056..b6a12b634c4 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/curve25519_key_exchange.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/curve25519_key_exchange.h @@ -9,8 +9,8 @@ #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/key_exchange.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/key_exchange.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/curve25519_key_exchange_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/curve25519_key_exchange_test.cc index f100df58ae4..968b9693a4c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/curve25519_key_exchange_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/curve25519_key_exchange_test.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/curve25519_key_exchange.h" +#include "quic/core/crypto/curve25519_key_exchange.h" #include <memory> #include <string> #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/key_exchange.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/key_exchange.cc index d7c01052f9c..411dd3b9bb5 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/key_exchange.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/key_exchange.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/key_exchange.h" +#include "quic/core/crypto/key_exchange.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/curve25519_key_exchange.h" -#include "net/third_party/quiche/src/quic/core/crypto/p256_key_exchange.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" +#include "quic/core/crypto/curve25519_key_exchange.h" +#include "quic/core/crypto/p256_key_exchange.h" +#include "quic/platform/api/quic_bug_tracker.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/key_exchange.h b/chromium/net/third_party/quiche/src/quic/core/crypto/key_exchange.h index e4288d75ffb..0937caaef31 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/key_exchange.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/key_exchange.h @@ -9,8 +9,8 @@ #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/null_decrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/null_decrypter.cc index 2fc1acee1fc..5e0c9fb9fc0 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/null_decrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/null_decrypter.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/null_decrypter.h" +#include "quic/core/crypto/null_decrypter.h" #include <cstdint> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_data_reader.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/core/quic_data_reader.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_uint128.h" +#include "common/quiche_endian.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/null_decrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/null_decrypter.h index 3c856f44397..fd06d3a6ee8 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/null_decrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/null_decrypter.h @@ -9,10 +9,10 @@ #include <cstdint> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_uint128.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/null_decrypter_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/null_decrypter_test.cc index b8b7268e3ea..394fcfb3ed8 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/null_decrypter_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/null_decrypter_test.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/null_decrypter.h" +#include "quic/core/crypto/null_decrypter.h" #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/null_encrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/null_encrypter.cc index f379ff23b69..dd9cfd9eb95 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/null_encrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/null_encrypter.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" +#include "quic/core/crypto/null_encrypter.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_utils.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/null_encrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/null_encrypter.h index 82cb2c12f6e..9df1906db31 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/null_encrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/null_encrypter.h @@ -8,9 +8,9 @@ #include <cstddef> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/null_encrypter_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/null_encrypter_test.cc index 1bc5932ec4f..6924f8a3672 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/null_encrypter_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/null_encrypter_test.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" +#include "quic/core/crypto/null_encrypter.h" #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/test_tools/quiche_test_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/p256_key_exchange.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/p256_key_exchange.cc index 7a543b90e24..0ce7a24fa8c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/p256_key_exchange.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/p256_key_exchange.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/p256_key_exchange.h" +#include "quic/core/crypto/p256_key_exchange.h" #include <cstdint> #include <cstring> @@ -15,8 +15,8 @@ #include "third_party/boringssl/src/include/openssl/ecdh.h" #include "third_party/boringssl/src/include/openssl/err.h" #include "third_party/boringssl/src/include/openssl/evp.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_ptr_util.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/p256_key_exchange.h b/chromium/net/third_party/quiche/src/quic/core/crypto/p256_key_exchange.h index 2b6f9b87b47..7c2125572a6 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/p256_key_exchange.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/p256_key_exchange.h @@ -10,8 +10,8 @@ #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/base.h" -#include "net/third_party/quiche/src/quic/core/crypto/key_exchange.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/key_exchange.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/p256_key_exchange_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/p256_key_exchange_test.cc index 9419dcb5783..4d183567f50 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/p256_key_exchange_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/p256_key_exchange_test.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/p256_key_exchange.h" +#include "quic/core/crypto/p256_key_exchange.h" #include <memory> #include <string> #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source.cc index 3a980296a96..bb3a79568b0 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source.cc @@ -4,7 +4,7 @@ #include <string> -#include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" +#include "quic/core/crypto/proof_source.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source.h b/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source.h index e9358d50b85..cee94f2e4af 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source.h @@ -11,14 +11,18 @@ #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_proof.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.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 "quic/core/crypto/quic_crypto_proof.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_reference_counted.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { +namespace test { +class FakeProofSourceHandle; +} // namespace test + // CryptoBuffers is a RAII class to own a std::vector<CRYPTO_BUFFER*> and the // buffers the elements point to. struct QUIC_EXPORT_PRIVATE CryptoBuffers { @@ -211,6 +215,97 @@ class QUIC_EXPORT_PRIVATE ProofSource { virtual TicketCrypter* GetTicketCrypter() = 0; }; +// ProofSourceHandleCallback is an interface that contains the callbacks when +// the operations in ProofSourceHandle completes. +// TODO(wub): Consider deprecating ProofSource by moving all functionalities of +// ProofSource into ProofSourceHandle. +class QUIC_EXPORT_PRIVATE ProofSourceHandleCallback { + public: + virtual ~ProofSourceHandleCallback() = default; + + // Called when a ProofSourceHandle::SelectCertificate operation completes. + // |ok| indicates whether the operation was successful. + // |is_sync| indicates whether the operation completed synchronously, i.e. + // whether it is completed before ProofSourceHandle::SelectCertificate + // returned. + // |chain| the certificate chain in leaf-first order. + // + // When called asynchronously(is_sync=false), this method will be responsible + // to continue the handshake from where it left off. + virtual void OnSelectCertificateDone(bool ok, + bool is_sync, + const ProofSource::Chain* chain) = 0; + + // Called when a ProofSourceHandle::ComputeSignature operation completes. + virtual void OnComputeSignatureDone( + bool ok, + bool is_sync, + std::string signature, + std::unique_ptr<ProofSource::Details> details) = 0; +}; + +// ProofSourceHandle is an interface by which a TlsServerHandshaker can obtain +// certificate chains and signatures that prove its identity. +// The operations this interface supports are similar to those in ProofSource, +// the main difference is that ProofSourceHandle is per-handshaker, so +// an implementation can have states that are shared by multiple calls on the +// same handle. +// +// A handle object is owned by a TlsServerHandshaker. Since there might be an +// async operation pending when the handle destructs, an implementation must +// ensure when such operations finish, their corresponding callback method won't +// be invoked. +// +// A handle will have at most one async operation pending at a time. +class QUIC_EXPORT_PRIVATE ProofSourceHandle { + public: + virtual ~ProofSourceHandle() = default; + + // Cancel the pending operation, if any. + // Once called, any completion method on |callback()| won't be invoked. + virtual void CancelPendingOperation() = 0; + + // Starts a select certificate operation. If the operation is not cancelled + // when it completes, callback()->OnSelectCertificateDone will be invoked. + // + // If the operation is handled synchronously: + // - QUIC_SUCCESS or QUIC_FAILURE will be returned. + // - callback()->OnSelectCertificateDone should be invoked before the function + // returns. + // + // If the operation is handled asynchronously: + // - QUIC_PENDING will be returned. + // - When the operation is done, callback()->OnSelectCertificateDone should be + // invoked. + virtual QuicAsyncStatus SelectCertificate( + const QuicSocketAddress& server_address, + const QuicSocketAddress& client_address, + const std::string& hostname, + absl::string_view client_hello, + const std::string& alpn, + const std::vector<uint8_t>& quic_transport_params, + const absl::optional<std::vector<uint8_t>>& early_data_context) = 0; + + // Starts a compute signature operation. If the operation is not cancelled + // when it completes, callback()->OnComputeSignatureDone will be invoked. + // + // See the comments of SelectCertificate for sync vs. async operations. + virtual QuicAsyncStatus ComputeSignature( + const QuicSocketAddress& server_address, + const QuicSocketAddress& client_address, + const std::string& hostname, + uint16_t signature_algorithm, + absl::string_view in, + size_t max_signature_size) = 0; + + protected: + // Returns the object that will be notified when an operation completes. + virtual ProofSourceHandleCallback* callback() = 0; + + private: + friend class test::FakeProofSourceHandle; +}; + } // namespace quic #endif // QUICHE_QUIC_CORE_CRYPTO_PROOF_SOURCE_H_ diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source_x509.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source_x509.cc index 530f9d52ae1..06c694000cf 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source_x509.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source_x509.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/proof_source_x509.h" +#include "quic/core/crypto/proof_source_x509.h" #include <memory> +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/crypto/certificate_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/core/crypto/certificate_view.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/quic_data_writer.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "common/quiche_endian.h" namespace quic { @@ -123,7 +123,7 @@ ProofSourceX509::Certificate* ProofSourceX509::GetCertificate( } auto dot_pos = hostname.find('.'); if (dot_pos != std::string::npos) { - std::string wildcard = quiche::QuicheStrCat("*", hostname.substr(dot_pos)); + std::string wildcard = absl::StrCat("*", hostname.substr(dot_pos)); it = certificate_map_.find(wildcard); if (it != certificate_map_.end()) { return it->second; diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source_x509.h b/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source_x509.h index bc6baaad77b..83de1de204e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source_x509.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source_x509.h @@ -9,10 +9,11 @@ #include <memory> #include "absl/base/attributes.h" +#include "absl/container/node_hash_map.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/certificate_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" +#include "quic/core/crypto/certificate_view.h" +#include "quic/core/crypto/proof_source.h" +#include "quic/platform/api/quic_containers.h" namespace quic { @@ -68,7 +69,7 @@ class QUIC_EXPORT_PRIVATE ProofSourceX509 : public ProofSource { std::forward_list<Certificate> certificates_; Certificate* default_certificate_; - QuicUnorderedMap<std::string, Certificate*> certificate_map_; + absl::node_hash_map<std::string, Certificate*> certificate_map_; }; } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source_x509_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source_x509_test.cc index e0b45c6bd5d..75a60993e15 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source_x509_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/proof_source_x509_test.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/proof_source_x509.h" +#include "quic/core/crypto/proof_source_x509.h" #include <memory> #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/crypto/certificate_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.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/test_certificates.h" +#include "quic/core/crypto/certificate_view.h" +#include "quic/core/crypto/proof_source.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_reference_counted.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/test_certificates.h" namespace quic { namespace test { @@ -36,8 +36,8 @@ class ProofSourceX509Test : public QuicTest { CertificatePrivateKey::LoadFromDer(kTestCertificatePrivateKey)), wildcard_key_(CertificatePrivateKey::LoadFromDer( kWildcardCertificatePrivateKey)) { - CHECK(test_key_ != nullptr); - CHECK(wildcard_key_ != nullptr); + QUICHE_CHECK(test_key_ != nullptr); + QUICHE_CHECK(wildcard_key_ != nullptr); } protected: diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/proof_verifier.h b/chromium/net/third_party/quiche/src/quic/core/crypto/proof_verifier.h index ab09811c1c8..a487fa5beb9 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/proof_verifier.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/proof_verifier.h @@ -10,9 +10,9 @@ #include <vector> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache.cc index ae2124c5a89..fcc081f9088 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache.cc @@ -4,7 +4,7 @@ #include <string> -#include "net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache.h" +#include "quic/core/crypto/quic_compressed_certs_cache.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache.h b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache.h index 586ea88f676..9f6929ab242 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache.h @@ -8,9 +8,9 @@ #include <string> #include <vector> -#include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" -#include "net/third_party/quiche/src/quic/core/quic_lru_cache.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/proof_source.h" +#include "quic/core/quic_lru_cache.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache_test.cc index e8f7309cb83..5b94e54e08c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache_test.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache.h" +#include "quic/core/crypto/quic_compressed_certs_cache.h" #include <string> -#include "net/third_party/quiche/src/quic/core/crypto/cert_compressor.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/cert_compressor.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypter.cc index 036f694699b..d41ce21f269 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypter.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypter.h" +#include "quic/core/crypto/quic_crypter.h" #include "absl/strings/string_view.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypter.h index 348a3fbe56e..001b6ecd95f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypter.h @@ -6,8 +6,8 @@ #define QUICHE_QUIC_CORE_CRYPTO_QUIC_CRYPTER_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.cc index 102678105dd..45db92bd494 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.h" +#include "quic/core/crypto/quic_crypto_client_config.h" #include <algorithm> #include <memory> @@ -12,29 +12,29 @@ #include "absl/strings/match.h" #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/crypto/cert_compressor.h" -#include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/common_cert_set.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_framer.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" -#include "net/third_party/quiche/src/quic/core/crypto/curve25519_key_exchange.h" -#include "net/third_party/quiche/src/quic/core/crypto/key_exchange.h" -#include "net/third_party/quiche/src/quic/core/crypto/p256_key_exchange.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_verifier.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/crypto/tls_client_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_client_stats.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_hostname_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/cert_compressor.h" +#include "quic/core/crypto/chacha20_poly1305_encrypter.h" +#include "quic/core/crypto/common_cert_set.h" +#include "quic/core/crypto/crypto_framer.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/crypto_utils.h" +#include "quic/core/crypto/curve25519_key_exchange.h" +#include "quic/core/crypto/key_exchange.h" +#include "quic/core/crypto/p256_key_exchange.h" +#include "quic/core/crypto/proof_verifier.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/crypto/tls_client_connection.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_client_stats.h" +#include "quic/platform/api/quic_hostname_utils.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_map_util.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { @@ -70,7 +70,7 @@ QuicCryptoClientConfig::QuicCryptoClientConfig( session_cache_(std::move(session_cache)), ssl_ctx_(TlsClientConnection::CreateSslCtx( !GetQuicFlag(FLAGS_quic_disable_client_tls_zero_rtt))) { - DCHECK(proof_verifier_.get()); + QUICHE_DCHECK(proof_verifier_.get()); SetDefaults(); } @@ -98,7 +98,7 @@ bool QuicCryptoClientConfig::CachedState::IsComplete(QuicWallTime now) const { if (!scfg) { // Should be impossible short of cache corruption. RecordInchoateClientHelloReason(SERVER_CONFIG_CORRUPTED); - DCHECK(false); + QUICHE_DCHECK(false); return false; } @@ -129,7 +129,7 @@ QuicCryptoClientConfig::CachedState::GetServerConfig() const { if (!scfg_) { scfg_ = CryptoFramer::ParseMessage(server_config_); - DCHECK(scfg_.get()); + QUICHE_DCHECK(scfg_.get()); } return scfg_.get(); } @@ -266,7 +266,7 @@ bool QuicCryptoClientConfig::CachedState::Initialize( absl::string_view signature, QuicWallTime now, QuicWallTime expiration_time) { - DCHECK(server_config_.empty()); + QUICHE_DCHECK(server_config_.empty()); if (server_config.empty()) { RecordDiskCacheServerConfigState(SERVER_CONFIG_EMPTY); @@ -347,8 +347,8 @@ void QuicCryptoClientConfig::CachedState::SetProofVerifyDetails( void QuicCryptoClientConfig::CachedState::InitializeFrom( const QuicCryptoClientConfig::CachedState& other) { - DCHECK(server_config_.empty()); - DCHECK(!server_config_valid_); + QUICHE_DCHECK(server_config_.empty()); + QUICHE_DCHECK(!server_config_valid_); server_config_ = other.server_config_; source_address_token_ = other.source_address_token_; certs_ = other.certs_; @@ -494,12 +494,11 @@ QuicErrorCode QuicCryptoClientConfig::FillClientHello( QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params, CryptoHandshakeMessage* out, std::string* error_details) const { - DCHECK(error_details != nullptr); + QUICHE_DCHECK(error_details != nullptr); QUIC_BUG_IF(!QuicUtils::IsConnectionIdValidForVersion( connection_id, preferred_version.transport_version)) << "FillClientHello: attempted to use connection ID " << connection_id - << " which is invalid with version " - << QuicVersionToString(preferred_version.transport_version); + << " which is invalid with version " << preferred_version; FillInchoateClientHello(server_id, preferred_version, cached, rand, /* demand_x509_proof= */ true, out_params, out); @@ -575,7 +574,7 @@ QuicErrorCode QuicCryptoClientConfig::FillClientHello( P256KeyExchange::New(P256KeyExchange::NewPrivateKey()); break; default: - DCHECK(false); + QUICHE_DCHECK(false); *error_details = "Configured to support an unknown key exchange"; return QUIC_CRYPTO_INTERNAL_ERROR; } @@ -640,7 +639,7 @@ QuicErrorCode QuicCryptoClientConfig::CacheNewServerConfig( const std::vector<std::string>& cached_certs, CachedState* cached, std::string* error_details) { - DCHECK(error_details != nullptr); + QUICHE_DCHECK(error_details != nullptr); absl::string_view scfg; if (!message.GetStringPiece(kSCFG, &scfg)) { @@ -712,7 +711,7 @@ QuicErrorCode QuicCryptoClientConfig::ProcessRejection( CachedState* cached, QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params, std::string* error_details) { - DCHECK(error_details != nullptr); + QUICHE_DCHECK(error_details != nullptr); if (rej.tag() != kREJ) { *error_details = "Message is not REJ"; @@ -742,7 +741,7 @@ QuicErrorCode QuicCryptoClientConfig::ProcessServerHello( CachedState* cached, QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params, std::string* error_details) { - DCHECK(error_details != nullptr); + QUICHE_DCHECK(error_details != nullptr); QuicErrorCode valid = CryptoUtils::ValidateServerHello( server_hello, negotiated_versions, error_details); @@ -805,7 +804,7 @@ QuicErrorCode QuicCryptoClientConfig::ProcessServerConfigUpdate( CachedState* cached, QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params, std::string* error_details) { - DCHECK(error_details != nullptr); + QUICHE_DCHECK(error_details != nullptr); if (server_config_update.tag() != kSCUP) { *error_details = "ServerConfigUpdate must have kSCUP tag."; @@ -856,7 +855,7 @@ void QuicCryptoClientConfig::AddCanonicalSuffix(const std::string& suffix) { bool QuicCryptoClientConfig::PopulateFromCanonicalConfig( const QuicServerId& server_id, CachedState* server_state) { - DCHECK(server_state->IsEmpty()); + QUICHE_DCHECK(server_state->IsEmpty()); size_t i = 0; for (; i < canonical_suffixes_.size(); ++i) { if (absl::EndsWithIgnoreCase(server_id.host(), canonical_suffixes_[i])) { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.h b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.h index 913ddf94d23..b02f621b97c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.h @@ -14,14 +14,14 @@ #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/base.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" -#include "net/third_party/quiche/src/quic/core/crypto/transport_parameters.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_reference_counted.h" +#include "quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/proof_source.h" +#include "quic/core/crypto/transport_parameters.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_server_id.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_reference_counted.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config_test.cc index d7625cd4e09..536083fb70d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config_test.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.h" +#include "quic/core/crypto/quic_crypto_client_config.h" #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_verifier.h" -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/mock_random.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/crypto/proof_verifier.h" +#include "quic/core/quic_server_id.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/mock_random.h" +#include "quic/test_tools/quic_test_utils.h" using testing::StartsWith; @@ -486,10 +486,12 @@ TEST_F(QuicCryptoClientConfigTest, ProcessReject) { new QuicCryptoNegotiatedParameters); std::string error; QuicCryptoClientConfig config(crypto_test_utils::ProofVerifierForTesting()); - EXPECT_THAT(config.ProcessRejection(rej, QuicWallTime::FromUNIXSeconds(0), - AllSupportedTransportVersions().front(), - "", &cached, out_params, &error), - IsQuicNoError()); + EXPECT_THAT( + config.ProcessRejection( + rej, QuicWallTime::FromUNIXSeconds(0), + AllSupportedVersionsWithQuicCrypto().front().transport_version, "", + &cached, out_params, &error), + IsQuicNoError()); EXPECT_FALSE(cached.has_server_nonce()); } @@ -506,10 +508,12 @@ TEST_F(QuicCryptoClientConfigTest, ProcessRejectWithLongTTL) { new QuicCryptoNegotiatedParameters); std::string error; QuicCryptoClientConfig config(crypto_test_utils::ProofVerifierForTesting()); - EXPECT_THAT(config.ProcessRejection(rej, QuicWallTime::FromUNIXSeconds(0), - AllSupportedTransportVersions().front(), - "", &cached, out_params, &error), - IsQuicNoError()); + EXPECT_THAT( + config.ProcessRejection( + rej, QuicWallTime::FromUNIXSeconds(0), + AllSupportedVersionsWithQuicCrypto().front().transport_version, "", + &cached, out_params, &error), + IsQuicNoError()); cached.SetProofValid(); EXPECT_FALSE(cached.IsComplete(QuicWallTime::FromUNIXSeconds(long_ttl))); EXPECT_FALSE( diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_proof.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_proof.cc index 33780b4a556..033ef3292b0 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_proof.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_proof.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_proof.h" +#include "quic/core/crypto/quic_crypto_proof.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_proof.h b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_proof.h index c3350680133..6ca87fb0a33 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_proof.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_proof.h @@ -7,7 +7,7 @@ #include <string> -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.cc index b929dcc11b9..da04f4f1ca1 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" +#include "quic/core/crypto/quic_crypto_server_config.h" #include <algorithm> #include <cstdlib> @@ -16,43 +16,42 @@ #include "absl/types/optional.h" #include "third_party/boringssl/src/include/openssl/sha.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/cert_compressor.h" -#include "net/third_party/quiche/src/quic/core/crypto/certificate_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/channel_id.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_framer.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" -#include "net/third_party/quiche/src/quic/core/crypto/curve25519_key_exchange.h" -#include "net/third_party/quiche/src/quic/core/crypto/key_exchange.h" -#include "net/third_party/quiche/src/quic/core/crypto/p256_key_exchange.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_verifier.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_hkdf.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/crypto/server_proof_verifier.h" -#include "net/third_party/quiche/src/quic/core/crypto/tls_server_connection.h" -#include "net/third_party/quiche/src/quic/core/proto/crypto_server_config_proto.h" -#include "net/third_party/quiche/src/quic/core/proto/source_address_token_proto.h" -#include "net/third_party/quiche/src/quic/core/quic_clock.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_socket_address_coder.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_cert_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_hostname_utils.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_testvalue.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/aes_128_gcm_12_decrypter.h" +#include "quic/core/crypto/aes_128_gcm_12_encrypter.h" +#include "quic/core/crypto/cert_compressor.h" +#include "quic/core/crypto/certificate_view.h" +#include "quic/core/crypto/chacha20_poly1305_encrypter.h" +#include "quic/core/crypto/channel_id.h" +#include "quic/core/crypto/crypto_framer.h" +#include "quic/core/crypto/crypto_handshake_message.h" +#include "quic/core/crypto/crypto_utils.h" +#include "quic/core/crypto/curve25519_key_exchange.h" +#include "quic/core/crypto/key_exchange.h" +#include "quic/core/crypto/p256_key_exchange.h" +#include "quic/core/crypto/proof_source.h" +#include "quic/core/crypto/proof_verifier.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/crypto/quic_hkdf.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/crypto/server_proof_verifier.h" +#include "quic/core/crypto/tls_server_connection.h" +#include "quic/core/proto/crypto_server_config_proto.h" +#include "quic/core/proto/source_address_token_proto.h" +#include "quic/core/quic_clock.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_socket_address_coder.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_hostname_utils.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_reference_counted.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_testvalue.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { @@ -256,7 +255,7 @@ QuicCryptoServerConfig::QuicCryptoServerConfig( pad_shlo_(true), validate_chlo_size_(true), validate_source_address_token_(true) { - DCHECK(proof_source_.get()); + QUICHE_DCHECK(proof_source_.get()); source_address_token_boxer_.SetKeys( {DeriveSourceAddressTokenKey(source_address_token_secret)}); @@ -288,7 +287,7 @@ QuicServerConfigProtobuf QuicCryptoServerConfig::GenerateConfig( std::string encoded_public_values; // First three bytes encode the length of the public value. - DCHECK_LT(curve25519_public_value.size(), (1U << 24)); + QUICHE_DCHECK_LT(curve25519_public_value.size(), (1U << 24)); encoded_public_values.push_back( static_cast<char>(curve25519_public_value.size())); encoded_public_values.push_back( @@ -305,7 +304,7 @@ QuicServerConfigProtobuf QuicCryptoServerConfig::GenerateConfig( P256KeyExchange::New(p256_private_key)); absl::string_view p256_public_value = p256->public_value(); - DCHECK_LT(p256_public_value.size(), (1U << 24)); + QUICHE_DCHECK_LT(p256_public_value.size(), (1U << 24)); encoded_public_values.push_back( static_cast<char>(p256_public_value.size())); encoded_public_values.push_back( @@ -339,7 +338,7 @@ QuicServerConfigProtobuf QuicCryptoServerConfig::GenerateConfig( if (options.orbit.size() == sizeof(orbit_bytes)) { memcpy(orbit_bytes, options.orbit.data(), sizeof(orbit_bytes)); } else { - DCHECK(options.orbit.empty()); + QUICHE_DCHECK(options.orbit.empty()); rand->RandBytes(orbit_bytes, sizeof(orbit_bytes)); } msg.SetStringPiece(kORBT, @@ -417,9 +416,9 @@ std::unique_ptr<CryptoHandshakeMessage> QuicCryptoServerConfig::AddConfig( configs_[config->id] = config; SelectNewPrimaryConfig(now); - DCHECK(primary_config_.get()); - DCHECK_EQ(configs_.find(primary_config_->id)->second.get(), - primary_config_.get()); + QUICHE_DCHECK(primary_config_.get()); + QUICHE_DCHECK_EQ(configs_.find(primary_config_->id)->second.get(), + primary_config_.get()); } return msg; @@ -507,9 +506,9 @@ bool QuicCryptoServerConfig::SetConfigs( configs_ = std::move(new_configs); fallback_config_ = fallback_config; SelectNewPrimaryConfig(now); - DCHECK(primary_config_.get()); - DCHECK_EQ(configs_.find(primary_config_->id)->second.get(), - primary_config_.get()); + QUICHE_DCHECK(primary_config_.get()); + QUICHE_DCHECK_EQ(configs_.find(primary_config_->id)->second.get(), + primary_config_.get()); return true; } @@ -673,7 +672,7 @@ void QuicCryptoServerConfig::ProcessClientHello( QuicByteCount total_framing_overhead, QuicByteCount chlo_packet_size, std::unique_ptr<ProcessClientHelloResultCallback> done_cb) const { - DCHECK(done_cb); + QUICHE_DCHECK(done_cb); auto context = std::make_unique<ProcessClientHelloContext>( validate_chlo_result, reject_only, connection_id, server_address, client_address, version, supported_versions, clock, rand, @@ -721,7 +720,7 @@ void QuicCryptoServerConfig::ProcessClientHello( auto cb = std::make_unique<ProcessClientHelloCallback>( this, std::move(context), configs); - DCHECK(proof_source_.get()); + QUICHE_DCHECK(proof_source_.get()); proof_source_->GetProof(server_address, client_address, sni, configs.primary->serialized, transport_version, chlo_hash, std::move(cb)); @@ -742,7 +741,7 @@ void QuicCryptoServerConfig::ProcessClientHelloAfterGetProof( context->connection_id(), context->transport_version())) << "ProcessClientHelloAfterGetProof: attempted to use connection ID " << context->connection_id() << " which is invalid with version " - << QuicVersionToString(context->transport_version()); + << context->version(); if (found_error) { context->Fail(QUIC_HANDSHAKE_FAILED, "Failed to get proof"); @@ -830,7 +829,7 @@ void QuicCryptoServerConfig::ProcessClientHelloAfterCalculateSharedKeys( << "ProcessClientHelloAfterCalculateSharedKeys:" " attempted to use connection ID " << context->connection_id() << " which is invalid with version " - << QuicVersionToString(context->transport_version()); + << context->version(); if (found_error) { // If we are already using the fallback config, or there is no fallback @@ -863,7 +862,7 @@ void QuicCryptoServerConfig::ProcessClientHelloAfterCalculateSharedKeys( hkdf_suffix.append(client_hello_serialized.data(), client_hello_serialized.length()); hkdf_suffix.append(configs.requested->serialized); - DCHECK(proof_source_.get()); + QUICHE_DCHECK(proof_source_.get()); if (context->signed_config()->chain->certs.empty()) { context->Fail(QUIC_CRYPTO_INTERNAL_ERROR, "Failed to get certs"); return; @@ -1001,7 +1000,7 @@ void QuicCryptoServerConfig::ProcessClientHelloAfterCalculateSharedKeys( out->SetVersionVector(kVER, context->supported_versions()); out->SetStringPiece( kSourceAddressTokenTag, - NewSourceAddressToken(*configs.requested, + NewSourceAddressToken(*configs.requested->source_address_token_boxer, context->info().source_address_tokens, context->client_address().host(), context->rand(), context->info().now, nullptr)); @@ -1086,9 +1085,9 @@ bool QuicCryptoServerConfig::GetCurrentConfigs( configs_lock_.ReaderUnlock(); configs_lock_.WriterLock(); SelectNewPrimaryConfig(now); - DCHECK(primary_config_.get()); - DCHECK_EQ(configs_.find(primary_config_->id)->second.get(), - primary_config_.get()); + QUICHE_DCHECK(primary_config_.get()); + QUICHE_DCHECK_EQ(configs_.find(primary_config_->id)->second.get(), + primary_config_.get()); configs_lock_.WriterUnlock(); configs_lock_.ReaderLock(); } @@ -1235,7 +1234,8 @@ void QuicCryptoServerConfig::EvaluateClientHello( Config& config = configs.requested != nullptr ? *configs.requested : *configs.primary; source_address_token_error = - ParseSourceAddressToken(config, srct, &info->source_address_tokens); + ParseSourceAddressToken(*config.source_address_token_boxer, srct, + &info->source_address_tokens); if (source_address_token_error == HANDSHAKE_OK) { source_address_token_error = ValidateSourceAddressTokens( @@ -1326,8 +1326,9 @@ void QuicCryptoServerConfig::BuildServerConfigUpdateMessage( serialized = primary_config_->serialized; common_cert_sets = primary_config_->common_cert_sets; source_address_token = NewSourceAddressToken( - *primary_config_, previous_source_address_tokens, client_address.host(), - rand, clock->WallNow(), cached_network_params); + *primary_config_->source_address_token_boxer, + previous_source_address_tokens, client_address.host(), rand, + clock->WallNow(), cached_network_params); } CryptoHandshakeMessage message; @@ -1438,8 +1439,9 @@ void QuicCryptoServerConfig::BuildRejection( out->SetStringPiece( kSourceAddressTokenTag, NewSourceAddressToken( - config, context.info().source_address_tokens, - context.info().client_ip, context.rand(), context.info().now, + *config.source_address_token_boxer, + context.info().source_address_tokens, context.info().client_ip, + context.rand(), context.info().now, &context.validate_chlo_result()->cached_network_params)); out->SetValue(kSTTL, config.expiry_time.AbsoluteDifference(now).ToSeconds()); if (replay_protection_) { @@ -1448,7 +1450,7 @@ void QuicCryptoServerConfig::BuildRejection( } // Send client the reject reason for debugging purposes. - DCHECK_LT(0u, reject_reasons.size()); + QUICHE_DCHECK_LT(0u, reject_reasons.size()); out->SetVector(kRREJ, reject_reasons); // The client may have requested a certificate chain. @@ -1477,7 +1479,7 @@ void QuicCryptoServerConfig::BuildRejection( context.params()->client_common_set_hashes, context.params()->client_cached_cert_hashes, config.common_cert_sets); - DCHECK_GT(context.chlo_packet_size(), context.client_hello().size()); + QUICHE_DCHECK_GT(context.chlo_packet_size(), context.client_hello().size()); // kREJOverheadBytes is a very rough estimate of how much of a REJ // message is taken up by things other than the certificates. // STK: 56 bytes @@ -1513,27 +1515,15 @@ void QuicCryptoServerConfig::BuildRejection( context.signed_config()->chain->certs; std::string ca_subject; if (!certs.empty()) { - if (GetQuicReloadableFlag( - quic_extract_x509_subject_using_certificate_view)) { - QUIC_RELOADABLE_FLAG_COUNT_N( - quic_extract_x509_subject_using_certificate_view, 1, 2); std::unique_ptr<CertificateView> view = CertificateView::ParseSingleCertificate(certs[0]); if (view != nullptr) { absl::optional<std::string> maybe_ca_subject = view->GetHumanReadableSubject(); if (maybe_ca_subject.has_value()) { - QUIC_RELOADABLE_FLAG_COUNT_N( - quic_extract_x509_subject_using_certificate_view, 2, 2); ca_subject = *maybe_ca_subject; } } - } else { - absl::string_view ca_subject_view; - QuicCertUtils::ExtractSubjectNameFromDERCert(certs[0], - &ca_subject_view); - ca_subject = std::string(ca_subject_view); - } } QUIC_LOG_EVERY_N_SEC(WARNING, 60) << "SCT is expected but it is empty. sni: '" @@ -1559,7 +1549,7 @@ std::string QuicCryptoServerConfig::CompressChain( const std::string& client_cached_cert_hashes, const CommonCertSets* common_sets) { // Check whether the compressed certs is available in the cache. - DCHECK(compressed_certs_cache); + QUICHE_DCHECK(compressed_certs_cache); const std::string* cached_value = compressed_certs_cache->GetCompressedCert( chain, client_common_set_hashes, client_cached_cert_hashes); if (cached_value) { @@ -1718,7 +1708,7 @@ void QuicCryptoServerConfig::AcquirePrimaryConfigChangedCb( } std::string QuicCryptoServerConfig::NewSourceAddressToken( - const Config& config, + const CryptoSecretBoxer& crypto_secret_boxer, const SourceAddressTokens& previous_tokens, const QuicIpAddress& ip, QuicRandom* rand, @@ -1751,8 +1741,8 @@ std::string QuicCryptoServerConfig::NewSourceAddressToken( *(source_address_tokens.add_tokens()) = token; } - return config.source_address_token_boxer->Box( - rand, source_address_tokens.SerializeAsString()); + return crypto_secret_boxer.Box(rand, + source_address_tokens.SerializeAsString()); } int QuicCryptoServerConfig::NumberOfConfigs() const { @@ -1786,12 +1776,12 @@ SSL_CTX* QuicCryptoServerConfig::ssl_ctx() const { } HandshakeFailureReason QuicCryptoServerConfig::ParseSourceAddressToken( - const Config& config, + const CryptoSecretBoxer& crypto_secret_boxer, absl::string_view token, SourceAddressTokens* tokens) const { std::string storage; absl::string_view plaintext; - if (!config.source_address_token_boxer->Unbox(token, &storage, &plaintext)) { + if (!crypto_secret_boxer.Unbox(token, &storage, &plaintext)) { return SOURCE_ADDRESS_TOKEN_DECRYPTION_FAILURE; } diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h index 7fae412bce2..4f3ad0819e4 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h @@ -14,23 +14,23 @@ #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/base.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_secret_boxer.h" -#include "net/third_party/quiche/src/quic/core/crypto/key_exchange.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_verifier.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_proof.h" -#include "net/third_party/quiche/src/quic/core/crypto/server_proof_verifier.h" -#include "net/third_party/quiche/src/quic/core/proto/cached_network_parameters_proto.h" -#include "net/third_party/quiche/src/quic/core/proto/source_address_token_proto.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_mutex.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 "quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/crypto_handshake_message.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/crypto_secret_boxer.h" +#include "quic/core/crypto/key_exchange.h" +#include "quic/core/crypto/proof_source.h" +#include "quic/core/crypto/proof_verifier.h" +#include "quic/core/crypto/quic_compressed_certs_cache.h" +#include "quic/core/crypto/quic_crypto_proof.h" +#include "quic/core/crypto/server_proof_verifier.h" +#include "quic/core/proto/cached_network_parameters_proto.h" +#include "quic/core/proto/source_address_token_proto.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_mutex.h" +#include "quic/platform/api/quic_reference_counted.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { @@ -417,6 +417,37 @@ class QUIC_EXPORT_PRIVATE QuicCryptoServerConfig { // Returns the number of configs this object owns. int NumberOfConfigs() const; + // NewSourceAddressToken returns a fresh source address token for the given + // IP address. |previous_tokens| is the received tokens, and can be empty. + // |cached_network_params| is optional, and can be nullptr. + std::string NewSourceAddressToken( + const CryptoSecretBoxer& crypto_secret_boxer, + const SourceAddressTokens& previous_tokens, + const QuicIpAddress& ip, + QuicRandom* rand, + QuicWallTime now, + const CachedNetworkParameters* cached_network_params) const; + + // ParseSourceAddressToken parses the source address tokens contained in + // the encrypted |token|, and populates |tokens| with the parsed tokens. + // Returns HANDSHAKE_OK if |token| could be parsed, or the reason for the + // failure. + HandshakeFailureReason ParseSourceAddressToken( + const CryptoSecretBoxer& crypto_secret_boxer, + absl::string_view token, + SourceAddressTokens* tokens) const; + + // ValidateSourceAddressTokens returns HANDSHAKE_OK if the source address + // tokens in |tokens| contain a valid and timely token for the IP address + // |ip| given that the current time is |now|. Otherwise it returns the + // reason for failure. |cached_network_params| is populated if the valid + // token contains a CachedNetworkParameters proto. + HandshakeFailureReason ValidateSourceAddressTokens( + const SourceAddressTokens& tokens, + const QuicIpAddress& ip, + QuicWallTime now, + CachedNetworkParameters* cached_network_params) const; + // Callers retain the ownership of |rejection_observer| which must outlive the // config. void set_rejection_observer(RejectionObserver* rejection_observer) { @@ -444,6 +475,10 @@ class QUIC_EXPORT_PRIVATE QuicCryptoServerConfig { bool pad_shlo() const { return pad_shlo_; } void set_pad_shlo(bool new_value) { pad_shlo_ = new_value; } + const CryptoSecretBoxer& source_address_token_boxer() const { + return source_address_token_boxer_; + } + private: friend class test::QuicCryptoServerConfigPeer; friend struct QuicSignedServerConfig; @@ -745,36 +780,6 @@ class QUIC_EXPORT_PRIVATE QuicCryptoServerConfig { const QuicServerConfigProtobuf& protobuf, bool is_fallback) const; - // NewSourceAddressToken returns a fresh source address token for the given - // IP address. |cached_network_params| is optional, and can be nullptr. - std::string NewSourceAddressToken( - const Config& config, - const SourceAddressTokens& previous_tokens, - const QuicIpAddress& ip, - QuicRandom* rand, - QuicWallTime now, - const CachedNetworkParameters* cached_network_params) const; - - // ParseSourceAddressToken parses the source address tokens contained in - // the encrypted |token|, and populates |tokens| with the parsed tokens. - // Returns HANDSHAKE_OK if |token| could be parsed, or the reason for the - // failure. - HandshakeFailureReason ParseSourceAddressToken( - const Config& config, - absl::string_view token, - SourceAddressTokens* tokens) const; - - // ValidateSourceAddressTokens returns HANDSHAKE_OK if the source address - // tokens in |tokens| contain a valid and timely token for the IP address - // |ip| given that the current time is |now|. Otherwise it returns the - // reason for failure. |cached_network_params| is populated if the valid - // token contains a CachedNetworkParameters proto. - HandshakeFailureReason ValidateSourceAddressTokens( - const SourceAddressTokens& tokens, - const QuicIpAddress& ip, - QuicWallTime now, - CachedNetworkParameters* cached_network_params) const; - // ValidateSingleSourceAddressToken returns HANDSHAKE_OK if the source // address token in |token| is a timely token for the IP address |ip| // given that the current time is |now|. Otherwise it returns the reason diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config_test.cc index e612a33b6d5..9f70c355237 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" +#include "quic/core/crypto/quic_crypto_server_config.h" #include <stdarg.h> @@ -11,21 +11,21 @@ #include "absl/strings/match.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/cert_compressor.h" -#include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_secret_boxer.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/proto/crypto_server_config_proto.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.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/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/mock_clock.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_crypto_server_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/cert_compressor.h" +#include "quic/core/crypto/chacha20_poly1305_encrypter.h" +#include "quic/core/crypto/crypto_handshake_message.h" +#include "quic/core/crypto/crypto_secret_boxer.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/proto/crypto_server_config_proto.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/mock_clock.h" +#include "quic/test_tools/quic_crypto_server_config_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_decrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_decrypter.cc index 29e1e18c967..02be1a1cd26 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_decrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_decrypter.cc @@ -2,23 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_decrypter.h" #include <string> #include <utility> #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/tls1.h" -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_hkdf.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/crypto/aes_128_gcm_12_decrypter.h" +#include "quic/core/crypto/aes_128_gcm_decrypter.h" +#include "quic/core/crypto/aes_256_gcm_decrypter.h" +#include "quic/core/crypto/chacha20_poly1305_decrypter.h" +#include "quic/core/crypto/chacha20_poly1305_tls_decrypter.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/null_decrypter.h" +#include "quic/core/crypto/quic_hkdf.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_logging.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h index 4a6cc59d0ab..73f84c9481d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h @@ -11,10 +11,10 @@ #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypter.h" -#include "net/third_party/quiche/src/quic/core/quic_data_reader.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/quic_crypter.h" +#include "quic/core/quic_data_reader.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_encrypter.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_encrypter.cc index e26884c2da5..4f7f7c9cd6d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_encrypter.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_encrypter.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" +#include "quic/core/crypto/quic_encrypter.h" #include <utility> #include "third_party/boringssl/src/include/openssl/tls1.h" -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/aes_256_gcm_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/crypto/aes_128_gcm_12_encrypter.h" +#include "quic/core/crypto/aes_128_gcm_encrypter.h" +#include "quic/core/crypto/aes_256_gcm_encrypter.h" +#include "quic/core/crypto/chacha20_poly1305_encrypter.h" +#include "quic/core/crypto/chacha20_poly1305_tls_encrypter.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_logging.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h index b454997f397..5465e393246 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h @@ -9,9 +9,9 @@ #include <memory> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypter.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/quic_crypter.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_hkdf.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_hkdf.cc index 59c3eb0fb9d..8dcf104fdf3 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_hkdf.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_hkdf.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/quic_hkdf.h" +#include "quic/core/crypto/quic_hkdf.h" #include <memory> #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/digest.h" #include "third_party/boringssl/src/include/openssl/hkdf.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -43,7 +43,7 @@ QuicHKDF::QuicHKDF(absl::string_view secret, 2 * client_key_bytes_to_generate + client_iv_bytes_to_generate + 2 * server_key_bytes_to_generate + server_iv_bytes_to_generate + subkey_secret_bytes_to_generate; - DCHECK_LT(material_length, kMaxKeyMaterialSize); + QUICHE_DCHECK_LT(material_length, kMaxKeyMaterialSize); output_.resize(material_length); // On Windows, when the size of output_ is zero, dereference of 0'th element diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_hkdf.h b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_hkdf.h index 63018b4443a..9a14bc46497 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_hkdf.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_hkdf.h @@ -8,7 +8,7 @@ #include <vector> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_hkdf_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_hkdf_test.cc index 48e089f7bc4..73f850ed68a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_hkdf_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_hkdf_test.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/quic_hkdf.h" +#include "quic/core/crypto/quic_hkdf.h" #include <string> #include "absl/base/macros.h" #include "absl/strings/escaping.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/platform/api/quic_test.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_random.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_random.cc index 230264c00c2..56657b507f9 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_random.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_random.cc @@ -2,15 +2,46 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" +#include "quic/core/crypto/quic_random.h" +#include <cstdint> +#include <cstring> #include "third_party/boringssl/src/include/openssl/rand.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_logging.h" +#include "common/platform/api/quiche_logging.h" namespace quic { namespace { +// Insecure randomness in DefaultRandom uses an implementation of +// xoshiro256++ 1.0 based on code in the public domain from +// <http://prng.di.unimi.it/xoshiro256plusplus.c>. + +inline uint64_t Xoshiro256PlusPlusRotLeft(uint64_t x, int k) { + return (x << k) | (x >> (64 - k)); +} + +uint64_t Xoshiro256PlusPlus() { + static thread_local uint64_t rng_state[4]; + static thread_local bool rng_state_initialized = false; + if (QUIC_PREDICT_FALSE(!rng_state_initialized)) { + RAND_bytes(reinterpret_cast<uint8_t*>(&rng_state), sizeof(rng_state)); + rng_state_initialized = true; + } + const uint64_t result = + Xoshiro256PlusPlusRotLeft(rng_state[0] + rng_state[3], 23) + rng_state[0]; + const uint64_t t = rng_state[1] << 17; + rng_state[2] ^= rng_state[0]; + rng_state[3] ^= rng_state[1]; + rng_state[1] ^= rng_state[2]; + rng_state[0] ^= rng_state[3]; + rng_state[2] ^= t; + rng_state[3] = Xoshiro256PlusPlusRotLeft(rng_state[3], 45); + return result; +} + class DefaultRandom : public QuicRandom { public: DefaultRandom() {} @@ -21,6 +52,8 @@ class DefaultRandom : public QuicRandom { // QuicRandom implementation void RandBytes(void* data, size_t len) override; uint64_t RandUint64() override; + void InsecureRandBytes(void* data, size_t len) override; + uint64_t InsecureRandUint64() override; }; void DefaultRandom::RandBytes(void* data, size_t len) { @@ -33,6 +66,24 @@ uint64_t DefaultRandom::RandUint64() { return value; } +void DefaultRandom::InsecureRandBytes(void* data, size_t len) { + while (len >= sizeof(uint64_t)) { + uint64_t random_bytes64 = Xoshiro256PlusPlus(); + memcpy(data, &random_bytes64, sizeof(uint64_t)); + data = reinterpret_cast<char*>(data) + sizeof(uint64_t); + len -= sizeof(uint64_t); + } + if (len > 0) { + QUICHE_DCHECK_LT(len, sizeof(uint64_t)); + uint64_t random_bytes64 = Xoshiro256PlusPlus(); + memcpy(data, &random_bytes64, len); + } +} + +uint64_t DefaultRandom::InsecureRandUint64() { + return Xoshiro256PlusPlus(); +} + } // namespace // static diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_random.h b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_random.h index 79e09534be7..4d7bf943ac4 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_random.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_random.h @@ -8,7 +8,7 @@ #include <cstddef> #include <cstdint> -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -26,6 +26,14 @@ class QUIC_EXPORT_PRIVATE QuicRandom { // Returns a random number in the range [0, kuint64max]. virtual uint64_t RandUint64() = 0; + + // Generates |len| random bytes in the |data| buffer. This MUST NOT be used + // for any application that requires cryptographically-secure randomness. + virtual void InsecureRandBytes(void* data, size_t len) = 0; + + // Returns a random number in the range [0, kuint64max]. This MUST NOT be used + // for any application that requires cryptographically-secure randomness. + virtual uint64_t InsecureRandUint64() = 0; }; } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_random_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_random_test.cc index d38bcf408c2..ab279185fa7 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/quic_random_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/quic_random_test.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" +#include "quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { @@ -30,5 +30,24 @@ TEST_F(QuicRandomTest, RandUint64) { EXPECT_NE(value1, value2); } +TEST_F(QuicRandomTest, InsecureRandBytes) { + unsigned char buf1[16]; + unsigned char buf2[16]; + memset(buf1, 0xaf, sizeof(buf1)); + memset(buf2, 0xaf, sizeof(buf2)); + ASSERT_EQ(0, memcmp(buf1, buf2, sizeof(buf1))); + + QuicRandom* rng = QuicRandom::GetInstance(); + rng->InsecureRandBytes(buf1, sizeof(buf1)); + EXPECT_NE(0, memcmp(buf1, buf2, sizeof(buf1))); +} + +TEST_F(QuicRandomTest, InsecureRandUint64) { + QuicRandom* rng = QuicRandom::GetInstance(); + uint64_t value1 = rng->InsecureRandUint64(); + uint64_t value2 = rng->InsecureRandUint64(); + EXPECT_NE(value1, value2); +} + } // namespace test } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/server_proof_verifier.h b/chromium/net/third_party/quiche/src/quic/core/crypto/server_proof_verifier.h index 94fe131bd07..3e5e67bedf9 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/server_proof_verifier.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/server_proof_verifier.h @@ -9,8 +9,8 @@ #include <string> #include <vector> -#include "net/third_party/quiche/src/quic/core/crypto/proof_verifier.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/crypto/proof_verifier.h" +#include "quic/core/quic_types.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/tls_client_connection.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/tls_client_connection.cc index 0591571ae39..c6a45c4b834 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/tls_client_connection.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/tls_client_connection.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/tls_client_connection.h" +#include "quic/core/crypto/tls_client_connection.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/tls_client_connection.h b/chromium/net/third_party/quiche/src/quic/core/crypto/tls_client_connection.h index 6bea641be84..c9471536b67 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/tls_client_connection.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/tls_client_connection.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_CORE_CRYPTO_TLS_CLIENT_CONNECTION_H_ #define QUICHE_QUIC_CORE_CRYPTO_TLS_CLIENT_CONNECTION_H_ -#include "net/third_party/quiche/src/quic/core/crypto/tls_connection.h" +#include "quic/core/crypto/tls_connection.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/tls_connection.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/tls_connection.cc index be274e2cb2a..9b5636c0824 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/tls_connection.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/tls_connection.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/tls_connection.h" +#include "quic/core/crypto/tls_connection.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_bug_tracker.h" namespace quic { @@ -36,7 +36,7 @@ class SslIndexSingleton { CRYPTO_library_init(); ssl_ex_data_index_connection_ = SSL_get_ex_new_index(0, nullptr, nullptr, nullptr, nullptr); - CHECK_LE(0, ssl_ex_data_index_connection_); + QUICHE_CHECK_LE(0, ssl_ex_data_index_connection_); } SslIndexSingleton(const SslIndexSingleton&) = delete; diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/tls_connection.h b/chromium/net/third_party/quiche/src/quic/core/crypto/tls_connection.h index 037e4b03f1e..28b5684ad4a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/tls_connection.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/tls_connection.h @@ -9,7 +9,7 @@ #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/quic_types.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/tls_server_connection.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/tls_server_connection.cc index f47e5ad7258..f4d0ac2ed4f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/tls_server_connection.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/tls_server_connection.cc @@ -2,12 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/tls_server_connection.h" +#include "quic/core/crypto/tls_server_connection.h" #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "quic/core/crypto/proof_source.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" namespace quic { @@ -21,7 +22,7 @@ bssl::UniquePtr<SSL_CTX> TlsServerConnection::CreateSslCtx( bssl::UniquePtr<SSL_CTX> ssl_ctx = TlsConnection::CreateSslCtx(SSL_VERIFY_NONE); SSL_CTX_set_tlsext_servername_callback(ssl_ctx.get(), - &SelectCertificateCallback); + &TlsExtServernameCallback); SSL_CTX_set_alpn_select_cb(ssl_ctx.get(), &SelectAlpnCallback, nullptr); // We don't actually need the TicketCrypter here, but we need to know // whether it's set. @@ -40,6 +41,12 @@ bssl::UniquePtr<SSL_CTX> TlsServerConnection::CreateSslCtx( GetQuicRestartFlag(quic_session_tickets_always_enabled))) { SSL_CTX_set_early_data_enabled(ssl_ctx.get(), 1); } + SSL_CTX_set_select_certificate_cb( + ssl_ctx.get(), &TlsServerConnection::EarlySelectCertCallback); + if (GetQuicRestartFlag(quic_tls_prefer_server_cipher_and_curve_list)) { + QUIC_RESTART_FLAG_COUNT(quic_tls_prefer_server_cipher_and_curve_list); + SSL_CTX_set_options(ssl_ctx.get(), SSL_OP_CIPHER_SERVER_PREFERENCE); + } return ssl_ctx; } @@ -62,10 +69,17 @@ TlsServerConnection* TlsServerConnection::ConnectionFromSsl(SSL* ssl) { } // static -int TlsServerConnection::SelectCertificateCallback(SSL* ssl, - int* out_alert, - void* /*arg*/) { - return ConnectionFromSsl(ssl)->delegate_->SelectCertificate(out_alert); +ssl_select_cert_result_t TlsServerConnection::EarlySelectCertCallback( + const SSL_CLIENT_HELLO* client_hello) { + return ConnectionFromSsl(client_hello->ssl) + ->delegate_->EarlySelectCertCallback(client_hello); +} + +// static +int TlsServerConnection::TlsExtServernameCallback(SSL* ssl, + int* out_alert, + void* /*arg*/) { + return ConnectionFromSsl(ssl)->delegate_->TlsExtServernameCallback(out_alert); } // static diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/tls_server_connection.h b/chromium/net/third_party/quiche/src/quic/core/crypto/tls_server_connection.h index 954f8303163..774bb440f64 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/tls_server_connection.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/tls_server_connection.h @@ -6,8 +6,8 @@ #define QUICHE_QUIC_CORE_CRYPTO_TLS_SERVER_CONNECTION_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" -#include "net/third_party/quiche/src/quic/core/crypto/tls_connection.h" +#include "quic/core/crypto/proof_source.h" +#include "quic/core/crypto/tls_connection.h" namespace quic { @@ -22,13 +22,23 @@ class QUIC_EXPORT_PRIVATE TlsServerConnection : public TlsConnection { virtual ~Delegate() {} protected: - // Configures the certificate to use on |ssl_| based on the SNI sent by the - // client. Returns an SSL_TLSEXT_ERR_* value (see + // Called from BoringSSL right after SNI is extracted, which is very early + // in the handshake process. + virtual ssl_select_cert_result_t EarlySelectCertCallback( + const SSL_CLIENT_HELLO* client_hello) = 0; + + // Called after the ClientHello extensions have been successfully parsed. + // Returns an SSL_TLSEXT_ERR_* value (see // https://commondatastorage.googleapis.com/chromium-boringssl-docs/ssl.h.html#SSL_CTX_set_tlsext_servername_callback). // - // If SelectCertificate returns SSL_TLSEXT_ERR_ALERT_FATAL, then it puts in + // On success, return SSL_TLSEXT_ERR_OK causes the server_name extension to + // be acknowledged in the ServerHello, or return SSL_TLSEXT_ERR_NOACK which + // causes it to be not acknowledged. + // + // If the function returns SSL_TLSEXT_ERR_ALERT_FATAL, then it puts in // |*out_alert| the TLS alert value that the server will send. - virtual int SelectCertificate(int* out_alert) = 0; + // + virtual int TlsExtServernameCallback(int* out_alert) = 0; // Selects which ALPN to use based on the list sent by the client. virtual int SelectAlpn(const uint8_t** out, @@ -121,9 +131,12 @@ class QUIC_EXPORT_PRIVATE TlsServerConnection : public TlsConnection { // Specialization of TlsConnection::ConnectionFromSsl. static TlsServerConnection* ConnectionFromSsl(SSL* ssl); + static ssl_select_cert_result_t EarlySelectCertCallback( + const SSL_CLIENT_HELLO* client_hello); + // These functions are registered as callbacks in BoringSSL and delegate their // implementation to the matching methods in Delegate above. - static int SelectCertificateCallback(SSL* ssl, int* out_alert, void* arg); + static int TlsExtServernameCallback(SSL* ssl, int* out_alert, void* arg); static int SelectAlpnCallback(SSL* ssl, const uint8_t** out, uint8_t* out_len, diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/transport_parameters.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/transport_parameters.cc index c047e0ff143..8cbd06e66b2 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/transport_parameters.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/transport_parameters.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/transport_parameters.h" +#include "quic/core/crypto/transport_parameters.h" #include <cstdint> #include <cstring> @@ -11,18 +11,18 @@ #include <utility> #include "absl/strings/escaping.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/digest.h" #include "third_party/boringssl/src/include/openssl/sha.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_data_reader.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_data_reader.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { @@ -55,14 +55,14 @@ enum TransportParameters::TransportParameterId : uint64_t { kInitialRoundTripTime = 0x3127, kGoogleConnectionOptions = 0x3128, kGoogleUserAgentId = 0x3129, - kGoogleSupportHandshakeDone = 0x312A, // Only used in T050. + // 0x312A was used only in T050 to indicate support for HANDSHAKE_DONE. kGoogleKeyUpdateNotYetSupported = 0x312B, // 0x4751 was used for non-standard Google-specific parameters encoded as a // Google QUIC_CRYPTO CHLO, it has been replaced by individual parameters. kGoogleQuicVersion = 0x4752, // Used to transmit version and supported_versions. - kMinAckDelay = 0xDE1A // draft-iyengar-quic-delayed-ack. + kMinAckDelay = 0xDE1A, // draft-iyengar-quic-delayed-ack. }; namespace { @@ -124,8 +124,6 @@ std::string TransportParameterIdToString( return "google_connection_options"; case TransportParameters::kGoogleUserAgentId: return "user_agent_id"; - case TransportParameters::kGoogleSupportHandshakeDone: - return "support_handshake_done"; case TransportParameters::kGoogleKeyUpdateNotYetSupported: return "key_update_not_yet_supported"; case TransportParameters::kGoogleQuicVersion: @@ -160,7 +158,6 @@ bool TransportParameterIdIsKnown( case TransportParameters::kInitialRoundTripTime: case TransportParameters::kGoogleConnectionOptions: case TransportParameters::kGoogleUserAgentId: - case TransportParameters::kGoogleSupportHandshakeDone: case TransportParameters::kGoogleKeyUpdateNotYetSupported: case TransportParameters::kGoogleQuicVersion: case TransportParameters::kMinAckDelay: @@ -169,87 +166,6 @@ bool TransportParameterIdIsKnown( return false; } -bool WriteTransportParameterId( - QuicDataWriter* writer, - TransportParameters::TransportParameterId param_id, - ParsedQuicVersion version) { - if (version.HasVarIntTransportParams()) { - if (!writer->WriteVarInt62(param_id)) { - QUIC_BUG << "Failed to write param_id for " - << TransportParameterIdToString(param_id); - return false; - } - } else { - if (static_cast<uint64_t>(param_id) > - std::numeric_limits<uint16_t>::max()) { - QUIC_BUG << "Cannot serialize transport parameter " - << TransportParameterIdToString(param_id) << " with version " - << version; - return false; - } - if (!writer->WriteUInt16(param_id)) { - QUIC_BUG << "Failed to write param_id16 for " - << TransportParameterIdToString(param_id); - return false; - } - } - return true; -} - -bool WriteTransportParameterLength(QuicDataWriter* writer, - uint64_t length, - ParsedQuicVersion version) { - if (version.HasVarIntTransportParams()) { - return writer->WriteVarInt62(length); - } - if (length > std::numeric_limits<uint16_t>::max()) { - QUIC_BUG << "Cannot serialize transport parameter length " << length - << " with version " << version; - return false; - } - return writer->WriteUInt16(length); -} - -bool WriteTransportParameterStringPiece(QuicDataWriter* writer, - absl::string_view value, - ParsedQuicVersion version) { - if (version.HasVarIntTransportParams()) { - return writer->WriteStringPieceVarInt62(value); - } - return writer->WriteStringPiece16(value); -} - -bool ReadTransportParameterId( - QuicDataReader* reader, - ParsedQuicVersion version, - TransportParameters::TransportParameterId* out_param_id) { - if (version.HasVarIntTransportParams()) { - uint64_t param_id64; - if (!reader->ReadVarInt62(¶m_id64)) { - return false; - } - *out_param_id = - static_cast<TransportParameters::TransportParameterId>(param_id64); - } else { - uint16_t param_id16; - if (!reader->ReadUInt16(¶m_id16)) { - return false; - } - *out_param_id = - static_cast<TransportParameters::TransportParameterId>(param_id16); - } - return true; -} - -bool ReadTransportParameterLengthAndValue(QuicDataReader* reader, - ParsedQuicVersion version, - absl::string_view* out_value) { - if (version.HasVarIntTransportParams()) { - return reader->ReadStringPieceVarInt62(out_value); - } - return reader->ReadStringPiece16(out_value); -} - } // namespace TransportParameters::IntegerParameter::IntegerParameter( @@ -263,9 +179,9 @@ TransportParameters::IntegerParameter::IntegerParameter( min_value_(min_value), max_value_(max_value), has_been_read_(false) { - DCHECK_LE(min_value, default_value); - DCHECK_LE(default_value, max_value); - DCHECK_LE(max_value, kVarInt62MaxValue); + QUICHE_DCHECK_LE(min_value, default_value); + QUICHE_DCHECK_LE(default_value, max_value); + QUICHE_DCHECK_LE(max_value, kVarInt62MaxValue); } TransportParameters::IntegerParameter::IntegerParameter( @@ -289,29 +205,21 @@ bool TransportParameters::IntegerParameter::IsValid() const { } bool TransportParameters::IntegerParameter::Write( - QuicDataWriter* writer, - ParsedQuicVersion version) const { - DCHECK(IsValid()); + QuicDataWriter* writer) const { + QUICHE_DCHECK(IsValid()); if (value_ == default_value_) { // Do not write if the value is default. return true; } - if (!WriteTransportParameterId(writer, param_id_, version)) { + if (!writer->WriteVarInt62(param_id_)) { QUIC_BUG << "Failed to write param_id for " << *this; return false; } const QuicVariableLengthIntegerLength value_length = QuicDataWriter::GetVarInt62Len(value_); - if (version.HasVarIntTransportParams()) { - if (!writer->WriteVarInt62(value_length)) { - QUIC_BUG << "Failed to write value_length for " << *this; - return false; - } - } else { - if (!writer->WriteUInt16(value_length)) { - QUIC_BUG << "Failed to write value_length16 for " << *this; - return false; - } + if (!writer->WriteVarInt62(value_length)) { + QUIC_BUG << "Failed to write value_length for " << *this; + return false; } if (!writer->WriteVarInt62(value_, value_length)) { QUIC_BUG << "Failed to write value for " << *this; @@ -336,8 +244,8 @@ bool TransportParameters::IntegerParameter::Read(QuicDataReader* reader, } if (!reader->IsDoneReading()) { *error_details = - quiche::QuicheStrCat("Received unexpected ", reader->BytesRemaining(), - " bytes after parsing ", this->ToString(false)); + absl::StrCat("Received unexpected ", reader->BytesRemaining(), + " bytes after parsing ", this->ToString(false)); return false; } return true; @@ -475,9 +383,6 @@ std::string TransportParameters::ToString() const { rv += " " + TransportParameterIdToString(kGoogleUserAgentId) + " \"" + user_agent_id.value() + "\""; } - if (support_handshake_done) { - rv += " " + TransportParameterIdToString(kGoogleSupportHandshakeDone); - } if (key_update_not_yet_supported) { rv += " " + TransportParameterIdToString(kGoogleKeyUpdateNotYetSupported); } @@ -489,8 +394,8 @@ std::string TransportParameters::ToString() const { rv += absl::BytesToHexString(kv.second); } else { absl::string_view truncated(kv.second.data(), kMaxPrintableLength); - rv += quiche::QuicheStrCat(absl::BytesToHexString(truncated), - "...(length ", kv.second.length(), ")"); + rv += absl::StrCat(absl::BytesToHexString(truncated), "...(length ", + kv.second.length(), ")"); } } rv += "]"; @@ -529,7 +434,6 @@ TransportParameters::TransportParameters() kVarInt62MaxValue), max_datagram_frame_size(kMaxDatagramFrameSize), initial_round_trip_time_us(kInitialRoundTripTime), - support_handshake_done(false), key_update_not_yet_supported(false) // Important note: any new transport parameters must be added // to TransportParameters::AreValid, SerializeTransportParameters and @@ -565,7 +469,6 @@ TransportParameters::TransportParameters(const TransportParameters& other) initial_round_trip_time_us(other.initial_round_trip_time_us), google_connection_options(other.google_connection_options), user_agent_id(other.user_agent_id), - support_handshake_done(other.support_handshake_done), key_update_not_yet_supported(other.key_update_not_yet_supported), custom_parameters(other.custom_parameters) { if (other.preferred_address) { @@ -607,7 +510,6 @@ bool TransportParameters::operator==(const TransportParameters& rhs) const { rhs.initial_round_trip_time_us.value() && google_connection_options == rhs.google_connection_options && user_agent_id == rhs.user_agent_id && - support_handshake_done == rhs.support_handshake_done && key_update_not_yet_supported == rhs.key_update_not_yet_supported && custom_parameters == rhs.custom_parameters)) { return false; @@ -630,8 +532,8 @@ bool TransportParameters::operator!=(const TransportParameters& rhs) const { } bool TransportParameters::AreValid(std::string* error_details) const { - DCHECK(perspective == Perspective::IS_CLIENT || - perspective == Perspective::IS_SERVER); + QUICHE_DCHECK(perspective == Perspective::IS_CLIENT || + perspective == Perspective::IS_SERVER); if (perspective == Perspective::IS_CLIENT && !stateless_reset_token.empty()) { *error_details = "Client cannot send stateless reset token"; return false; @@ -643,8 +545,8 @@ bool TransportParameters::AreValid(std::string* error_details) const { } if (!stateless_reset_token.empty() && stateless_reset_token.size() != kStatelessResetTokenLength) { - *error_details = quiche::QuicheStrCat( - "Stateless reset token has bad length ", stateless_reset_token.size()); + *error_details = absl::StrCat("Stateless reset token has bad length ", + stateless_reset_token.size()); return false; } if (perspective == Perspective::IS_CLIENT && preferred_address) { @@ -653,9 +555,9 @@ bool TransportParameters::AreValid(std::string* error_details) const { } if (preferred_address && preferred_address->stateless_reset_token.size() != kStatelessResetTokenLength) { - *error_details = quiche::QuicheStrCat( - "Preferred address stateless reset token has bad length ", - preferred_address->stateless_reset_token.size()); + *error_details = + absl::StrCat("Preferred address stateless reset token has bad length ", + preferred_address->stateless_reset_token.size()); return false; } if (preferred_address && @@ -672,9 +574,9 @@ bool TransportParameters::AreValid(std::string* error_details) const { } for (const auto& kv : custom_parameters) { if (TransportParameterIdIsKnown(kv.first)) { - *error_details = quiche::QuicheStrCat( - "Using custom_parameters with known ID ", - TransportParameterIdToString(kv.first), " is not allowed"); + *error_details = absl::StrCat("Using custom_parameters with known ID ", + TransportParameterIdToString(kv.first), + " is not allowed"); return false; } } @@ -705,7 +607,7 @@ bool TransportParameters::AreValid(std::string* error_details) const { TransportParameters::~TransportParameters() = default; -bool SerializeTransportParameters(ParsedQuicVersion version, +bool SerializeTransportParameters(ParsedQuicVersion /*version*/, const TransportParameters& in, std::vector<uint8_t>* out) { std::string error_details; @@ -763,7 +665,6 @@ bool SerializeTransportParameters(ParsedQuicVersion version, kIntegerParameterLength + // initial_round_trip_time_us kTypeAndValueLength + // google_connection_options kTypeAndValueLength + // user_agent_id - kTypeAndValueLength + // support_handshake_done kTypeAndValueLength + // key_update_not_yet_supported kTypeAndValueLength + // google-version kGreaseParameterLength; // GREASE @@ -790,82 +691,62 @@ bool SerializeTransportParameters(ParsedQuicVersion version, out->resize(max_transport_param_length); QuicDataWriter writer(out->size(), reinterpret_cast<char*>(out->data())); - if (!version.HasVarIntTransportParams()) { - // Versions that do not use variable integer transport parameters carry - // a 16-bit length of the remaining transport parameters. We write 0 here - // to reserve 16 bits, and we fill it in at the end of this function. - // TODO(b/150465921) add support for doing this in QuicDataWriter. - if (!writer.WriteUInt16(0)) { - QUIC_BUG << "Failed to write transport parameter fake length prefix for " - << in; - return false; - } - } - // original_destination_connection_id if (in.original_destination_connection_id.has_value()) { - DCHECK_EQ(Perspective::IS_SERVER, in.perspective); + QUICHE_DCHECK_EQ(Perspective::IS_SERVER, in.perspective); QuicConnectionId original_destination_connection_id = in.original_destination_connection_id.value(); - if (!WriteTransportParameterId( - &writer, TransportParameters::kOriginalDestinationConnectionId, - version) || - !WriteTransportParameterStringPiece( - &writer, + if (!writer.WriteVarInt62( + TransportParameters::kOriginalDestinationConnectionId) || + !writer.WriteStringPieceVarInt62( absl::string_view(original_destination_connection_id.data(), - original_destination_connection_id.length()), - version)) { + original_destination_connection_id.length()))) { QUIC_BUG << "Failed to write original_destination_connection_id " << original_destination_connection_id << " for " << in; return false; } } - if (!in.max_idle_timeout_ms.Write(&writer, version)) { + if (!in.max_idle_timeout_ms.Write(&writer)) { QUIC_BUG << "Failed to write idle_timeout for " << in; return false; } // stateless_reset_token if (!in.stateless_reset_token.empty()) { - DCHECK_EQ(kStatelessResetTokenLength, in.stateless_reset_token.size()); - DCHECK_EQ(Perspective::IS_SERVER, in.perspective); - if (!WriteTransportParameterId( - &writer, TransportParameters::kStatelessResetToken, version) || - !WriteTransportParameterStringPiece( - &writer, - absl::string_view( - reinterpret_cast<const char*>(in.stateless_reset_token.data()), - in.stateless_reset_token.size()), - version)) { + QUICHE_DCHECK_EQ(kStatelessResetTokenLength, + in.stateless_reset_token.size()); + QUICHE_DCHECK_EQ(Perspective::IS_SERVER, in.perspective); + if (!writer.WriteVarInt62(TransportParameters::kStatelessResetToken) || + !writer.WriteStringPieceVarInt62(absl::string_view( + reinterpret_cast<const char*>(in.stateless_reset_token.data()), + in.stateless_reset_token.size()))) { QUIC_BUG << "Failed to write stateless_reset_token of length " << in.stateless_reset_token.size() << " for " << in; return false; } } - if (!in.max_udp_payload_size.Write(&writer, version) || - !in.initial_max_data.Write(&writer, version) || - !in.initial_max_stream_data_bidi_local.Write(&writer, version) || - !in.initial_max_stream_data_bidi_remote.Write(&writer, version) || - !in.initial_max_stream_data_uni.Write(&writer, version) || - !in.initial_max_streams_bidi.Write(&writer, version) || - !in.initial_max_streams_uni.Write(&writer, version) || - !in.ack_delay_exponent.Write(&writer, version) || - !in.max_ack_delay.Write(&writer, version) || - !in.min_ack_delay_us.Write(&writer, version) || - !in.active_connection_id_limit.Write(&writer, version) || - !in.max_datagram_frame_size.Write(&writer, version) || - !in.initial_round_trip_time_us.Write(&writer, version)) { + if (!in.max_udp_payload_size.Write(&writer) || + !in.initial_max_data.Write(&writer) || + !in.initial_max_stream_data_bidi_local.Write(&writer) || + !in.initial_max_stream_data_bidi_remote.Write(&writer) || + !in.initial_max_stream_data_uni.Write(&writer) || + !in.initial_max_streams_bidi.Write(&writer) || + !in.initial_max_streams_uni.Write(&writer) || + !in.ack_delay_exponent.Write(&writer) || + !in.max_ack_delay.Write(&writer) || !in.min_ack_delay_us.Write(&writer) || + !in.active_connection_id_limit.Write(&writer) || + !in.max_datagram_frame_size.Write(&writer) || + !in.initial_round_trip_time_us.Write(&writer)) { QUIC_BUG << "Failed to write integers for " << in; return false; } // disable_active_migration if (in.disable_active_migration) { - if (!WriteTransportParameterId( - &writer, TransportParameters::kDisableActiveMigration, version) || - !WriteTransportParameterLength(&writer, /*length=*/0, version)) { + if (!writer.WriteVarInt62(TransportParameters::kDisableActiveMigration) || + !writer.WriteVarInt62(/* transport parameter length */ 0)) { QUIC_BUG << "Failed to write disable_active_migration for " << in; return false; } @@ -889,10 +770,9 @@ bool SerializeTransportParameters(ParsedQuicVersion version, /* connection ID length byte */ sizeof(uint8_t) + in.preferred_address->connection_id.length() + in.preferred_address->stateless_reset_token.size(); - if (!WriteTransportParameterId( - &writer, TransportParameters::kPreferredAddress, version) || - !WriteTransportParameterLength(&writer, preferred_address_length, - version) || + if (!writer.WriteVarInt62(TransportParameters::kPreferredAddress) || + !writer.WriteVarInt62( + /* transport parameter length */ preferred_address_length) || !writer.WriteStringPiece(v4_address_bytes) || !writer.WriteUInt16(in.preferred_address->ipv4_socket_address.port()) || !writer.WriteStringPiece(v6_address_bytes) || @@ -912,14 +792,11 @@ bool SerializeTransportParameters(ParsedQuicVersion version, if (in.initial_source_connection_id.has_value()) { QuicConnectionId initial_source_connection_id = in.initial_source_connection_id.value(); - if (!WriteTransportParameterId( - &writer, TransportParameters::kInitialSourceConnectionId, - version) || - !WriteTransportParameterStringPiece( - &writer, + if (!writer.WriteVarInt62( + TransportParameters::kInitialSourceConnectionId) || + !writer.WriteStringPieceVarInt62( absl::string_view(initial_source_connection_id.data(), - initial_source_connection_id.length()), - version)) { + initial_source_connection_id.length()))) { QUIC_BUG << "Failed to write initial_source_connection_id " << initial_source_connection_id << " for " << in; return false; @@ -928,16 +805,13 @@ bool SerializeTransportParameters(ParsedQuicVersion version, // retry_source_connection_id if (in.retry_source_connection_id.has_value()) { - DCHECK_EQ(Perspective::IS_SERVER, in.perspective); + QUICHE_DCHECK_EQ(Perspective::IS_SERVER, in.perspective); QuicConnectionId retry_source_connection_id = in.retry_source_connection_id.value(); - if (!WriteTransportParameterId( - &writer, TransportParameters::kRetrySourceConnectionId, version) || - !WriteTransportParameterStringPiece( - &writer, + if (!writer.WriteVarInt62(TransportParameters::kRetrySourceConnectionId) || + !writer.WriteStringPieceVarInt62( absl::string_view(retry_source_connection_id.data(), - retry_source_connection_id.length()), - version)) { + retry_source_connection_id.length()))) { QUIC_BUG << "Failed to write retry_source_connection_id " << retry_source_connection_id << " for " << in; return false; @@ -950,10 +824,9 @@ bool SerializeTransportParameters(ParsedQuicVersion version, "bad size"); uint64_t connection_options_length = in.google_connection_options.value().size() * 4; - if (!WriteTransportParameterId( - &writer, TransportParameters::kGoogleConnectionOptions, version) || - !WriteTransportParameterLength(&writer, connection_options_length, - version)) { + if (!writer.WriteVarInt62(TransportParameters::kGoogleConnectionOptions) || + !writer.WriteVarInt62( + /* transport parameter length */ connection_options_length)) { QUIC_BUG << "Failed to write google_connection_options of length " << connection_options_length << " for " << in; return false; @@ -970,33 +843,19 @@ bool SerializeTransportParameters(ParsedQuicVersion version, // Google-specific user agent identifier. if (in.user_agent_id.has_value()) { - if (!WriteTransportParameterId( - &writer, TransportParameters::kGoogleUserAgentId, version) || - !WriteTransportParameterStringPiece(&writer, in.user_agent_id.value(), - version)) { + if (!writer.WriteVarInt62(TransportParameters::kGoogleUserAgentId) || + !writer.WriteStringPieceVarInt62(in.user_agent_id.value())) { QUIC_BUG << "Failed to write Google user agent ID \"" << in.user_agent_id.value() << "\" for " << in; return false; } } - // Google-specific support handshake done. - if (in.support_handshake_done) { - if (!WriteTransportParameterId( - &writer, TransportParameters::kGoogleSupportHandshakeDone, - version) || - !WriteTransportParameterLength(&writer, /*length=*/0, version)) { - QUIC_BUG << "Failed to write support_handshake_done for " << in; - return false; - } - } - // Google-specific indicator for key update not yet supported. if (in.key_update_not_yet_supported) { - if (!WriteTransportParameterId( - &writer, TransportParameters::kGoogleKeyUpdateNotYetSupported, - version) || - !WriteTransportParameterLength(&writer, /*length=*/0, version)) { + if (!writer.WriteVarInt62( + TransportParameters::kGoogleKeyUpdateNotYetSupported) || + !writer.WriteVarInt62(/* transport parameter length */ 0)) { QUIC_BUG << "Failed to write key_update_not_yet_supported for " << in; return false; } @@ -1010,9 +869,9 @@ bool SerializeTransportParameters(ParsedQuicVersion version, /* versions length */ sizeof(uint8_t) + sizeof(QuicVersionLabel) * in.supported_versions.size(); } - if (!WriteTransportParameterId( - &writer, TransportParameters::kGoogleQuicVersion, version) || - !WriteTransportParameterLength(&writer, google_version_length, version) || + if (!writer.WriteVarInt62(TransportParameters::kGoogleQuicVersion) || + !writer.WriteVarInt62( + /* transport parameter length */ google_version_length) || !writer.WriteUInt32(in.version)) { QUIC_BUG << "Failed to write Google version extension for " << in; return false; @@ -1040,8 +899,8 @@ bool SerializeTransportParameters(ParsedQuicVersion version, << " is not allowed"; return false; } - if (!WriteTransportParameterId(&writer, param_id, version) || - !WriteTransportParameterStringPiece(&writer, kv.second, version)) { + if (!writer.WriteVarInt62(param_id) || + !writer.WriteStringPieceVarInt62(kv.second)) { QUIC_BUG << "Failed to write custom parameter " << param_id; return false; } @@ -1053,55 +912,28 @@ bool SerializeTransportParameters(ParsedQuicVersion version, // https://quicwg.org/base-drafts/draft-ietf-quic-transport.html // This forces receivers to support unexpected input. QuicRandom* random = QuicRandom::GetInstance(); - uint64_t grease_id64 = random->RandUint64(); - if (version.HasVarIntTransportParams()) { - // With these versions, identifiers are 62 bits long so we need to ensure - // that the output of the computation below fits in 62 bits. - grease_id64 %= ((1ULL << 62) - 31); - } else { - // Same with 16 bits. - grease_id64 %= ((1ULL << 16) - 31); - } + // Transport parameter identifiers are 62 bits long so we need to ensure + // that the output of the computation below fits in 62 bits. + uint64_t grease_id64 = random->RandUint64() % ((1ULL << 62) - 31); // Make sure grease_id % 31 == 27. Note that this is not uniformely // distributed but is acceptable since no security depends on this // randomness. grease_id64 = (grease_id64 / 31) * 31 + 27; - DCHECK(version.HasVarIntTransportParams() || - grease_id64 <= std::numeric_limits<uint16_t>::max()) - << grease_id64 << " invalid for " << version; TransportParameters::TransportParameterId grease_id = static_cast<TransportParameters::TransportParameterId>(grease_id64); const size_t grease_length = random->RandUint64() % kMaxGreaseLength; - DCHECK_GE(kMaxGreaseLength, grease_length); + QUICHE_DCHECK_GE(kMaxGreaseLength, grease_length); char grease_contents[kMaxGreaseLength]; random->RandBytes(grease_contents, grease_length); - if (!WriteTransportParameterId(&writer, grease_id, version) || - !WriteTransportParameterStringPiece( - &writer, absl::string_view(grease_contents, grease_length), - version)) { + if (!writer.WriteVarInt62(grease_id) || + !writer.WriteStringPieceVarInt62( + absl::string_view(grease_contents, grease_length))) { QUIC_BUG << "Failed to write GREASE parameter " << TransportParameterIdToString(grease_id); return false; } } - if (!version.HasVarIntTransportParams()) { - // Fill in the length prefix at the start of the transport parameters. - if (writer.length() < sizeof(uint16_t) || - writer.length() - sizeof(uint16_t) > - std::numeric_limits<uint16_t>::max()) { - QUIC_BUG << "Cannot write length " << writer.length() << " for " << in; - return false; - } - const uint16_t length_prefix = writer.length() - sizeof(uint16_t); - QuicDataWriter length_prefix_writer(out->size(), - reinterpret_cast<char*>(out->data())); - if (!length_prefix_writer.WriteUInt16(length_prefix)) { - QUIC_BUG << "Failed to write length prefix for " << in; - return false; - } - } - out->resize(writer.length()); QUIC_DLOG(INFO) << "Serialized " << in << " as " << writer.length() @@ -1119,28 +951,16 @@ bool ParseTransportParameters(ParsedQuicVersion version, out->perspective = perspective; QuicDataReader reader(reinterpret_cast<const char*>(in), in_len); - if (!version.HasVarIntTransportParams()) { - uint16_t full_length; - if (!reader.ReadUInt16(&full_length)) { - *error_details = "Failed to parse the transport parameter full length"; - return false; - } - if (full_length != reader.BytesRemaining()) { - *error_details = - quiche::QuicheStrCat("Invalid transport parameter full length ", - full_length, " != ", reader.BytesRemaining()); - return false; - } - } - while (!reader.IsDoneReading()) { - TransportParameters::TransportParameterId param_id; - if (!ReadTransportParameterId(&reader, version, ¶m_id)) { + uint64_t param_id64; + if (!reader.ReadVarInt62(¶m_id64)) { *error_details = "Failed to parse transport parameter ID"; return false; } + TransportParameters::TransportParameterId param_id = + static_cast<TransportParameters::TransportParameterId>(param_id64); absl::string_view value; - if (!ReadTransportParameterLengthAndValue(&reader, version, &value)) { + if (!reader.ReadStringPieceVarInt62(&value)) { *error_details = "Failed to read length and value of transport parameter " + TransportParameterIdToString(param_id); @@ -1158,7 +978,7 @@ bool ParseTransportParameters(ParsedQuicVersion version, const size_t connection_id_length = value_reader.BytesRemaining(); if (!QuicUtils::IsConnectionIdLengthValidForVersion( connection_id_length, version.transport_version)) { - *error_details = quiche::QuicheStrCat( + *error_details = absl::StrCat( "Received original_destination_connection_id of invalid length ", connection_id_length); return false; @@ -1184,9 +1004,9 @@ bool ParseTransportParameters(ParsedQuicVersion version, absl::string_view stateless_reset_token = value_reader.ReadRemainingPayload(); if (stateless_reset_token.length() != kStatelessResetTokenLength) { - *error_details = quiche::QuicheStrCat( - "Received stateless_reset_token of invalid length ", - stateless_reset_token.length()); + *error_details = + absl::StrCat("Received stateless_reset_token of invalid length ", + stateless_reset_token.length()); return false; } out->stateless_reset_token.assign( @@ -1285,7 +1105,7 @@ bool ParseTransportParameters(ParsedQuicVersion version, const size_t connection_id_length = value_reader.BytesRemaining(); if (!QuicUtils::IsConnectionIdLengthValidForVersion( connection_id_length, version.transport_version)) { - *error_details = quiche::QuicheStrCat( + *error_details = absl::StrCat( "Received initial_source_connection_id of invalid length ", connection_id_length); return false; @@ -1306,7 +1126,7 @@ bool ParseTransportParameters(ParsedQuicVersion version, const size_t connection_id_length = value_reader.BytesRemaining(); if (!QuicUtils::IsConnectionIdLengthValidForVersion( connection_id_length, version.transport_version)) { - *error_details = quiche::QuicheStrCat( + *error_details = absl::StrCat( "Received retry_source_connection_id of invalid length ", connection_id_length); return false; @@ -1349,13 +1169,6 @@ bool ParseTransportParameters(ParsedQuicVersion version, } out->user_agent_id = std::string(value_reader.ReadRemainingPayload()); break; - case TransportParameters::kGoogleSupportHandshakeDone: - if (out->support_handshake_done) { - *error_details = "Received a second support_handshake_done"; - return false; - } - out->support_handshake_done = true; - break; case TransportParameters::kGoogleKeyUpdateNotYetSupported: if (out->key_update_not_yet_supported) { *error_details = "Received a second key_update_not_yet_supported"; @@ -1401,11 +1214,11 @@ bool ParseTransportParameters(ParsedQuicVersion version, break; } if (!parse_success) { - DCHECK(!error_details->empty()); + QUICHE_DCHECK(!error_details->empty()); return false; } if (!value_reader.IsDoneReading()) { - *error_details = quiche::QuicheStrCat( + *error_details = absl::StrCat( "Received unexpected ", value_reader.BytesRemaining(), " bytes after parsing ", TransportParameterIdToString(param_id)); return false; @@ -1413,7 +1226,7 @@ bool ParseTransportParameters(ParsedQuicVersion version, } if (!out->AreValid(error_details)) { - DCHECK(!error_details->empty()); + QUICHE_DCHECK(!error_details->empty()); return false; } diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/transport_parameters.h b/chromium/net/third_party/quiche/src/quic/core/crypto/transport_parameters.h index 8c7970c29d5..b6ecb69d077 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/transport_parameters.h +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/transport_parameters.h @@ -8,28 +8,29 @@ #include <memory> #include <vector> +#include "absl/container/flat_hash_map.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_data_reader.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_tag.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_data_reader.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_tag.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { // TransportParameters contains parameters for QUIC's transport layer that are // exchanged during the TLS handshake. This struct is a mirror of the struct in // the "Transport Parameter Encoding" section of draft-ietf-quic-transport. -// This struct currently uses the values from draft 20. +// This struct currently uses the values from draft 29. struct QUIC_EXPORT_PRIVATE TransportParameters { // The identifier used to differentiate transport parameters. enum TransportParameterId : uint64_t; // A map used to specify custom parameters. - using ParameterMap = QuicHashMap<TransportParameterId, std::string>; + using ParameterMap = absl::flat_hash_map<TransportParameterId, std::string>; // Represents an individual QUIC transport parameter that only encodes a // variable length integer. Can only be created inside the constructor for // TransportParameters. @@ -47,7 +48,7 @@ struct QUIC_EXPORT_PRIVATE TransportParameters { // Writes to a crypto byte buffer, used during serialization. Does not write // anything if the value is equal to the parameter's default value. // Returns whether the write was successful. - bool Write(QuicDataWriter* writer, ParsedQuicVersion version) const; + bool Write(QuicDataWriter* writer) const; // Reads from a crypto byte string, used during parsing. // Returns whether the read was successful. // On failure, this method will write a human-readable error message to @@ -207,9 +208,6 @@ struct QUIC_EXPORT_PRIVATE TransportParameters { // Google-specific user agent identifier. absl::optional<std::string> user_agent_id; - // Google-specific handshake done support. This is only used for T050. - bool support_handshake_done; - // Google-specific mechanism to indicate that IETF QUIC Key Update has not // yet been implemented. This will be removed once we implement it. bool key_update_not_yet_supported; diff --git a/chromium/net/third_party/quiche/src/quic/core/crypto/transport_parameters_test.cc b/chromium/net/third_party/quiche/src/quic/core/crypto/transport_parameters_test.cc index ab8360eabca..3d23ae6a33b 100644 --- a/chromium/net/third_party/quiche/src/quic/core/crypto/transport_parameters_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/crypto/transport_parameters_test.cc @@ -2,22 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/crypto/transport_parameters.h" +#include "quic/core/crypto/transport_parameters.h" #include <cstring> #include <utility> #include "absl/base/macros.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_tag.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_tag.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { @@ -37,7 +37,6 @@ const uint64_t kFakeInitialRoundTripTime = 53; const uint8_t kFakePreferredStatelessResetTokenData[16] = { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F}; -const bool kFakeSupportHandshakeDone = true; const bool kFakeKeyUpdateNotYetSupported = true; const auto kCustomParameter1 = @@ -250,7 +249,6 @@ TEST_P(TransportParametersTest, CopyConstructor) { orig_params.initial_round_trip_time_us.set_value(kFakeInitialRoundTripTime); orig_params.google_connection_options = CreateFakeGoogleConnectionOptions(); orig_params.user_agent_id = CreateFakeUserAgentId(); - orig_params.support_handshake_done = kFakeSupportHandshakeDone; orig_params.key_update_not_yet_supported = kFakeKeyUpdateNotYetSupported; orig_params.custom_parameters[kCustomParameter1] = kCustomParameter1Value; orig_params.custom_parameters[kCustomParameter2] = kCustomParameter2Value; @@ -285,7 +283,6 @@ TEST_P(TransportParametersTest, RoundTripClient) { orig_params.initial_round_trip_time_us.set_value(kFakeInitialRoundTripTime); orig_params.google_connection_options = CreateFakeGoogleConnectionOptions(); orig_params.user_agent_id = CreateFakeUserAgentId(); - orig_params.support_handshake_done = kFakeSupportHandshakeDone; orig_params.key_update_not_yet_supported = kFakeKeyUpdateNotYetSupported; orig_params.custom_parameters[kCustomParameter1] = kCustomParameter1Value; orig_params.custom_parameters[kCustomParameter2] = kCustomParameter2Value; @@ -461,88 +458,6 @@ TEST_P(TransportParametersTest, NoClientParamsWithStatelessResetToken) { TEST_P(TransportParametersTest, ParseClientParams) { // clang-format off - const uint8_t kClientParamsOld[] = { - 0x00, 0x84, // length of the parameters array that follows - // max_idle_timeout - 0x00, 0x01, // parameter id - 0x00, 0x02, // length - 0x6e, 0xec, // value - // max_udp_payload_size - 0x00, 0x03, // parameter id - 0x00, 0x02, // length - 0x63, 0x29, // value - // initial_max_data - 0x00, 0x04, // parameter id - 0x00, 0x02, // length - 0x40, 0x65, // value - // initial_max_stream_data_bidi_local - 0x00, 0x05, // parameter id - 0x00, 0x02, // length - 0x47, 0xD1, // value - // initial_max_stream_data_bidi_remote - 0x00, 0x06, // parameter id - 0x00, 0x02, // length - 0x47, 0xD2, // value - // initial_max_stream_data_uni - 0x00, 0x07, // parameter id - 0x00, 0x02, // length - 0x4B, 0xB8, // value - // initial_max_streams_bidi - 0x00, 0x08, // parameter id - 0x00, 0x01, // length - 0x15, // value - // initial_max_streams_uni - 0x00, 0x09, // parameter id - 0x00, 0x01, // length - 0x16, // value - // ack_delay_exponent - 0x00, 0x0a, // parameter id - 0x00, 0x01, // length - 0x0a, // value - // max_ack_delay - 0x00, 0x0b, // parameter id - 0x00, 0x01, // length - 0x33, // value - // min_ack_delay_us - 0xde, 0x1a, // parameter id - 0x00, 0x02, // length - 0x43, 0xe8, // value - // disable_active_migration - 0x00, 0x0c, // parameter id - 0x00, 0x00, // length - // active_connection_id_limit - 0x00, 0x0e, // parameter id - 0x00, 0x01, // length - 0x34, // value - // initial_source_connection_id - 0x00, 0x0f, // parameter id - 0x00, 0x08, // length - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x45, - // initial_round_trip_time_us - 0x31, 0x27, // parameter id - 0x00, 0x01, // length - 0x35, // value - // google_connection_options - 0x31, 0x28, // parameter id - 0x00, 0x0c, // length - 'A', 'L', 'P', 'N', // value - 'E', 'F', 'G', 0x00, - 'H', 'I', 'J', 0xff, - // user_agent_id - 0x31, 0x29, // parameter id - 0x00, 0x08, // length - 'F', 'a', 'k', 'e', 'U', 'A', 'I', 'D', // value - // support_handshake_done - 0x31, 0x2A, // parameter id - 0x00, 0x00, // value - // key_update_not_yet_supported - 0x31, 0x2B, // parameter id - 0x00, 0x00, // value - // Google version extension - 0x47, 0x52, // parameter id - 0x00, 0x04, // length - 0x01, 0x23, 0x45, 0x67, // initial version - }; const uint8_t kClientParams[] = { // max_idle_timeout 0x01, // parameter id @@ -613,9 +528,6 @@ TEST_P(TransportParametersTest, ParseClientParams) { 0x71, 0x29, // parameter id 0x08, // length 'F', 'a', 'k', 'e', 'U', 'A', 'I', 'D', // value - // support_handshake_done - 0x71, 0x2A, // parameter id - 0x00, // length // key_update_not_yet_supported 0x71, 0x2B, // parameter id 0x00, // length @@ -628,10 +540,6 @@ TEST_P(TransportParametersTest, ParseClientParams) { const uint8_t* client_params = reinterpret_cast<const uint8_t*>(kClientParams); size_t client_params_length = ABSL_ARRAYSIZE(kClientParams); - if (!version_.HasVarIntTransportParams()) { - client_params = reinterpret_cast<const uint8_t*>(kClientParamsOld); - client_params_length = ABSL_ARRAYSIZE(kClientParamsOld); - } TransportParameters new_params; std::string error_details; ASSERT_TRUE(ParseTransportParameters(version_, Perspective::IS_CLIENT, @@ -675,33 +583,12 @@ TEST_P(TransportParametersTest, ParseClientParams) { new_params.google_connection_options.value()); ASSERT_TRUE(new_params.user_agent_id.has_value()); EXPECT_EQ(CreateFakeUserAgentId(), new_params.user_agent_id.value()); - EXPECT_TRUE(new_params.support_handshake_done); EXPECT_TRUE(new_params.key_update_not_yet_supported); } TEST_P(TransportParametersTest, ParseClientParamsFailsWithFullStatelessResetToken) { // clang-format off - const uint8_t kClientParamsWithFullTokenOld[] = { - 0x00, 0x26, // length parameters array that follows - // max_idle_timeout - 0x00, 0x01, // parameter id - 0x00, 0x02, // length - 0x6e, 0xec, // value - // stateless_reset_token - 0x00, 0x02, // parameter id - 0x00, 0x10, // length - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, - 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - // max_udp_payload_size - 0x00, 0x03, // parameter id - 0x00, 0x02, // length - 0x63, 0x29, // value - // initial_max_data - 0x00, 0x04, // parameter id - 0x00, 0x02, // length - 0x40, 0x65, // value - }; const uint8_t kClientParamsWithFullToken[] = { // max_idle_timeout 0x01, // parameter id @@ -725,11 +612,6 @@ TEST_P(TransportParametersTest, const uint8_t* client_params = reinterpret_cast<const uint8_t*>(kClientParamsWithFullToken); size_t client_params_length = ABSL_ARRAYSIZE(kClientParamsWithFullToken); - if (!version_.HasVarIntTransportParams()) { - client_params = - reinterpret_cast<const uint8_t*>(kClientParamsWithFullTokenOld); - client_params_length = ABSL_ARRAYSIZE(kClientParamsWithFullTokenOld); - } TransportParameters out_params; std::string error_details; EXPECT_FALSE(ParseTransportParameters(version_, Perspective::IS_CLIENT, @@ -741,24 +623,6 @@ TEST_P(TransportParametersTest, TEST_P(TransportParametersTest, ParseClientParamsFailsWithEmptyStatelessResetToken) { // clang-format off - const uint8_t kClientParamsWithEmptyTokenOld[] = { - 0x00, 0x16, // length parameters array that follows - // max_idle_timeout - 0x00, 0x01, // parameter id - 0x00, 0x02, // length - 0x6e, 0xec, // value - // stateless_reset_token - 0x00, 0x02, // parameter id - 0x00, 0x00, - // max_udp_payload_size - 0x00, 0x03, // parameter id - 0x00, 0x02, // length - 0x63, 0x29, // value - // initial_max_data - 0x00, 0x04, // parameter id - 0x00, 0x02, // length - 0x40, 0x65, // value - }; const uint8_t kClientParamsWithEmptyToken[] = { // max_idle_timeout 0x01, // parameter id @@ -780,11 +644,6 @@ TEST_P(TransportParametersTest, const uint8_t* client_params = reinterpret_cast<const uint8_t*>(kClientParamsWithEmptyToken); size_t client_params_length = ABSL_ARRAYSIZE(kClientParamsWithEmptyToken); - if (!version_.HasVarIntTransportParams()) { - client_params = - reinterpret_cast<const uint8_t*>(kClientParamsWithEmptyTokenOld); - client_params_length = ABSL_ARRAYSIZE(kClientParamsWithEmptyTokenOld); - } TransportParameters out_params; std::string error_details; EXPECT_FALSE(ParseTransportParameters(version_, Perspective::IS_CLIENT, @@ -796,21 +655,6 @@ TEST_P(TransportParametersTest, TEST_P(TransportParametersTest, ParseClientParametersRepeated) { // clang-format off - const uint8_t kClientParamsRepeatedOld[] = { - 0x00, 0x12, // length parameters array that follows - // max_idle_timeout - 0x00, 0x01, // parameter id - 0x00, 0x02, // length - 0x6e, 0xec, // value - // max_udp_payload_size - 0x00, 0x03, // parameter id - 0x00, 0x02, // length - 0x63, 0x29, // value - // max_idle_timeout (repeated) - 0x00, 0x01, // parameter id - 0x00, 0x02, // length - 0x6e, 0xec, // value - }; const uint8_t kClientParamsRepeated[] = { // max_idle_timeout 0x01, // parameter id @@ -829,10 +673,6 @@ TEST_P(TransportParametersTest, ParseClientParametersRepeated) { const uint8_t* client_params = reinterpret_cast<const uint8_t*>(kClientParamsRepeated); size_t client_params_length = ABSL_ARRAYSIZE(kClientParamsRepeated); - if (!version_.HasVarIntTransportParams()) { - client_params = reinterpret_cast<const uint8_t*>(kClientParamsRepeatedOld); - client_params_length = ABSL_ARRAYSIZE(kClientParamsRepeatedOld); - } TransportParameters out_params; std::string error_details; EXPECT_FALSE(ParseTransportParameters(version_, Perspective::IS_CLIENT, @@ -843,108 +683,6 @@ TEST_P(TransportParametersTest, ParseClientParametersRepeated) { TEST_P(TransportParametersTest, ParseServerParams) { // clang-format off - const uint8_t kServerParamsOld[] = { - 0x00, 0xdd, // length of parameters array that follows - // original_destination_connection_id - 0x00, 0x00, // parameter id - 0x00, 0x08, // length - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x37, - // max_idle_timeout - 0x00, 0x01, // parameter id - 0x00, 0x02, // length - 0x6e, 0xec, // value - // stateless_reset_token - 0x00, 0x02, // parameter id - 0x00, 0x10, // length - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, - 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - // max_udp_payload_size - 0x00, 0x03, // parameter id - 0x00, 0x02, // length - 0x63, 0x29, // value - // initial_max_data - 0x00, 0x04, // parameter id - 0x00, 0x02, // length - 0x40, 0x65, // value - // initial_max_stream_data_bidi_local - 0x00, 0x05, // parameter id - 0x00, 0x02, // length - 0x47, 0xD1, // value - // initial_max_stream_data_bidi_remote - 0x00, 0x06, // parameter id - 0x00, 0x02, // length - 0x47, 0xD2, // value - // initial_max_stream_data_uni - 0x00, 0x07, // parameter id - 0x00, 0x02, // length - 0x4B, 0xB8, // value - // initial_max_streams_bidi - 0x00, 0x08, // parameter id - 0x00, 0x01, // length - 0x15, // value - // initial_max_streams_uni - 0x00, 0x09, // parameter id - 0x00, 0x01, // length - 0x16, // value - // ack_delay_exponent - 0x00, 0x0a, // parameter id - 0x00, 0x01, // length - 0x0a, // value - // max_ack_delay - 0x00, 0x0b, // parameter id - 0x00, 0x01, // length - 0x33, // value - // min_ack_delay_us - 0xde, 0x1a, // parameter id - 0x00, 0x02, // length - 0x43, 0xe8, // value - // disable_active_migration - 0x00, 0x0c, // parameter id - 0x00, 0x00, // length - // preferred_address - 0x00, 0x0d, // parameter id - 0x00, 0x31, // length - 0x41, 0x42, 0x43, 0x44, // IPv4 address - 0x48, 0x84, // IPv4 port - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, // IPv6 address - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x63, 0x36, // IPv6 port - 0x08, // connection ID length - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBE, 0xEF, // connection ID - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, // stateless reset token - 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - // active_connection_id_limit - 0x00, 0x0e, // parameter id - 0x00, 0x01, // length - 0x34, // value - // initial_source_connection_id - 0x00, 0x0f, // parameter id - 0x00, 0x08, // length - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x45, - // retry_source_connection_id - 0x00, 0x10, // parameter id - 0x00, 0x08, // length - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x76, - // google_connection_options - 0x31, 0x28, // parameter id - 0x00, 0x0c, // length - 'A', 'L', 'P', 'N', // value - 'E', 'F', 'G', 0x00, - 'H', 'I', 'J', 0xff, - // support_handshake_done - 0x31, 0x2A, // parameter id - 0x00, 0x00, // value - // key_update_not_yet_supported - 0x31, 0x2B, // parameter id - 0x00, 0x00, // value - // Google version extension - 0x47, 0x52, // parameter id - 0x00, 0x0d, // length - 0x01, 0x23, 0x45, 0x67, // negotiated_version - 0x08, // length of supported versions array - 0x01, 0x23, 0x45, 0x67, - 0x89, 0xab, 0xcd, 0xef, - }; const uint8_t kServerParams[] = { // original_destination_connection_id 0x00, // parameter id @@ -1032,9 +770,6 @@ TEST_P(TransportParametersTest, ParseServerParams) { 'A', 'L', 'P', 'N', // value 'E', 'F', 'G', 0x00, 'H', 'I', 'J', 0xff, - // support_handshake_done - 0x71, 0x2A, // parameter id - 0x00, // length // key_update_not_yet_supported 0x71, 0x2B, // parameter id 0x00, // length @@ -1050,10 +785,6 @@ TEST_P(TransportParametersTest, ParseServerParams) { const uint8_t* server_params = reinterpret_cast<const uint8_t*>(kServerParams); size_t server_params_length = ABSL_ARRAYSIZE(kServerParams); - if (!version_.HasVarIntTransportParams()) { - server_params = reinterpret_cast<const uint8_t*>(kServerParamsOld); - server_params_length = ABSL_ARRAYSIZE(kServerParamsOld); - } TransportParameters new_params; std::string error_details; ASSERT_TRUE(ParseTransportParameters(version_, Perspective::IS_SERVER, @@ -1110,32 +841,11 @@ TEST_P(TransportParametersTest, ParseServerParams) { EXPECT_EQ(CreateFakeGoogleConnectionOptions(), new_params.google_connection_options.value()); EXPECT_FALSE(new_params.user_agent_id.has_value()); - EXPECT_TRUE(new_params.support_handshake_done); EXPECT_TRUE(new_params.key_update_not_yet_supported); } TEST_P(TransportParametersTest, ParseServerParametersRepeated) { // clang-format off - const uint8_t kServerParamsRepeatedOld[] = { - 0x00, 0x2c, // length of parameters array that follows - // original_destination_connection_id - 0x00, 0x00, // parameter id - 0x00, 0x08, // length - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x37, - // max_idle_timeout - 0x00, 0x01, // parameter id - 0x00, 0x02, // length - 0x6e, 0xec, // value - // stateless_reset_token - 0x00, 0x02, // parameter id - 0x00, 0x10, // length - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, - // max_idle_timeout (repeated) - 0x00, 0x01, // parameter id - 0x00, 0x02, // length - 0x6e, 0xec, // value - }; const uint8_t kServerParamsRepeated[] = { // original_destination_connection_id 0x00, // parameter id @@ -1159,10 +869,6 @@ TEST_P(TransportParametersTest, ParseServerParametersRepeated) { const uint8_t* server_params = reinterpret_cast<const uint8_t*>(kServerParamsRepeated); size_t server_params_length = ABSL_ARRAYSIZE(kServerParamsRepeated); - if (!version_.HasVarIntTransportParams()) { - server_params = reinterpret_cast<const uint8_t*>(kServerParamsRepeatedOld); - server_params_length = ABSL_ARRAYSIZE(kServerParamsRepeatedOld); - } TransportParameters out_params; std::string error_details; EXPECT_FALSE(ParseTransportParameters(version_, Perspective::IS_SERVER, @@ -1174,21 +880,6 @@ TEST_P(TransportParametersTest, ParseServerParametersRepeated) { TEST_P(TransportParametersTest, ParseServerParametersEmptyOriginalConnectionId) { // clang-format off - const uint8_t kServerParamsEmptyOriginalConnectionIdOld[] = { - 0x00, 0x1e, // length of parameters array that follows - // original_destination_connection_id - 0x00, 0x00, // parameter id - 0x00, 0x00, // length - // max_idle_timeout - 0x00, 0x01, // parameter id - 0x00, 0x02, // length - 0x6e, 0xec, // value - // stateless_reset_token - 0x00, 0x02, // parameter id - 0x00, 0x10, // length - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, - }; const uint8_t kServerParamsEmptyOriginalConnectionId[] = { // original_destination_connection_id 0x00, // parameter id @@ -1208,12 +899,6 @@ TEST_P(TransportParametersTest, reinterpret_cast<const uint8_t*>(kServerParamsEmptyOriginalConnectionId); size_t server_params_length = ABSL_ARRAYSIZE(kServerParamsEmptyOriginalConnectionId); - if (!version_.HasVarIntTransportParams()) { - server_params = reinterpret_cast<const uint8_t*>( - kServerParamsEmptyOriginalConnectionIdOld); - server_params_length = - ABSL_ARRAYSIZE(kServerParamsEmptyOriginalConnectionIdOld); - } TransportParameters out_params; std::string error_details; ASSERT_TRUE(ParseTransportParameters(version_, Perspective::IS_SERVER, @@ -1227,12 +912,7 @@ TEST_P(TransportParametersTest, TEST_P(TransportParametersTest, VeryLongCustomParameter) { // Ensure we can handle a 70KB custom parameter on both send and receive. - size_t custom_value_length = 70000; - if (!version_.HasVarIntTransportParams()) { - // These versions encode lengths as uint16 so they cannot send as much. - custom_value_length = 65000; - } - std::string custom_value(custom_value_length, '?'); + std::string custom_value(70000, '?'); TransportParameters orig_params; orig_params.perspective = Perspective::IS_CLIENT; orig_params.version = kFakeVersionLabel; diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_ack_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_ack_frame.cc index 3fd3dea6120..7c112c2c5e0 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_ack_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_ack_frame.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_ack_frame.h" +#include "quic/core/frames/quic_ack_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_interval.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_interval.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" namespace quic { @@ -20,7 +20,7 @@ const QuicPacketCount kMaxPrintRange = 128; bool IsAwaitingPacket(const QuicAckFrame& ack_frame, QuicPacketNumber packet_number, QuicPacketNumber peer_least_packet_awaiting_ack) { - DCHECK(packet_number.IsInitialized()); + QUICHE_DCHECK(packet_number.IsInitialized()); return (!peer_least_packet_awaiting_ack.IsInitialized() || packet_number >= peer_least_packet_awaiting_ack) && !ack_frame.packets.Contains(packet_number); @@ -118,12 +118,12 @@ bool PacketNumberQueue::Empty() const { } QuicPacketNumber PacketNumberQueue::Min() const { - DCHECK(!Empty()); + QUICHE_DCHECK(!Empty()); return packet_number_intervals_.begin()->min(); } QuicPacketNumber PacketNumberQueue::Max() const { - DCHECK(!Empty()); + QUICHE_DCHECK(!Empty()); return packet_number_intervals_.rbegin()->max() - 1; } @@ -156,7 +156,7 @@ PacketNumberQueue::const_reverse_iterator PacketNumberQueue::rend() const { } QuicPacketCount PacketNumberQueue::LastIntervalLength() const { - DCHECK(!Empty()); + QUICHE_DCHECK(!Empty()); return packet_number_intervals_.rbegin()->Length(); } diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_ack_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_ack_frame.h index e69cbbed9a0..8a5c7e6e12e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_ack_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_ack_frame.h @@ -7,12 +7,12 @@ #include <ostream> -#include "net/third_party/quiche/src/quic/core/quic_interval.h" -#include "net/third_party/quiche/src/quic/core/quic_interval_set.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "quic/core/quic_interval.h" +#include "quic/core/quic_interval_set.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_flags.h" namespace quic { @@ -128,7 +128,8 @@ struct QUIC_EXPORT_PRIVATE QuicAckFrame { // have been observed, return 0. inline QUIC_EXPORT_PRIVATE QuicPacketNumber LargestAcked(const QuicAckFrame& frame) { - DCHECK(frame.packets.Empty() || frame.packets.Max() == frame.largest_acked); + QUICHE_DCHECK(frame.packets.Empty() || + frame.packets.Max() == frame.largest_acked); return frame.largest_acked; } diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.cc index 1486327cb18..4bbfa17e160 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.h" +#include "quic/core/frames/quic_ack_frequency_frame.h" #include <cstdint> #include <limits> diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.h index 3f9397c2f8c..68e08e49113 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.h @@ -8,10 +8,10 @@ #include <cstdint> #include <ostream> -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_blocked_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_blocked_frame.cc index 1da520e03b0..1d46a12790a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_blocked_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_blocked_frame.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_blocked_frame.h" +#include "quic/core/frames/quic_blocked_frame.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_blocked_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_blocked_frame.h index 64f3aeed477..f979fe0d7e5 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_blocked_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_blocked_frame.h @@ -7,8 +7,8 @@ #include <ostream> -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_types.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_connection_close_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_connection_close_frame.cc index e1b9302ceb4..0eee910af5d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_connection_close_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_connection_close_frame.cc @@ -2,18 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_connection_close_frame.h" +#include "quic/core/frames/quic_connection_close_frame.h" #include <memory> -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_types.h" namespace quic { QuicConnectionCloseFrame::QuicConnectionCloseFrame( QuicTransportVersion transport_version, QuicErrorCode error_code, + QuicIetfTransportErrorCodes ietf_error, std::string error_phrase, uint64_t frame_type) : quic_error_code(error_code), error_details(error_phrase) { @@ -25,7 +26,11 @@ QuicConnectionCloseFrame::QuicConnectionCloseFrame( } QuicErrorCodeToIetfMapping mapping = QuicErrorCodeToTransportErrorCode(error_code); - wire_error_code = mapping.error_code; + if (ietf_error != NO_IETF_QUIC_ERROR) { + wire_error_code = ietf_error; + } else { + wire_error_code = mapping.error_code; + } if (mapping.is_transport_close) { // Maps to a transport close close_type = IETF_QUIC_TRANSPORT_CONNECTION_CLOSE; diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_connection_close_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_connection_close_frame.h index de40dadc860..66a90ad7d34 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_connection_close_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_connection_close_frame.h @@ -8,10 +8,10 @@ #include <ostream> #include <string> -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -22,8 +22,12 @@ struct QUIC_EXPORT_PRIVATE QuicConnectionCloseFrame { // and the mapping of error_code. THIS IS THE PREFERRED C'TOR // TO USE IF YOU NEED TO CREATE A CONNECTION-CLOSE-FRAME AND // HAVE IT BE CORRECT FOR THE VERSION AND CODE MAPPINGS. + // |ietf_error| may optionally be be used to directly specify the wire + // error code. Otherwise if |ietf_error| is NO_IETF_QUIC_ERROR, the + // QuicErrorCodeToTransportErrorCode mapping of |error_code| will be used. QuicConnectionCloseFrame(QuicTransportVersion transport_version, QuicErrorCode error_code, + QuicIetfTransportErrorCodes ietf_error, std::string error_phrase, uint64_t transport_close_frame_type); diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_crypto_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_crypto_frame.cc index e804f273521..7b72beb10c9 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_crypto_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_crypto_frame.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_crypto_frame.h" +#include "quic/core/frames/quic_crypto_frame.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_logging.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_crypto_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_crypto_frame.h index a8f0fe3733f..e1e79a6c4cb 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_crypto_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_crypto_frame.h @@ -9,9 +9,9 @@ #include <ostream> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_buffer_allocator.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_frame.cc index 7fe322dffaf..e54e2544c0c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_frame.cc @@ -2,13 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_frame.h" +#include "quic/core/frames/quic_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/frames/quic_new_connection_id_frame.h" +#include "quic/core/frames/quic_retire_connection_id_frame.h" +#include "quic/core/quic_buffer_allocator.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -94,7 +96,7 @@ void DeleteFrame(QuicFrame* frame) { frame->type != STOP_WAITING_FRAME && frame->type != STREAMS_BLOCKED_FRAME && frame->type != STREAM_FRAME && frame->type != HANDSHAKE_DONE_FRAME) { - CHECK(!frame->delete_forbidden) << *frame; + QUICHE_CHECK(!frame->delete_forbidden) << *frame; } #endif // QUIC_FRAME_DEBUG switch (frame->type) { @@ -154,7 +156,7 @@ void DeleteFrame(QuicFrame* frame) { delete frame->ack_frequency_frame; break; case NUM_FRAME_TYPES: - DCHECK(false) << "Cannot delete type: " << frame->type; + QUICHE_DCHECK(false) << "Cannot delete type: " << frame->type; } } @@ -179,8 +181,11 @@ bool IsControlFrame(QuicFrameType type) { case MAX_STREAMS_FRAME: case PING_FRAME: case STOP_SENDING_FRAME: + case NEW_CONNECTION_ID_FRAME: + case RETIRE_CONNECTION_ID_FRAME: case HANDSHAKE_DONE_FRAME: case ACK_FREQUENCY_FRAME: + case NEW_TOKEN_FRAME: return true; default: return false; @@ -205,10 +210,16 @@ QuicControlFrameId GetControlFrameId(const QuicFrame& frame) { return frame.ping_frame.control_frame_id; case STOP_SENDING_FRAME: return frame.stop_sending_frame->control_frame_id; + case NEW_CONNECTION_ID_FRAME: + return frame.new_connection_id_frame->control_frame_id; + case RETIRE_CONNECTION_ID_FRAME: + return frame.retire_connection_id_frame->control_frame_id; case HANDSHAKE_DONE_FRAME: return frame.handshake_done_frame.control_frame_id; case ACK_FREQUENCY_FRAME: return frame.ack_frequency_frame->control_frame_id; + case NEW_TOKEN_FRAME: + return frame.new_token_frame->control_frame_id; default: return kInvalidControlFrameId; } @@ -240,12 +251,21 @@ void SetControlFrameId(QuicControlFrameId control_frame_id, QuicFrame* frame) { case STOP_SENDING_FRAME: frame->stop_sending_frame->control_frame_id = control_frame_id; return; + case NEW_CONNECTION_ID_FRAME: + frame->new_connection_id_frame->control_frame_id = control_frame_id; + return; + case RETIRE_CONNECTION_ID_FRAME: + frame->retire_connection_id_frame->control_frame_id = control_frame_id; + return; case HANDSHAKE_DONE_FRAME: frame->handshake_done_frame.control_frame_id = control_frame_id; return; case ACK_FREQUENCY_FRAME: frame->ack_frequency_frame->control_frame_id = control_frame_id; return; + case NEW_TOKEN_FRAME: + frame->new_token_frame->control_frame_id = control_frame_id; + return; default: QUIC_BUG << "Try to set control frame id of a frame without control frame id"; @@ -273,6 +293,14 @@ QuicFrame CopyRetransmittableControlFrame(const QuicFrame& frame) { case STOP_SENDING_FRAME: copy = QuicFrame(new QuicStopSendingFrame(*frame.stop_sending_frame)); break; + case NEW_CONNECTION_ID_FRAME: + copy = QuicFrame( + new QuicNewConnectionIdFrame(*frame.new_connection_id_frame)); + break; + case RETIRE_CONNECTION_ID_FRAME: + copy = QuicFrame( + new QuicRetireConnectionIdFrame(*frame.retire_connection_id_frame)); + break; case STREAMS_BLOCKED_FRAME: copy = QuicFrame(QuicStreamsBlockedFrame(frame.streams_blocked_frame)); break; @@ -286,6 +314,9 @@ QuicFrame CopyRetransmittableControlFrame(const QuicFrame& frame) { case ACK_FREQUENCY_FRAME: copy = QuicFrame(new QuicAckFrequencyFrame(*frame.ack_frequency_frame)); break; + case NEW_TOKEN_FRAME: + copy = QuicFrame(new QuicNewTokenFrame(*frame.new_token_frame)); + break; default: QUIC_BUG << "Try to copy a non-retransmittable control frame: " << frame; copy = QuicFrame(QuicPingFrame(kInvalidControlFrameId)); diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_frame.h index 505f562b7c8..1efe1e662d7 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_frame.h @@ -9,32 +9,32 @@ #include <type_traits> #include <vector> -#include "net/third_party/quiche/src/quic/core/frames/quic_ack_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_blocked_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_connection_close_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_crypto_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_goaway_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_handshake_done_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_max_streams_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_message_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_mtu_discovery_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_new_connection_id_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_new_token_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_padding_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_path_challenge_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_path_response_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_ping_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_retire_connection_id_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_rst_stream_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_stop_sending_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_stop_waiting_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_stream_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_streams_blocked_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_window_update_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/frames/quic_ack_frame.h" +#include "quic/core/frames/quic_ack_frequency_frame.h" +#include "quic/core/frames/quic_blocked_frame.h" +#include "quic/core/frames/quic_connection_close_frame.h" +#include "quic/core/frames/quic_crypto_frame.h" +#include "quic/core/frames/quic_goaway_frame.h" +#include "quic/core/frames/quic_handshake_done_frame.h" +#include "quic/core/frames/quic_max_streams_frame.h" +#include "quic/core/frames/quic_message_frame.h" +#include "quic/core/frames/quic_mtu_discovery_frame.h" +#include "quic/core/frames/quic_new_connection_id_frame.h" +#include "quic/core/frames/quic_new_token_frame.h" +#include "quic/core/frames/quic_padding_frame.h" +#include "quic/core/frames/quic_path_challenge_frame.h" +#include "quic/core/frames/quic_path_response_frame.h" +#include "quic/core/frames/quic_ping_frame.h" +#include "quic/core/frames/quic_retire_connection_id_frame.h" +#include "quic/core/frames/quic_rst_stream_frame.h" +#include "quic/core/frames/quic_stop_sending_frame.h" +#include "quic/core/frames/quic_stop_waiting_frame.h" +#include "quic/core/frames/quic_stream_frame.h" +#include "quic/core/frames/quic_streams_blocked_frame.h" +#include "quic/core/frames/quic_window_update_frame.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_export.h" #ifndef QUIC_FRAME_DEBUG #if !defined(NDEBUG) || defined(ADDRESS_SANITIZER) diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_frames_test.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_frames_test.cc index 3177b0cc191..d5ca0a4d624 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_frames_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_frames_test.cc @@ -2,23 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_ack_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_blocked_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_connection_close_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_goaway_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_mtu_discovery_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_padding_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_ping_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_rst_stream_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_stop_waiting_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_stream_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_window_update_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_interval.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/frames/quic_ack_frame.h" +#include "quic/core/frames/quic_blocked_frame.h" +#include "quic/core/frames/quic_connection_close_frame.h" +#include "quic/core/frames/quic_frame.h" +#include "quic/core/frames/quic_goaway_frame.h" +#include "quic/core/frames/quic_mtu_discovery_frame.h" +#include "quic/core/frames/quic_new_connection_id_frame.h" +#include "quic/core/frames/quic_padding_frame.h" +#include "quic/core/frames/quic_ping_frame.h" +#include "quic/core/frames/quic_rst_stream_frame.h" +#include "quic/core/frames/quic_stop_waiting_frame.h" +#include "quic/core/frames/quic_stream_frame.h" +#include "quic/core/frames/quic_window_update_frame.h" +#include "quic/core/quic_interval.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { @@ -104,7 +105,40 @@ TEST_F(QuicFramesTest, StopSendingFrameToString) { "{ control_frame_id: 1, stream_id: 321, error_code: 6, ietf_error_code: " "268 }\n", stream.str()); - EXPECT_TRUE(IsControlFrame(frame.type)); +} + +TEST_F(QuicFramesTest, NewConnectionIdFrameToString) { + QuicNewConnectionIdFrame new_connection_id_frame; + QuicFrame frame(&new_connection_id_frame); + SetControlFrameId(1, &frame); + QuicFrame frame_copy = CopyRetransmittableControlFrame(frame); + EXPECT_EQ(1u, GetControlFrameId(frame_copy)); + new_connection_id_frame.connection_id = TestConnectionId(2); + new_connection_id_frame.sequence_number = 2u; + new_connection_id_frame.retire_prior_to = 1u; + new_connection_id_frame.stateless_reset_token = MakeQuicUint128(0, 1); + std::ostringstream stream; + stream << new_connection_id_frame; + EXPECT_EQ( + "{ control_frame_id: 1, connection_id: 0000000000000002, " + "sequence_number: 2, retire_prior_to: 1 }\n", + stream.str()); + EXPECT_TRUE(IsControlFrame(frame_copy.type)); + DeleteFrame(&frame_copy); +} + +TEST_F(QuicFramesTest, RetireConnectionIdFrameToString) { + QuicRetireConnectionIdFrame retire_connection_id_frame; + QuicFrame frame(&retire_connection_id_frame); + SetControlFrameId(1, &frame); + QuicFrame frame_copy = CopyRetransmittableControlFrame(frame); + EXPECT_EQ(1u, GetControlFrameId(frame_copy)); + retire_connection_id_frame.sequence_number = 1u; + std::ostringstream stream; + stream << retire_connection_id_frame; + EXPECT_EQ("{ control_frame_id: 1, sequence_number: 1 }\n", stream.str()); + EXPECT_TRUE(IsControlFrame(frame_copy.type)); + DeleteFrame(&frame_copy); } TEST_F(QuicFramesTest, StreamsBlockedFrameToString) { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_goaway_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_goaway_frame.cc index 4c8848d1738..c73e6cb7bfb 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_goaway_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_goaway_frame.cc @@ -4,7 +4,7 @@ #include <string> -#include "net/third_party/quiche/src/quic/core/frames/quic_goaway_frame.h" +#include "quic/core/frames/quic_goaway_frame.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_goaway_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_goaway_frame.h index b642cfa0372..436c7a3b774 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_goaway_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_goaway_frame.h @@ -8,9 +8,9 @@ #include <ostream> #include <string> -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_types.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_handshake_done_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_handshake_done_frame.cc index f4a97c1d2e6..9501ff889b1 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_handshake_done_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_handshake_done_frame.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_handshake_done_frame.h" +#include "quic/core/frames/quic_handshake_done_frame.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_handshake_done_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_handshake_done_frame.h index 1dd3fa03a62..69fc68cbd42 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_handshake_done_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_handshake_done_frame.h @@ -5,10 +5,10 @@ #ifndef QUICHE_QUIC_CORE_FRAMES_QUIC_HANDSHAKE_DONE_FRAME_H_ #define QUICHE_QUIC_CORE_FRAMES_QUIC_HANDSHAKE_DONE_FRAME_H_ -#include "net/third_party/quiche/src/quic/core/frames/quic_inlined_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/frames/quic_inlined_frame.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_inlined_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_inlined_frame.h index cfa32dc0ecd..1ef15321209 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_inlined_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_inlined_frame.h @@ -7,8 +7,8 @@ #include <type_traits> -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_max_streams_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_max_streams_frame.cc index 1726080e2e1..b2574e8db12 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_max_streams_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_max_streams_frame.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_max_streams_frame.h" +#include "quic/core/frames/quic_max_streams_frame.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_max_streams_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_max_streams_frame.h index 902dbc2c971..8b0231ef0df 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_max_streams_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_max_streams_frame.h @@ -7,10 +7,10 @@ #include <ostream> -#include "net/third_party/quiche/src/quic/core/frames/quic_inlined_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/frames/quic_inlined_frame.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_message_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_message_frame.cc index 45748ad0180..054303ac1ee 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_message_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_message_frame.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_message_frame.h" +#include "quic/core/frames/quic_message_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_mem_slice.h" +#include "quic/core/quic_constants.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_mem_slice.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_message_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_message_frame.h index 68fbf2201ad..ef1e070deb5 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_message_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_message_frame.h @@ -5,11 +5,11 @@ #ifndef QUICHE_QUIC_CORE_FRAMES_QUIC_MESSAGE_FRAME_H_ #define QUICHE_QUIC_CORE_FRAMES_QUIC_MESSAGE_FRAME_H_ -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_mem_slice.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_mem_slice_span.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_mem_slice.h" +#include "quic/platform/api/quic_mem_slice_span.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_mtu_discovery_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_mtu_discovery_frame.h index 52e980d3438..014af3a07b4 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_mtu_discovery_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_mtu_discovery_frame.h @@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_CORE_FRAMES_QUIC_MTU_DISCOVERY_FRAME_H_ #define QUICHE_QUIC_CORE_FRAMES_QUIC_MTU_DISCOVERY_FRAME_H_ -#include "net/third_party/quiche/src/quic/core/frames/quic_inlined_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/frames/quic_inlined_frame.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_new_connection_id_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_new_connection_id_frame.cc index d2e8cea2ad2..fa99dfe7b6b 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_new_connection_id_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_new_connection_id_frame.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_new_connection_id_frame.h" +#include "quic/core/frames/quic_new_connection_id_frame.h" namespace quic { @@ -17,7 +17,7 @@ QuicNewConnectionIdFrame::QuicNewConnectionIdFrame( sequence_number(sequence_number), stateless_reset_token(stateless_reset_token), retire_prior_to(retire_prior_to) { - DCHECK(retire_prior_to <= sequence_number); + QUICHE_DCHECK(retire_prior_to <= sequence_number); } std::ostream& operator<<(std::ostream& os, diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_new_connection_id_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_new_connection_id_frame.h index 7bd45865f47..4cf0258ca10 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_new_connection_id_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_new_connection_id_frame.h @@ -7,11 +7,11 @@ #include <ostream> -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_uint128.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_new_token_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_new_token_frame.cc index 6806cda221f..8ad442fc694 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_new_token_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_new_token_frame.cc @@ -2,17 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_new_token_frame.h" +#include "quic/core/frames/quic_new_token_frame.h" #include "absl/strings/escaping.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/platform/api/quic_logging.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { QuicNewTokenFrame::QuicNewTokenFrame(QuicControlFrameId control_frame_id, - std::string token) - : control_frame_id(control_frame_id), token(token) {} + absl::string_view token) + : control_frame_id(control_frame_id), + token(std::string(token.data(), token.length())) {} std::ostream& operator<<(std::ostream& os, const QuicNewTokenFrame& s) { os << "{ control_frame_id: " << s.control_frame_id diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_new_token_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_new_token_frame.h index abb0eecb2fb..805216bf919 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_new_token_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_new_token_frame.h @@ -8,16 +8,18 @@ #include <memory> #include <ostream> -#include "net/third_party/quiche/src/quic/core/quic_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "absl/strings/string_view.h" +#include "quic/core/quic_buffer_allocator.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { struct QUIC_EXPORT_PRIVATE QuicNewTokenFrame { QuicNewTokenFrame() = default; - QuicNewTokenFrame(QuicControlFrameId control_frame_id, std::string token); + QuicNewTokenFrame(QuicControlFrameId control_frame_id, + absl::string_view token); friend QUIC_EXPORT_PRIVATE std::ostream& operator<<( std::ostream& os, diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_padding_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_padding_frame.cc index 098a6647dec..5679a2bf55a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_padding_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_padding_frame.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_padding_frame.h" +#include "quic/core/frames/quic_padding_frame.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_padding_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_padding_frame.h index 09ddb89dd2e..146721e6228 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_padding_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_padding_frame.h @@ -8,9 +8,9 @@ #include <cstdint> #include <ostream> -#include "net/third_party/quiche/src/quic/core/frames/quic_inlined_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/frames/quic_inlined_frame.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_path_challenge_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_path_challenge_frame.cc index eb841b26ddc..857ca19291f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_path_challenge_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_path_challenge_frame.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_path_challenge_frame.h" +#include "quic/core/frames/quic_path_challenge_frame.h" #include "absl/strings/escaping.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_path_challenge_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_path_challenge_frame.h index e173117b581..7c27a4258b3 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_path_challenge_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_path_challenge_frame.h @@ -8,8 +8,8 @@ #include <memory> #include <ostream> -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_types.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_path_response_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_path_response_frame.cc index 1623777b0e6..ade4156b8ab 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_path_response_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_path_response_frame.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_path_response_frame.h" +#include "quic/core/frames/quic_path_response_frame.h" #include "absl/strings/escaping.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_path_response_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_path_response_frame.h index cdb0ba89e7c..6b43bda16ae 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_path_response_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_path_response_frame.h @@ -8,8 +8,8 @@ #include <memory> #include <ostream> -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_types.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_ping_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_ping_frame.cc index 064d9170303..d4e6daa7114 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_ping_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_ping_frame.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_ping_frame.h" +#include "quic/core/frames/quic_ping_frame.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_ping_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_ping_frame.h index 04f5afb9195..012d73d29ec 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_ping_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_ping_frame.h @@ -5,10 +5,10 @@ #ifndef QUICHE_QUIC_CORE_FRAMES_QUIC_PING_FRAME_H_ #define QUICHE_QUIC_CORE_FRAMES_QUIC_PING_FRAME_H_ -#include "net/third_party/quiche/src/quic/core/frames/quic_inlined_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/frames/quic_inlined_frame.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_retire_connection_id_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_retire_connection_id_frame.cc index 0da9e0cfc02..c3009f0ea80 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_retire_connection_id_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_retire_connection_id_frame.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_retire_connection_id_frame.h" +#include "quic/core/frames/quic_retire_connection_id_frame.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_retire_connection_id_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_retire_connection_id_frame.h index 4451d319546..c6fc4117d18 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_retire_connection_id_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_retire_connection_id_frame.h @@ -7,10 +7,10 @@ #include <ostream> -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_uint128.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_rst_stream_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_rst_stream_frame.cc index 41a1fd391fe..646425a674c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_rst_stream_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_rst_stream_frame.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_rst_stream_frame.h" +#include "quic/core/frames/quic_rst_stream_frame.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_rst_stream_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_rst_stream_frame.h index 691a868cbee..9c9e42e4d38 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_rst_stream_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_rst_stream_frame.h @@ -7,9 +7,9 @@ #include <ostream> -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_types.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_stop_sending_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_stop_sending_frame.cc index 20281e522b1..ad02337b5ef 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_stop_sending_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_stop_sending_frame.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_stop_sending_frame.h" +#include "quic/core/frames/quic_stop_sending_frame.h" namespace quic { @@ -13,13 +13,7 @@ QuicStopSendingFrame::QuicStopSendingFrame(QuicControlFrameId control_frame_id, stream_id(stream_id), error_code(error_code), ietf_error_code( - GetQuicReloadableFlag(quic_stop_sending_uses_ietf_error_code) - ? RstStreamErrorCodeToIetfResetStreamErrorCode(error_code) - : static_cast<uint64_t>(error_code)) { - if (GetQuicReloadableFlag(quic_stop_sending_uses_ietf_error_code)) { - QUIC_RELOADABLE_FLAG_COUNT_N(quic_stop_sending_uses_ietf_error_code, 1, 2); - } -} + RstStreamErrorCodeToIetfResetStreamErrorCode(error_code)) {} std::ostream& operator<<(std::ostream& os, const QuicStopSendingFrame& frame) { os << "{ control_frame_id: " << frame.control_frame_id diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_stop_sending_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_stop_sending_frame.h index 57114d77c56..60158b221d8 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_stop_sending_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_stop_sending_frame.h @@ -7,9 +7,9 @@ #include <ostream> -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_types.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_stop_waiting_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_stop_waiting_frame.cc index 02e0a62eac9..c5ce9389dc3 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_stop_waiting_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_stop_waiting_frame.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_stop_waiting_frame.h" +#include "quic/core/frames/quic_stop_waiting_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" +#include "quic/core/quic_constants.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_stop_waiting_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_stop_waiting_frame.h index b05d2e12eab..fda5c614dc2 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_stop_waiting_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_stop_waiting_frame.h @@ -7,9 +7,9 @@ #include <ostream> -#include "net/third_party/quiche/src/quic/core/frames/quic_inlined_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/frames/quic_inlined_frame.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_stream_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_stream_frame.cc index 728d320e3ac..c383c8f168e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_stream_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_stream_frame.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_stream_frame.h" +#include "quic/core/frames/quic_stream_frame.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_logging.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_stream_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_stream_frame.h index 32b2c7404bf..9ba8ccc1606 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_stream_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_stream_frame.h @@ -9,10 +9,10 @@ #include <ostream> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_inlined_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/frames/quic_inlined_frame.h" +#include "quic/core/quic_buffer_allocator.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_streams_blocked_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_streams_blocked_frame.cc index 9300ce32e51..4ec8caa5def 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_streams_blocked_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_streams_blocked_frame.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_streams_blocked_frame.h" +#include "quic/core/frames/quic_streams_blocked_frame.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_streams_blocked_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_streams_blocked_frame.h index 2df9636bc32..94676fb00da 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_streams_blocked_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_streams_blocked_frame.h @@ -7,10 +7,10 @@ #include <ostream> -#include "net/third_party/quiche/src/quic/core/frames/quic_inlined_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/frames/quic_inlined_frame.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_window_update_frame.cc b/chromium/net/third_party/quiche/src/quic/core/frames/quic_window_update_frame.cc index a4f3ec32c01..4f21b5711ab 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_window_update_frame.cc +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_window_update_frame.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/frames/quic_window_update_frame.h" +#include "quic/core/frames/quic_window_update_frame.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/frames/quic_window_update_frame.h b/chromium/net/third_party/quiche/src/quic/core/frames/quic_window_update_frame.h index 74181f5f1d2..e4f2a86eac7 100644 --- a/chromium/net/third_party/quiche/src/quic/core/frames/quic_window_update_frame.h +++ b/chromium/net/third_party/quiche/src/quic/core/frames/quic_window_update_frame.h @@ -7,8 +7,8 @@ #include <ostream> -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_types.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/handshaker_delegate_interface.h b/chromium/net/third_party/quiche/src/quic/core/handshaker_delegate_interface.h index a8e5e968ab3..ae291b7826f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/handshaker_delegate_interface.h +++ b/chromium/net/third_party/quiche/src/quic/core/handshaker_delegate_interface.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_CORE_HANDSHAKER_DELEGATE_INTERFACE_H_ #define QUICHE_QUIC_CORE_HANDSHAKER_DELEGATE_INTERFACE_H_ -#include "net/third_party/quiche/src/quic/core/crypto/transport_parameters.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/crypto/transport_parameters.h" +#include "quic/core/quic_types.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/http/end_to_end_test.cc b/chromium/net/third_party/quiche/src/quic/core/http/end_to_end_test.cc index 6b188fcf38d..2000733ba9a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/end_to_end_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/end_to_end_test.cc @@ -11,62 +11,62 @@ #include <utility> #include <vector> +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/http/http_constants.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_creator.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_epoll.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_error_code_wrappers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#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_port_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_sleep.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/platform/api/quic_test_loopback.h" -#include "net/third_party/quiche/src/quic/test_tools/bad_packet_writer.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/packet_dropping_test_writer.h" -#include "net/third_party/quiche/src/quic/test_tools/packet_reordering_writer.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_header_table_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_client_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_dispatcher_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_flow_controller_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_server_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_id_manager_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_client.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_server.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/server_thread.h" -#include "net/third_party/quiche/src/quic/test_tools/simple_session_cache.h" -#include "net/third_party/quiche/src/quic/tools/quic_backend_response.h" -#include "net/third_party/quiche/src/quic/tools/quic_client.h" -#include "net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h" -#include "net/third_party/quiche/src/quic/tools/quic_server.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_client_stream.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_stream.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/http/http_constants.h" +#include "quic/core/http/quic_spdy_client_stream.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_epoll_connection_helper.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_packet_creator.h" +#include "quic/core/quic_packet_writer_wrapper.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_epoll.h" +#include "quic/platform/api/quic_error_code_wrappers.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_port_utils.h" +#include "quic/platform/api/quic_sleep.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test_loopback.h" +#include "quic/test_tools/bad_packet_writer.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/packet_dropping_test_writer.h" +#include "quic/test_tools/packet_reordering_writer.h" +#include "quic/test_tools/qpack/qpack_encoder_peer.h" +#include "quic/test_tools/qpack/qpack_encoder_test_utils.h" +#include "quic/test_tools/qpack/qpack_header_table_peer.h" +#include "quic/test_tools/qpack/qpack_test_utils.h" +#include "quic/test_tools/quic_client_peer.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_dispatcher_peer.h" +#include "quic/test_tools/quic_flow_controller_peer.h" +#include "quic/test_tools/quic_sent_packet_manager_peer.h" +#include "quic/test_tools/quic_server_peer.h" +#include "quic/test_tools/quic_session_peer.h" +#include "quic/test_tools/quic_spdy_session_peer.h" +#include "quic/test_tools/quic_stream_id_manager_peer.h" +#include "quic/test_tools/quic_stream_peer.h" +#include "quic/test_tools/quic_stream_sequencer_peer.h" +#include "quic/test_tools/quic_test_client.h" +#include "quic/test_tools/quic_test_server.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/server_thread.h" +#include "quic/test_tools/simple_session_cache.h" +#include "quic/tools/quic_backend_response.h" +#include "quic/tools/quic_client.h" +#include "quic/tools/quic_memory_cache_backend.h" +#include "quic/tools/quic_server.h" +#include "quic/tools/quic_simple_client_stream.h" +#include "quic/tools/quic_simple_server_stream.h" +#include "common/platform/api/quiche_text_utils.h" using spdy::kV3LowestPriority; using spdy::SpdyFramer; @@ -104,9 +104,8 @@ struct TestParams { // Used by ::testing::PrintToStringParamName(). std::string PrintToString(const TestParams& p) { - std::string rv = - quiche::QuicheStrCat(ParsedQuicVersionToString(p.version), "_", - QuicTagToString(p.congestion_control_tag)); + std::string rv = absl::StrCat(ParsedQuicVersionToString(p.version), "_", + QuicTagToString(p.congestion_control_tag)); std::replace(rv.begin(), rv.end(), ',', '_'); std::replace(rv.begin(), rv.end(), ' ', '_'); return rv; @@ -200,7 +199,6 @@ class EndToEndTest : public QuicTestWithParam<TestParams> { AddToCache("/bar", 200, kBarResponseBody); // Enable fixes for bugs found in tests and prod. SetQuicRestartFlag(quic_enable_zero_rtt_for_tls_v2, true); - SetQuicReloadableFlag(quic_fix_out_of_order_sending2, true); } ~EndToEndTest() override { QuicRecyclePort(server_address_.port()); } @@ -349,13 +347,13 @@ class EndToEndTest : public QuicTestWithParam<TestParams> { ADD_FAILURE() << "Missing dispatcher"; return nullptr; } - if (dispatcher->session_map().empty()) { + if (dispatcher->NumSessions() == 0) { ADD_FAILURE() << "Empty dispatcher session map"; return nullptr; } - EXPECT_EQ(1u, dispatcher->session_map().size()); + EXPECT_EQ(1u, dispatcher->NumSessions()); return static_cast<QuicSpdySession*>( - dispatcher->session_map().begin()->second.get()); + QuicDispatcherPeer::GetFirstSessionIfAny(dispatcher)); } bool Initialize() { @@ -1442,6 +1440,56 @@ TEST_P(EndToEndTest, LargePostNoPacketLossWithDelayAndReordering) { client_->SendCustomSynchronousRequest(headers, body)); } +TEST_P(EndToEndTest, AddressToken) { + ASSERT_TRUE(Initialize()); + if (!version_.HasIetfQuicFrames()) { + return; + } + + SendSynchronousFooRequestAndCheckResponse(); + QuicSpdyClientSession* client_session = GetClientSession(); + ASSERT_TRUE(client_session); + EXPECT_FALSE(client_session->EarlyDataAccepted()); + EXPECT_FALSE(client_session->ReceivedInchoateReject()); + EXPECT_FALSE(client_->client()->EarlyDataAccepted()); + EXPECT_FALSE(client_->client()->ReceivedInchoateReject()); + + client_->Disconnect(); + + // The 0-RTT handshake should succeed. + client_->Connect(); + EXPECT_TRUE(client_->client()->WaitForOneRttKeysAvailable()); + ASSERT_TRUE(client_->client()->connected()); + SendSynchronousFooRequestAndCheckResponse(); + + client_session = GetClientSession(); + ASSERT_TRUE(client_session); + EXPECT_TRUE(client_session->EarlyDataAccepted()); + EXPECT_TRUE(client_->client()->EarlyDataAccepted()); + + server_thread_->Pause(); + QuicConnection* server_connection = GetServerConnection(); + if (server_connection != nullptr) { + if (GetQuicReloadableFlag(quic_enable_token_based_address_validation)) { + // Verify address is validated via validating token received in INITIAL + // packet. + EXPECT_FALSE(server_connection->GetStats() + .address_validated_via_decrypting_packet); + EXPECT_TRUE(server_connection->GetStats().address_validated_via_token); + } else { + EXPECT_TRUE(server_connection->GetStats() + .address_validated_via_decrypting_packet); + EXPECT_FALSE(server_connection->GetStats().address_validated_via_token); + } + } else { + ADD_FAILURE() << "Missing server connection"; + } + + server_thread_->Resume(); + + client_->Disconnect(); +} + TEST_P(EndToEndTest, LargePostZeroRTTFailure) { // Send a request and then disconnect. This prepares the client to attempt // a 0-RTT handshake for the next request. @@ -1499,9 +1547,7 @@ TEST_P(EndToEndTest, LargePostZeroRTTFailure) { } // Regression test for b/168020146. -// TODO(renjietang): Reenable this test in Chrome once the BoringSSL fix is -// rolled in. -TEST_P(EndToEndTest, QUIC_TEST_DISABLED_IN_CHROME(MultipleZeroRtt)) { +TEST_P(EndToEndTest, MultipleZeroRtt) { ASSERT_TRUE(Initialize()); EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); @@ -2389,7 +2435,7 @@ TEST_P(EndToEndTest, StreamCancelErrorTest) { const QuicPacketCount packets_sent_now = client_connection->GetStats().packets_sent; - if (version_.UsesHttp3() && GetQuicReloadableFlag(quic_split_up_send_rst_2)) { + if (version_.UsesHttp3()) { // Make sure 2 packets were sent, one for QPACK instructions, another for // RESET_STREAM and STOP_SENDING. EXPECT_EQ(packets_sent_before + 2, packets_sent_now); @@ -2420,6 +2466,195 @@ TEST_P(EndToEndTest, ConnectionMigrationClientIPChanged) { // Send a request using the new socket. SendSynchronousBarRequestAndCheckResponse(); + + if (!version_.HasIetfQuicFrames() || + !client_->client()->session()->connection()->validate_client_address()) { + return; + } + QuicConnection* client_connection = GetClientConnection(); + ASSERT_TRUE(client_connection); + EXPECT_EQ(1u, + client_connection->GetStats().num_connectivity_probing_received); + + // Send another request. + SendSynchronousBarRequestAndCheckResponse(); + // By the time the 2nd request is completed, the PATH_RESPONSE must have been + // received by the server. + server_thread_->Pause(); + QuicConnection* server_connection = GetServerConnection(); + if (server_connection != nullptr) { + EXPECT_FALSE(server_connection->HasPendingPathValidation()); + EXPECT_EQ(1u, server_connection->GetStats().num_validated_peer_migration); + } else { + ADD_FAILURE() << "Missing server connection"; + } + server_thread_->Resume(); +} + +TEST_P(EndToEndTest, ConnectionMigrationNewTokenForNewIp) { + ASSERT_TRUE(Initialize()); + if (!version_.HasIetfQuicFrames() || + !client_->client()->session()->connection()->validate_client_address()) { + return; + } + SendSynchronousFooRequestAndCheckResponse(); + + // Store the client IP address which was used to send the first request. + QuicIpAddress old_host = + client_->client()->network_helper()->GetLatestClientAddress().host(); + + // Migrate socket to the new IP address. + QuicIpAddress new_host = TestLoopback(2); + EXPECT_NE(old_host, new_host); + ASSERT_TRUE(client_->client()->MigrateSocket(new_host)); + + // Send a request using the new socket. + SendSynchronousBarRequestAndCheckResponse(); + QuicConnection* client_connection = GetClientConnection(); + ASSERT_TRUE(client_connection); + EXPECT_EQ(1u, + client_connection->GetStats().num_connectivity_probing_received); + + // Send another request to ensure that the server will time to finish the + // reverse path validation and send address token. + SendSynchronousBarRequestAndCheckResponse(); + + client_->Disconnect(); + // The 0-RTT handshake should succeed. + client_->Connect(); + EXPECT_TRUE(client_->client()->WaitForOneRttKeysAvailable()); + ASSERT_TRUE(client_->client()->connected()); + SendSynchronousFooRequestAndCheckResponse(); + + EXPECT_TRUE(GetClientSession()->EarlyDataAccepted()); + EXPECT_TRUE(client_->client()->EarlyDataAccepted()); + + server_thread_->Pause(); + QuicConnection* server_connection = GetServerConnection(); + if (server_connection != nullptr) { + if (GetQuicReloadableFlag(quic_enable_token_based_address_validation)) { + // Verify address is validated via validating token received in INITIAL + // packet. + EXPECT_FALSE(server_connection->GetStats() + .address_validated_via_decrypting_packet); + EXPECT_TRUE(server_connection->GetStats().address_validated_via_token); + } else { + EXPECT_TRUE(server_connection->GetStats() + .address_validated_via_decrypting_packet); + EXPECT_FALSE(server_connection->GetStats().address_validated_via_token); + } + } else { + ADD_FAILURE() << "Missing server connection"; + } + server_thread_->Resume(); + client_->Disconnect(); +} + +// A writer which copies the packet and send the copy with a specified self +// address and then send the same packet with the original self address. +class DuplicatePacketWithSpoofedSelfAddressWriter + : public QuicPacketWriterWrapper { + public: + WriteResult WritePacket(const char* buffer, + size_t buf_len, + const QuicIpAddress& self_address, + const QuicSocketAddress& peer_address, + PerPacketOptions* options) override { + if (self_address_to_overwrite_.IsInitialized()) { + // Send the same packet on the overwriting address before sending on the + // actual self address. + QuicPacketWriterWrapper::WritePacket( + buffer, buf_len, self_address_to_overwrite_, peer_address, options); + } + return QuicPacketWriterWrapper::WritePacket(buffer, buf_len, self_address, + peer_address, options); + } + + void set_self_address_to_overwrite(const QuicIpAddress& self_address) { + self_address_to_overwrite_ = self_address; + } + + private: + QuicIpAddress self_address_to_overwrite_; +}; + +TEST_P(EndToEndTest, ClientAddressSpoofedForSomePeriod) { + ASSERT_TRUE(Initialize()); + if (!version_.HasIetfQuicFrames() || + !client_->client()->session()->connection()->validate_client_address()) { + return; + } + auto writer = new DuplicatePacketWithSpoofedSelfAddressWriter(); + client_.reset(CreateQuicClient(writer)); + QuicIpAddress real_host = TestLoopback(1); + client_->MigrateSocket(real_host); + SendSynchronousFooRequestAndCheckResponse(); + EXPECT_EQ( + 0u, GetClientConnection()->GetStats().num_connectivity_probing_received); + EXPECT_EQ( + real_host, + client_->client()->network_helper()->GetLatestClientAddress().host()); + client_->WaitForDelayedAcks(); + + std::string large_body(10240, 'a'); + AddToCache("/large_response", 200, large_body); + + QuicIpAddress spoofed_host = TestLoopback(2); + writer->set_self_address_to_overwrite(spoofed_host); + + client_->SendRequest("/large_response"); + QuicConnection* client_connection = GetClientConnection(); + QuicPacketCount num_packets_received = + client_connection->GetStats().packets_received; + + while (client_->client()->WaitForEvents() && client_->connected()) { + if (client_connection->GetStats().packets_received > num_packets_received) { + // Ideally the client won't receive any packets till the server finds out + // the new client address is not working. But there are 2 corner cases: + // 1) Before the server received the packet from spoofed address, it might + // send packets to the real client address. So the client will immediately + // switch back to use the original address; + // 2) Between the server fails reverse path validation and the client + // receives packets again, the client might sent some packets with the + // spoofed address and triggers another migration. + // In both corner cases, the attempted migration should fail and fall back + // to the working path. + writer->set_self_address_to_overwrite(QuicIpAddress()); + } + } + client_->WaitForResponse(); + EXPECT_EQ(large_body, client_->response_body()); +} + +TEST_P(EndToEndTest, AsynchronousConnectionMigrationClientIPChanged) { + ASSERT_TRUE(Initialize()); + if (!version_.HasIetfQuicFrames() || + !client_->client()->session()->connection()->use_path_validator()) { + return; + } + client_.reset(CreateQuicClient(nullptr)); + + SendSynchronousFooRequestAndCheckResponse(); + + // Store the client IP address which was used to send the first request. + QuicIpAddress old_host = + client_->client()->network_helper()->GetLatestClientAddress().host(); + + // Migrate socket to the new IP address. + QuicIpAddress new_host = TestLoopback(2); + EXPECT_NE(old_host, new_host); + ASSERT_TRUE(client_->client()->ValidateAndMigrateSocket(new_host)); + + while (client_->client()->HasPendingPathValidation()) { + client_->client()->WaitForEvents(); + } + EXPECT_EQ(new_host, client_->client()->session()->self_address().host()); + QuicConnection* client_connection = GetClientConnection(); + ASSERT_TRUE(client_connection); + EXPECT_EQ(client_connection->validate_client_address() ? 1u : 0, + client_connection->GetStats().num_connectivity_probing_received); + // Send a request using the new socket. + SendSynchronousBarRequestAndCheckResponse(); } TEST_P(EndToEndTest, ConnectionMigrationClientPortChanged) { @@ -2473,6 +2708,21 @@ TEST_P(EndToEndTest, ConnectionMigrationClientPortChanged) { client_->client()->network_helper()->GetLatestClientAddress(); EXPECT_EQ(old_address.host(), new_address.host()); EXPECT_NE(old_address.port(), new_address.port()); + + if (!version_.HasIetfQuicFrames() || + !GetClientConnection()->validate_client_address()) { + return; + } + + server_thread_->Pause(); + QuicConnection* server_connection = GetServerConnection(); + if (server_connection != nullptr) { + EXPECT_FALSE(server_connection->HasPendingPathValidation()); + EXPECT_EQ(1u, server_connection->GetStats().num_validated_peer_migration); + } else { + ADD_FAILURE() << "Missing server connection"; + } + server_thread_->Resume(); } TEST_P(EndToEndTest, NegotiatedInitialCongestionWindow) { @@ -2979,9 +3229,9 @@ TEST_P(EndToEndTest, ServerSendPublicReset) { // We must pause the server's thread in order to call WritePacket without // race conditions. server_thread_->Pause(); - server_writer_->WritePacket( - packet->data(), packet->length(), server_address_.host(), - client_->client()->network_helper()->GetLatestClientAddress(), nullptr); + auto client_address = client_connection->self_address(); + server_writer_->WritePacket(packet->data(), packet->length(), + server_address_.host(), client_address, nullptr); server_thread_->Resume(); // The request should fail. @@ -3027,9 +3277,9 @@ TEST_P(EndToEndTest, ServerSendPublicResetWithDifferentConnectionId) { // We must pause the server's thread in order to call WritePacket without // race conditions. server_thread_->Pause(); - server_writer_->WritePacket( - packet->data(), packet->length(), server_address_.host(), - client_->client()->network_helper()->GetLatestClientAddress(), nullptr); + auto client_address = client_connection->self_address(); + server_writer_->WritePacket(packet->data(), packet->length(), + server_address_.host(), client_address, nullptr); server_thread_->Resume(); if (version_.HasIetfInvariantHeader()) { @@ -3460,11 +3710,9 @@ TEST_P(EndToEndTest, EarlyResponseFinRecording) { QuicDispatcher* dispatcher = QuicServerPeer::GetDispatcher(server_thread_->server()); - QuicDispatcher::SessionMap const& map = - QuicDispatcherPeer::session_map(dispatcher); - auto it = map.begin(); - EXPECT_TRUE(it != map.end()); - QuicSession* server_session = it->second.get(); + QuicSession* server_session = + QuicDispatcherPeer::GetFirstSessionIfAny(dispatcher); + EXPECT_TRUE(server_session != nullptr); // The stream is not waiting for the arrival of the peer's final offset. EXPECT_EQ( @@ -3540,8 +3788,7 @@ class EndToEndTestServerPush : public EndToEndTest { std::string body = use_large_response ? large_resource - : quiche::QuicheStrCat("This is server push response body for ", - url); + : absl::StrCat("This is server push response body for ", url); SpdyHeaderBlock response_headers; response_headers[":status"] = "200"; response_headers["content-length"] = @@ -3604,7 +3851,7 @@ TEST_P(EndToEndTestServerPush, ServerPush) { for (const std::string& url : push_urls) { QUIC_DVLOG(1) << "send request for pushed stream on url " << url; std::string expected_body = - quiche::QuicheStrCat("This is server push response body for ", url); + absl::StrCat("This is server push response body for ", url); std::string response_body = client_->SendSynchronousRequest(url); QUIC_DVLOG(1) << "response body " << response_body; EXPECT_EQ(expected_body, response_body); @@ -3658,7 +3905,7 @@ TEST_P(EndToEndTestServerPush, ServerPushUnderLimit) { // as the responses are already in the client's cache. QUIC_DVLOG(1) << "send request for pushed stream on url " << url; std::string expected_body = - quiche::QuicheStrCat("This is server push response body for ", url); + absl::StrCat("This is server push response body for ", url); std::string response_body = client_->SendSynchronousRequest(url); QUIC_DVLOG(1) << "response body " << response_body; EXPECT_EQ(expected_body, response_body); @@ -3698,8 +3945,7 @@ TEST_P(EndToEndTestServerPush, ServerPushOverLimitNonBlocking) { const size_t kNumResources = 1 + kNumMaxStreams; // 11. std::string push_urls[11]; for (size_t i = 0; i < kNumResources; ++i) { - push_urls[i] = - quiche::QuicheStrCat("https://example.com/push_resources", i); + push_urls[i] = absl::StrCat("https://example.com/push_resources", i); } AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody, push_urls, kNumResources, 0); @@ -3716,9 +3962,8 @@ TEST_P(EndToEndTestServerPush, ServerPushOverLimitNonBlocking) { for (const std::string& url : push_urls) { // Sending subsequent requesets will not actually send anything on the wire, // as the responses are already in the client's cache. - EXPECT_EQ( - quiche::QuicheStrCat("This is server push response body for ", url), - client_->SendSynchronousRequest(url)); + EXPECT_EQ(absl::StrCat("This is server push response body for ", url), + client_->SendSynchronousRequest(url)); } // Only 1 request should have been sent. @@ -3761,7 +4006,7 @@ TEST_P(EndToEndTestServerPush, ServerPushOverLimitWithBlocking) { const size_t kNumResources = kNumMaxStreams + 1; std::string push_urls[11]; for (size_t i = 0; i < kNumResources; ++i) { - push_urls[i] = quiche::QuicheStrCat("http://example.com/push_resources", i); + push_urls[i] = absl::StrCat("http://example.com/push_resources", i); } AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody, push_urls, kNumResources, kBodySize); @@ -4060,7 +4305,7 @@ TEST_P(EndToEndTest, server_thread_->Resume(); return; } - if (!dispatcher->session_map().empty()) { + if (dispatcher->NumSessions() > 0) { ADD_FAILURE() << "Dispatcher session map not empty"; server_thread_->Resume(); return; @@ -4101,7 +4346,7 @@ TEST_P(EndToEndTest, server_thread_->Resume(); return; } - if (!dispatcher->session_map().empty()) { + if (dispatcher->NumSessions() > 0) { ADD_FAILURE() << "Dispatcher session map not empty"; server_thread_->Resume(); return; @@ -4397,8 +4642,6 @@ INSTANTIATE_TEST_SUITE_P(EndToEndPacketReorderingTests, TEST_P(EndToEndPacketReorderingTest, ReorderedConnectivityProbing) { ASSERT_TRUE(Initialize()); if (version_.HasIetfQuicFrames()) { - // TODO(b/143909619): Reenable this test when supporting IETF connection - // migration. return; } @@ -4452,6 +4695,195 @@ TEST_P(EndToEndPacketReorderingTest, ReorderedConnectivityProbing) { client_connection->GetStats().num_connectivity_probing_received); } +// A writer which holds the next packet to be sent till ReleasePacket() is +// called. +class PacketHoldingWriter : public QuicPacketWriterWrapper { + public: + WriteResult WritePacket(const char* buffer, + size_t buf_len, + const QuicIpAddress& self_address, + const QuicSocketAddress& peer_address, + PerPacketOptions* options) override { + if (!hold_next_packet_) { + return QuicPacketWriterWrapper::WritePacket(buffer, buf_len, self_address, + peer_address, options); + } + QUIC_DLOG(INFO) << "Packet is held by the writer"; + packet_content_ = std::string(buffer, buf_len); + self_address_ = self_address; + peer_address_ = peer_address; + options_ = (options == nullptr ? nullptr : options->Clone()); + hold_next_packet_ = false; + return WriteResult(WRITE_STATUS_OK, buf_len); + } + + void HoldNextPacket() { + QUICHE_DCHECK(packet_content_.empty()) + << "There is already one packet on hold."; + hold_next_packet_ = true; + } + + void ReleasePacket() { + QUIC_DLOG(INFO) << "Release packet"; + ASSERT_EQ(WRITE_STATUS_OK, + QuicPacketWriterWrapper::WritePacket( + packet_content_.data(), packet_content_.length(), + self_address_, peer_address_, options_.release()) + .status); + packet_content_.clear(); + } + + private: + bool hold_next_packet_{false}; + std::string packet_content_; + QuicIpAddress self_address_; + QuicSocketAddress peer_address_; + std::unique_ptr<PerPacketOptions> options_; +}; + +TEST_P(EndToEndTest, ClientValidateNewNetwork) { + ASSERT_TRUE(Initialize()); + if (!version_.HasIetfQuicFrames() || + !GetClientConnection()->validate_client_address()) { + return; + } + client_.reset(EndToEndTest::CreateQuicClient(nullptr)); + SendSynchronousFooRequestAndCheckResponse(); + + // Store the client IP address which was used to send the first request. + QuicIpAddress old_host = + client_->client()->network_helper()->GetLatestClientAddress().host(); + + // Migrate socket to the new IP address. + QuicIpAddress new_host = TestLoopback(2); + EXPECT_NE(old_host, new_host); + + client_->client()->ValidateNewNetwork(new_host); + // Send a request using the old socket. + EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); + // Client should have received a PATH_CHALLENGE. + QuicConnection* client_connection = GetClientConnection(); + ASSERT_TRUE(client_connection); + EXPECT_EQ(1u, + client_connection->GetStats().num_connectivity_probing_received); + + // Send another request to make sure THE server will receive PATH_RESPONSE. + client_->SendSynchronousRequest("/eep"); + + server_thread_->Pause(); + QuicConnection* server_connection = GetServerConnection(); + if (server_connection != nullptr) { + EXPECT_EQ(1u, + server_connection->GetStats().num_connectivity_probing_received); + } else { + ADD_FAILURE() << "Missing server connection"; + } + server_thread_->Resume(); +} + +TEST_P(EndToEndPacketReorderingTest, ReorderedPathChallenge) { + ASSERT_TRUE(Initialize()); + if (!version_.HasIetfQuicFrames() || + !client_->client()->session()->connection()->use_path_validator()) { + return; + } + client_.reset(EndToEndTest::CreateQuicClient(nullptr)); + + // Finish one request to make sure handshake established. + EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); + + // Wait for the connection to become idle, to make sure the packet gets + // delayed is the connectivity probing packet. + client_->WaitForDelayedAcks(); + + QuicSocketAddress old_addr = + client_->client()->network_helper()->GetLatestClientAddress(); + + // Migrate socket to the new IP address. + QuicIpAddress new_host = TestLoopback(2); + EXPECT_NE(old_addr.host(), new_host); + + // Setup writer wrapper to hold the probing packet. + auto holding_writer = new PacketHoldingWriter(); + client_->UseWriter(holding_writer); + // Write a connectivity probing after the next /foo request. + holding_writer->HoldNextPacket(); + + // A packet with PATH_CHALLENGE will be held in the writer. + client_->client()->ValidateNewNetwork(new_host); + + // Send (on-hold) PATH_CHALLENGE after this request. + client_->SendRequest("/foo"); + holding_writer->ReleasePacket(); + + client_->WaitForResponse(); + + EXPECT_EQ(kFooResponseBody, client_->response_body()); + // Send yet another request after the PATH_CHALLENGE, when this request + // returns, the probing is guaranteed to have been received by the server, and + // the server's response to probing is guaranteed to have been received by the + // client. + EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); + + // Client should have received a PATH_CHALLENGE. + QuicConnection* client_connection = GetClientConnection(); + ASSERT_TRUE(client_connection); + EXPECT_EQ(client_connection->validate_client_address() ? 1u : 0, + client_connection->GetStats().num_connectivity_probing_received); + + server_thread_->Pause(); + QuicConnection* server_connection = GetServerConnection(); + if (server_connection != nullptr) { + EXPECT_EQ(1u, + server_connection->GetStats().num_connectivity_probing_received); + } else { + ADD_FAILURE() << "Missing server connection"; + } + server_thread_->Resume(); +} + +TEST_P(EndToEndPacketReorderingTest, PathValidationFailure) { + ASSERT_TRUE(Initialize()); + if (!version_.HasIetfQuicFrames() || + !client_->client()->session()->connection()->use_path_validator()) { + return; + } + + client_.reset(CreateQuicClient(nullptr)); + // Finish one request to make sure handshake established. + EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); + + // Wait for the connection to become idle, to make sure the packet gets + // delayed is the connectivity probing packet. + client_->WaitForDelayedAcks(); + + QuicSocketAddress old_addr = client_->client()->session()->self_address(); + + // Migrate socket to the new IP address. + QuicIpAddress new_host = TestLoopback(2); + EXPECT_NE(old_addr.host(), new_host); + + // Drop PATH_RESPONSE packets to timeout the path validation. + server_writer_->set_fake_packet_loss_percentage(100); + ASSERT_TRUE(client_->client()->ValidateAndMigrateSocket(new_host)); + while (client_->client()->HasPendingPathValidation()) { + client_->client()->WaitForEvents(); + } + EXPECT_EQ(old_addr, client_->client()->session()->self_address()); + server_writer_->set_fake_packet_loss_percentage(0); + EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); + + server_thread_->Pause(); + QuicConnection* server_connection = GetServerConnection(); + if (server_connection != nullptr) { + EXPECT_EQ(3u, + server_connection->GetStats().num_connectivity_probing_received); + } else { + ADD_FAILURE() << "Missing server connection"; + } + server_thread_->Resume(); +} + TEST_P(EndToEndPacketReorderingTest, Buffer0RttRequest) { ASSERT_TRUE(Initialize()); // Finish one request to make sure handshake established. @@ -4568,7 +5000,7 @@ TEST_P(EndToEndTest, ConnectionCloseBeforeHandshakeComplete) { server_thread_->Resume(); return; } - if (!dispatcher->session_map().empty()) { + if (dispatcher->NumSessions() > 0) { ADD_FAILURE() << "Dispatcher session map not empty"; server_thread_->Resume(); return; @@ -4637,7 +5069,7 @@ TEST_P(EndToEndTest, ForwardSecureConnectionClose) { server_thread_->Resume(); return; } - if (!dispatcher->session_map().empty()) { + if (dispatcher->NumSessions() > 0) { ADD_FAILURE() << "Dispatcher session map not empty"; server_thread_->Resume(); return; @@ -4858,8 +5290,6 @@ TEST_P(EndToEndTest, LegacyVersionEncapsulationWithLoss) { } TEST_P(EndToEndTest, KeyUpdateInitiatedByClient) { - SetQuicReloadableFlag(quic_key_update_supported, true); - if (!version_.UsesTls()) { // Key Update is only supported in TLS handshake. ASSERT_TRUE(Initialize()); @@ -4898,8 +5328,6 @@ TEST_P(EndToEndTest, KeyUpdateInitiatedByClient) { } TEST_P(EndToEndTest, KeyUpdateInitiatedByServer) { - SetQuicReloadableFlag(quic_key_update_supported, true); - if (!version_.UsesTls()) { // Key Update is only supported in TLS handshake. ASSERT_TRUE(Initialize()); @@ -4971,8 +5399,6 @@ TEST_P(EndToEndTest, KeyUpdateInitiatedByServer) { } TEST_P(EndToEndTest, KeyUpdateInitiatedByBoth) { - SetQuicReloadableFlag(quic_key_update_supported, true); - if (!version_.UsesTls()) { // Key Update is only supported in TLS handshake. ASSERT_TRUE(Initialize()); @@ -5052,8 +5478,6 @@ TEST_P(EndToEndTest, KeyUpdateInitiatedByBoth) { } TEST_P(EndToEndTest, KeyUpdateInitiatedByConfidentialityLimit) { - SetQuicReloadableFlag(quic_enable_aead_limits, true); - SetQuicReloadableFlag(quic_key_update_supported, true); SetQuicFlag(FLAGS_quic_key_update_confidentiality_limit, 4U); if (!version_.UsesTls()) { diff --git a/chromium/net/third_party/quiche/src/quic/core/http/http_constants.cc b/chromium/net/third_party/quiche/src/quic/core/http/http_constants.cc new file mode 100644 index 00000000000..b3262d25b7d --- /dev/null +++ b/chromium/net/third_party/quiche/src/quic/core/http/http_constants.cc @@ -0,0 +1,26 @@ +// Copyright (c) 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "quic/core/http/http_constants.h" + +#include "absl/strings/str_cat.h" + +namespace quic { + +#define RETURN_STRING_LITERAL(x) \ + case x: \ + return #x; + +std::string H3SettingsToString(Http3AndQpackSettingsIdentifiers identifier) { + switch (identifier) { + RETURN_STRING_LITERAL(SETTINGS_QPACK_MAX_TABLE_CAPACITY); + RETURN_STRING_LITERAL(SETTINGS_MAX_FIELD_SECTION_SIZE); + RETURN_STRING_LITERAL(SETTINGS_QPACK_BLOCKED_STREAMS); + } + return absl::StrCat("UNSUPPORTED_SETTINGS_TYPE(", identifier, ")"); +} + +#undef RETURN_STRING_LITERAL // undef for jumbo builds + +} // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/http/http_constants.h b/chromium/net/third_party/quiche/src/quic/core/http/http_constants.h index 5164a4b67c8..8c68e74bccc 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/http_constants.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/http_constants.h @@ -6,8 +6,10 @@ #define QUICHE_QUIC_CORE_HTTP_HTTP_CONSTANTS_H_ #include <cstdint> +#include <string> -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -34,6 +36,10 @@ enum Http3AndQpackSettingsIdentifiers : uint64_t { SETTINGS_QPACK_BLOCKED_STREAMS = 0x07, }; +// Returns HTTP/3 SETTINGS identifier as a string. +QUIC_EXPORT std::string H3SettingsToString( + Http3AndQpackSettingsIdentifiers identifier); + // Default maximum dynamic table capacity, communicated via // SETTINGS_QPACK_MAX_TABLE_CAPACITY. const QuicByteCount kDefaultQpackMaxDynamicTableCapacity = 64 * 1024; // 64 KB @@ -47,6 +53,7 @@ const QuicByteCount kDefaultMaxUncompressedHeaderSize = 16 * 1024; // 16 KB const uint64_t kDefaultMaximumBlockedStreams = 100; const char kUserAgentHeaderName[] = "user-agent"; + } // namespace quic #endif // QUICHE_QUIC_CORE_HTTP_HTTP_CONSTANTS_H_ diff --git a/chromium/net/third_party/quiche/src/quic/core/http/http_decoder.cc b/chromium/net/third_party/quiche/src/quic/core/http/http_decoder.cc index 1a160e9d5f6..fe33a817152 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/http_decoder.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/http_decoder.cc @@ -2,20 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/http_decoder.h" +#include "quic/core/http/http_decoder.h" #include <cstdint> #include "absl/base/attributes.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/http2/http2_constants.h" -#include "net/third_party/quiche/src/quic/core/http/http_frames.h" -#include "net/third_party/quiche/src/quic/core/quic_data_reader.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#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 "http2/http2_constants.h" +#include "quic/core/http/http_frames.h" +#include "quic/core/quic_data_reader.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -33,7 +34,7 @@ HttpDecoder::HttpDecoder(Visitor* visitor) remaining_push_id_length_(0), error_(QUIC_NO_ERROR), error_detail_("") { - DCHECK(visitor_); + QUICHE_DCHECK(visitor_); } HttpDecoder::~HttpDecoder() {} @@ -83,16 +84,16 @@ bool HttpDecoder::DecodeSettings(const char* data, } QuicByteCount HttpDecoder::ProcessInput(const char* data, QuicByteCount len) { - DCHECK_EQ(QUIC_NO_ERROR, error_); - DCHECK_NE(STATE_ERROR, state_); + QUICHE_DCHECK_EQ(QUIC_NO_ERROR, error_); + QUICHE_DCHECK_NE(STATE_ERROR, state_); QuicDataReader reader(data, len); bool continue_processing = true; while (continue_processing && (reader.BytesRemaining() != 0 || state_ == STATE_FINISH_PARSING)) { // |continue_processing| must have been set to false upon error. - DCHECK_EQ(QUIC_NO_ERROR, error_); - DCHECK_NE(STATE_ERROR, state_); + QUICHE_DCHECK_EQ(QUIC_NO_ERROR, error_); + QUICHE_DCHECK_NE(STATE_ERROR, state_); switch (state_) { case STATE_READING_FRAME_TYPE: @@ -118,11 +119,11 @@ QuicByteCount HttpDecoder::ProcessInput(const char* data, QuicByteCount len) { } bool HttpDecoder::ReadFrameType(QuicDataReader* reader) { - DCHECK_NE(0u, reader->BytesRemaining()); + QUICHE_DCHECK_NE(0u, reader->BytesRemaining()); if (current_type_field_length_ == 0) { // A new frame is coming. current_type_field_length_ = reader->PeekVarInt62Length(); - DCHECK_NE(0u, current_type_field_length_); + QUICHE_DCHECK_NE(0u, current_type_field_length_); if (current_type_field_length_ > reader->BytesRemaining()) { // Buffer a new type field. remaining_type_field_length_ = current_type_field_length_; @@ -131,7 +132,7 @@ bool HttpDecoder::ReadFrameType(QuicDataReader* reader) { } // The reader has all type data needed, so no need to buffer. bool success = reader->ReadVarInt62(¤t_frame_type_); - DCHECK(success); + QUICHE_DCHECK(success); } else { // Buffer the existing type field. BufferFrameType(reader); @@ -141,38 +142,34 @@ bool HttpDecoder::ReadFrameType(QuicDataReader* reader) { } QuicDataReader type_reader(type_buffer_.data(), current_type_field_length_); bool success = type_reader.ReadVarInt62(¤t_frame_type_); - DCHECK(success); + QUICHE_DCHECK(success); } - if (GetQuicReloadableFlag(quic_reject_spdy_frames)) { - QUIC_RELOADABLE_FLAG_COUNT(quic_reject_spdy_frames); - // https://tools.ietf.org/html/draft-ietf-quic-http-31#section-7.2.8 - // specifies that the following frames are treated as errors. - if (current_frame_type_ == - static_cast<uint64_t>(http2::Http2FrameType::PRIORITY) || - current_frame_type_ == - static_cast<uint64_t>(http2::Http2FrameType::PING) || - current_frame_type_ == - static_cast<uint64_t>(http2::Http2FrameType::WINDOW_UPDATE) || - current_frame_type_ == - static_cast<uint64_t>(http2::Http2FrameType::CONTINUATION)) { - RaiseError( - QUIC_HTTP_RECEIVE_SPDY_FRAME, - quiche::QuicheStrCat("HTTP/2 frame received in a HTTP/3 connection: ", - current_frame_type_)); - return false; - } + // https://tools.ietf.org/html/draft-ietf-quic-http-31#section-7.2.8 + // specifies that the following frames are treated as errors. + if (current_frame_type_ == + static_cast<uint64_t>(http2::Http2FrameType::PRIORITY) || + current_frame_type_ == + static_cast<uint64_t>(http2::Http2FrameType::PING) || + current_frame_type_ == + static_cast<uint64_t>(http2::Http2FrameType::WINDOW_UPDATE) || + current_frame_type_ == + static_cast<uint64_t>(http2::Http2FrameType::CONTINUATION)) { + RaiseError(QUIC_HTTP_RECEIVE_SPDY_FRAME, + absl::StrCat("HTTP/2 frame received in a HTTP/3 connection: ", + current_frame_type_)); + return false; } state_ = STATE_READING_FRAME_LENGTH; return true; } bool HttpDecoder::ReadFrameLength(QuicDataReader* reader) { - DCHECK_NE(0u, reader->BytesRemaining()); + QUICHE_DCHECK_NE(0u, reader->BytesRemaining()); if (current_length_field_length_ == 0) { // A new frame is coming. current_length_field_length_ = reader->PeekVarInt62Length(); - DCHECK_NE(0u, current_length_field_length_); + QUICHE_DCHECK_NE(0u, current_length_field_length_); if (current_length_field_length_ > reader->BytesRemaining()) { // Buffer a new length field. remaining_length_field_length_ = current_length_field_length_; @@ -181,7 +178,7 @@ bool HttpDecoder::ReadFrameLength(QuicDataReader* reader) { } // The reader has all length data needed, so no need to buffer. bool success = reader->ReadVarInt62(¤t_frame_length_); - DCHECK(success); + QUICHE_DCHECK(success); } else { // Buffer the existing length field. BufferFrameLength(reader); @@ -192,7 +189,7 @@ bool HttpDecoder::ReadFrameLength(QuicDataReader* reader) { QuicDataReader length_reader(length_buffer_.data(), current_length_field_length_); bool success = length_reader.ReadVarInt62(¤t_frame_length_); - DCHECK(success); + QUICHE_DCHECK(success); } if (current_frame_length_ > MaxFrameLength(current_frame_type_)) { @@ -238,13 +235,17 @@ bool HttpDecoder::ReadFrameLength(QuicDataReader* reader) { continue_processing = visitor_->OnPriorityUpdateFrameStart(header_length); break; case static_cast<uint64_t>(HttpFrameType::PRIORITY_UPDATE_REQUEST_STREAM): - if (GetQuicReloadableFlag(quic_new_priority_update_frame)) { - QUIC_CODE_COUNT_N(quic_new_priority_update_frame, 2, 2); - continue_processing = - visitor_->OnPriorityUpdateFrameStart(header_length); - break; + continue_processing = visitor_->OnPriorityUpdateFrameStart(header_length); + break; + case static_cast<uint64_t>(HttpFrameType::ACCEPT_CH): + if (GetQuicReloadableFlag(quic_parse_accept_ch_frame)) { + QUIC_RELOADABLE_FLAG_COUNT(quic_parse_accept_ch_frame); + continue_processing = visitor_->OnAcceptChFrameStart(header_length); + } else { + continue_processing = visitor_->OnUnknownFrameStart( + current_frame_type_, header_length, current_frame_length_); } - ABSL_FALLTHROUGH_INTENDED; + break; default: continue_processing = visitor_->OnUnknownFrameStart( current_frame_type_, header_length, current_frame_length_); @@ -258,8 +259,8 @@ bool HttpDecoder::ReadFrameLength(QuicDataReader* reader) { } bool HttpDecoder::ReadFramePayload(QuicDataReader* reader) { - DCHECK_NE(0u, reader->BytesRemaining()); - DCHECK_NE(0u, remaining_frame_length_); + QUICHE_DCHECK_NE(0u, reader->BytesRemaining()); + QUICHE_DCHECK_NE(0u, remaining_frame_length_); bool continue_processing = true; @@ -269,8 +270,8 @@ bool HttpDecoder::ReadFramePayload(QuicDataReader* reader) { remaining_frame_length_, reader->BytesRemaining()); absl::string_view payload; bool success = reader->ReadStringPiece(&payload, bytes_to_read); - DCHECK(success); - DCHECK(!payload.empty()); + QUICHE_DCHECK(success); + QUICHE_DCHECK(!payload.empty()); continue_processing = visitor_->OnDataFramePayload(payload); remaining_frame_length_ -= payload.length(); break; @@ -280,8 +281,8 @@ bool HttpDecoder::ReadFramePayload(QuicDataReader* reader) { remaining_frame_length_, reader->BytesRemaining()); absl::string_view payload; bool success = reader->ReadStringPiece(&payload, bytes_to_read); - DCHECK(success); - DCHECK(!payload.empty()); + QUICHE_DCHECK(success); + QUICHE_DCHECK(!payload.empty()); continue_processing = visitor_->OnHeadersFramePayload(payload); remaining_frame_length_ -= payload.length(); break; @@ -298,7 +299,7 @@ bool HttpDecoder::ReadFramePayload(QuicDataReader* reader) { PushId push_id; if (current_frame_length_ == remaining_frame_length_) { // A new Push Promise frame just arrived. - DCHECK_EQ(0u, current_push_id_length_); + QUICHE_DCHECK_EQ(0u, current_push_id_length_); current_push_id_length_ = reader->PeekVarInt62Length(); if (current_push_id_length_ > remaining_frame_length_) { RaiseError(QUIC_HTTP_FRAME_ERROR, @@ -307,13 +308,13 @@ bool HttpDecoder::ReadFramePayload(QuicDataReader* reader) { } if (current_push_id_length_ > reader->BytesRemaining()) { // Not all bytes of push id is present yet, buffer push id. - DCHECK_EQ(0u, remaining_push_id_length_); + QUICHE_DCHECK_EQ(0u, remaining_push_id_length_); remaining_push_id_length_ = current_push_id_length_; BufferPushId(reader); break; } bool success = reader->ReadVarInt62(&push_id); - DCHECK(success); + QUICHE_DCHECK(success); remaining_frame_length_ -= current_push_id_length_; if (!visitor_->OnPushPromiseFramePushId( push_id, current_push_id_length_, @@ -333,7 +334,7 @@ bool HttpDecoder::ReadFramePayload(QuicDataReader* reader) { current_push_id_length_); bool success = push_id_reader.ReadVarInt62(&push_id); - DCHECK(success); + QUICHE_DCHECK(success); if (!visitor_->OnPushPromiseFramePushId( push_id, current_push_id_length_, current_frame_length_ - current_push_id_length_)) { @@ -345,7 +346,7 @@ bool HttpDecoder::ReadFramePayload(QuicDataReader* reader) { } // Read Push Promise headers. - DCHECK_LT(remaining_frame_length_, current_frame_length_); + QUICHE_DCHECK_LT(remaining_frame_length_, current_frame_length_); QuicByteCount bytes_to_read = std::min<QuicByteCount>( remaining_frame_length_, reader->BytesRemaining()); if (bytes_to_read == 0) { @@ -353,8 +354,8 @@ bool HttpDecoder::ReadFramePayload(QuicDataReader* reader) { } absl::string_view payload; bool success = reader->ReadStringPiece(&payload, bytes_to_read); - DCHECK(success); - DCHECK(!payload.empty()); + QUICHE_DCHECK(success); + QUICHE_DCHECK(!payload.empty()); continue_processing = visitor_->OnPushPromiseFramePayload(payload); remaining_frame_length_ -= payload.length(); break; @@ -374,23 +375,23 @@ bool HttpDecoder::ReadFramePayload(QuicDataReader* reader) { break; } case static_cast<uint64_t>(HttpFrameType::PRIORITY_UPDATE_REQUEST_STREAM): { - if (GetQuicReloadableFlag(quic_new_priority_update_frame)) { + // TODO(bnc): Avoid buffering if the entire frame is present, and + // instead parse directly out of |reader|. + BufferFramePayload(reader); + break; + } + case static_cast<uint64_t>(HttpFrameType::ACCEPT_CH): { + if (GetQuicReloadableFlag(quic_parse_accept_ch_frame)) { // TODO(bnc): Avoid buffering if the entire frame is present, and // instead parse directly out of |reader|. BufferFramePayload(reader); - break; + } else { + continue_processing = HandleUnknownFramePayload(reader); } - ABSL_FALLTHROUGH_INTENDED; + break; } default: { - QuicByteCount bytes_to_read = std::min<QuicByteCount>( - remaining_frame_length_, reader->BytesRemaining()); - absl::string_view payload; - bool success = reader->ReadStringPiece(&payload, bytes_to_read); - DCHECK(success); - DCHECK(!payload.empty()); - continue_processing = visitor_->OnUnknownFramePayload(payload); - remaining_frame_length_ -= payload.length(); + continue_processing = HandleUnknownFramePayload(reader); break; } } @@ -403,7 +404,7 @@ bool HttpDecoder::ReadFramePayload(QuicDataReader* reader) { } bool HttpDecoder::FinishParsing() { - DCHECK_EQ(0u, remaining_frame_length_); + QUICHE_DCHECK_EQ(0u, remaining_frame_length_); bool continue_processing = true; @@ -487,23 +488,33 @@ bool HttpDecoder::FinishParsing() { break; } case static_cast<uint64_t>(HttpFrameType::PRIORITY_UPDATE_REQUEST_STREAM): { - if (GetQuicReloadableFlag(quic_new_priority_update_frame)) { + // TODO(bnc): Avoid buffering if the entire frame is present, and + // instead parse directly out of |reader|. + PriorityUpdateFrame frame; + QuicDataReader reader(buffer_.data(), current_frame_length_); + if (!ParseNewPriorityUpdateFrame(&reader, &frame)) { + return false; + } + continue_processing = visitor_->OnPriorityUpdateFrame(frame); + break; + } + case static_cast<uint64_t>(HttpFrameType::ACCEPT_CH): { + if (GetQuicReloadableFlag(quic_parse_accept_ch_frame)) { // TODO(bnc): Avoid buffering if the entire frame is present, and // instead parse directly out of |reader|. - PriorityUpdateFrame frame; + AcceptChFrame frame; QuicDataReader reader(buffer_.data(), current_frame_length_); - if (!ParseNewPriorityUpdateFrame(&reader, &frame)) { + if (!ParseAcceptChFrame(&reader, &frame)) { return false; } - continue_processing = visitor_->OnPriorityUpdateFrame(frame); - break; + continue_processing = visitor_->OnAcceptChFrame(frame); + } else { + continue_processing = visitor_->OnUnknownFrameEnd(); } - ABSL_FALLTHROUGH_INTENDED; - } - default: { - continue_processing = visitor_->OnUnknownFrameEnd(); break; } + default: + continue_processing = visitor_->OnUnknownFrameEnd(); } current_length_field_length_ = 0; @@ -512,12 +523,23 @@ bool HttpDecoder::FinishParsing() { return continue_processing; } +bool HttpDecoder::HandleUnknownFramePayload(QuicDataReader* reader) { + QuicByteCount bytes_to_read = std::min<QuicByteCount>( + remaining_frame_length_, reader->BytesRemaining()); + absl::string_view payload; + bool success = reader->ReadStringPiece(&payload, bytes_to_read); + QUICHE_DCHECK(success); + QUICHE_DCHECK(!payload.empty()); + remaining_frame_length_ -= payload.length(); + return visitor_->OnUnknownFramePayload(payload); +} + void HttpDecoder::DiscardFramePayload(QuicDataReader* reader) { QuicByteCount bytes_to_read = std::min<QuicByteCount>( remaining_frame_length_, reader->BytesRemaining()); absl::string_view payload; bool success = reader->ReadStringPiece(&payload, bytes_to_read); - DCHECK(success); + QUICHE_DCHECK(success); remaining_frame_length_ -= payload.length(); if (remaining_frame_length_ == 0) { state_ = STATE_READING_FRAME_TYPE; @@ -536,7 +558,7 @@ void HttpDecoder::BufferFramePayload(QuicDataReader* reader) { bool success = reader->ReadBytes( &(buffer_[0]) + current_frame_length_ - remaining_frame_length_, bytes_to_read); - DCHECK(success); + QUICHE_DCHECK(success); remaining_frame_length_ -= bytes_to_read; } @@ -547,7 +569,7 @@ void HttpDecoder::BufferFrameLength(QuicDataReader* reader) { reader->ReadBytes(length_buffer_.data() + current_length_field_length_ - remaining_length_field_length_, bytes_to_read); - DCHECK(success); + QUICHE_DCHECK(success); remaining_length_field_length_ -= bytes_to_read; } @@ -558,19 +580,19 @@ void HttpDecoder::BufferFrameType(QuicDataReader* reader) { reader->ReadBytes(type_buffer_.data() + current_type_field_length_ - remaining_type_field_length_, bytes_to_read); - DCHECK(success); + QUICHE_DCHECK(success); remaining_type_field_length_ -= bytes_to_read; } void HttpDecoder::BufferPushId(QuicDataReader* reader) { - DCHECK_LE(remaining_push_id_length_, current_frame_length_); + QUICHE_DCHECK_LE(remaining_push_id_length_, current_frame_length_); QuicByteCount bytes_to_read = std::min<QuicByteCount>( reader->BytesRemaining(), remaining_push_id_length_); bool success = reader->ReadBytes(push_id_buffer_.data() + current_push_id_length_ - remaining_push_id_length_, bytes_to_read); - DCHECK(success); + QUICHE_DCHECK(success); remaining_push_id_length_ -= bytes_to_read; remaining_frame_length_ -= bytes_to_read; } @@ -651,6 +673,26 @@ bool HttpDecoder::ParseNewPriorityUpdateFrame(QuicDataReader* reader, return true; } +bool HttpDecoder::ParseAcceptChFrame(QuicDataReader* reader, + AcceptChFrame* frame) { + absl::string_view origin; + absl::string_view value; + while (!reader->IsDoneReading()) { + if (!reader->ReadStringPieceVarInt62(&origin)) { + RaiseError(QUIC_HTTP_FRAME_ERROR, "Unable to read ACCEPT_CH origin."); + return false; + } + if (!reader->ReadStringPieceVarInt62(&value)) { + RaiseError(QUIC_HTTP_FRAME_ERROR, "Unable to read ACCEPT_CH value."); + return false; + } + // Copy data. + frame->entries.push_back({std::string(origin.data(), origin.size()), + std::string(value.data(), value.size())}); + } + return true; +} + QuicByteCount HttpDecoder::MaxFrameLength(uint64_t frame_type) { switch (frame_type) { case static_cast<uint64_t>(HttpFrameType::CANCEL_PUSH): @@ -668,6 +710,9 @@ QuicByteCount HttpDecoder::MaxFrameLength(uint64_t frame_type) { case static_cast<uint64_t>(HttpFrameType::PRIORITY_UPDATE_REQUEST_STREAM): // This limit is arbitrary. return 1024 * 1024; + case static_cast<uint64_t>(HttpFrameType::ACCEPT_CH): + // This limit is arbitrary. + return 1024 * 1024; default: // Other frames require no data buffering, so it's safe to have no limit. return std::numeric_limits<QuicByteCount>::max(); diff --git a/chromium/net/third_party/quiche/src/quic/core/http/http_decoder.h b/chromium/net/third_party/quiche/src/quic/core/http/http_decoder.h index 479f4448866..fe955c32bf8 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/http_decoder.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/http_decoder.h @@ -8,10 +8,10 @@ #include <cstdint> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/http/http_frames.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/http/http_frames.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -102,6 +102,13 @@ class QUIC_EXPORT_PRIVATE HttpDecoder { // Called when a PRIORITY_UPDATE frame has been successfully parsed. virtual bool OnPriorityUpdateFrame(const PriorityUpdateFrame& frame) = 0; + // Called when an ACCEPT_CH frame has been received. + // |header_length| contains ACCEPT_CH frame length and payload length. + virtual bool OnAcceptChFrameStart(QuicByteCount header_length) = 0; + + // Called when an ACCEPT_CH frame has been successfully parsed. + virtual bool OnAcceptChFrame(const AcceptChFrame& frame) = 0; + // Called when a frame of unknown type |frame_type| has been received. // Frame type might be reserved, Visitor must make sure to ignore. // |header_length| and |payload_length| are the length of the frame header @@ -143,6 +150,9 @@ class QUIC_EXPORT_PRIVATE HttpDecoder { const std::string& error_detail() const { return error_detail_; } + // Returns true if input data processed so far ends on a frame boundary. + bool AtFrameBoundary() const { return state_ == STATE_READING_FRAME_TYPE; } + private: friend test::HttpDecoderPeer; @@ -174,6 +184,11 @@ class QUIC_EXPORT_PRIVATE HttpDecoder { // had been parsed completely. Returns whether processing should continue. bool FinishParsing(); + // Read payload of unknown frame from |reader| and call + // Visitor::OnUnknownFramePayload(). Returns true decoding should continue, + // false if it should be paused. + bool HandleUnknownFramePayload(QuicDataReader* reader); + // Discards any remaining frame payload from |reader|. void DiscardFramePayload(QuicDataReader* reader); @@ -207,6 +222,9 @@ class QUIC_EXPORT_PRIVATE HttpDecoder { bool ParseNewPriorityUpdateFrame(QuicDataReader* reader, PriorityUpdateFrame* frame); + // Parses the payload of an ACCEPT_CH frame from |reader| into |frame|. + bool ParseAcceptChFrame(QuicDataReader* reader, AcceptChFrame* frame); + // Returns the max frame size of a given |frame_type|. QuicByteCount MaxFrameLength(uint64_t frame_type); diff --git a/chromium/net/third_party/quiche/src/quic/core/http/http_decoder_test.cc b/chromium/net/third_party/quiche/src/quic/core/http/http_decoder_test.cc index d56626ffa21..1be5084f77d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/http_decoder_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/http_decoder_test.cc @@ -2,25 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/http_decoder.h" +#include "quic/core/http/http_decoder.h" #include <memory> #include <utility> #include "absl/base/macros.h" #include "absl/strings/escaping.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/http/http_encoder.h" -#include "net/third_party/quiche/src/quic/core/http/http_frames.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/http/http_encoder.h" +#include "quic/core/http/http_frames.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" using ::testing::_; +using ::testing::AnyNumber; using ::testing::Eq; using ::testing::InSequence; using ::testing::Return; @@ -104,6 +105,12 @@ class MockVisitor : public HttpDecoder::Visitor { (override)); MOCK_METHOD(bool, + OnAcceptChFrameStart, + (QuicByteCount header_length), + (override)); + MOCK_METHOD(bool, OnAcceptChFrame, (const AcceptChFrame& frame), (override)); + + MOCK_METHOD(bool, OnUnknownFrameStart, (uint64_t frame_type, QuicByteCount header_length, @@ -138,6 +145,8 @@ class HttpDecoderTest : public QuicTest { ON_CALL(visitor_, OnPriorityUpdateFrameStart(_)) .WillByDefault(Return(true)); ON_CALL(visitor_, OnPriorityUpdateFrame(_)).WillByDefault(Return(true)); + ON_CALL(visitor_, OnAcceptChFrameStart(_)).WillByDefault(Return(true)); + ON_CALL(visitor_, OnAcceptChFrame(_)).WillByDefault(Return(true)); ON_CALL(visitor_, OnUnknownFrameStart(_, _, _)).WillByDefault(Return(true)); ON_CALL(visitor_, OnUnknownFramePayload(_)).WillByDefault(Return(true)); ON_CALL(visitor_, OnUnknownFrameEnd()).WillByDefault(Return(true)); @@ -164,12 +173,11 @@ class HttpDecoderTest : public QuicTest { // Append garbage to |input|, then process it in a single call to // HttpDecoder::ProcessInput(). Verify that garbage is not read. QuicByteCount ProcessInputWithGarbageAppended(absl::string_view input) { - std::string input_with_garbage_appended = - quiche::QuicheStrCat(input, "blahblah"); + std::string input_with_garbage_appended = absl::StrCat(input, "blahblah"); QuicByteCount processed_bytes = ProcessInput(input_with_garbage_appended); // Guaranteed by HttpDecoder::ProcessInput() contract. - DCHECK_LE(processed_bytes, input_with_garbage_appended.size()); + QUICHE_DCHECK_LE(processed_bytes, input_with_garbage_appended.size()); // Caller should set up visitor to pause decoding // before HttpDecoder would read garbage. @@ -258,11 +266,11 @@ TEST_F(HttpDecoderTest, CancelPush) { TEST_F(HttpDecoderTest, PushPromiseFrame) { InSequence s; - std::string input = quiche::QuicheStrCat( - absl::HexStringToBytes("05" // type (PUSH PROMISE) - "0f" // length - "C000000000000101"), // push id 257 - "Headers"); // headers + std::string input = + absl::StrCat(absl::HexStringToBytes("05" // type (PUSH PROMISE) + "0f" // length + "C000000000000101"), // push id 257 + "Headers"); // headers // Visitor pauses processing. EXPECT_CALL(visitor_, OnPushPromiseFrameStart(2)).WillOnce(Return(false)); @@ -485,10 +493,9 @@ TEST_F(HttpDecoderTest, DuplicateSettingsIdentifier) { TEST_F(HttpDecoderTest, DataFrame) { InSequence s; - std::string input = - quiche::QuicheStrCat(absl::HexStringToBytes("00" // type (DATA) - "05"), // length - "Data!"); // data + std::string input = absl::StrCat(absl::HexStringToBytes("00" // type (DATA) + "05"), // length + "Data!"); // data // Visitor pauses processing. EXPECT_CALL(visitor_, OnDataFrameStart(2, 5)).WillOnce(Return(false)); @@ -615,9 +622,9 @@ TEST_F(HttpDecoderTest, GoAway) { TEST_F(HttpDecoderTest, HeadersFrame) { InSequence s; std::string input = - quiche::QuicheStrCat(absl::HexStringToBytes("01" // type (HEADERS) - "07"), // length - "Headers"); // headers + absl::StrCat(absl::HexStringToBytes("01" // type (HEADERS) + "07"), // length + "Headers"); // headers // Visitor pauses processing. EXPECT_CALL(visitor_, OnHeadersFrameStart(2, 7)).WillOnce(Return(false)); @@ -783,7 +790,6 @@ TEST_F(HttpDecoderTest, MalformedSettingsFrame) { } TEST_F(HttpDecoderTest, Http2Frame) { - SetQuicReloadableFlag(quic_reject_spdy_frames, true); std::string input = absl::HexStringToBytes( "06" // PING in HTTP/2 but not supported in HTTP/3. "05" // length @@ -800,12 +806,12 @@ TEST_F(HttpDecoderTest, Http2Frame) { TEST_F(HttpDecoderTest, HeadersPausedThenData) { InSequence s; std::string input = - quiche::QuicheStrCat(absl::HexStringToBytes("01" // type (HEADERS) - "07"), // length - "Headers", // headers - absl::HexStringToBytes("00" // type (DATA) - "05"), // length - "Data!"); // data + absl::StrCat(absl::HexStringToBytes("01" // type (HEADERS) + "07"), // length + "Headers", // headers + absl::HexStringToBytes("00" // type (DATA) + "05"), // length + "Data!"); // data // Visitor pauses processing, maybe because header decompression is blocked. EXPECT_CALL(visitor_, OnHeadersFrameStart(2, 7)); @@ -1042,10 +1048,6 @@ TEST_F(HttpDecoderTest, PriorityUpdateFrame) { } TEST_F(HttpDecoderTest, NewPriorityUpdateFrame) { - if (!GetQuicReloadableFlag(quic_new_priority_update_frame)) { - return; - } - InSequence s; std::string input1 = absl::HexStringToBytes( "800f0700" // type (PRIORITY_UPDATE) @@ -1162,10 +1164,6 @@ TEST_F(HttpDecoderTest, CorruptPriorityUpdateFrame) { } TEST_F(HttpDecoderTest, CorruptNewPriorityUpdateFrame) { - if (!GetQuicReloadableFlag(quic_new_priority_update_frame)) { - return; - } - std::string payload = absl::HexStringToBytes("4005"); // prioritized element id struct { @@ -1195,6 +1193,153 @@ TEST_F(HttpDecoderTest, CorruptNewPriorityUpdateFrame) { } } +TEST_F(HttpDecoderTest, AcceptChFrame) { + if (!GetQuicReloadableFlag(quic_parse_accept_ch_frame)) { + return; + } + + InSequence s; + std::string input1 = absl::HexStringToBytes( + "4089" // type (ACCEPT_CH) + "00"); // length + + AcceptChFrame accept_ch1; + + // Visitor pauses processing. + EXPECT_CALL(visitor_, OnAcceptChFrameStart(3)).WillOnce(Return(false)); + absl::string_view remaining_input(input1); + QuicByteCount processed_bytes = + ProcessInputWithGarbageAppended(remaining_input); + EXPECT_EQ(3u, processed_bytes); + remaining_input = remaining_input.substr(processed_bytes); + + EXPECT_CALL(visitor_, OnAcceptChFrame(accept_ch1)).WillOnce(Return(false)); + processed_bytes = ProcessInputWithGarbageAppended(remaining_input); + EXPECT_EQ(remaining_input.size(), processed_bytes); + EXPECT_THAT(decoder_.error(), IsQuicNoError()); + EXPECT_EQ("", decoder_.error_detail()); + + // Process the full frame. + EXPECT_CALL(visitor_, OnAcceptChFrameStart(3)); + EXPECT_CALL(visitor_, OnAcceptChFrame(accept_ch1)); + EXPECT_EQ(input1.size(), ProcessInput(input1)); + EXPECT_THAT(decoder_.error(), IsQuicNoError()); + EXPECT_EQ("", decoder_.error_detail()); + + // Process the frame incrementally. + EXPECT_CALL(visitor_, OnAcceptChFrameStart(3)); + EXPECT_CALL(visitor_, OnAcceptChFrame(accept_ch1)); + ProcessInputCharByChar(input1); + EXPECT_THAT(decoder_.error(), IsQuicNoError()); + EXPECT_EQ("", decoder_.error_detail()); + + std::string input2 = absl::HexStringToBytes( + "4089" // type (ACCEPT_CH) + "08" // length + "03" // length of origin + "666f6f" // origin "foo" + "03" // length of value + "626172"); // value "bar" + + AcceptChFrame accept_ch2; + accept_ch2.entries.push_back({"foo", "bar"}); + + // Visitor pauses processing. + EXPECT_CALL(visitor_, OnAcceptChFrameStart(3)).WillOnce(Return(false)); + remaining_input = input2; + processed_bytes = ProcessInputWithGarbageAppended(remaining_input); + EXPECT_EQ(3u, processed_bytes); + remaining_input = remaining_input.substr(processed_bytes); + + EXPECT_CALL(visitor_, OnAcceptChFrame(accept_ch2)).WillOnce(Return(false)); + processed_bytes = ProcessInputWithGarbageAppended(remaining_input); + EXPECT_EQ(remaining_input.size(), processed_bytes); + EXPECT_THAT(decoder_.error(), IsQuicNoError()); + EXPECT_EQ("", decoder_.error_detail()); + + // Process the full frame. + EXPECT_CALL(visitor_, OnAcceptChFrameStart(3)); + EXPECT_CALL(visitor_, OnAcceptChFrame(accept_ch2)); + EXPECT_EQ(input2.size(), ProcessInput(input2)); + EXPECT_THAT(decoder_.error(), IsQuicNoError()); + EXPECT_EQ("", decoder_.error_detail()); + + // Process the frame incrementally. + EXPECT_CALL(visitor_, OnAcceptChFrameStart(3)); + EXPECT_CALL(visitor_, OnAcceptChFrame(accept_ch2)); + ProcessInputCharByChar(input2); + EXPECT_THAT(decoder_.error(), IsQuicNoError()); + EXPECT_EQ("", decoder_.error_detail()); +} + +TEST_F(HttpDecoderTest, CorruptAcceptChFrame) { + if (!GetQuicReloadableFlag(quic_parse_accept_ch_frame)) { + // TODO(bnc): merge this test into HttpDecoderTest.CorruptFrame when + // deprecating flag. + return; + } + + EXPECT_CALL(visitor_, OnAcceptChFrameStart(_)).Times(AnyNumber()); + + struct { + const char* const input; + const char* const error_message; + } kTestData[] = {{"\x40\x89" // type (ACCEPT_CH) + "\x01" // length + "\x40", // first byte of two-byte varint origin length + "Unable to read ACCEPT_CH origin."}, + {"\x40\x89" // type (ACCEPT_CH) + "\x01" // length + "\x05", // valid origin length but no origin string + "Unable to read ACCEPT_CH origin."}, + {"\x40\x89" // type (ACCEPT_CH) + "\x04" // length + "\x05" // valid origin length + "foo", // payload ends before origin ends + "Unable to read ACCEPT_CH origin."}, + {"\x40\x89" // type (ACCEPT_CH) + "\x04" // length + "\x03" // valid origin length + "foo", // payload ends at end of origin: no value + "Unable to read ACCEPT_CH value."}, + {"\x40\x89" // type (ACCEPT_CH) + "\x05" // length + "\x03" // valid origin length + "foo" // payload ends at end of origin: no value + "\x40", // first byte of two-byte varint value length + "Unable to read ACCEPT_CH value."}, + {"\x40\x89" // type (ACCEPT_CH) + "\x08" // length + "\x03" // valid origin length + "foo" // origin + "\x05" // valid value length + "bar", // payload ends before value ends + "Unable to read ACCEPT_CH value."}}; + + for (const auto& test_data : kTestData) { + { + HttpDecoder decoder(&visitor_); + EXPECT_CALL(visitor_, OnError(&decoder)); + + absl::string_view input(test_data.input); + decoder.ProcessInput(input.data(), input.size()); + EXPECT_THAT(decoder.error(), IsError(QUIC_HTTP_FRAME_ERROR)); + EXPECT_EQ(test_data.error_message, decoder.error_detail()); + } + { + HttpDecoder decoder(&visitor_); + EXPECT_CALL(visitor_, OnError(&decoder)); + + absl::string_view input(test_data.input); + for (auto c : input) { + decoder.ProcessInput(&c, 1); + } + EXPECT_THAT(decoder.error(), IsError(QUIC_HTTP_FRAME_ERROR)); + EXPECT_EQ(test_data.error_message, decoder.error_detail()); + } + } +} + TEST_F(HttpDecoderTest, DecodeSettings) { std::string input = absl::HexStringToBytes( "04" // type (SETTINGS) diff --git a/chromium/net/third_party/quiche/src/quic/core/http/http_encoder.cc b/chromium/net/third_party/quiche/src/quic/core/http/http_encoder.cc index 4f86d45b7b7..fafe3b83d08 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/http_encoder.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/http_encoder.cc @@ -2,15 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/http_encoder.h" +#include "quic/core/http/http_encoder.h" #include <cstdint> #include <memory> -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#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 "quic/core/crypto/quic_random.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -35,7 +37,7 @@ QuicByteCount GetTotalLength(QuicByteCount payload_length, HttpFrameType type) { QuicByteCount HttpEncoder::SerializeDataFrameHeader( QuicByteCount payload_length, std::unique_ptr<char[]>* output) { - DCHECK_NE(0u, payload_length); + QUICHE_DCHECK_NE(0u, payload_length); QuicByteCount header_length = QuicDataWriter::GetVarInt62Len(payload_length) + QuicDataWriter::GetVarInt62Len( static_cast<uint64_t>(HttpFrameType::DATA)); @@ -55,7 +57,7 @@ QuicByteCount HttpEncoder::SerializeDataFrameHeader( QuicByteCount HttpEncoder::SerializeHeadersFrameHeader( QuicByteCount payload_length, std::unique_ptr<char[]>* output) { - DCHECK_NE(0u, payload_length); + QUICHE_DCHECK_NE(0u, payload_length); QuicByteCount header_length = QuicDataWriter::GetVarInt62Len(payload_length) + QuicDataWriter::GetVarInt62Len( @@ -202,50 +204,23 @@ QuicByteCount HttpEncoder::SerializeMaxPushIdFrame( QuicByteCount HttpEncoder::SerializePriorityUpdateFrame( const PriorityUpdateFrame& priority_update, std::unique_ptr<char[]>* output) { - if (GetQuicReloadableFlag(quic_new_priority_update_frame)) { - QUIC_CODE_COUNT_N(quic_new_priority_update_frame, 1, 2); - - if (priority_update.prioritized_element_type != REQUEST_STREAM) { - QUIC_BUG << "PRIORITY_UPDATE for push streams not implemented"; - return 0; - } - - QuicByteCount payload_length = - QuicDataWriter::GetVarInt62Len(priority_update.prioritized_element_id) + - priority_update.priority_field_value.size(); - QuicByteCount total_length = GetTotalLength( - payload_length, HttpFrameType::PRIORITY_UPDATE_REQUEST_STREAM); - - output->reset(new char[total_length]); - QuicDataWriter writer(total_length, output->get()); - - if (WriteFrameHeader(payload_length, - HttpFrameType::PRIORITY_UPDATE_REQUEST_STREAM, - &writer) && - writer.WriteVarInt62(priority_update.prioritized_element_id) && - writer.WriteBytes(priority_update.priority_field_value.data(), - priority_update.priority_field_value.size())) { - return total_length; - } - - QUIC_DLOG(ERROR) << "Http encoder failed when attempting to serialize " - "PRIORITY_UPDATE frame."; + if (priority_update.prioritized_element_type != REQUEST_STREAM) { + QUIC_BUG << "PRIORITY_UPDATE for push streams not implemented"; return 0; } QuicByteCount payload_length = - kPriorityFirstByteLength + QuicDataWriter::GetVarInt62Len(priority_update.prioritized_element_id) + priority_update.priority_field_value.size(); - QuicByteCount total_length = - GetTotalLength(payload_length, HttpFrameType::PRIORITY_UPDATE); + QuicByteCount total_length = GetTotalLength( + payload_length, HttpFrameType::PRIORITY_UPDATE_REQUEST_STREAM); output->reset(new char[total_length]); QuicDataWriter writer(total_length, output->get()); - if (WriteFrameHeader(payload_length, HttpFrameType::PRIORITY_UPDATE, + if (WriteFrameHeader(payload_length, + HttpFrameType::PRIORITY_UPDATE_REQUEST_STREAM, &writer) && - writer.WriteUInt8(priority_update.prioritized_element_type) && writer.WriteVarInt62(priority_update.prioritized_element_id) && writer.WriteBytes(priority_update.priority_field_value.data(), priority_update.priority_field_value.size())) { @@ -258,6 +233,42 @@ QuicByteCount HttpEncoder::SerializePriorityUpdateFrame( } // static +QuicByteCount HttpEncoder::SerializeAcceptChFrame( + const AcceptChFrame& accept_ch, + std::unique_ptr<char[]>* output) { + QuicByteCount payload_length = 0; + for (const auto& entry : accept_ch.entries) { + payload_length += QuicDataWriter::GetVarInt62Len(entry.origin.size()); + payload_length += entry.origin.size(); + payload_length += QuicDataWriter::GetVarInt62Len(entry.value.size()); + payload_length += entry.value.size(); + } + + QuicByteCount total_length = + GetTotalLength(payload_length, HttpFrameType::ACCEPT_CH); + + output->reset(new char[total_length]); + QuicDataWriter writer(total_length, output->get()); + + if (!WriteFrameHeader(payload_length, HttpFrameType::ACCEPT_CH, &writer)) { + QUIC_DLOG(ERROR) + << "Http encoder failed to serialize ACCEPT_CH frame header."; + return 0; + } + + for (const auto& entry : accept_ch.entries) { + if (!writer.WriteStringPieceVarInt62(entry.origin) || + !writer.WriteStringPieceVarInt62(entry.value)) { + QUIC_DLOG(ERROR) + << "Http encoder failed to serialize ACCEPT_CH frame payload."; + return 0; + } + } + + return total_length; +} + +// static QuicByteCount HttpEncoder::SerializeGreasingFrame( std::unique_ptr<char[]>* output) { uint64_t frame_type; diff --git a/chromium/net/third_party/quiche/src/quic/core/http/http_encoder.h b/chromium/net/third_party/quiche/src/quic/core/http/http_encoder.h index 4d6a54a283e..429502b0cbb 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/http_encoder.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/http_encoder.h @@ -6,9 +6,9 @@ #define QUICHE_QUIC_CORE_HTTP_HTTP_ENCODER_H_ #include <memory> -#include "net/third_party/quiche/src/quic/core/http/http_frames.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/http/http_frames.h" +#include "quic/core/quic_error_codes.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -67,6 +67,11 @@ class QUIC_EXPORT_PRIVATE HttpEncoder { const PriorityUpdateFrame& priority_update, std::unique_ptr<char[]>* output); + // Serializes an ACCEPT_CH frame into a new buffer stored in |output|. + // Returns the length of the buffer on success, or 0 otherwise. + static QuicByteCount SerializeAcceptChFrame(const AcceptChFrame& accept_ch, + std::unique_ptr<char[]>* output); + // Serializes a frame with reserved frame type specified in // https://tools.ietf.org/html/draft-ietf-quic-http-25#section-7.2.9. static QuicByteCount SerializeGreasingFrame(std::unique_ptr<char[]>* output); diff --git a/chromium/net/third_party/quiche/src/quic/core/http/http_encoder_test.cc b/chromium/net/third_party/quiche/src/quic/core/http/http_encoder_test.cc index 2466326586c..ad25cc40dd5 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/http_encoder_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/http_encoder_test.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/http_encoder.h" +#include "quic/core/http/http_encoder.h" #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/test_tools/quiche_test_utils.h" namespace quic { namespace test { @@ -134,31 +134,12 @@ TEST(HttpEncoderTest, SerializeMaxPushIdFrame) { } TEST(HttpEncoderTest, SerializePriorityUpdateFrame) { - if (GetQuicReloadableFlag(quic_new_priority_update_frame)) { - PriorityUpdateFrame priority_update1; - priority_update1.prioritized_element_type = REQUEST_STREAM; - priority_update1.prioritized_element_id = 0x03; - char output1[] = {0x80, 0x0f, 0x07, 0x00, // type (PRIORITY_UPDATE) - 0x01, // length - 0x03}; // prioritized element id - - std::unique_ptr<char[]> buffer; - uint64_t length = - HttpEncoder::SerializePriorityUpdateFrame(priority_update1, &buffer); - EXPECT_EQ(ABSL_ARRAYSIZE(output1), length); - quiche::test::CompareCharArraysWithHexError("PRIORITY_UPDATE", buffer.get(), - length, output1, - ABSL_ARRAYSIZE(output1)); - return; - } - PriorityUpdateFrame priority_update1; priority_update1.prioritized_element_type = REQUEST_STREAM; priority_update1.prioritized_element_id = 0x03; - char output1[] = {0x0f, // type (PRIORITY_UPDATE) - 0x02, // length - 0x00, // prioritized element type: REQUEST_STREAM - 0x03}; // prioritized element id + char output1[] = {0x80, 0x0f, 0x07, 0x00, // type (PRIORITY_UPDATE) + 0x01, // length + 0x03}; // prioritized element id std::unique_ptr<char[]> buffer; uint64_t length = @@ -167,21 +148,29 @@ TEST(HttpEncoderTest, SerializePriorityUpdateFrame) { quiche::test::CompareCharArraysWithHexError("PRIORITY_UPDATE", buffer.get(), length, output1, ABSL_ARRAYSIZE(output1)); +} + +TEST(HttpEncoderTest, SerializeAcceptChFrame) { + AcceptChFrame accept_ch; + char output1[] = {0x40, 0x89, // type (ACCEPT_CH) + 0x00}; // length + + std::unique_ptr<char[]> buffer; + uint64_t length = HttpEncoder::SerializeAcceptChFrame(accept_ch, &buffer); + EXPECT_EQ(ABSL_ARRAYSIZE(output1), length); + quiche::test::CompareCharArraysWithHexError("ACCEPT_CH", buffer.get(), length, + output1, ABSL_ARRAYSIZE(output1)); - PriorityUpdateFrame priority_update2; - priority_update2.prioritized_element_type = PUSH_STREAM; - priority_update2.prioritized_element_id = 0x05; - priority_update2.priority_field_value = "foo"; - char output2[] = {0x0f, // type (PRIORIRTY) - 0x05, // length - 0x80, // prioritized element type: PUSH_STREAM - 0x05, // prioritized element id - 'f', 'o', 'o'}; // priority field value - length = HttpEncoder::SerializePriorityUpdateFrame(priority_update2, &buffer); + accept_ch.entries.push_back({"foo", "bar"}); + char output2[] = {0x40, 0x89, // type (ACCEPT_CH) + 0x08, // payload length + 0x03, 0x66, 0x6f, 0x6f, // length of "foo"; "foo" + 0x03, 0x62, 0x61, 0x72}; // length of "bar"; "bar" + + length = HttpEncoder::SerializeAcceptChFrame(accept_ch, &buffer); EXPECT_EQ(ABSL_ARRAYSIZE(output2), length); - quiche::test::CompareCharArraysWithHexError("PRIORITY_UPDATE", buffer.get(), - length, output2, - ABSL_ARRAYSIZE(output2)); + quiche::test::CompareCharArraysWithHexError("ACCEPT_CH", buffer.get(), length, + output2, ABSL_ARRAYSIZE(output2)); } } // namespace test diff --git a/chromium/net/third_party/quiche/src/quic/core/http/http_frames.h b/chromium/net/third_party/quiche/src/quic/core/http/http_frames.h index ed7ad2c2d24..34c3d607c0e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/http_frames.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/http_frames.h @@ -5,16 +5,17 @@ #ifndef QUICHE_QUIC_CORE_HTTP_HTTP_FRAMES_H_ #define QUICHE_QUIC_CORE_HTTP_HTTP_FRAMES_H_ +#include <algorithm> #include <cstdint> #include <map> #include <ostream> +#include <sstream> +#include "absl/container/flat_hash_map.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/spdy/core/spdy_framer.h" +#include "quic/core/http/http_constants.h" +#include "quic/core/quic_types.h" namespace quic { @@ -28,6 +29,8 @@ enum class HttpFrameType { MAX_PUSH_ID = 0xD, // https://tools.ietf.org/html/draft-ietf-httpbis-priority-01 PRIORITY_UPDATE = 0XF, + // https://tools.ietf.org/html/draft-davidben-http-client-hint-reliability-02 + ACCEPT_CH = 0x89, // https://tools.ietf.org/html/draft-ietf-httpbis-priority-02 PRIORITY_UPDATE_REQUEST_STREAM = 0xF0700, }; @@ -68,7 +71,7 @@ struct QUIC_EXPORT_PRIVATE CancelPushFrame { // affect how endpoints communicate, such as preferences and constraints // on peer behavior -using SettingsMap = QuicHashMap<uint64_t, uint64_t>; +using SettingsMap = absl::flat_hash_map<uint64_t, uint64_t>; struct QUIC_EXPORT_PRIVATE SettingsFrame { SettingsMap values; @@ -80,11 +83,11 @@ struct QUIC_EXPORT_PRIVATE SettingsFrame { std::string ToString() const { std::string s; for (auto it : values) { - std::string setting = quiche::QuicheStrCat( - SpdyUtils::H3SettingsToString( + std::string setting = absl::StrCat( + H3SettingsToString( static_cast<Http3AndQpackSettingsIdentifiers>(it.first)), " = ", it.second, "; "); - QuicStrAppend(&s, setting); + absl::StrAppend(&s, setting); } return s; } @@ -161,11 +164,10 @@ struct QUIC_EXPORT_PRIVATE PriorityUpdateFrame { rhs.priority_field_value); } std::string ToString() const { - return quiche::QuicheStrCat( - "Priority Frame : {prioritized_element_type: ", - static_cast<int>(prioritized_element_type), - ", prioritized_element_id: ", prioritized_element_id, - ", priority_field_value: ", priority_field_value, "}"); + return absl::StrCat("Priority Frame : {prioritized_element_type: ", + static_cast<int>(prioritized_element_type), + ", prioritized_element_id: ", prioritized_element_id, + ", priority_field_value: ", priority_field_value, "}"); } friend QUIC_EXPORT_PRIVATE std::ostream& operator<<( @@ -176,6 +178,42 @@ struct QUIC_EXPORT_PRIVATE PriorityUpdateFrame { } }; +// ACCEPT_CH +// https://tools.ietf.org/html/draft-davidben-http-client-hint-reliability-02 +// +struct QUIC_EXPORT_PRIVATE AcceptChFrame { + struct QUIC_EXPORT_PRIVATE OriginValuePair { + std::string origin; + std::string value; + bool operator==(const OriginValuePair& rhs) const { + return origin == rhs.origin && value == rhs.value; + } + }; + + std::vector<OriginValuePair> entries; + + bool operator==(const AcceptChFrame& rhs) const { + return entries.size() == rhs.entries.size() && + std::equal(entries.begin(), entries.end(), rhs.entries.begin()); + } + + std::string ToString() const { + std::stringstream s; + s << *this; + return s.str(); + } + + friend QUIC_EXPORT_PRIVATE std::ostream& operator<<( + std::ostream& os, + const AcceptChFrame& frame) { + os << "ACCEPT_CH frame with " << frame.entries.size() << " entries: "; + for (auto& entry : frame.entries) { + os << "origin: " << entry.origin << "; value: " << entry.value; + } + return os; + } +}; + } // namespace quic #endif // QUICHE_QUIC_CORE_HTTP_HTTP_FRAMES_H_ diff --git a/chromium/net/third_party/quiche/src/quic/core/http/http_frames_test.cc b/chromium/net/third_party/quiche/src/quic/core/http/http_frames_test.cc new file mode 100644 index 00000000000..c9a285dc8d9 --- /dev/null +++ b/chromium/net/third_party/quiche/src/quic/core/http/http_frames_test.cc @@ -0,0 +1,131 @@ +// Copyright (c) 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "quic/core/http/http_frames.h" + +#include <sstream> + +#include "quic/core/http/http_constants.h" +#include "quic/platform/api/quic_test.h" + +namespace quic { +namespace test { + +TEST(HttpFramesTest, CancelPushFrame) { + CancelPushFrame a{1}; + EXPECT_TRUE(a == a); + + CancelPushFrame b{1}; + EXPECT_TRUE(a == b); + + b.push_id = 2; + EXPECT_FALSE(a == b); +} + +TEST(HttpFramesTest, SettingsFrame) { + SettingsFrame a; + EXPECT_TRUE(a == a); + EXPECT_EQ("", a.ToString()); + + SettingsFrame b; + b.values[SETTINGS_QPACK_MAX_TABLE_CAPACITY] = 1; + EXPECT_FALSE(a == b); + EXPECT_TRUE(b == b); + + a.values[SETTINGS_QPACK_MAX_TABLE_CAPACITY] = 2; + EXPECT_FALSE(a == b); + a.values[SETTINGS_QPACK_MAX_TABLE_CAPACITY] = 1; + EXPECT_TRUE(a == b); + + EXPECT_EQ("SETTINGS_QPACK_MAX_TABLE_CAPACITY = 1; ", b.ToString()); + std::stringstream s; + s << b; + EXPECT_EQ("SETTINGS_QPACK_MAX_TABLE_CAPACITY = 1; ", s.str()); +} + +TEST(HttpFramesTest, PushPromiseFrame) { + PushPromiseFrame a{1, ""}; + EXPECT_TRUE(a == a); + + PushPromiseFrame b{2, ""}; + EXPECT_FALSE(a == b); + + b.push_id = 1; + EXPECT_TRUE(a == b); + + b.headers = "foo"; + EXPECT_FALSE(a == b); + EXPECT_TRUE(b == b); +} + +TEST(HttpFramesTest, GoAwayFrame) { + GoAwayFrame a{1}; + EXPECT_TRUE(a == a); + + GoAwayFrame b{2}; + EXPECT_FALSE(a == b); + + b.id = 1; + EXPECT_TRUE(a == b); +} + +TEST(HttpFramesTest, MaxPushIdFrame) { + MaxPushIdFrame a{1}; + EXPECT_TRUE(a == a); + + MaxPushIdFrame b{2}; + EXPECT_FALSE(a == b); + + b.push_id = 1; + EXPECT_TRUE(a == b); +} + +TEST(HttpFramesTest, PriorityUpdateFrame) { + PriorityUpdateFrame a{REQUEST_STREAM, 0, ""}; + EXPECT_TRUE(a == a); + PriorityUpdateFrame b{REQUEST_STREAM, 4, ""}; + EXPECT_FALSE(a == b); + a.prioritized_element_id = 4; + EXPECT_TRUE(a == b); + + a.prioritized_element_type = PUSH_STREAM; + EXPECT_FALSE(a == b); + b.prioritized_element_type = PUSH_STREAM; + EXPECT_TRUE(a == b); + + a.priority_field_value = "foo"; + EXPECT_FALSE(a == b); + + EXPECT_EQ( + "Priority Frame : {prioritized_element_type: 128, " + "prioritized_element_id: 4, priority_field_value: foo}", + a.ToString()); + std::stringstream s; + s << a; + EXPECT_EQ( + "Priority Frame : {prioritized_element_type: 128, " + "prioritized_element_id: 4, priority_field_value: foo}", + s.str()); +} + +TEST(HttpFramesTest, AcceptChFrame) { + AcceptChFrame a; + EXPECT_TRUE(a == a); + EXPECT_EQ("ACCEPT_CH frame with 0 entries: ", a.ToString()); + + AcceptChFrame b{{{"foo", "bar"}}}; + EXPECT_FALSE(a == b); + + a.entries.push_back({"foo", "bar"}); + EXPECT_TRUE(a == b); + + EXPECT_EQ("ACCEPT_CH frame with 1 entries: origin: foo; value: bar", + a.ToString()); + std::stringstream s; + s << a; + EXPECT_EQ("ACCEPT_CH frame with 1 entries: origin: foo; value: bar", s.str()); +} + +} // namespace test +} // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_client_promised_info.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_client_promised_info.cc index 607e16f1296..a32a6a8dbc9 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_client_promised_info.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_client_promised_info.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_client_promised_info.h" +#include "quic/core/http/quic_client_promised_info.h" #include <string> #include <utility> -#include "net/third_party/quiche/src/quic/core/http/spdy_server_push_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" +#include "quic/core/http/spdy_server_push_utils.h" +#include "quic/platform/api/quic_logging.h" +#include "spdy/core/spdy_protocol.h" using spdy::SpdyHeaderBlock; diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_client_promised_info.h b/chromium/net/third_party/quiche/src/quic/core/http/quic_client_promised_info.h index 9268940240e..0666c3ac02e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_client_promised_info.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_client_promised_info.h @@ -8,13 +8,13 @@ #include <cstddef> #include <string> -#include "net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session_base.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_alarm.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/spdy/core/spdy_framer.h" +#include "quic/core/http/quic_client_push_promise_index.h" +#include "quic/core/http/quic_spdy_client_session_base.h" +#include "quic/core/http/quic_spdy_stream.h" +#include "quic/core/quic_alarm.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_export.h" +#include "spdy/core/spdy_framer.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_client_promised_info_test.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_client_promised_info_test.cc index 9e21f41c50c..2f2b2a4125b 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_client_promised_info_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_client_promised_info_test.cc @@ -2,23 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_client_promised_info.h" +#include "quic/core/http/quic_client_promised_info.h" #include <memory> #include <string> #include <utility> -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_server_push_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.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/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_client_promised_info_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/http/quic_spdy_client_session.h" +#include "quic/core/http/spdy_server_push_utils.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/quic_client_promised_info_peer.h" +#include "quic/test_tools/quic_spdy_session_peer.h" +#include "quic/test_tools/quic_test_utils.h" using spdy::SpdyHeaderBlock; using testing::_; diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.cc index 877525a31e5..79e4f31c863 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.h" +#include "quic/core/http/quic_client_push_promise_index.h" #include <string> -#include "net/third_party/quiche/src/quic/core/http/quic_client_promised_info.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_server_push_utils.h" +#include "quic/core/http/quic_client_promised_info.h" +#include "quic/core/http/spdy_server_push_utils.h" using spdy::SpdyHeaderBlock; diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.h b/chromium/net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.h index 10e83c81eae..de070e6ef5e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.h @@ -7,9 +7,9 @@ #include <string> -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session_base.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/http/quic_spdy_client_session_base.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index_test.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index_test.cc index 3e825a05ce8..03f4eb7183a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index_test.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.h" +#include "quic/core/http/quic_client_push_promise_index.h" #include <string> -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_server_push_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/mock_quic_client_promised_info.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/http/quic_spdy_client_session.h" +#include "quic/core/http/spdy_server_push_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/mock_quic_client_promised_info.h" +#include "quic/test_tools/quic_spdy_session_peer.h" +#include "quic/test_tools/quic_test_utils.h" using testing::_; using testing::Return; diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_header_list.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_header_list.cc index 5282f2d852e..f7f656754e5 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_header_list.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_header_list.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_header_list.h" +#include "quic/core/http/quic_header_list.h" #include <limits> #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "quic/core/qpack/qpack_header_table.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_flags.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_header_list.h b/chromium/net/third_party/quiche/src/quic/core/http/quic_header_list.h index bc3a73bcf41..9ddf6de8a84 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_header_list.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_header_list.h @@ -11,11 +11,11 @@ #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_circular_deque.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" -#include "net/third_party/quiche/src/spdy/core/spdy_headers_handler_interface.h" +#include "quic/core/quic_circular_deque.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_export.h" +#include "spdy/core/spdy_header_block.h" +#include "spdy/core/spdy_headers_handler_interface.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_header_list_test.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_header_list_test.cc index 5ff3c5a6b58..edd52dd91ae 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_header_list_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_header_list_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_header_list.h" +#include "quic/core/http/quic_header_list.h" #include <string> -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" using ::testing::ElementsAre; using ::testing::Pair; diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_headers_stream.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_headers_stream.cc index 1cce85f7271..d8cfbdf3ba8 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_headers_stream.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_headers_stream.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_headers_stream.h" +#include "quic/core/http/quic_headers_stream.h" #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_session.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "quic/core/http/quic_spdy_session.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_headers_stream.h b/chromium/net/third_party/quiche/src/quic/core/http/quic_headers_stream.h index 3786ddf9c3a..ae9e2afe0d1 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_headers_stream.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_headers_stream.h @@ -8,12 +8,12 @@ #include <cstddef> #include <memory> -#include "net/third_party/quiche/src/quic/core/http/quic_header_list.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/spdy/core/spdy_framer.h" +#include "quic/core/http/quic_header_list.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_stream.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_export.h" +#include "spdy/core/spdy_framer.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_headers_stream_test.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_headers_stream_test.cc index 8f604b37dd4..cfccc922688 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_headers_stream_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_headers_stream_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_headers_stream.h" +#include "quic/core/http/quic_headers_stream.h" #include <cstdint> #include <ostream> @@ -11,27 +11,27 @@ #include <utility> #include <vector> +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#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_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" -#include "net/third_party/quiche/src/spdy/core/http2_frame_decoder_adapter.h" -#include "net/third_party/quiche/src/spdy/core/recording_headers_handler.h" -#include "net/third_party/quiche/src/spdy/core/spdy_alt_svc_wire_format.h" -#include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" -#include "net/third_party/quiche/src/spdy/core/spdy_test_utils.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/http/spdy_utils.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_spdy_session_peer.h" +#include "quic/test_tools/quic_stream_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/quiche_endian.h" +#include "spdy/core/http2_frame_decoder_adapter.h" +#include "spdy/core/recording_headers_handler.h" +#include "spdy/core/spdy_alt_svc_wire_format.h" +#include "spdy/core/spdy_protocol.h" +#include "spdy/core/spdy_test_utils.h" using spdy::ERROR_CODE_PROTOCOL_ERROR; using spdy::RecordingHeadersHandler; @@ -162,6 +162,11 @@ class MockVisitor : public SpdyFramerVisitorInterface { int weight, bool exclusive), (override)); + MOCK_METHOD(void, + OnPriorityUpdate, + (SpdyStreamId prioritized_stream_id, + absl::string_view priority_field_value), + (override)); MOCK_METHOD(bool, OnUnknownFrame, (SpdyStreamId stream_id, uint8_t frame_type), @@ -191,7 +196,7 @@ struct TestParams { // Used by ::testing::PrintToStringParamName(). std::string PrintToString(const TestParams& tp) { - return quiche::QuicheStrCat( + return absl::StrCat( ParsedQuicVersionToString(tp.version), "_", (tp.perspective == Perspective::IS_CLIENT ? "client" : "server")); } @@ -687,36 +692,32 @@ TEST_P(QuicHeadersStreamTest, RespectHttp2SettingsFrameUnsupportedFields) { data.AddSetting(SETTINGS_ENABLE_PUSH, 1); data.AddSetting(SETTINGS_MAX_FRAME_SIZE, 1250); SpdySerializedFrame frame(framer_->SerializeFrame(data)); - EXPECT_CALL( - *connection_, - CloseConnection( - QUIC_INVALID_HEADERS_STREAM_DATA, - quiche::QuicheStrCat("Unsupported field of HTTP/2 SETTINGS frame: ", + EXPECT_CALL(*connection_, + CloseConnection( + QUIC_INVALID_HEADERS_STREAM_DATA, + absl::StrCat("Unsupported field of HTTP/2 SETTINGS frame: ", SETTINGS_MAX_CONCURRENT_STREAMS), - _)); - EXPECT_CALL( - *connection_, - CloseConnection( - QUIC_INVALID_HEADERS_STREAM_DATA, - quiche::QuicheStrCat("Unsupported field of HTTP/2 SETTINGS frame: ", + _)); + EXPECT_CALL(*connection_, + CloseConnection( + QUIC_INVALID_HEADERS_STREAM_DATA, + absl::StrCat("Unsupported field of HTTP/2 SETTINGS frame: ", SETTINGS_INITIAL_WINDOW_SIZE), - _)); + _)); if (session_.perspective() == Perspective::IS_CLIENT) { - EXPECT_CALL( - *connection_, - CloseConnection( - QUIC_INVALID_HEADERS_STREAM_DATA, - quiche::QuicheStrCat("Unsupported field of HTTP/2 SETTINGS frame: ", + EXPECT_CALL(*connection_, + CloseConnection( + QUIC_INVALID_HEADERS_STREAM_DATA, + absl::StrCat("Unsupported field of HTTP/2 SETTINGS frame: ", SETTINGS_ENABLE_PUSH), - _)); + _)); } - EXPECT_CALL( - *connection_, - CloseConnection( - QUIC_INVALID_HEADERS_STREAM_DATA, - quiche::QuicheStrCat("Unsupported field of HTTP/2 SETTINGS frame: ", + EXPECT_CALL(*connection_, + CloseConnection( + QUIC_INVALID_HEADERS_STREAM_DATA, + absl::StrCat("Unsupported field of HTTP/2 SETTINGS frame: ", SETTINGS_MAX_FRAME_SIZE), - _)); + _)); stream_frame_.data_buffer = frame.data(); stream_frame_.data_length = frame.size(); headers_stream_->OnStreamFrame(stream_frame_); diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_receive_control_stream.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_receive_control_stream.cc index 4f5f1cf186c..35d590286cb 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_receive_control_stream.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_receive_control_stream.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_receive_control_stream.h" +#include "quic/core/http/quic_receive_control_stream.h" #include <utility> #include "absl/strings/numbers.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/http/http_constants.h" -#include "net/third_party/quiche/src/quic/core/http/http_decoder.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_session.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/http/http_constants.h" +#include "quic/core/http/http_decoder.h" +#include "quic/core/http/quic_spdy_session.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { @@ -45,7 +45,7 @@ void QuicReceiveControlStream::OnDataAvailable() { iovec iov; while (!reading_stopped() && decoder_.error() == QUIC_NO_ERROR && sequencer()->GetReadableRegion(&iov)) { - DCHECK(!sequencer()->IsClosed()); + QUICHE_DCHECK(!sequencer()->IsClosed()); QuicByteCount processed_bytes = decoder_.ProcessInput( reinterpret_cast<const char*>(iov.iov_base), iov.iov_len); @@ -57,12 +57,12 @@ void QuicReceiveControlStream::OnDataAvailable() { // The only reason QuicReceiveControlStream pauses HttpDecoder is an error, // in which case the connection would have already been closed. - DCHECK_EQ(iov.iov_len, processed_bytes); + QUICHE_DCHECK_EQ(iov.iov_len, processed_bytes); } } void QuicReceiveControlStream::OnError(HttpDecoder* decoder) { - OnUnrecoverableError(decoder->error(), decoder->error_detail()); + stream_delegate()->OnStreamError(decoder->error(), decoder->error_detail()); } bool QuicReceiveControlStream::OnCancelPushFrame(const CancelPushFrame& frame) { @@ -70,15 +70,8 @@ bool QuicReceiveControlStream::OnCancelPushFrame(const CancelPushFrame& frame) { spdy_session()->debug_visitor()->OnCancelPushFrameReceived(frame); } - if (!settings_frame_received_) { - stream_delegate()->OnStreamError( - QUIC_HTTP_MISSING_SETTINGS_FRAME, - "CANCEL_PUSH frame received before SETTINGS."); - return false; - } - // TODO(b/151841240): Handle CANCEL_PUSH frames instead of ignoring them. - return true; + return ValidateFrameType(HttpFrameType::CANCEL_PUSH); } bool QuicReceiveControlStream::OnMaxPushIdFrame(const MaxPushIdFrame& frame) { @@ -86,15 +79,7 @@ bool QuicReceiveControlStream::OnMaxPushIdFrame(const MaxPushIdFrame& frame) { spdy_session()->debug_visitor()->OnMaxPushIdFrameReceived(frame); } - if (!settings_frame_received_) { - stream_delegate()->OnStreamError( - QUIC_HTTP_MISSING_SETTINGS_FRAME, - "MAX_PUSH_ID frame received before SETTINGS."); - return false; - } - - if (spdy_session()->perspective() == Perspective::IS_CLIENT) { - OnWrongFrame("Max Push Id"); + if (!ValidateFrameType(HttpFrameType::MAX_PUSH_ID)) { return false; } @@ -106,9 +91,7 @@ bool QuicReceiveControlStream::OnGoAwayFrame(const GoAwayFrame& frame) { spdy_session()->debug_visitor()->OnGoAwayFrameReceived(frame); } - if (!settings_frame_received_) { - stream_delegate()->OnStreamError(QUIC_HTTP_MISSING_SETTINGS_FRAME, - "GOAWAY frame received before SETTINGS."); + if (!ValidateFrameType(HttpFrameType::GOAWAY)) { return false; } @@ -118,16 +101,7 @@ bool QuicReceiveControlStream::OnGoAwayFrame(const GoAwayFrame& frame) { bool QuicReceiveControlStream::OnSettingsFrameStart( QuicByteCount /*header_length*/) { - if (settings_frame_received_) { - stream_delegate()->OnStreamError( - QUIC_HTTP_INVALID_FRAME_SEQUENCE_ON_CONTROL_STREAM, - "Settings frames are received twice."); - return false; - } - - settings_frame_received_ = true; - - return true; + return ValidateFrameType(HttpFrameType::SETTINGS); } bool QuicReceiveControlStream::OnSettingsFrame(const SettingsFrame& frame) { @@ -139,18 +113,17 @@ bool QuicReceiveControlStream::OnSettingsFrame(const SettingsFrame& frame) { bool QuicReceiveControlStream::OnDataFrameStart(QuicByteCount /*header_length*/, QuicByteCount /*payload_length*/) { - OnWrongFrame("Data"); - return false; + return ValidateFrameType(HttpFrameType::DATA); } bool QuicReceiveControlStream::OnDataFramePayload( absl::string_view /*payload*/) { - OnWrongFrame("Data"); + QUICHE_NOTREACHED(); return false; } bool QuicReceiveControlStream::OnDataFrameEnd() { - OnWrongFrame("Data"); + QUICHE_NOTREACHED(); return false; } @@ -158,55 +131,47 @@ bool QuicReceiveControlStream::OnHeadersFrameStart( QuicByteCount /*header_length*/, QuicByteCount /*payload_length*/) { - OnWrongFrame("Headers"); - return false; + return ValidateFrameType(HttpFrameType::HEADERS); } bool QuicReceiveControlStream::OnHeadersFramePayload( absl::string_view /*payload*/) { - OnWrongFrame("Headers"); + QUICHE_NOTREACHED(); return false; } bool QuicReceiveControlStream::OnHeadersFrameEnd() { - OnWrongFrame("Headers"); + QUICHE_NOTREACHED(); return false; } bool QuicReceiveControlStream::OnPushPromiseFrameStart( QuicByteCount /*header_length*/) { - OnWrongFrame("Push Promise"); - return false; + return ValidateFrameType(HttpFrameType::PUSH_PROMISE); } bool QuicReceiveControlStream::OnPushPromiseFramePushId( PushId /*push_id*/, QuicByteCount /*push_id_length*/, QuicByteCount /*header_block_length*/) { - OnWrongFrame("Push Promise"); + QUICHE_NOTREACHED(); return false; } bool QuicReceiveControlStream::OnPushPromiseFramePayload( absl::string_view /*payload*/) { - OnWrongFrame("Push Promise"); + QUICHE_NOTREACHED(); return false; } bool QuicReceiveControlStream::OnPushPromiseFrameEnd() { - OnWrongFrame("Push Promise"); + QUICHE_NOTREACHED(); return false; } bool QuicReceiveControlStream::OnPriorityUpdateFrameStart( QuicByteCount /*header_length*/) { - if (!settings_frame_received_) { - stream_delegate()->OnStreamError( - QUIC_HTTP_MISSING_SETTINGS_FRAME, - "PRIORITY_UPDATE frame received before SETTINGS."); - return false; - } - return true; + return ValidateFrameType(HttpFrameType::PRIORITY_UPDATE); } bool QuicReceiveControlStream::OnPriorityUpdateFrame( @@ -234,7 +199,7 @@ bool QuicReceiveControlStream::OnPriorityUpdateFrame( int urgency; if (!absl::SimpleAtoi(value, &urgency) || urgency < 0 || urgency > 7) { stream_delegate()->OnStreamError( - QUIC_INVALID_STREAM_ID, + QUIC_INVALID_PRIORITY_UPDATE, "Invalid value for PRIORITY_UPDATE urgency parameter."); return false; } @@ -252,6 +217,22 @@ bool QuicReceiveControlStream::OnPriorityUpdateFrame( return true; } +bool QuicReceiveControlStream::OnAcceptChFrameStart( + QuicByteCount /* header_length */) { + return ValidateFrameType(HttpFrameType::ACCEPT_CH); +} + +bool QuicReceiveControlStream::OnAcceptChFrame(const AcceptChFrame& frame) { + QUICHE_DCHECK_EQ(Perspective::IS_CLIENT, spdy_session()->perspective()); + + if (spdy_session()->debug_visitor()) { + spdy_session()->debug_visitor()->OnAcceptChFrameReceived(frame); + } + + spdy_session()->OnAcceptChFrame(frame); + return true; +} + bool QuicReceiveControlStream::OnUnknownFrameStart( uint64_t frame_type, QuicByteCount /*header_length*/, @@ -261,13 +242,7 @@ bool QuicReceiveControlStream::OnUnknownFrameStart( payload_length); } - if (!settings_frame_received_) { - stream_delegate()->OnStreamError(QUIC_HTTP_MISSING_SETTINGS_FRAME, - "Unknown frame received before SETTINGS."); - return false; - } - - return true; + return ValidateFrameType(static_cast<HttpFrameType>(frame_type)); } bool QuicReceiveControlStream::OnUnknownFramePayload( @@ -281,10 +256,43 @@ bool QuicReceiveControlStream::OnUnknownFrameEnd() { return true; } -void QuicReceiveControlStream::OnWrongFrame(absl::string_view frame_type) { - OnUnrecoverableError( - QUIC_HTTP_FRAME_UNEXPECTED_ON_CONTROL_STREAM, - quiche::QuicheStrCat(frame_type, " frame received on control stream")); +bool QuicReceiveControlStream::ValidateFrameType(HttpFrameType frame_type) { + // Certain frame types are forbidden. + if ((frame_type == HttpFrameType::DATA || + frame_type == HttpFrameType::HEADERS || + frame_type == HttpFrameType::PUSH_PROMISE) || + (spdy_session()->perspective() == Perspective::IS_CLIENT && + frame_type == HttpFrameType::MAX_PUSH_ID) || + (GetQuicReloadableFlag(quic_parse_accept_ch_frame) && + spdy_session()->perspective() == Perspective::IS_SERVER && + frame_type == HttpFrameType::ACCEPT_CH)) { + stream_delegate()->OnStreamError( + QUIC_HTTP_FRAME_UNEXPECTED_ON_CONTROL_STREAM, + absl::StrCat("Invalid frame type ", static_cast<int>(frame_type), + " received on control stream.")); + return false; + } + + if (settings_frame_received_) { + if (frame_type == HttpFrameType::SETTINGS) { + // SETTINGS frame may only be the first frame on the control stream. + stream_delegate()->OnStreamError( + QUIC_HTTP_INVALID_FRAME_SEQUENCE_ON_CONTROL_STREAM, + "SETTINGS frame can only be received once."); + return false; + } + return true; + } + + if (frame_type == HttpFrameType::SETTINGS) { + settings_frame_received_ = true; + return true; + } + stream_delegate()->OnStreamError( + QUIC_HTTP_MISSING_SETTINGS_FRAME, + absl::StrCat("First frame received on control stream is type ", + static_cast<int>(frame_type), ", but it must be SETTINGS.")); + return false; } } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_receive_control_stream.h b/chromium/net/third_party/quiche/src/quic/core/http/quic_receive_control_stream.h index 2654bb8e549..326dba3e38a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_receive_control_stream.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_receive_control_stream.h @@ -5,10 +5,10 @@ #ifndef QUICHE_QUIC_CORE_HTTP_QUIC_RECEIVE_CONTROL_STREAM_H_ #define QUICHE_QUIC_CORE_HTTP_QUIC_RECEIVE_CONTROL_STREAM_H_ -#include "net/third_party/quiche/src/quic/core/http/http_decoder.h" -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/http/http_decoder.h" +#include "quic/core/quic_stream.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -56,6 +56,8 @@ class QUIC_EXPORT_PRIVATE QuicReceiveControlStream bool OnPushPromiseFrameEnd() override; bool OnPriorityUpdateFrameStart(QuicByteCount header_length) override; bool OnPriorityUpdateFrame(const PriorityUpdateFrame& frame) override; + bool OnAcceptChFrameStart(QuicByteCount header_length) override; + bool OnAcceptChFrame(const AcceptChFrame& frame) override; bool OnUnknownFrameStart(uint64_t frame_type, QuicByteCount header_length, QuicByteCount payload_length) override; @@ -67,7 +69,10 @@ class QUIC_EXPORT_PRIVATE QuicReceiveControlStream QuicSpdySession* spdy_session() { return spdy_session_; } private: - void OnWrongFrame(absl::string_view frame_type); + // Called when a frame of allowed type is received. Returns true if the frame + // is allowed in this position. Returns false and resets the stream + // otherwise. + bool ValidateFrameType(HttpFrameType frame_type); // False until a SETTINGS frame is received. bool settings_frame_received_; diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_receive_control_stream_test.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_receive_control_stream_test.cc index 5a401b68019..3e4532f4a66 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_receive_control_stream_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_receive_control_stream_test.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_receive_control_stream.h" +#include "quic/core/http/quic_receive_control_stream.h" #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/http/http_constants.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/http/http_constants.h" +#include "quic/core/qpack/qpack_header_table.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/test_tools/qpack/qpack_encoder_peer.h" +#include "quic/test_tools/quic_spdy_session_peer.h" +#include "quic/test_tools/quic_stream_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { @@ -51,7 +51,7 @@ struct TestParams { // Used by ::testing::PrintToStringParamName(). std::string PrintToString(const TestParams& tp) { - return quiche::QuicheStrCat( + return absl::StrCat( ParsedQuicVersionToString(tp.version), "_", (tp.perspective == Perspective::IS_CLIENT ? "client" : "server")); } @@ -206,10 +206,10 @@ TEST_P(QuicReceiveControlStreamTest, ReceiveSettingsTwice) { EXPECT_CALL( *connection_, CloseConnection(QUIC_HTTP_INVALID_FRAME_SEQUENCE_ON_CONTROL_STREAM, - "Settings frames are received twice.", _)) + "SETTINGS frame can only be received once.", _)) .WillOnce( Invoke(connection_, &MockQuicConnection::ReallyCloseConnection)); - EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _)); + EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _, _)); EXPECT_CALL(session_, OnConnectionClosed(_, _)); // Receive second SETTINGS frame. @@ -258,13 +258,14 @@ TEST_P(QuicReceiveControlStreamTest, QuicStreamFrame data(receive_control_stream_->id(), /* fin = */ false, /* offset = */ 1, serialized_frame); - EXPECT_CALL( - *connection_, - CloseConnection(QUIC_HTTP_MISSING_SETTINGS_FRAME, - "PRIORITY_UPDATE frame received before SETTINGS.", _)) + EXPECT_CALL(*connection_, + CloseConnection(QUIC_HTTP_MISSING_SETTINGS_FRAME, + "First frame received on control stream is type " + "15, but it must be SETTINGS.", + _)) .WillOnce( Invoke(connection_, &MockQuicConnection::ReallyCloseConnection)); - EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _)); + EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _, _)); EXPECT_CALL(session_, OnConnectionClosed(_, _)); receive_control_stream_->OnStreamFrame(data); @@ -315,7 +316,7 @@ TEST_P(QuicReceiveControlStreamTest, PushPromiseOnControlStreamShouldClose) { CloseConnection(QUIC_HTTP_FRAME_UNEXPECTED_ON_CONTROL_STREAM, _, _)) .WillOnce( Invoke(connection_, &MockQuicConnection::ReallyCloseConnection)); - EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _)); + EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _, _)); EXPECT_CALL(session_, OnConnectionClosed(_, _)); receive_control_stream_->OnStreamFrame(frame); } @@ -385,10 +386,12 @@ TEST_P(QuicReceiveControlStreamTest, CancelPushFrameBeforeSettings) { EXPECT_CALL(*connection_, CloseConnection(QUIC_HTTP_MISSING_SETTINGS_FRAME, - "CANCEL_PUSH frame received before SETTINGS.", _)) + "First frame received on control stream is type " + "3, but it must be SETTINGS.", + _)) .WillOnce( Invoke(connection_, &MockQuicConnection::ReallyCloseConnection)); - EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _)); + EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _, _)); EXPECT_CALL(session_, OnConnectionClosed(_, _)); receive_control_stream_->OnStreamFrame( @@ -396,6 +399,79 @@ TEST_P(QuicReceiveControlStreamTest, CancelPushFrameBeforeSettings) { /* offset = */ 1, cancel_push_frame)); } +TEST_P(QuicReceiveControlStreamTest, AcceptChFrameBeforeSettings) { + std::string accept_ch_frame = absl::HexStringToBytes( + "4089" // type (ACCEPT_CH) + "00"); // length + + if (GetQuicReloadableFlag(quic_parse_accept_ch_frame) && + perspective() == Perspective::IS_SERVER) { + EXPECT_CALL(*connection_, + CloseConnection( + QUIC_HTTP_FRAME_UNEXPECTED_ON_CONTROL_STREAM, + "Invalid frame type 137 received on control stream.", _)) + .WillOnce( + Invoke(connection_, &MockQuicConnection::ReallyCloseConnection)); + } else { + EXPECT_CALL(*connection_, + CloseConnection(QUIC_HTTP_MISSING_SETTINGS_FRAME, + "First frame received on control stream is " + "type 137, but it must be SETTINGS.", + _)) + .WillOnce( + Invoke(connection_, &MockQuicConnection::ReallyCloseConnection)); + } + EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _, _)); + EXPECT_CALL(session_, OnConnectionClosed(_, _)); + + receive_control_stream_->OnStreamFrame( + QuicStreamFrame(receive_control_stream_->id(), /* fin = */ false, + /* offset = */ 1, accept_ch_frame)); +} + +TEST_P(QuicReceiveControlStreamTest, ReceiveAcceptChFrame) { + StrictMock<MockHttp3DebugVisitor> debug_visitor; + session_.set_debug_visitor(&debug_visitor); + + const QuicStreamId id = receive_control_stream_->id(); + QuicStreamOffset offset = 1; + + // Receive SETTINGS frame. + SettingsFrame settings; + std::string settings_frame = EncodeSettings(settings); + EXPECT_CALL(debug_visitor, OnSettingsFrameReceived(settings)); + receive_control_stream_->OnStreamFrame( + QuicStreamFrame(id, /* fin = */ false, offset, settings_frame)); + offset += settings_frame.length(); + + // Receive ACCEPT_CH frame. + std::string accept_ch_frame = absl::HexStringToBytes( + "4089" // type (ACCEPT_CH) + "00"); // length + + if (GetQuicReloadableFlag(quic_parse_accept_ch_frame)) { + if (perspective() == Perspective::IS_CLIENT) { + EXPECT_CALL(debug_visitor, OnAcceptChFrameReceived(_)); + } else { + EXPECT_CALL(*connection_, + CloseConnection( + QUIC_HTTP_FRAME_UNEXPECTED_ON_CONTROL_STREAM, + "Invalid frame type 137 received on control stream.", _)) + .WillOnce( + Invoke(connection_, &MockQuicConnection::ReallyCloseConnection)); + EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _, _)); + EXPECT_CALL(session_, OnConnectionClosed(_, _)); + } + } else { + EXPECT_CALL(debug_visitor, + OnUnknownFrameReceived(id, /* frame_type = */ 0x89, + /* payload_length = */ 0)); + } + + receive_control_stream_->OnStreamFrame( + QuicStreamFrame(id, /* fin = */ false, offset, accept_ch_frame)); +} + TEST_P(QuicReceiveControlStreamTest, UnknownFrameBeforeSettings) { std::string unknown_frame = absl::HexStringToBytes( "21" // reserved frame type @@ -404,10 +480,12 @@ TEST_P(QuicReceiveControlStreamTest, UnknownFrameBeforeSettings) { EXPECT_CALL(*connection_, CloseConnection(QUIC_HTTP_MISSING_SETTINGS_FRAME, - "Unknown frame received before SETTINGS.", _)) + "First frame received on control stream is type " + "33, but it must be SETTINGS.", + _)) .WillOnce( Invoke(connection_, &MockQuicConnection::ReallyCloseConnection)); - EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _)); + EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _, _)); EXPECT_CALL(session_, OnConnectionClosed(_, _)); receive_control_stream_->OnStreamFrame( diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_send_control_stream.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_send_control_stream.cc index 939c32724db..833413039a7 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_send_control_stream.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_send_control_stream.cc @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_send_control_stream.h" +#include "quic/core/http/quic_send_control_stream.h" #include <cstdint> #include <memory> #include "absl/base/macros.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/http/http_constants.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_session.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/http/http_constants.h" +#include "quic/core/http/quic_spdy_session.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -104,7 +104,7 @@ void QuicSendControlStream::WritePriorityUpdate( } void QuicSendControlStream::SendMaxPushIdFrame(PushId max_push_id) { - DCHECK_EQ(Perspective::IS_CLIENT, session()->perspective()); + QUICHE_DCHECK_EQ(Perspective::IS_CLIENT, session()->perspective()); QuicConnection::ScopedPacketFlusher flusher(session()->connection()); MaybeSendSettingsFrame(); @@ -126,12 +126,6 @@ void QuicSendControlStream::SendGoAway(QuicStreamId id) { MaybeSendSettingsFrame(); GoAwayFrame frame; - // If the peer has not created any stream yet, use stream ID 0 to indicate no - // request is accepted. - if (!GetQuicReloadableFlag(quic_fix_http3_goaway_stream_id) && - id == QuicUtils::GetInvalidStreamId(session()->transport_version())) { - id = 0; - } frame.id = id; if (spdy_session_->debug_visitor()) { spdy_session_->debug_visitor()->OnGoAwayFrameSent(id); diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_send_control_stream.h b/chromium/net/third_party/quiche/src/quic/core/http/quic_send_control_stream.h index 25ea5b7a192..155b423ae72 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_send_control_stream.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_send_control_stream.h @@ -5,11 +5,11 @@ #ifndef QUICHE_QUIC_CORE_HTTP_QUIC_SEND_CONTROL_STREAM_H_ #define QUICHE_QUIC_CORE_HTTP_QUIC_SEND_CONTROL_STREAM_H_ -#include "net/third_party/quiche/src/quic/core/http/http_encoder.h" -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/http/http_encoder.h" +#include "quic/core/quic_stream.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_logging.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_send_control_stream_test.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_send_control_stream_test.cc index 4f1b461d0f5..fe849733c82 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_send_control_stream_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_send_control_stream_test.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_send_control_stream.h" +#include "quic/core/http/quic_send_control_stream.h" #include <utility> #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_spdy_session_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { namespace test { @@ -48,7 +48,7 @@ struct TestParams { // Used by ::testing::PrintToStringParamName(). std::string PrintToString(const TestParams& tp) { - return quiche::QuicheStrCat( + return absl::StrCat( ParsedQuicVersionToString(tp.version), "_", (tp.perspective == Perspective::IS_CLIENT ? "client" : "server")); } diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_server_session_base.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_server_session_base.cc index c4082571003..f91146b3b49 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_server_session_base.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_server_session_base.cc @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_server_session_base.h" +#include "quic/core/http/quic_server_session_base.h" #include <string> -#include "net/third_party/quiche/src/quic/core/proto/cached_network_parameters_proto.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_tag.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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 "quic/core/proto/cached_network_parameters_proto.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_stream.h" +#include "quic/core/quic_tag.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_server_session_base.h b/chromium/net/third_party/quiche/src/quic/core/http/quic_server_session_base.h index b4a467fedff..9bdaa30adf9 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_server_session_base.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_server_session_base.h @@ -13,11 +13,11 @@ #include <string> #include <vector> -#include "net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_session.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/quic_compressed_certs_cache.h" +#include "quic/core/http/quic_spdy_session.h" +#include "quic/core/quic_crypto_server_stream_base.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_server_session_base_test.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_server_session_base_test.cc index 4abde4262ac..f9483fefeeb 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_server_session_base_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_server_session_base_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_server_session_base.h" +#include "quic/core/http/quic_server_session_base.h" #include <cstdint> #include <memory> @@ -10,36 +10,36 @@ #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/proto/cached_network_parameters_proto.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/tls_server_handshaker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.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/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/fake_proof_source.h" -#include "net/third_party/quiche/src/quic/test_tools/mock_quic_session_visitor.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_crypto_server_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_server_session_base_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_id_manager_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_sustained_bandwidth_recorder_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_stream.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/crypto/quic_crypto_server_config.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/proto/cached_network_parameters_proto.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_crypto_server_stream.h" +#include "quic/core/quic_crypto_server_stream_base.h" +#include "quic/core/quic_utils.h" +#include "quic/core/tls_server_handshaker.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/fake_proof_source.h" +#include "quic/test_tools/mock_quic_session_visitor.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_crypto_server_config_peer.h" +#include "quic/test_tools/quic_sent_packet_manager_peer.h" +#include "quic/test_tools/quic_server_session_base_peer.h" +#include "quic/test_tools/quic_session_peer.h" +#include "quic/test_tools/quic_spdy_session_peer.h" +#include "quic/test_tools/quic_stream_id_manager_peer.h" +#include "quic/test_tools/quic_stream_peer.h" +#include "quic/test_tools/quic_sustained_bandwidth_recorder_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/tools/quic_memory_cache_backend.h" +#include "quic/tools/quic_simple_server_stream.h" using testing::_; using testing::StrictMock; @@ -95,7 +95,7 @@ class TestServerSession : public QuicServerSessionBase { } QuicSpdyStream* CreateOutgoingBidirectionalStream() override { - DCHECK(false); + QUICHE_DCHECK(false); return nullptr; } @@ -492,7 +492,7 @@ class MockQuicCryptoServerStream : public QuicCryptoServerStream { class MockTlsServerHandshaker : public TlsServerHandshaker { public: explicit MockTlsServerHandshaker(QuicServerSessionBase* session, - const QuicCryptoServerConfig& crypto_config) + const QuicCryptoServerConfig* crypto_config) : TlsServerHandshaker(session, crypto_config) {} MockTlsServerHandshaker(const MockTlsServerHandshaker&) = delete; MockTlsServerHandshaker& operator=(const MockTlsServerHandshaker&) = delete; @@ -542,7 +542,7 @@ TEST_P(QuicServerSessionBaseTest, BandwidthEstimates) { quic_crypto_stream); } else { tls_server_stream = - new MockTlsServerHandshaker(session_.get(), crypto_config_); + new MockTlsServerHandshaker(session_.get(), &crypto_config_); QuicServerSessionBasePeer::SetCryptoStream(session_.get(), tls_server_stream); } diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.cc index d7a7b034bfe..ba5b457052e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.cc @@ -2,21 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h" +#include "quic/core/http/quic_spdy_client_session.h" #include <string> #include <utility> -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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_ptr_util.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/http/quic_spdy_client_stream.h" +#include "quic/core/http/spdy_utils.h" +#include "quic/core/quic_server_id.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_ptr_util.h" namespace quic { @@ -103,7 +103,7 @@ const QuicCryptoClientStreamBase* QuicSpdyClientSession::GetCryptoStream() } void QuicSpdyClientSession::CryptoConnect() { - DCHECK(flow_controller()); + QUICHE_DCHECK(flow_controller()); crypto_stream_->CryptoConnect(); } diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h index e8171baf8a1..c21eeea4c81 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h @@ -10,10 +10,10 @@ #include <memory> #include <string> -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session_base.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_client_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" +#include "quic/core/http/quic_spdy_client_session_base.h" +#include "quic/core/http/quic_spdy_client_stream.h" +#include "quic/core/quic_crypto_client_stream.h" +#include "quic/core/quic_packets.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session_base.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session_base.cc index 1bfe2a74e68..49f0198a041 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session_base.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session_base.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session_base.h" +#include "quic/core/http/quic_spdy_client_session_base.h" #include <string> -#include "net/third_party/quiche/src/quic/core/http/quic_client_promised_info.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_server_push_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#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 "quic/core/http/quic_client_promised_info.h" +#include "quic/core/http/spdy_server_push_utils.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" using spdy::SpdyHeaderBlock; @@ -155,7 +155,7 @@ bool QuicSpdyClientSessionBase::HandlePromised(QuicStreamId /* associated_id */, promised_by_id_[promised_id] = std::move(promised_owner); bool result = promised->OnPromiseHeaders(headers); if (result) { - DCHECK(promised_by_id_.find(promised_id) != promised_by_id_.end()); + QUICHE_DCHECK(promised_by_id_.find(promised_id) != promised_by_id_.end()); } return result; } @@ -206,7 +206,7 @@ void QuicSpdyClientSessionBase::OnPushStreamTimedOut( void QuicSpdyClientSessionBase::ResetPromised( QuicStreamId id, QuicRstStreamErrorCode error_code) { - DCHECK(QuicUtils::IsServerInitiatedStreamId(transport_version(), id)); + QUICHE_DCHECK(QuicUtils::IsServerInitiatedStreamId(transport_version(), id)); ResetStream(id, error_code); if (!IsOpenStream(id) && !IsClosedStream(id)) { MaybeIncreaseLargestPeerStreamId(id); diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session_base.h b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session_base.h index e09f7cfdac6..71236bf8d46 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session_base.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session_base.h @@ -7,10 +7,11 @@ #include <string> -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_session.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_client_stream.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "absl/container/flat_hash_map.h" +#include "quic/core/http/quic_spdy_session.h" +#include "quic/core/quic_crypto_client_stream.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -24,7 +25,8 @@ class QuicSpdyClientStream; // to authority constraints). Clients should use this map to enforce // session affinity for requests corresponding to cross-origin push // promised streams. -using QuicPromisedByUrlMap = QuicHashMap<std::string, QuicClientPromisedInfo*>; +using QuicPromisedByUrlMap = + absl::flat_hash_map<std::string, QuicClientPromisedInfo*>; // The maximum time a promises stream can be reserved without being // claimed by a client request. @@ -126,7 +128,8 @@ class QUIC_EXPORT_PRIVATE QuicSpdyClientSessionBase // For QuicSpdyClientStream to detect that a response corresponds to a // promise. using QuicPromisedByIdMap = - QuicHashMap<QuicStreamId, std::unique_ptr<QuicClientPromisedInfo>>; + absl::flat_hash_map<QuicStreamId, + std::unique_ptr<QuicClientPromisedInfo>>; // As per rfc7540, section 10.5: track promise streams in "reserved // (remote)". The primary key is URL from the promise request diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session_test.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session_test.cc index 5444c9d9d55..e2b5003bc4a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_session_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h" +#include "quic/core/http/quic_spdy_client_session.h" #include <memory> #include <string> @@ -10,35 +10,35 @@ #include <vector> #include "absl/base/macros.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/http/http_constants.h" -#include "net/third_party/quiche/src/quic/core/http/http_frames.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_server_push_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/core/tls_client_handshaker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.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/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/mock_quic_spdy_client_stream.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_framer_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_packet_creator_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/simple_session_cache.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "quic/core/crypto/null_decrypter.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/http/http_constants.h" +#include "quic/core/http/http_frames.h" +#include "quic/core/http/quic_spdy_client_stream.h" +#include "quic/core/http/spdy_server_push_utils.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/core/tls_client_handshaker.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/mock_quic_spdy_client_stream.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_framer_peer.h" +#include "quic/test_tools/quic_packet_creator_peer.h" +#include "quic/test_tools/quic_session_peer.h" +#include "quic/test_tools/quic_spdy_session_peer.h" +#include "quic/test_tools/quic_stream_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/simple_session_cache.h" using spdy::SpdyHeaderBlock; using ::testing::_; @@ -230,10 +230,7 @@ class QuicSpdyClientSessionTest : public QuicTestWithParam<ParsedQuicVersion> { std::string ParamNameFormatter( const testing::TestParamInfo<QuicSpdyClientSessionTest::ParamType>& info) { - const ParsedQuicVersion& version = info.param; - return quiche::QuicheStrCat( - QuicVersionToString(version.transport_version), "_", - HandshakeProtocolToString(version.handshake_protocol)); + return ParsedQuicVersionToString(info.param); } INSTANTIATE_TEST_SUITE_P(Tests, @@ -583,7 +580,7 @@ TEST_P(QuicSpdyClientSessionTest, InvalidFramedPacketReceived) { QuicConnectionPeer::GetFramer(connection_), destination_connection_id); bool version_flag = false; QuicConnectionIdIncluded scid_included = CONNECTION_ID_ABSENT; - if (VersionHasIetfInvariantHeader(version.transport_version)) { + if (version.HasIetfInvariantHeader()) { version_flag = true; source_connection_id = destination_connection_id; scid_included = CONNECTION_ID_PRESENT; @@ -771,7 +768,7 @@ TEST_P(QuicSpdyClientSessionTest, PushPromiseDuplicateUrl) { TEST_P(QuicSpdyClientSessionTest, ReceivingPromiseEnhanceYourCalm) { CompleteCryptoHandshake(); for (size_t i = 0u; i < session_->get_max_promises(); i++) { - push_promise_[":path"] = quiche::QuicheStringPrintf("/bar%zu", i); + push_promise_[":path"] = absl::StrCat("/bar", i); QuicStreamId id = promised_stream_id_ + @@ -789,7 +786,7 @@ TEST_P(QuicSpdyClientSessionTest, ReceivingPromiseEnhanceYourCalm) { // One more promise, this should be refused. int i = session_->get_max_promises(); - push_promise_[":path"] = quiche::QuicheStringPrintf("/bar%d", i); + push_promise_[":path"] = absl::StrCat("/bar", i); QuicStreamId id = promised_stream_id_ + @@ -953,7 +950,7 @@ TEST_P(QuicSpdyClientSessionTest, TooManyPushPromises) { connection_->transport_version(), promise_count); auto headers = QuicHeaderList(); headers.OnHeaderBlockStart(); - headers.OnHeader(":path", quiche::QuicheStrCat("/", promise_count)); + headers.OnHeader(":path", absl::StrCat("/", promise_count)); headers.OnHeader(":authority", "www.google.com"); headers.OnHeader(":method", "GET"); headers.OnHeader(":scheme", "https"); diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.cc index f4bbca55850..931bfb3fdcb 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.h" +#include "quic/core/http/quic_spdy_client_stream.h" #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/http/quic_client_promised_info.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_alarm.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" +#include "quic/core/http/quic_client_promised_info.h" +#include "quic/core/http/quic_spdy_client_session.h" +#include "quic/core/http/spdy_utils.h" +#include "quic/core/quic_alarm.h" +#include "quic/platform/api/quic_logging.h" +#include "spdy/core/spdy_protocol.h" using spdy::SpdyHeaderBlock; @@ -48,7 +48,7 @@ void QuicSpdyClientStream::OnInitialHeadersComplete( const QuicHeaderList& header_list) { QuicSpdyStream::OnInitialHeadersComplete(fin, frame_len, header_list); - DCHECK(headers_decompressed()); + QUICHE_DCHECK(headers_decompressed()); header_bytes_read_ += frame_len; if (!SpdyUtils::CopyAndValidateHeaders(header_list, &content_length_, &response_headers_)) { diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.h b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.h index e426db7baf4..b62f49639eb 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.h @@ -9,9 +9,9 @@ #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/spdy/core/spdy_framer.h" +#include "quic/core/http/quic_spdy_stream.h" +#include "quic/core/quic_packets.h" +#include "spdy/core/spdy_framer.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream_test.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream_test.cc index 90d4ee13e9c..c1ad5c6a17c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream_test.cc @@ -2,23 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.h" +#include "quic/core/http/quic_spdy_client_stream.h" #include <memory> #include <string> #include <utility> -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.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/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/http/quic_spdy_client_session.h" +#include "quic/core/http/spdy_utils.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/quic_spdy_session_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" using spdy::SpdyHeaderBlock; using testing::_; diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_server_stream_base.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_server_stream_base.cc index aee50456d05..c2e7845edb7 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_server_stream_base.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_server_stream_base.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_server_stream_base.h" +#include "quic/core/http/quic_spdy_server_stream_base.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_session.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -25,14 +25,10 @@ void QuicSpdyServerStreamBase::CloseWriteSide() { !rst_sent()) { // Early cancel the stream if it has stopped reading before receiving FIN // or RST. - DCHECK(fin_sent() || !session()->connection()->connected()); + QUICHE_DCHECK(fin_sent() || !session()->connection()->connected()); // Tell the peer to stop sending further data. QUIC_DVLOG(1) << " Server: Send QUIC_STREAM_NO_ERROR on stream " << id(); - if (session()->split_up_send_rst()) { - MaybeSendStopSending(QUIC_STREAM_NO_ERROR); - } else { - Reset(QUIC_STREAM_NO_ERROR); - } + MaybeSendStopSending(QUIC_STREAM_NO_ERROR); } QuicSpdyStream::CloseWriteSide(); @@ -41,14 +37,10 @@ void QuicSpdyServerStreamBase::CloseWriteSide() { void QuicSpdyServerStreamBase::StopReading() { if (!fin_received() && !rst_received() && write_side_closed() && !rst_sent()) { - DCHECK(fin_sent()); + QUICHE_DCHECK(fin_sent()); // Tell the peer to stop sending further data. QUIC_DVLOG(1) << " Server: Send QUIC_STREAM_NO_ERROR on stream " << id(); - if (session()->split_up_send_rst()) { - MaybeSendStopSending(QUIC_STREAM_NO_ERROR); - } else { - Reset(QUIC_STREAM_NO_ERROR); - } + MaybeSendStopSending(QUIC_STREAM_NO_ERROR); } QuicSpdyStream::StopReading(); } diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_server_stream_base.h b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_server_stream_base.h index b66b459d021..252addfaab6 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_server_stream_base.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_server_stream_base.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_CORE_HTTP_QUIC_SPDY_SERVER_STREAM_BASE_H_ #define QUICHE_QUIC_CORE_HTTP_QUIC_SPDY_SERVER_STREAM_BASE_H_ -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_stream.h" +#include "quic/core/http/quic_spdy_stream.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_server_stream_base_test.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_server_stream_base_test.cc index 4505cd0ce50..bada26378f4 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_server_stream_base_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_server_stream_base_test.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_server_stream_base.h" +#include "quic/core/http/quic_spdy_server_stream_base.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_spdy_session_peer.h" +#include "quic/test_tools/quic_stream_peer.h" +#include "quic/test_tools/quic_test_utils.h" using testing::_; @@ -55,17 +55,12 @@ TEST_F(QuicSpdyServerStreamBaseTest, SendQuicRstStreamNoErrorWithEarlyResponse) { stream_->StopReading(); - if (!session_.split_up_send_rst()) { - EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _, _)) + if (session_.version().UsesHttp3()) { + EXPECT_CALL(session_, MaybeSendStopSendingFrame(_, QUIC_STREAM_NO_ERROR)) .Times(1); } else { - if (session_.version().UsesHttp3()) { - EXPECT_CALL(session_, MaybeSendStopSendingFrame(_, QUIC_STREAM_NO_ERROR)) - .Times(1); - } else { - EXPECT_CALL(session_, MaybeSendRstStreamFrame(_, QUIC_STREAM_NO_ERROR, _)) - .Times(1); - } + EXPECT_CALL(session_, MaybeSendRstStreamFrame(_, QUIC_STREAM_NO_ERROR, _)) + .Times(1); } QuicStreamPeer::SetFinSent(stream_); stream_->CloseWriteSide(); @@ -75,27 +70,14 @@ TEST_F(QuicSpdyServerStreamBaseTest, DoNotSendQuicRstStreamNoErrorWithRstReceived) { EXPECT_FALSE(stream_->reading_stopped()); - EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _, _)).Times(0); - - if (!session_.split_up_send_rst()) { - EXPECT_CALL( - session_, - SendRstStream(_, - VersionHasIetfQuicFrames(session_.transport_version()) - ? QUIC_STREAM_CANCELLED - : QUIC_RST_ACKNOWLEDGEMENT, - _, _)) - .Times(1); - } else { - EXPECT_CALL(session_, - MaybeSendRstStreamFrame( - _, - VersionHasIetfQuicFrames(session_.transport_version()) - ? QUIC_STREAM_CANCELLED - : QUIC_RST_ACKNOWLEDGEMENT, - _)) - .Times(1); - } + EXPECT_CALL(session_, + MaybeSendRstStreamFrame( + _, + VersionHasIetfQuicFrames(session_.transport_version()) + ? QUIC_STREAM_CANCELLED + : QUIC_RST_ACKNOWLEDGEMENT, + _)) + .Times(1); QuicRstStreamFrame rst_frame(kInvalidControlFrameId, stream_->id(), QUIC_STREAM_CANCELLED, 1234); stream_->OnStreamReset(rst_frame); diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_session.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_session.cc index 581a4fa79ae..91530d36443 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_session.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_session.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_session.h" +#include "quic/core/http/quic_spdy_session.h" #include <algorithm> #include <cstdint> @@ -12,22 +12,24 @@ #include "absl/base/attributes.h" #include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/http/http_constants.h" -#include "net/third_party/quiche/src/quic/core/http/quic_headers_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_exported_stats.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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_stack_trace.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/spdy/core/http2_frame_decoder_adapter.h" +#include "quic/core/http/http_constants.h" +#include "quic/core/http/http_decoder.h" +#include "quic/core/http/http_frames.h" +#include "quic/core/http/quic_headers_stream.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_exported_stats.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_stack_trace.h" +#include "common/platform/api/quiche_text_utils.h" +#include "spdy/core/http2_frame_decoder_adapter.h" using http2::Http2DecoderAdapter; using spdy::HpackEntry; @@ -86,6 +88,112 @@ class HeaderTableDebugVisitor : public HpackHeaderTable::DebugVisitorInterface { std::unique_ptr<QuicHpackDebugVisitor> headers_stream_hpack_visitor_; }; +// Class to forward ACCEPT_CH frame to QuicSpdySession, +// and ignore every other frame. +class AlpsFrameDecoder : public HttpDecoder::Visitor { + public: + explicit AlpsFrameDecoder(QuicSpdySession* session) : session_(session) {} + ~AlpsFrameDecoder() override = default; + + // HttpDecoder::Visitor implementation. + void OnError(HttpDecoder* /*decoder*/) override {} + bool OnCancelPushFrame(const CancelPushFrame& /*frame*/) override { + error_detail_ = "CANCEL_PUSH frame forbidden"; + return false; + } + bool OnMaxPushIdFrame(const MaxPushIdFrame& /*frame*/) override { + error_detail_ = "MAX_PUSH_ID frame forbidden"; + return false; + } + bool OnGoAwayFrame(const GoAwayFrame& /*frame*/) override { + error_detail_ = "GOAWAY frame forbidden"; + return false; + } + bool OnSettingsFrameStart(QuicByteCount /*header_length*/) override { + return true; + } + bool OnSettingsFrame(const SettingsFrame& /*frame*/) override { return true; } + bool OnDataFrameStart(QuicByteCount /*header_length*/, QuicByteCount + /*payload_length*/) override { + error_detail_ = "DATA frame forbidden"; + return false; + } + bool OnDataFramePayload(absl::string_view /*payload*/) override { + QUICHE_NOTREACHED(); + return false; + } + bool OnDataFrameEnd() override { + QUICHE_NOTREACHED(); + return false; + } + bool OnHeadersFrameStart(QuicByteCount /*header_length*/, + QuicByteCount /*payload_length*/) override { + error_detail_ = "HEADERS frame forbidden"; + return false; + } + bool OnHeadersFramePayload(absl::string_view /*payload*/) override { + QUICHE_NOTREACHED(); + return false; + } + bool OnHeadersFrameEnd() override { + QUICHE_NOTREACHED(); + return false; + } + bool OnPushPromiseFrameStart(QuicByteCount /*header_length*/) override { + error_detail_ = "PUSH_PROMISE frame forbidden"; + return false; + } + bool OnPushPromiseFramePushId( + PushId /*push_id*/, + QuicByteCount + /*push_id_length*/, + QuicByteCount /*header_block_length*/) override { + QUICHE_NOTREACHED(); + return false; + } + bool OnPushPromiseFramePayload(absl::string_view /*payload*/) override { + QUICHE_NOTREACHED(); + return false; + } + bool OnPushPromiseFrameEnd() override { + QUICHE_NOTREACHED(); + return false; + } + bool OnPriorityUpdateFrameStart(QuicByteCount /*header_length*/) override { + error_detail_ = "PRIORITY_UPDATE frame forbidden"; + return false; + } + bool OnPriorityUpdateFrame(const PriorityUpdateFrame& /*frame*/) override { + QUICHE_NOTREACHED(); + return false; + } + bool OnAcceptChFrameStart(QuicByteCount /*header_length*/) override { + return true; + } + bool OnAcceptChFrame(const AcceptChFrame& frame) override { + session_->OnAcceptChFrameReceivedViaAlps(frame); + return true; + } + bool OnUnknownFrameStart(uint64_t /*frame_type*/, + QuicByteCount + /*header_length*/, + QuicByteCount /*payload_length*/) override { + return true; + } + bool OnUnknownFramePayload(absl::string_view /*payload*/) override { + return true; + } + bool OnUnknownFrameEnd() override { return true; } + + const absl::optional<std::string>& error_detail() const { + return error_detail_; + } + + private: + QuicSpdySession* const session_; + absl::optional<std::string> error_detail_; +}; + } // namespace // A SpdyFramerVisitor that passes HEADERS frames to the QuicSpdyStream, and @@ -100,12 +208,12 @@ class QuicSpdySession::SpdyFramerVisitor SpdyHeadersHandlerInterface* OnHeaderFrameStart( SpdyStreamId /* stream_id */) override { - DCHECK(!VersionUsesHttp3(session_->transport_version())); + QUICHE_DCHECK(!VersionUsesHttp3(session_->transport_version())); return &header_list_; } void OnHeaderFrameEnd(SpdyStreamId /* stream_id */) override { - DCHECK(!VersionUsesHttp3(session_->transport_version())); + QUICHE_DCHECK(!VersionUsesHttp3(session_->transport_version())); LogHeaderCompressionRatioHistogram( /* using_qpack = */ false, @@ -121,7 +229,7 @@ class QuicSpdySession::SpdyFramerVisitor void OnStreamFrameData(SpdyStreamId /*stream_id*/, const char* /*data*/, size_t /*len*/) override { - DCHECK(!VersionUsesHttp3(session_->transport_version())); + QUICHE_DCHECK(!VersionUsesHttp3(session_->transport_version())); CloseConnection("SPDY DATA frame received.", QUIC_INVALID_HEADERS_STREAM_DATA); } @@ -201,16 +309,16 @@ class QuicSpdySession::SpdyFramerVisitor default: code = QUIC_INVALID_HEADERS_STREAM_DATA; } - CloseConnection(quiche::QuicheStrCat( - "SPDY framing error: ", detailed_error, - Http2DecoderAdapter::SpdyFramerErrorToString(error)), - code); + CloseConnection( + absl::StrCat("SPDY framing error: ", detailed_error, + Http2DecoderAdapter::SpdyFramerErrorToString(error)), + code); } void OnDataFrameHeader(SpdyStreamId /*stream_id*/, size_t /*length*/, bool /*fin*/) override { - DCHECK(!VersionUsesHttp3(session_->transport_version())); + QUICHE_DCHECK(!VersionUsesHttp3(session_->transport_version())); CloseConnection("SPDY DATA frame received.", QUIC_INVALID_HEADERS_STREAM_DATA); } @@ -222,12 +330,12 @@ class QuicSpdySession::SpdyFramerVisitor } void OnSetting(SpdySettingsId id, uint32_t value) override { - DCHECK(!VersionUsesHttp3(session_->transport_version())); + QUICHE_DCHECK(!VersionUsesHttp3(session_->transport_version())); session_->OnSetting(id, value); } void OnSettingsEnd() override { - DCHECK(!VersionUsesHttp3(session_->transport_version())); + QUICHE_DCHECK(!VersionUsesHttp3(session_->transport_version())); } void OnPing(SpdyPingId /*unique_id*/, bool /*is_ack*/) override { @@ -244,8 +352,8 @@ class QuicSpdySession::SpdyFramerVisitor void OnHeaders(SpdyStreamId stream_id, bool has_priority, int weight, - SpdyStreamId parent_stream_id, - bool exclusive, + SpdyStreamId /* parent_stream_id */, + bool /* exclusive */, bool fin, bool /*end*/) override { if (!session_->IsConnected()) { @@ -262,13 +370,6 @@ class QuicSpdySession::SpdyFramerVisitor << "QuicSpdyStream use after free. " << session_->destruction_indicator() << QuicStackTrace(); - if (session_->use_http2_priority_write_scheduler()) { - session_->OnHeaders( - stream_id, has_priority, - spdy::SpdyStreamPrecedence(parent_stream_id, weight, exclusive), fin); - return; - } - SpdyPriority priority = has_priority ? Http2WeightToSpdy3Priority(weight) : 0; session_->OnHeaders(stream_id, has_priority, @@ -284,7 +385,7 @@ class QuicSpdySession::SpdyFramerVisitor void OnPushPromise(SpdyStreamId stream_id, SpdyStreamId promised_stream_id, bool /*end*/) override { - DCHECK(!VersionUsesHttp3(session_->transport_version())); + QUICHE_DCHECK(!VersionUsesHttp3(session_->transport_version())); if (session_->perspective() != Perspective::IS_CLIENT) { CloseConnection("PUSH_PROMISE not supported.", QUIC_INVALID_HEADERS_STREAM_DATA); @@ -299,22 +400,23 @@ class QuicSpdySession::SpdyFramerVisitor void OnContinuation(SpdyStreamId /*stream_id*/, bool /*end*/) override {} void OnPriority(SpdyStreamId stream_id, - SpdyStreamId parent_id, + SpdyStreamId /* parent_id */, int weight, - bool exclusive) override { - DCHECK(!VersionUsesHttp3(session_->transport_version())); + bool /* exclusive */) override { + QUICHE_DCHECK(!VersionUsesHttp3(session_->transport_version())); if (!session_->IsConnected()) { return; } - if (session_->use_http2_priority_write_scheduler()) { - session_->OnPriority( - stream_id, spdy::SpdyStreamPrecedence(parent_id, weight, exclusive)); - return; - } SpdyPriority priority = Http2WeightToSpdy3Priority(weight); session_->OnPriority(stream_id, spdy::SpdyStreamPrecedence(priority)); } + void OnPriorityUpdate(SpdyStreamId /*prioritized_stream_id*/, + absl::string_view /*priority_field_value*/) override { + // TODO(b/171470299): Parse and call + // QuicSpdySession::OnPriorityUpdateForRequestStream(). + } + bool OnUnknownFrame(SpdyStreamId /*stream_id*/, uint8_t /*frame_type*/) override { CloseConnection("Unknown frame type received.", @@ -406,7 +508,6 @@ QuicSpdySession::QuicSpdySession( ietf_server_push_enabled_( GetQuicFlag(FLAGS_quic_enable_http3_server_push)), http3_max_push_id_sent_(false), - reject_spdy_settings_(GetQuicReloadableFlag(quic_reject_spdy_settings)), goaway_with_max_stream_id_( GetQuicReloadableFlag(quic_goaway_with_max_stream_id)) { if (goaway_with_max_stream_id_) { @@ -422,21 +523,6 @@ QuicSpdySession::~QuicSpdySession() { << "QuicSpdyStream use after free. " << destruction_indicator_ << QuicStackTrace(); destruction_indicator_ = 987654321; - - if (GetQuicReloadableFlag(quic_clean_up_spdy_session_destructor)) { - QUIC_RELOADABLE_FLAG_COUNT(quic_clean_up_spdy_session_destructor); - return; - } - // Set the streams' session pointers in closed and dynamic stream lists - // to null to avoid subsequent use of this session. - for (auto& stream : *closed_streams()) { - static_cast<QuicSpdyStream*>(stream.get())->ClearSession(); - } - for (auto const& kv : stream_map()) { - if (!kv.second->is_static()) { - static_cast<QuicSpdyStream*>(kv.second.get())->ClearSession(); - } - } } void QuicSpdySession::Initialize() { @@ -449,12 +535,12 @@ void QuicSpdySession::Initialize() { QuicUtils::GetHeadersStreamId(transport_version())); } else { QuicStreamId headers_stream_id = GetNextOutgoingBidirectionalStreamId(); - DCHECK_EQ(headers_stream_id, - QuicUtils::GetHeadersStreamId(transport_version())); + QUICHE_DCHECK_EQ(headers_stream_id, + QuicUtils::GetHeadersStreamId(transport_version())); } auto headers_stream = std::make_unique<QuicHeadersStream>((this)); - DCHECK_EQ(QuicUtils::GetHeadersStreamId(transport_version()), - headers_stream->id()); + QUICHE_DCHECK_EQ(QuicUtils::GetHeadersStreamId(transport_version()), + headers_stream->id()); headers_stream_ = headers_stream.get(); ActivateStream(std::move(headers_stream)); @@ -484,20 +570,18 @@ void QuicSpdySession::FillSettingsFrame() { void QuicSpdySession::OnDecoderStreamError(QuicErrorCode error_code, absl::string_view error_message) { - DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); CloseConnectionWithDetails( - error_code, - quiche::QuicheStrCat("Decoder stream error: ", error_message)); + error_code, absl::StrCat("Decoder stream error: ", error_message)); } void QuicSpdySession::OnEncoderStreamError(QuicErrorCode error_code, absl::string_view error_message) { - DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); CloseConnectionWithDetails( - error_code, - quiche::QuicheStrCat("Encoder stream error: ", error_message)); + error_code, absl::StrCat("Encoder stream error: ", error_message)); } void QuicSpdySession::OnStreamHeadersPriority( @@ -599,11 +683,11 @@ bool QuicSpdySession::OnPriorityUpdateForRequestStream(QuicStreamId stream_id, // This should never happen, because |buffered_stream_priorities_| should // only contain entries for streams that are allowed to be open by the peer // but have not been opened yet. - std::string error_message = quiche::QuicheStrCat( - "Too many stream priority values buffered: ", - buffered_stream_priorities_.size(), - ", which should not exceed the incoming stream limit of ", - max_open_incoming_bidirectional_streams()); + std::string error_message = + absl::StrCat("Too many stream priority values buffered: ", + buffered_stream_priorities_.size(), + ", which should not exceed the incoming stream limit of ", + max_open_incoming_bidirectional_streams()); QUIC_BUG << error_message; connection()->CloseConnection( QUIC_INTERNAL_ERROR, error_message, @@ -634,7 +718,7 @@ size_t QuicSpdySession::WriteHeadersOnHeadersStream( bool fin, const spdy::SpdyStreamPrecedence& precedence, QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener) { - DCHECK(!VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(!VersionUsesHttp3(transport_version())); return WriteHeadersOnHeadersStreamImpl( id, std::move(headers), fin, @@ -647,7 +731,7 @@ size_t QuicSpdySession::WritePriority(QuicStreamId id, QuicStreamId parent_stream_id, int weight, bool exclusive) { - DCHECK(!VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(!VersionUsesHttp3(transport_version())); SpdyPriorityIR priority_frame(id, parent_stream_id, weight, exclusive); SpdySerializedFrame frame(spdy_framer_.SerializeFrame(priority_frame)); headers_stream()->WriteOrBufferData( @@ -657,7 +741,7 @@ size_t QuicSpdySession::WritePriority(QuicStreamId id, void QuicSpdySession::WriteHttp3PriorityUpdate( const PriorityUpdateFrame& priority_update) { - DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); send_control_stream_->WritePriorityUpdate(priority_update); } @@ -670,9 +754,9 @@ void QuicSpdySession::OnHttp3GoAway(uint64_t id) { id > last_received_http3_goaway_id_.value()) { CloseConnectionWithDetails( QUIC_HTTP_GOAWAY_ID_LARGER_THAN_PREVIOUS, - quiche::QuicheStrCat("GOAWAY received with ID ", id, - " greater than previously received ID ", - last_received_http3_goaway_id_.value())); + absl::StrCat("GOAWAY received with ID ", id, + " greater than previously received ID ", + last_received_http3_goaway_id_.value())); return; } last_received_http3_goaway_id_ = id; @@ -709,16 +793,26 @@ bool QuicSpdySession::OnStreamsBlockedFrame( // goaway. if (perspective() == Perspective::IS_SERVER && frame.stream_count >= QuicUtils::GetMaxStreamCount()) { - DCHECK_EQ(frame.stream_count, QuicUtils::GetMaxStreamCount()); - SendHttp3GoAway(); + QUICHE_DCHECK_EQ(frame.stream_count, QuicUtils::GetMaxStreamCount()); + SendHttp3GoAway(QUIC_PEER_GOING_AWAY, "stream count too large"); } return true; } -void QuicSpdySession::SendHttp3GoAway() { - DCHECK_EQ(perspective(), Perspective::IS_SERVER); - DCHECK(VersionUsesHttp3(transport_version())); - +void QuicSpdySession::SendHttp3GoAway(QuicErrorCode error_code, + const std::string& reason) { + QUICHE_DCHECK_EQ(perspective(), Perspective::IS_SERVER); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); + if (GetQuicReloadableFlag(quic_encrypted_goaway)) { + QUIC_RELOADABLE_FLAG_COUNT_N(quic_encrypted_goaway, 2, 2); + if (!IsEncryptionEstablished()) { + QUIC_CODE_COUNT(quic_h3_goaway_before_encryption_established); + connection()->CloseConnection( + error_code, reason, + ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); + return; + } + } QuicStreamId stream_id; if (goaway_with_max_stream_id_) { @@ -740,25 +834,22 @@ void QuicSpdySession::SendHttp3GoAway() { } else { stream_id = GetLargestPeerCreatedStreamId(/*unidirectional = */ false); - if (GetQuicReloadableFlag(quic_fix_http3_goaway_stream_id)) { - QUIC_RELOADABLE_FLAG_COUNT(quic_fix_http3_goaway_stream_id); - if (stream_id == QuicUtils::GetInvalidStreamId(transport_version())) { - // No client-initiated bidirectional streams received yet. - // Send 0 to let client know that all requests can be retried. - stream_id = 0; - } else { - // Tell client that streams starting with the next after the largest - // received one can be retried. - stream_id += QuicUtils::StreamIdDelta(transport_version()); - } - if (last_sent_http3_goaway_id_.has_value() && - last_sent_http3_goaway_id_.value() <= stream_id) { - // MUST not send GOAWAY with identifier larger than previously sent. - // Do not bother sending one with same identifier as before, since - // GOAWAY frames on the control stream are guaranteed to be processed in - // order. - return; - } + if (stream_id == QuicUtils::GetInvalidStreamId(transport_version())) { + // No client-initiated bidirectional streams received yet. + // Send 0 to let client know that all requests can be retried. + stream_id = 0; + } else { + // Tell client that streams starting with the next after the largest + // received one can be retried. + stream_id += QuicUtils::StreamIdDelta(transport_version()); + } + if (last_sent_http3_goaway_id_.has_value() && + last_sent_http3_goaway_id_.value() <= stream_id) { + // MUST not send GOAWAY with identifier larger than previously sent. + // Do not bother sending one with same identifier as before, since + // GOAWAY frames on the control stream are guaranteed to be processed in + // order. + return; } } @@ -768,12 +859,12 @@ void QuicSpdySession::SendHttp3GoAway() { void QuicSpdySession::SendHttp3Shutdown() { if (goaway_with_max_stream_id_) { - SendHttp3GoAway(); + SendHttp3GoAway(QUIC_PEER_GOING_AWAY, "Server shutdown"); return; } - DCHECK_EQ(perspective(), Perspective::IS_SERVER); - DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK_EQ(perspective(), Perspective::IS_SERVER); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); QuicStreamCount advertised_max_incoming_bidirectional_streams = GetAdvertisedMaxIncomingBidirectionalStreams(); const QuicStreamId stream_id = @@ -852,13 +943,13 @@ void QuicSpdySession::SendInitialData() { } QpackEncoder* QuicSpdySession::qpack_encoder() { - DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); return qpack_encoder_.get(); } QpackDecoder* QuicSpdySession::qpack_decoder() { - DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); return qpack_decoder_.get(); } @@ -882,7 +973,7 @@ QuicSpdyStream* QuicSpdySession::GetOrCreateSpdyDataStream( << QuicStackTrace(); connection()->CloseConnection( QUIC_INVALID_STREAM_ID, - quiche::QuicheStrCat("stream ", stream_id, " is static"), + absl::StrCat("stream ", stream_id, " is static"), ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); return nullptr; } @@ -901,7 +992,8 @@ void QuicSpdySession::OnNewEncryptionKeyAvailable( // True if there are open HTTP requests. bool QuicSpdySession::ShouldKeepConnectionAlive() const { - DCHECK(VersionUsesHttp3(transport_version()) || 0u == pending_streams_size()); + QUICHE_DCHECK(VersionUsesHttp3(transport_version()) || + 0u == pending_streams_size()); return GetNumActiveStreams() + pending_streams_size() > 0; } @@ -920,7 +1012,7 @@ size_t QuicSpdySession::WriteHeadersOnHeadersStreamImpl( int weight, bool exclusive, QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener) { - DCHECK(!VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(!VersionUsesHttp3(transport_version())); const QuicByteCount uncompressed_size = headers.TotalBytesUsed(); SpdyHeadersIR headers_frame(id, std::move(headers)); @@ -964,8 +1056,8 @@ void QuicSpdySession::OnPromiseHeaderList( } bool QuicSpdySession::ResumeApplicationState(ApplicationState* cached_state) { - DCHECK_EQ(perspective(), Perspective::IS_CLIENT); - DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK_EQ(perspective(), Perspective::IS_CLIENT); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); SettingsFrame out; if (!HttpDecoder::DecodeSettings( @@ -983,8 +1075,36 @@ bool QuicSpdySession::ResumeApplicationState(ApplicationState* cached_state) { return true; } +absl::optional<std::string> QuicSpdySession::OnAlpsData( + const uint8_t* alps_data, + size_t alps_length) { + AlpsFrameDecoder alps_frame_decoder(this); + HttpDecoder decoder(&alps_frame_decoder); + decoder.ProcessInput(reinterpret_cast<const char*>(alps_data), alps_length); + if (alps_frame_decoder.error_detail()) { + return alps_frame_decoder.error_detail(); + } + + if (decoder.error() != QUIC_NO_ERROR) { + return decoder.error_detail(); + } + + if (!decoder.AtFrameBoundary()) { + return "incomplete HTTP/3 frame"; + } + + return absl::nullopt; +} + +void QuicSpdySession::OnAcceptChFrameReceivedViaAlps( + const AcceptChFrame& frame) { + if (debug_visitor_) { + debug_visitor_->OnAcceptChFrameReceivedViaAlps(frame); + } +} + bool QuicSpdySession::OnSettingsFrame(const SettingsFrame& frame) { - DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); if (debug_visitor_ != nullptr) { debug_visitor_->OnSettingsFrameReceived(frame); } @@ -998,9 +1118,6 @@ bool QuicSpdySession::OnSettingsFrame(const SettingsFrame& frame) { bool QuicSpdySession::OnSetting(uint64_t id, uint64_t value) { if (VersionUsesHttp3(transport_version())) { - if (reject_spdy_settings_) { - QUIC_RELOADABLE_FLAG_COUNT(quic_reject_spdy_settings); - } // SETTINGS frame received on the control stream. switch (id) { case SETTINGS_QPACK_MAX_TABLE_CAPACITY: { @@ -1016,13 +1133,12 @@ bool QuicSpdySession::OnSetting(uint64_t id, uint64_t value) { was_zero_rtt_rejected() ? QUIC_HTTP_ZERO_RTT_REJECTION_SETTINGS_MISMATCH : QUIC_HTTP_ZERO_RTT_RESUMPTION_SETTINGS_MISMATCH, - quiche::QuicheStrCat( - was_zero_rtt_rejected() - ? "Server rejected 0-RTT, aborting because " - : "", - "Server sent an SETTINGS_QPACK_MAX_TABLE_CAPACITY: ", value, - "while current value is: ", - qpack_encoder_->MaximumDynamicTableCapacity())); + absl::StrCat(was_zero_rtt_rejected() + ? "Server rejected 0-RTT, aborting because " + : "", + "Server sent an SETTINGS_QPACK_MAX_TABLE_CAPACITY: ", + value, "while current value is: ", + qpack_encoder_->MaximumDynamicTableCapacity())); return false; } // However, limit the dynamic table capacity to @@ -1043,13 +1159,12 @@ bool QuicSpdySession::OnSetting(uint64_t id, uint64_t value) { was_zero_rtt_rejected() ? QUIC_HTTP_ZERO_RTT_REJECTION_SETTINGS_MISMATCH : QUIC_HTTP_ZERO_RTT_RESUMPTION_SETTINGS_MISMATCH, - quiche::QuicheStrCat( - was_zero_rtt_rejected() - ? "Server rejected 0-RTT, aborting because " - : "", - "Server sent an SETTINGS_MAX_FIELD_SECTION_SIZE: ", value, - "which reduces current value: ", - max_outbound_header_list_size_)); + absl::StrCat(was_zero_rtt_rejected() + ? "Server rejected 0-RTT, aborting because " + : "", + "Server sent an SETTINGS_MAX_FIELD_SECTION_SIZE: ", + value, "which reduces current value: ", + max_outbound_header_list_size_)); return false; } max_outbound_header_list_size_ = value; @@ -1064,13 +1179,12 @@ bool QuicSpdySession::OnSetting(uint64_t id, uint64_t value) { was_zero_rtt_rejected() ? QUIC_HTTP_ZERO_RTT_REJECTION_SETTINGS_MISMATCH : QUIC_HTTP_ZERO_RTT_RESUMPTION_SETTINGS_MISMATCH, - quiche::QuicheStrCat( - was_zero_rtt_rejected() - ? "Server rejected 0-RTT, aborting because " - : "", - "Server sent an SETTINGS_QPACK_BLOCKED_STREAMS: ", value, - "which reduces current value: ", - qpack_encoder_->maximum_blocked_streams())); + absl::StrCat(was_zero_rtt_rejected() + ? "Server rejected 0-RTT, aborting because " + : "", + "Server sent an SETTINGS_QPACK_BLOCKED_STREAMS: ", + value, "which reduces current value: ", + qpack_encoder_->maximum_blocked_streams())); return false; } break; @@ -1082,14 +1196,11 @@ bool QuicSpdySession::OnSetting(uint64_t id, uint64_t value) { case spdy::SETTINGS_INITIAL_WINDOW_SIZE: ABSL_FALLTHROUGH_INTENDED; case spdy::SETTINGS_MAX_FRAME_SIZE: - if (reject_spdy_settings_) { - CloseConnectionWithDetails( - QUIC_HTTP_RECEIVE_SPDY_SETTING, - quiche::QuicheStrCat( - "received HTTP/2 specific setting in HTTP/3 session: ", id)); - return false; - } - break; + CloseConnectionWithDetails( + QUIC_HTTP_RECEIVE_SPDY_SETTING, + absl::StrCat("received HTTP/2 specific setting in HTTP/3 session: ", + id)); + return false; default: QUIC_DVLOG(1) << ENDPOINT << "Unknown setting identifier " << id << " received with value " << value; @@ -1116,8 +1227,8 @@ bool QuicSpdySession::OnSetting(uint64_t id, uint64_t value) { if (IsConnected()) { CloseConnectionWithDetails( QUIC_INVALID_HEADERS_STREAM_DATA, - quiche::QuicheStrCat("Invalid value for SETTINGS_ENABLE_PUSH: ", - value)); + absl::StrCat("Invalid value for SETTINGS_ENABLE_PUSH: ", + value)); } return true; } @@ -1133,8 +1244,7 @@ bool QuicSpdySession::OnSetting(uint64_t id, uint64_t value) { if (IsConnected()) { CloseConnectionWithDetails( QUIC_INVALID_HEADERS_STREAM_DATA, - quiche::QuicheStrCat( - "Unsupported field of HTTP/2 SETTINGS frame: ", id)); + absl::StrCat("Unsupported field of HTTP/2 SETTINGS frame: ", id)); } } break; @@ -1150,8 +1260,7 @@ bool QuicSpdySession::OnSetting(uint64_t id, uint64_t value) { if (IsConnected()) { CloseConnectionWithDetails( QUIC_INVALID_HEADERS_STREAM_DATA, - quiche::QuicheStrCat("Unsupported field of HTTP/2 SETTINGS frame: ", - id)); + absl::StrCat("Unsupported field of HTTP/2 SETTINGS frame: ", id)); } } return true; @@ -1179,18 +1288,20 @@ void QuicSpdySession::OnHeaders(SpdyStreamId stream_id, return; } } - DCHECK_EQ(QuicUtils::GetInvalidStreamId(transport_version()), stream_id_); - DCHECK_EQ(QuicUtils::GetInvalidStreamId(transport_version()), - promised_stream_id_); + QUICHE_DCHECK_EQ(QuicUtils::GetInvalidStreamId(transport_version()), + stream_id_); + QUICHE_DCHECK_EQ(QuicUtils::GetInvalidStreamId(transport_version()), + promised_stream_id_); stream_id_ = stream_id; fin_ = fin; } void QuicSpdySession::OnPushPromise(SpdyStreamId stream_id, SpdyStreamId promised_stream_id) { - DCHECK_EQ(QuicUtils::GetInvalidStreamId(transport_version()), stream_id_); - DCHECK_EQ(QuicUtils::GetInvalidStreamId(transport_version()), - promised_stream_id_); + QUICHE_DCHECK_EQ(QuicUtils::GetInvalidStreamId(transport_version()), + stream_id_); + QUICHE_DCHECK_EQ(QuicUtils::GetInvalidStreamId(transport_version()), + promised_stream_id_); stream_id_ = stream_id; promised_stream_id_ = promised_stream_id; } @@ -1212,8 +1323,8 @@ void QuicSpdySession::OnHeaderList(const QuicHeaderList& header_list) { << ": " << header_list.DebugString(); // This code path is only executed for push promise in IETF QUIC. if (VersionUsesHttp3(transport_version())) { - DCHECK(promised_stream_id_ != - QuicUtils::GetInvalidStreamId(transport_version())); + QUICHE_DCHECK(promised_stream_id_ != + QuicUtils::GetInvalidStreamId(transport_version())); } if (promised_stream_id_ == QuicUtils::GetInvalidStreamId(transport_version())) { @@ -1258,8 +1369,8 @@ bool QuicSpdySession::HasActiveRequestStreams() const { } bool QuicSpdySession::ProcessPendingStream(PendingStream* pending) { - DCHECK(VersionUsesHttp3(transport_version())); - DCHECK(connection()->connected()); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(connection()->connected()); struct iovec iov; if (!pending->sequencer()->GetReadableRegion(&iov)) { // The first byte hasn't been received yet. @@ -1338,12 +1449,14 @@ bool QuicSpdySession::ProcessPendingStream(PendingStream* pending) { return true; } default: - if (GetQuicReloadableFlag(quic_stop_sending_uses_ietf_error_code)) { - SendStopSending(QUIC_STREAM_STREAM_CREATION_ERROR, pending->id()); + if (GetQuicReloadableFlag(quic_unify_stop_sending)) { + QUIC_RELOADABLE_FLAG_COUNT(quic_unify_stop_sending); + MaybeSendStopSendingFrame(pending->id(), + QUIC_STREAM_STREAM_CREATION_ERROR); } else { - SendStopSending(static_cast<QuicRstStreamErrorCode>( - QuicHttp3ErrorCode::STREAM_CREATION_ERROR), - pending->id()); + // TODO(renjietang): deprecate SendStopSending() when the flag is + // deprecated. + SendStopSending(QUIC_STREAM_STREAM_CREATION_ERROR, pending->id()); } pending->StopReading(); } @@ -1351,7 +1464,7 @@ bool QuicSpdySession::ProcessPendingStream(PendingStream* pending) { } void QuicSpdySession::MaybeInitializeHttp3UnidirectionalStreams() { - DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); if (!send_control_stream_ && CanOpenNextOutgoingUnidirectionalStream()) { auto send_control = std::make_unique<QuicSendControlStream>( GetNextOutgoingUnidirectionalStreamId(), this, settings_); @@ -1397,38 +1510,35 @@ void QuicSpdySession::BeforeConnectionCloseSent() { return; } - DCHECK_EQ(perspective(), Perspective::IS_SERVER); + QUICHE_DCHECK_EQ(perspective(), Perspective::IS_SERVER); QUIC_CODE_COUNT(quic_send_goaway_with_connection_close); QuicStreamId stream_id = GetLargestPeerCreatedStreamId(/*unidirectional = */ false); - if (GetQuicReloadableFlag(quic_fix_http3_goaway_stream_id)) { - QUIC_RELOADABLE_FLAG_COUNT(quic_fix_http3_goaway_stream_id); - if (stream_id == QuicUtils::GetInvalidStreamId(transport_version())) { - // No client-initiated bidirectional streams received yet. - // Send 0 to let client know that all requests can be retried. - stream_id = 0; - } else { - // Tell client that streams starting with the next after the largest - // received one can be retried. - stream_id += QuicUtils::StreamIdDelta(transport_version()); - } - if (last_sent_http3_goaway_id_.has_value() && - last_sent_http3_goaway_id_.value() <= stream_id) { - if (goaway_with_max_stream_id_) { - // A previous GOAWAY frame was sent with smaller stream ID. This is not - // possible, because this is the only method sending a GOAWAY frame with - // non-maximal stream ID, and this must only be called once, right - // before closing connection. - QUIC_BUG << "GOAWAY frame with smaller ID already sent."; - } - // MUST not send GOAWAY with identifier larger than previously sent. - // Do not bother sending one with same identifier as before, since GOAWAY - // frames on the control stream are guaranteed to be processed in order. - return; + if (stream_id == QuicUtils::GetInvalidStreamId(transport_version())) { + // No client-initiated bidirectional streams received yet. + // Send 0 to let client know that all requests can be retried. + stream_id = 0; + } else { + // Tell client that streams starting with the next after the largest + // received one can be retried. + stream_id += QuicUtils::StreamIdDelta(transport_version()); + } + if (last_sent_http3_goaway_id_.has_value() && + last_sent_http3_goaway_id_.value() <= stream_id) { + if (goaway_with_max_stream_id_) { + // A previous GOAWAY frame was sent with smaller stream ID. This is not + // possible, because this is the only method sending a GOAWAY frame with + // non-maximal stream ID, and this must only be called once, right + // before closing connection. + QUIC_BUG << "GOAWAY frame with smaller ID already sent."; } + // MUST not send GOAWAY with identifier larger than previously sent. + // Do not bother sending one with same identifier as before, since GOAWAY + // frames on the control stream are guaranteed to be processed in order. + return; } send_control_stream_->SendGoAway(stream_id); @@ -1442,10 +1552,10 @@ void QuicSpdySession::OnCanCreateNewOutgoingStream(bool unidirectional) { } void QuicSpdySession::SetMaxPushId(PushId max_push_id) { - DCHECK(VersionUsesHttp3(transport_version())); - DCHECK_EQ(Perspective::IS_CLIENT, perspective()); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK_EQ(Perspective::IS_CLIENT, perspective()); if (max_push_id_.has_value()) { - DCHECK_GE(max_push_id, max_push_id_.value()); + QUICHE_DCHECK_GE(max_push_id, max_push_id_.value()); } if (!max_push_id_.has_value() && max_push_id == 0) { @@ -1474,8 +1584,8 @@ void QuicSpdySession::SetMaxPushId(PushId max_push_id) { } bool QuicSpdySession::OnMaxPushIdFrame(PushId max_push_id) { - DCHECK(VersionUsesHttp3(transport_version())); - DCHECK_EQ(Perspective::IS_SERVER, perspective()); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK_EQ(Perspective::IS_SERVER, perspective()); if (max_push_id_.has_value()) { QUIC_DVLOG(1) << "Setting max_push_id to: " << max_push_id @@ -1496,10 +1606,9 @@ bool QuicSpdySession::OnMaxPushIdFrame(PushId max_push_id) { if (max_push_id < old_max_push_id.value()) { CloseConnectionWithDetails( QUIC_HTTP_INVALID_MAX_PUSH_ID, - quiche::QuicheStrCat( - "MAX_PUSH_ID received with value ", max_push_id, - " which is smaller that previously received value ", - old_max_push_id.value())); + absl::StrCat("MAX_PUSH_ID received with value ", max_push_id, + " which is smaller that previously received value ", + old_max_push_id.value())); return false; } @@ -1507,16 +1616,16 @@ bool QuicSpdySession::OnMaxPushIdFrame(PushId max_push_id) { } void QuicSpdySession::SendMaxPushId() { - DCHECK(VersionUsesHttp3(transport_version())); - DCHECK_EQ(Perspective::IS_CLIENT, perspective()); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK_EQ(Perspective::IS_CLIENT, perspective()); send_control_stream_->SendMaxPushIdFrame(max_push_id_.value()); http3_max_push_id_sent_ = true; } void QuicSpdySession::EnableServerPush() { - DCHECK(VersionUsesHttp3(transport_version())); - DCHECK_EQ(perspective(), Perspective::IS_SERVER); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK_EQ(perspective(), Perspective::IS_SERVER); ietf_server_push_enabled_ = true; } @@ -1534,7 +1643,7 @@ bool QuicSpdySession::goaway_sent() const { } bool QuicSpdySession::CanCreatePushStreamWithId(PushId push_id) { - DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); return ietf_server_push_enabled_ && max_push_id_.has_value() && max_push_id_.value() >= push_id; @@ -1542,11 +1651,10 @@ bool QuicSpdySession::CanCreatePushStreamWithId(PushId push_id) { void QuicSpdySession::CloseConnectionOnDuplicateHttp3UnidirectionalStreams( absl::string_view type) { - QUIC_PEER_BUG << quiche::QuicheStrCat("Received a duplicate ", type, - " stream: Closing connection."); - CloseConnectionWithDetails( - QUIC_HTTP_DUPLICATE_UNIDIRECTIONAL_STREAM, - quiche::QuicheStrCat(type, " stream is received twice.")); + QUIC_PEER_BUG << absl::StrCat("Received a duplicate ", type, + " stream: Closing connection."); + CloseConnectionWithDetails(QUIC_HTTP_DUPLICATE_UNIDIRECTIONAL_STREAM, + absl::StrCat(type, " stream is received twice.")); } // static diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_session.h b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_session.h index 56719016053..3c3d558a1fe 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_session.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_session.h @@ -9,26 +9,27 @@ #include <memory> #include <string> +#include "absl/container/flat_hash_map.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include "net/third_party/quiche/src/quic/core/http/http_frames.h" -#include "net/third_party/quiche/src/quic/core/http/quic_header_list.h" -#include "net/third_party/quiche/src/quic/core/http/quic_headers_stream.h" -#include "net/third_party/quiche/src/quic/core/http/quic_receive_control_stream.h" -#include "net/third_party/quiche/src/quic/core/http/quic_send_control_stream.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_stream.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/spdy/core/http2_frame_decoder_adapter.h" +#include "quic/core/http/http_frames.h" +#include "quic/core/http/quic_header_list.h" +#include "quic/core/http/quic_headers_stream.h" +#include "quic/core/http/quic_receive_control_stream.h" +#include "quic/core/http/quic_send_control_stream.h" +#include "quic/core/http/quic_spdy_stream.h" +#include "quic/core/qpack/qpack_decoder.h" +#include "quic/core/qpack/qpack_decoder_stream_sender.h" +#include "quic/core/qpack/qpack_encoder.h" +#include "quic/core/qpack/qpack_encoder_stream_sender.h" +#include "quic/core/qpack/qpack_receive_stream.h" +#include "quic/core/qpack/qpack_send_stream.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_export.h" +#include "spdy/core/http2_frame_decoder_adapter.h" namespace quic { @@ -83,6 +84,9 @@ class QUIC_EXPORT_PRIVATE Http3DebugVisitor { // Called when peer's QPACK decoder stream type is received. virtual void OnPeerQpackDecoderStreamCreated(QuicStreamId /*stream_id*/) = 0; + // Incoming HTTP/3 frames in ALPS TLS extension. + virtual void OnAcceptChFrameReceivedViaAlps(const AcceptChFrame& /*frame*/) {} + // Incoming HTTP/3 frames on the control stream. virtual void OnCancelPushFrameReceived(const CancelPushFrame& /*frame*/) {} virtual void OnSettingsFrameReceived(const SettingsFrame& /*frame*/) = 0; @@ -90,6 +94,7 @@ class QUIC_EXPORT_PRIVATE Http3DebugVisitor { virtual void OnMaxPushIdFrameReceived(const MaxPushIdFrame& /*frame*/) {} virtual void OnPriorityUpdateFrameReceived( const PriorityUpdateFrame& /*frame*/) {} + virtual void OnAcceptChFrameReceived(const AcceptChFrame& /*frame*/) {} // Incoming HTTP/3 frames on request or push streams. virtual void OnDataFrameReceived(QuicStreamId /*stream_id*/, @@ -196,6 +201,10 @@ class QUIC_EXPORT_PRIVATE QuicSpdySession // stream. Returns false and closes connection if |push_id| is invalid. bool OnPriorityUpdateForPushStream(QuicStreamId push_id, int urgency); + // Called when an HTTP/3 ACCEPT_CH frame has been received. + // This method will only be called for client sessions. + virtual void OnAcceptChFrame(const AcceptChFrame& /*frame*/) {} + // Sends contents of |iov| to h2_deframer_, returns number of bytes processed. size_t ProcessHeaderData(const struct iovec& iov); @@ -230,8 +239,9 @@ class QUIC_EXPORT_PRIVATE QuicSpdySession // Write GOAWAY frame with maximum stream ID on the control stream. Called to // initite graceful connection shutdown. Do not use smaller stream ID, in // case client does not implement retry on GOAWAY. Do not send GOAWAY if one - // has already been sent. - void SendHttp3GoAway(); + // has already been sent. Send connection close with |error_code| and |reason| + // before encryption gets established. + void SendHttp3GoAway(QuicErrorCode error_code, const std::string& reason); // Same as SendHttp3GoAway(). TODO(bnc): remove when // gfe2_reloadable_flag_quic_goaway_with_max_stream_id flag is deprecated. @@ -400,6 +410,13 @@ class QUIC_EXPORT_PRIVATE QuicSpdySession // Decode SETTINGS from |cached_state| and apply it to the session. bool ResumeApplicationState(ApplicationState* cached_state) override; + absl::optional<std::string> OnAlpsData(const uint8_t* alps_data, + size_t alps_length) override; + + // Called when ACCEPT_CH frame is parsed out of data received in TLS ALPS + // extension. + virtual void OnAcceptChFrameReceivedViaAlps(const AcceptChFrame& /*frame*/); + protected: // Override CreateIncomingStream(), CreateOutgoingBidirectionalStream() and // CreateOutgoingUnidirectionalStream() with QuicSpdyStream return type to @@ -575,7 +592,7 @@ class QUIC_EXPORT_PRIVATE QuicSpdySession // Priority values received in PRIORITY_UPDATE frames for streams that are not // open yet. - QuicHashMap<QuicStreamId, int> buffered_stream_priorities_; + absl::flat_hash_map<QuicStreamId, int> buffered_stream_priorities_; // An integer used for live check. The indicator is assigned a value in // constructor. As long as it is not the assigned value, that would indicate @@ -603,9 +620,6 @@ class QUIC_EXPORT_PRIVATE QuicSpdySession // recent MAX_PUSH_ID frame. Once true, never goes back to false. bool http3_max_push_id_sent_; - // Latched value of reloadable flag quic_reject_spdy_settings. - const bool reject_spdy_settings_; - // Latched value of reloadable flag quic_goaway_with_max_stream_id. const bool goaway_with_max_stream_id_; }; diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_session_test.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_session_test.cc index 6d93b44db60..c2ab731e948 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_session_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_session_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_session.h" +#include "quic/core/http/quic_spdy_session.h" #include <cstdint> #include <limits> @@ -12,42 +12,43 @@ #include "absl/base/macros.h" #include "absl/strings/escaping.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_stream_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_streams_blocked_frame.h" -#include "net/third_party/quiche/src/quic/core/http/http_constants.h" -#include "net/third_party/quiche/src/quic/core/http/http_encoder.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_header_table_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_flow_controller_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_send_buffer_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" -#include "net/third_party/quiche/src/spdy/core/spdy_framer.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/frames/quic_stream_frame.h" +#include "quic/core/frames/quic_streams_blocked_frame.h" +#include "quic/core/http/http_constants.h" +#include "quic/core/http/http_encoder.h" +#include "quic/core/qpack/qpack_header_table.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_crypto_stream.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_stream.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_map_util.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/qpack/qpack_encoder_peer.h" +#include "quic/test_tools/qpack/qpack_header_table_peer.h" +#include "quic/test_tools/qpack/qpack_test_utils.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_flow_controller_peer.h" +#include "quic/test_tools/quic_session_peer.h" +#include "quic/test_tools/quic_spdy_session_peer.h" +#include "quic/test_tools/quic_stream_peer.h" +#include "quic/test_tools/quic_stream_send_buffer_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/quiche_endian.h" +#include "spdy/core/spdy_framer.h" using spdy::kV3HighestPriority; using spdy::Spdy3PriorityToHttp2Weight; @@ -101,7 +102,7 @@ class TestCryptoStream : public QuicCryptoStream, public QuicCryptoHandshaker { kInitialStreamFlowControlWindowForTest); session()->config()->SetInitialSessionFlowControlWindowToSend( kInitialSessionFlowControlWindowForTest); - if (session()->version().AuthenticatesHandshakeConnectionIds()) { + if (session()->version().UsesTls()) { if (session()->perspective() == Perspective::IS_CLIENT) { session()->config()->SetOriginalConnectionIdToSend( session()->connection()->connection_id()); @@ -111,9 +112,6 @@ class TestCryptoStream : public QuicCryptoStream, public QuicCryptoHandshaker { session()->config()->SetInitialSourceConnectionIdToSend( session()->connection()->client_connection_id()); } - } - if (session()->connection()->version().handshake_protocol == - PROTOCOL_TLS1_3) { TransportParameters transport_parameters; EXPECT_TRUE( session()->config()->FillTransportParameters(&transport_parameters)); @@ -173,6 +171,11 @@ class TestCryptoStream : public QuicCryptoStream, public QuicCryptoHandshaker { void OnOneRttPacketAcknowledged() override {} void OnHandshakePacketSent() override {} void OnHandshakeDoneReceived() override {} + void OnNewTokenReceived(absl::string_view /*token*/) override {} + std::string GetAddressToken() const override { return ""; } + bool ValidateAddressToken(absl::string_view /*token*/) const override { + return true; + } MOCK_METHOD(void, OnCanWrite, (), (override)); @@ -343,11 +346,13 @@ class TestSession : public QuicSpdySession { } QuicConsumedData SendLargeFakeData(QuicStream* stream, int bytes) { - DCHECK(writev_consumes_all_data_); + QUICHE_DCHECK(writev_consumes_all_data_); return WritevData(stream->id(), bytes, 0, FIN, NOT_RETRANSMISSION, GetEncryptionLevelToSendApplicationData()); } + MOCK_METHOD(void, OnAcceptChFrame, (const AcceptChFrame&), (override)); + using QuicSession::closed_streams; using QuicSession::ShouldKeepConnectionAlive; using QuicSpdySession::ProcessPendingStream; @@ -500,9 +505,9 @@ class QuicSpdySessionTestBase : public QuicTestWithParam<ParsedQuicVersion> { EXPECT_CALL(*writer_, WritePacket(_, _, _, _, _)) .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0))); } - // HANDSHAKE_DONE frame sent by the server. - if (connection_->version().HasHandshakeDone() && + if (connection_->version().UsesTls() && connection_->perspective() == Perspective::IS_SERVER) { + // HANDSHAKE_DONE frame. EXPECT_CALL(*connection_, SendControlFrame(_)) .WillOnce(Invoke(&ClearControlFrame)); } @@ -708,8 +713,8 @@ TEST_P(QuicSpdySessionTestServer, EXPECT_CALL(*connection_, SendControlFrame(_)); EXPECT_CALL(*connection_, OnStreamReset(closed_stream_id, _)); stream2->Reset(QUIC_BAD_APPLICATION_PAYLOAD); - std::string msg = quiche::QuicheStrCat("Marking unknown stream ", - closed_stream_id, " blocked."); + std::string msg = + absl::StrCat("Marking unknown stream ", closed_stream_id, " blocked."); EXPECT_QUIC_BUG(session_.MarkConnectionLevelWriteBlocked(closed_stream_id), msg); } @@ -1099,6 +1104,21 @@ TEST_P(QuicSpdySessionTestServer, SendGoAway) { EXPECT_TRUE(session_.GetOrCreateStream(kTestStreamId)); } +TEST_P(QuicSpdySessionTestServer, SendGoAwayWithoutEncryption) { + SetQuicReloadableFlag(quic_encrypted_goaway, true); + if (VersionHasIetfQuicFrames(transport_version())) { + // HTTP/3 GOAWAY has different semantic and thus has its own test. + return; + } + EXPECT_CALL( + *connection_, + CloseConnection(QUIC_PEER_GOING_AWAY, "Going Away.", + ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET)); + EXPECT_CALL(*connection_, SendControlFrame(_)).Times(0); + session_.SendGoAway(QUIC_PEER_GOING_AWAY, "Going Away."); + EXPECT_FALSE(session_.goaway_sent()); +} + TEST_P(QuicSpdySessionTestServer, SendHttp3GoAway) { if (!VersionUsesHttp3(transport_version())) { return; @@ -1119,7 +1139,7 @@ TEST_P(QuicSpdySessionTestServer, SendHttp3GoAway) { // retried on a different connection. EXPECT_CALL(debug_visitor, OnGoAwayFrameSent(/* stream_id = */ 0)); } - session_.SendHttp3GoAway(); + session_.SendHttp3GoAway(QUIC_PEER_GOING_AWAY, "Goaway"); EXPECT_TRUE(session_.goaway_sent()); // New incoming stream is not reset. @@ -1130,23 +1150,24 @@ TEST_P(QuicSpdySessionTestServer, SendHttp3GoAway) { // No more GOAWAY frames are sent because they could not convey new // information to the client. - if (!GetQuicReloadableFlag(quic_fix_http3_goaway_stream_id) && - !GetQuicReloadableFlag(quic_goaway_with_max_stream_id)) { - // Except when both these flags are false, in which case a second GOAWAY - // frame is sent. - EXPECT_CALL(*writer_, WritePacket(_, _, _, _, _)) - .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0))); - EXPECT_CALL(debug_visitor, OnGoAwayFrameSent(/* stream_id = */ 0)); - } - session_.SendHttp3GoAway(); + session_.SendHttp3GoAway(QUIC_PEER_GOING_AWAY, "Goaway"); } -TEST_P(QuicSpdySessionTestServer, SendHttp3GoAwayAfterStreamIsCreated) { +TEST_P(QuicSpdySessionTestServer, SendHttp3GoAwayWithoutEncryption) { + SetQuicReloadableFlag(quic_encrypted_goaway, true); if (!VersionUsesHttp3(transport_version())) { return; } + EXPECT_CALL( + *connection_, + CloseConnection(QUIC_PEER_GOING_AWAY, "Goaway", + ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET)); + session_.SendHttp3GoAway(QUIC_PEER_GOING_AWAY, "Goaway"); + EXPECT_FALSE(session_.goaway_sent()); +} - if (!GetQuicReloadableFlag(quic_fix_http3_goaway_stream_id)) { +TEST_P(QuicSpdySessionTestServer, SendHttp3GoAwayAfterStreamIsCreated) { + if (!VersionUsesHttp3(transport_version())) { return; } @@ -1169,12 +1190,12 @@ TEST_P(QuicSpdySessionTestServer, SendHttp3GoAwayAfterStreamIsCreated) { // starting with stream ID = 4 can be retried on a different connection. EXPECT_CALL(debug_visitor, OnGoAwayFrameSent(/* stream_id = */ 4)); } - session_.SendHttp3GoAway(); + session_.SendHttp3GoAway(QUIC_PEER_GOING_AWAY, "Goaway"); EXPECT_TRUE(session_.goaway_sent()); // No more GOAWAY frames are sent because they could not convey new // information to the client. - session_.SendHttp3GoAway(); + session_.SendHttp3GoAway(QUIC_PEER_GOING_AWAY, "Goaway"); } TEST_P(QuicSpdySessionTestServer, SendHttp3Shutdown) { @@ -1222,7 +1243,7 @@ TEST_P(QuicSpdySessionTestServer, SendHttp3GoAwayAfterShutdownNotice) { session_.SendHttp3Shutdown(); EXPECT_TRUE(session_.goaway_sent()); - session_.SendHttp3GoAway(); + session_.SendHttp3GoAway(QUIC_PEER_GOING_AWAY, "Goaway"); const QuicStreamId kTestStreamId = GetNthClientInitiatedBidirectionalStreamId(transport_version(), 0); @@ -1276,6 +1297,10 @@ TEST_P(QuicSpdySessionTestServer, Http3GoAwayLargerIdThanBefore) { // Test that server session will send a connectivity probe in response to a // connectivity probe on the same path. TEST_P(QuicSpdySessionTestServer, ServerReplyToConnecitivityProbe) { + if (VersionHasIetfQuicFrames(transport_version()) && + connection_->send_path_response()) { + return; + } connection_->SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); QuicSocketAddress old_peer_address = QuicSocketAddress(QuicIpAddress::Loopback4(), kTestPort); @@ -1566,8 +1591,8 @@ TEST_P(QuicSpdySessionTestServer, while (!headers_stream->IsFlowControlBlocked() && stream_id < 2000) { EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); EXPECT_FALSE(session_.IsStreamFlowControlBlocked()); - headers["header"] = quiche::QuicheStrCat( - random.RandUint64(), random.RandUint64(), random.RandUint64()); + headers["header"] = absl::StrCat(random.RandUint64(), random.RandUint64(), + random.RandUint64()); session_.WriteHeadersOnHeadersStream(stream_id, headers.Clone(), true, spdy::SpdyStreamPrecedence(0), nullptr); @@ -1886,10 +1911,12 @@ TEST_P(QuicSpdySessionTestClient, BadStreamFramePendingStream) { GetNthServerInitiatedUnidirectionalStreamId(transport_version(), 0); // A bad stream frame with no data and no fin. QuicStreamFrame data1(stream_id1, false, 0, 0); - EXPECT_CALL(*connection_, CloseConnection(_, _, _)) - .WillOnce( - Invoke(connection_, &MockQuicConnection::ReallyCloseConnection)); - EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _)); + if (!GetQuicReloadableFlag(quic_accept_empty_stream_frame_with_no_fin)) { + EXPECT_CALL(*connection_, CloseConnection(_, _, _)) + .WillOnce( + Invoke(connection_, &MockQuicConnection::ReallyCloseConnection)); + EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _, _)); + } session_.OnStreamFrame(data1); } @@ -2347,12 +2374,8 @@ TEST_P(QuicSpdySessionTestServer, SimplePendingStreamType) { QuicStopSendingFrame* stop_sending = frame.stop_sending_frame; EXPECT_EQ(stream_id, stop_sending->stream_id); - EXPECT_EQ( - GetQuicReloadableFlag(quic_stop_sending_uses_ietf_error_code) - ? QUIC_STREAM_STREAM_CREATION_ERROR - : static_cast<QuicRstStreamErrorCode>( - QuicHttp3ErrorCode::STREAM_CREATION_ERROR), - stop_sending->error_code); + EXPECT_EQ(QUIC_STREAM_STREAM_CREATION_ERROR, + stop_sending->error_code); EXPECT_EQ( static_cast<uint64_t>(QuicHttp3ErrorCode::STREAM_CREATION_ERROR), stop_sending->ietf_error_code); @@ -2547,8 +2570,7 @@ TEST_P(QuicSpdySessionTestServer, StreamClosedWhileHeaderDecodingBlocked) { &headers_buffer); absl::string_view headers_frame_header(headers_buffer.get(), headers_frame_header_length); - std::string headers = - quiche::QuicheStrCat(headers_frame_header, headers_payload); + std::string headers = absl::StrCat(headers_frame_header, headers_payload); stream->OnStreamFrame(QuicStreamFrame(stream_id, false, 0, headers)); // Decoding is blocked because dynamic table entry has not been received yet. @@ -2582,8 +2604,7 @@ TEST_P(QuicSpdySessionTestServer, SessionDestroyedWhileHeaderDecodingBlocked) { &headers_buffer); absl::string_view headers_frame_header(headers_buffer.get(), headers_frame_header_length); - std::string headers = - quiche::QuicheStrCat(headers_frame_header, headers_payload); + std::string headers = absl::StrCat(headers_frame_header, headers_payload); stream->OnStreamFrame(QuicStreamFrame(stream_id, false, 0, headers)); // Decoding is blocked because dynamic table entry has not been received yet. @@ -2807,13 +2828,10 @@ TEST_P(QuicSpdySessionTestClient, EncoderStreamError) { QuicStreamFrame frame(stream_id, /* fin = */ false, /* offset = */ 0, data); - EXPECT_CALL( - *connection_, - CloseConnection( - GetQuicReloadableFlag(quic_granular_qpack_error_codes) - ? QUIC_QPACK_ENCODER_STREAM_DUPLICATE_INVALID_RELATIVE_INDEX - : QUIC_QPACK_ENCODER_STREAM_ERROR, - "Encoder stream error: Invalid relative index.", _)); + EXPECT_CALL(*connection_, + CloseConnection( + QUIC_QPACK_ENCODER_STREAM_DUPLICATE_INVALID_RELATIVE_INDEX, + "Encoder stream error: Invalid relative index.", _)); session_.OnStreamFrame(frame); } @@ -2833,9 +2851,7 @@ TEST_P(QuicSpdySessionTestClient, DecoderStreamError) { EXPECT_CALL( *connection_, - CloseConnection(GetQuicReloadableFlag(quic_granular_qpack_error_codes) - ? QUIC_QPACK_DECODER_STREAM_INVALID_ZERO_INCREMENT - : QUIC_QPACK_DECODER_STREAM_ERROR, + CloseConnection(QUIC_QPACK_DECODER_STREAM_INVALID_ZERO_INCREMENT, "Decoder stream error: Invalid increment value 0.", _)); session_.OnStreamFrame(frame); } @@ -3160,16 +3176,11 @@ TEST_P(QuicSpdySessionTestServer, Http3GoAwayWhenClosingConnection) { &session_, /*unidirectional = */ false)); if (GetQuicReloadableFlag(quic_send_goaway_with_connection_close)) { - if (GetQuicReloadableFlag(quic_fix_http3_goaway_stream_id)) { - // Stream with stream_id is already received and potentially processed, - // therefore a GOAWAY frame is sent with the next stream ID. - EXPECT_CALL(debug_visitor, - OnGoAwayFrameSent(stream_id + QuicUtils::StreamIdDelta( - transport_version()))); - } else { - // GOAWAY frame stream id is incorrect, ignore. - EXPECT_CALL(debug_visitor, OnGoAwayFrameSent(_)); - } + // Stream with stream_id is already received and potentially processed, + // therefore a GOAWAY frame is sent with the next stream ID. + EXPECT_CALL(debug_visitor, + OnGoAwayFrameSent( + stream_id + QuicUtils::StreamIdDelta(transport_version()))); } // Close connection. @@ -3178,7 +3189,7 @@ TEST_P(QuicSpdySessionTestServer, Http3GoAwayWhenClosingConnection) { EXPECT_CALL(*connection_, CloseConnection(QUIC_NO_ERROR, _, _)) .WillOnce( Invoke(connection_, &MockQuicConnection::ReallyCloseConnection)); - EXPECT_CALL(*connection_, SendConnectionClosePacket(QUIC_NO_ERROR, _)) + EXPECT_CALL(*connection_, SendConnectionClosePacket(QUIC_NO_ERROR, _, _)) .WillOnce(Invoke(connection_, &MockQuicConnection::ReallySendConnectionClosePacket)); connection_->CloseConnection( @@ -3235,8 +3246,7 @@ TEST_P(QuicSpdySessionTestClient, DoNotSendInitialMaxPushIdIfSetToDefaut) { } TEST_P(QuicSpdySessionTestClient, ReceiveSpdySettingInHttp3) { - if (!VersionUsesHttp3(transport_version()) || - !GetQuicReloadableFlag(quic_reject_spdy_settings)) { + if (!VersionUsesHttp3(transport_version())) { return; } @@ -3253,6 +3263,118 @@ TEST_P(QuicSpdySessionTestClient, ReceiveSpdySettingInHttp3) { session_.OnSettingsFrame(frame); } +TEST_P(QuicSpdySessionTestClient, ReceiveAcceptChFrame) { + if (!VersionUsesHttp3(transport_version())) { + return; + } + + if (!GetQuicReloadableFlag(quic_parse_accept_ch_frame)) { + return; + } + + StrictMock<MockHttp3DebugVisitor> debug_visitor; + session_.set_debug_visitor(&debug_visitor); + + // Create control stream. + QuicStreamId receive_control_stream_id = + GetNthServerInitiatedUnidirectionalStreamId(transport_version(), 3); + char type[] = {kControlStream}; + absl::string_view stream_type(type, 1); + QuicStreamOffset offset = 0; + QuicStreamFrame data1(receive_control_stream_id, /* fin = */ false, offset, + stream_type); + offset += stream_type.length(); + EXPECT_CALL(debug_visitor, + OnPeerControlStreamCreated(receive_control_stream_id)); + + session_.OnStreamFrame(data1); + EXPECT_EQ(receive_control_stream_id, + QuicSpdySessionPeer::GetReceiveControlStream(&session_)->id()); + + // First frame has to be SETTINGS. + std::string serialized_settings = EncodeSettings({}); + QuicStreamFrame data2(receive_control_stream_id, /* fin = */ false, offset, + serialized_settings); + offset += serialized_settings.length(); + EXPECT_CALL(debug_visitor, OnSettingsFrameReceived(_)); + + session_.OnStreamFrame(data2); + + // Receive ACCEPT_CH frame. + AcceptChFrame accept_ch; + accept_ch.entries.push_back({"foo", "bar"}); + std::unique_ptr<char[]> buffer; + auto frame_length = HttpEncoder::SerializeAcceptChFrame(accept_ch, &buffer); + QuicStreamFrame data3(receive_control_stream_id, /* fin = */ false, offset, + absl::string_view(buffer.get(), frame_length)); + + EXPECT_CALL(debug_visitor, OnAcceptChFrameReceived(accept_ch)); + EXPECT_CALL(session_, OnAcceptChFrame(accept_ch)); + + session_.OnStreamFrame(data3); +} + +TEST_P(QuicSpdySessionTestClient, AcceptChViaAlps) { + if (!VersionUsesHttp3(transport_version())) { + return; + } + + StrictMock<MockHttp3DebugVisitor> debug_visitor; + session_.set_debug_visitor(&debug_visitor); + + std::string serialized_accept_ch_frame = absl::HexStringToBytes( + "4089" // type (ACCEPT_CH) + "08" // length + "03" // length of origin + "666f6f" // origin "foo" + "03" // length of value + "626172"); // value "bar" + + if (GetQuicReloadableFlag(quic_parse_accept_ch_frame)) { + AcceptChFrame expected_accept_ch_frame{{{"foo", "bar"}}}; + EXPECT_CALL(debug_visitor, + OnAcceptChFrameReceivedViaAlps(expected_accept_ch_frame)); + } + + auto error = session_.OnAlpsData( + reinterpret_cast<const uint8_t*>(serialized_accept_ch_frame.data()), + serialized_accept_ch_frame.size()); + EXPECT_FALSE(error); +} + +TEST_P(QuicSpdySessionTestClient, AlpsForbiddenFrame) { + if (!VersionUsesHttp3(transport_version())) { + return; + } + + std::string forbidden_frame = absl::HexStringToBytes( + "00" // type (DATA) + "03" // length + "66666f"); // "foo" + + auto error = session_.OnAlpsData( + reinterpret_cast<const uint8_t*>(forbidden_frame.data()), + forbidden_frame.size()); + ASSERT_TRUE(error); + EXPECT_EQ("DATA frame forbidden", error.value()); +} + +TEST_P(QuicSpdySessionTestClient, AlpsIncompleteFrame) { + if (!VersionUsesHttp3(transport_version())) { + return; + } + + std::string incomplete_frame = absl::HexStringToBytes( + "04" // type (SETTINGS) + "03"); // non-zero length but empty payload + + auto error = session_.OnAlpsData( + reinterpret_cast<const uint8_t*>(incomplete_frame.data()), + incomplete_frame.size()); + ASSERT_TRUE(error); + EXPECT_EQ("incomplete HTTP/3 frame", error.value()); +} + } // namespace } // namespace test } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream.cc index 7059fc0dee7..6ab6bb0aa68 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_stream.h" +#include "quic/core/http/quic_spdy_stream.h" #include <limits> #include <string> @@ -11,22 +11,22 @@ #include "absl/base/macros.h" #include "absl/strings/numbers.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/http/http_constants.h" -#include "net/third_party/quiche/src/quic/core/http/http_decoder.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_session.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/core/quic_write_blocked_list.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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_mem_slice_storage.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" +#include "quic/core/http/http_constants.h" +#include "quic/core/http/http_decoder.h" +#include "quic/core/http/quic_spdy_session.h" +#include "quic/core/http/spdy_utils.h" +#include "quic/core/qpack/qpack_decoder.h" +#include "quic/core/qpack/qpack_encoder.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/core/quic_write_blocked_list.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_mem_slice_storage.h" +#include "common/platform/api/quiche_text_utils.h" +#include "spdy/core/spdy_protocol.h" using spdy::SpdyHeaderBlock; using spdy::SpdyPriority; @@ -76,7 +76,7 @@ class QuicSpdyStream::HttpDecoderVisitor : public HttpDecoder::Visitor { } bool OnDataFramePayload(absl::string_view payload) override { - DCHECK(!payload.empty()); + QUICHE_DCHECK(!payload.empty()); return stream_->OnDataFramePayload(payload); } @@ -92,7 +92,7 @@ class QuicSpdyStream::HttpDecoderVisitor : public HttpDecoder::Visitor { } bool OnHeadersFramePayload(absl::string_view payload) override { - DCHECK(!payload.empty()); + QUICHE_DCHECK(!payload.empty()); if (!VersionUsesHttp3(stream_->transport_version())) { CloseConnectionOnWrongFrame("Headers"); return false; @@ -128,7 +128,7 @@ class QuicSpdyStream::HttpDecoderVisitor : public HttpDecoder::Visitor { } bool OnPushPromiseFramePayload(absl::string_view payload) override { - DCHECK(!payload.empty()); + QUICHE_DCHECK(!payload.empty()); if (!VersionUsesHttp3(stream_->transport_version())) { CloseConnectionOnWrongFrame("Push Promise"); return false; @@ -154,6 +154,16 @@ class QuicSpdyStream::HttpDecoderVisitor : public HttpDecoder::Visitor { return false; } + bool OnAcceptChFrameStart(QuicByteCount /*header_length*/) override { + CloseConnectionOnWrongFrame("ACCEPT_CH"); + return false; + } + + bool OnAcceptChFrame(const AcceptChFrame& /*frame*/) override { + CloseConnectionOnWrongFrame("ACCEPT_CH"); + return false; + } + bool OnUnknownFrameStart(uint64_t frame_type, QuicByteCount header_length, QuicByteCount payload_length) override { @@ -171,7 +181,7 @@ class QuicSpdyStream::HttpDecoderVisitor : public HttpDecoder::Visitor { void CloseConnectionOnWrongFrame(absl::string_view frame_type) { stream_->OnUnrecoverableError( QUIC_HTTP_FRAME_UNEXPECTED_ON_SPDY_STREAM, - quiche::QuicheStrCat(frame_type, " frame received on data stream")); + absl::StrCat(frame_type, " frame received on data stream")); } QuicSpdyStream* stream_; @@ -201,10 +211,10 @@ QuicSpdyStream::QuicSpdyStream(QuicStreamId id, is_decoder_processing_input_(false), ack_listener_(nullptr), last_sent_urgency_(kDefaultUrgency) { - DCHECK_EQ(session()->connection(), spdy_session->connection()); - DCHECK_EQ(transport_version(), spdy_session->transport_version()); - DCHECK(!QuicUtils::IsCryptoStreamId(transport_version(), id)); - DCHECK_EQ(0u, sequencer()->NumBytesConsumed()); + QUICHE_DCHECK_EQ(session()->connection(), spdy_session->connection()); + QUICHE_DCHECK_EQ(transport_version(), spdy_session->transport_version()); + QUICHE_DCHECK(!QuicUtils::IsCryptoStreamId(transport_version(), id)); + QUICHE_DCHECK_EQ(0u, sequencer()->NumBytesConsumed()); // If headers are sent on the headers stream, then do not receive any // callbacks from the sequencer until headers are complete. if (!VersionUsesHttp3(transport_version())) { @@ -237,9 +247,9 @@ QuicSpdyStream::QuicSpdyStream(PendingStream* pending, is_decoder_processing_input_(false), ack_listener_(nullptr), last_sent_urgency_(kDefaultUrgency) { - DCHECK_EQ(session()->connection(), spdy_session->connection()); - DCHECK_EQ(transport_version(), spdy_session->transport_version()); - DCHECK(!QuicUtils::IsCryptoStreamId(transport_version(), id())); + QUICHE_DCHECK_EQ(session()->connection(), spdy_session->connection()); + QUICHE_DCHECK_EQ(transport_version(), spdy_session->transport_version()); + QUICHE_DCHECK(!QuicUtils::IsCryptoStreamId(transport_version(), id())); // If headers are sent on the headers stream, then do not receive any // callbacks from the sequencer until headers are complete. if (!VersionUsesHttp3(transport_version())) { @@ -363,7 +373,7 @@ size_t QuicSpdyStream::WriteTrailers( } void QuicSpdyStream::WritePushPromise(const PushPromiseFrame& frame) { - DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); std::unique_ptr<char[]> push_promise_frame_with_id; const size_t push_promise_frame_length = HttpEncoder::SerializePushPromiseFrameWithOnlyPushId( @@ -443,7 +453,7 @@ QuicConsumedData QuicSpdyStream::WriteBodySlices(QuicMemSliceSpan slices, } size_t QuicSpdyStream::Readv(const struct iovec* iov, size_t iov_len) { - DCHECK(FinishedReadingHeaders()); + QUICHE_DCHECK(FinishedReadingHeaders()); if (!VersionUsesHttp3(transport_version())) { return sequencer()->Readv(iov, iov_len); } @@ -454,7 +464,7 @@ size_t QuicSpdyStream::Readv(const struct iovec* iov, size_t iov_len) { } int QuicSpdyStream::GetReadableRegions(iovec* iov, size_t iov_len) const { - DCHECK(FinishedReadingHeaders()); + QUICHE_DCHECK(FinishedReadingHeaders()); if (!VersionUsesHttp3(transport_version())) { return sequencer()->GetReadableRegions(iov, iov_len); } @@ -462,7 +472,7 @@ int QuicSpdyStream::GetReadableRegions(iovec* iov, size_t iov_len) const { } void QuicSpdyStream::MarkConsumed(size_t num_bytes) { - DCHECK(FinishedReadingHeaders()); + QUICHE_DCHECK(FinishedReadingHeaders()); if (!VersionUsesHttp3(transport_version())) { sequencer()->MarkConsumed(num_bytes); return; @@ -522,7 +532,8 @@ void QuicSpdyStream::ConsumeHeaderList() { void QuicSpdyStream::OnStreamHeadersPriority( const spdy::SpdyStreamPrecedence& precedence) { - DCHECK_EQ(Perspective::IS_SERVER, session()->connection()->perspective()); + QUICHE_DCHECK_EQ(Perspective::IS_SERVER, + session()->connection()->perspective()); SetPriority(precedence); } @@ -597,7 +608,7 @@ void QuicSpdyStream::OnHeadersDecoded(QuicHeaderList headers, void QuicSpdyStream::OnHeaderDecodingError(absl::string_view error_message) { qpack_decoded_headers_accumulator_.reset(); - std::string connection_close_error_message = quiche::QuicheStrCat( + std::string connection_close_error_message = absl::StrCat( "Error decoding ", headers_decompressed_ ? "trailers" : "headers", " on stream ", id(), ": ", error_message); OnUnrecoverableError(QUIC_QPACK_DECOMPRESSION_FAILED, @@ -620,7 +631,7 @@ void QuicSpdyStream::MaybeSendPriorityUpdateFrame() { PriorityUpdateFrame priority_update; priority_update.prioritized_element_type = REQUEST_STREAM; priority_update.prioritized_element_id = id(); - priority_update.priority_field_value = quiche::QuicheStrCat("u=", urgency); + priority_update.priority_field_value = absl::StrCat("u=", urgency); spdy_session_->WriteHttp3PriorityUpdate(priority_update); } @@ -669,7 +680,7 @@ void QuicSpdyStream::OnTrailingHeadersComplete( size_t /*frame_len*/, const QuicHeaderList& header_list) { // TODO(b/134706391): remove |fin| argument. - DCHECK(!trailers_decompressed_); + QUICHE_DCHECK(!trailers_decompressed_); if (!VersionUsesHttp3(transport_version()) && fin_received()) { QUIC_DLOG(INFO) << ENDPOINT << "Received Trailers after FIN, on stream: " << id(); @@ -708,15 +719,36 @@ void QuicSpdyStream::OnTrailingHeadersComplete( void QuicSpdyStream::OnPriorityFrame( const spdy::SpdyStreamPrecedence& precedence) { - DCHECK_EQ(Perspective::IS_SERVER, session()->connection()->perspective()); + QUICHE_DCHECK_EQ(Perspective::IS_SERVER, + session()->connection()->perspective()); SetPriority(precedence); } void QuicSpdyStream::OnStreamReset(const QuicRstStreamFrame& frame) { + // TODO(bnc): Merge the two blocks below when both + // quic_abort_qpack_on_stream_reset and quic_fix_on_stream_reset are + // deprecated. if (frame.error_code != QUIC_STREAM_NO_ERROR) { if (VersionUsesHttp3(transport_version()) && !fin_received() && spdy_session_->qpack_decoder()) { + QUIC_CODE_COUNT_N(quic_abort_qpack_on_stream_reset, 1, 2); spdy_session_->qpack_decoder()->OnStreamReset(id()); + if (GetQuicReloadableFlag(quic_abort_qpack_on_stream_reset)) { + QUIC_RELOADABLE_FLAG_COUNT_N(quic_abort_qpack_on_stream_reset, 1, 2); + qpack_decoded_headers_accumulator_.reset(); + } + } + + QuicStream::OnStreamReset(frame); + return; + } + + if (GetQuicReloadableFlag(quic_fix_on_stream_reset) && + VersionUsesHttp3(transport_version())) { + QUIC_RELOADABLE_FLAG_COUNT(quic_fix_on_stream_reset); + if (!fin_received() && spdy_session_->qpack_decoder()) { + spdy_session_->qpack_decoder()->OnStreamReset(id()); + qpack_decoded_headers_accumulator_.reset(); } QuicStream::OnStreamReset(frame); @@ -734,7 +766,12 @@ void QuicSpdyStream::OnStreamReset(const QuicRstStreamFrame& frame) { void QuicSpdyStream::Reset(QuicRstStreamErrorCode error) { if (VersionUsesHttp3(transport_version()) && !fin_received() && spdy_session_->qpack_decoder()) { + QUIC_CODE_COUNT_N(quic_abort_qpack_on_stream_reset, 2, 2); spdy_session_->qpack_decoder()->OnStreamReset(id()); + if (GetQuicReloadableFlag(quic_abort_qpack_on_stream_reset)) { + QUIC_RELOADABLE_FLAG_COUNT_N(quic_abort_qpack_on_stream_reset, 2, 2); + qpack_decoded_headers_accumulator_.reset(); + } } QuicStream::Reset(error); @@ -743,7 +780,7 @@ void QuicSpdyStream::Reset(QuicRstStreamErrorCode error) { void QuicSpdyStream::OnDataAvailable() { if (!VersionUsesHttp3(transport_version())) { // Sequencer must be blocked until headers are consumed. - DCHECK(FinishedReadingHeaders()); + QUICHE_DCHECK(FinishedReadingHeaders()); } if (!VersionUsesHttp3(transport_version())) { @@ -763,12 +800,12 @@ void QuicSpdyStream::OnDataAvailable() { iovec iov; while (session()->connection()->connected() && !reading_stopped() && decoder_.error() == QUIC_NO_ERROR) { - DCHECK_GE(sequencer_offset_, sequencer()->NumBytesConsumed()); + QUICHE_DCHECK_GE(sequencer_offset_, sequencer()->NumBytesConsumed()); if (!sequencer()->PeekRegion(sequencer_offset_, &iov)) { break; } - DCHECK(!sequencer()->IsClosed()); + QUICHE_DCHECK(!sequencer()->IsClosed()); is_decoder_processing_input_ = true; QuicByteCount processed_bytes = decoder_.ProcessInput( reinterpret_cast<const char*>(iov.iov_base), iov.iov_len); @@ -799,10 +836,7 @@ void QuicSpdyStream::OnDataAvailable() { void QuicSpdyStream::OnClose() { QuicStream::OnClose(); - if (GetQuicReloadableFlag(quic_abort_qpack_on_stream_close)) { - QUIC_RELOADABLE_FLAG_COUNT(quic_abort_qpack_on_stream_close); - qpack_decoded_headers_accumulator_.reset(); - } + qpack_decoded_headers_accumulator_.reset(); if (visitor_) { Visitor* visitor = visitor_; @@ -860,13 +894,9 @@ bool QuicSpdyStream::FinishedReadingTrailers() const { } } -void QuicSpdyStream::ClearSession() { - spdy_session_ = nullptr; -} - bool QuicSpdyStream::OnDataFrameStart(QuicByteCount header_length, QuicByteCount payload_length) { - DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); if (spdy_session_->debug_visitor()) { spdy_session_->debug_visitor()->OnDataFrameReceived(id(), payload_length); @@ -885,7 +915,7 @@ bool QuicSpdyStream::OnDataFrameStart(QuicByteCount header_length, } bool QuicSpdyStream::OnDataFramePayload(absl::string_view payload) { - DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); body_manager_.OnBody(payload); @@ -893,7 +923,7 @@ bool QuicSpdyStream::OnDataFramePayload(absl::string_view payload) { } bool QuicSpdyStream::OnDataFrameEnd() { - DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); QUIC_DVLOG(1) << ENDPOINT << "Reaches the end of a data frame. Total bytes received are " @@ -913,7 +943,7 @@ bool QuicSpdyStream::OnStreamFrameAcked(QuicStreamOffset offset, const QuicByteCount newly_acked_header_length = GetNumFrameHeadersInInterval(offset, data_length); - DCHECK_LE(newly_acked_header_length, *newly_acked_length); + QUICHE_DCHECK_LE(newly_acked_header_length, *newly_acked_length); unacked_frame_headers_offsets_.Difference(offset, offset + data_length); if (ack_listener_ != nullptr && new_data_acked) { ack_listener_->OnPacketAcked( @@ -930,7 +960,7 @@ void QuicSpdyStream::OnStreamFrameRetransmitted(QuicStreamOffset offset, const QuicByteCount retransmitted_header_length = GetNumFrameHeadersInInterval(offset, data_length); - DCHECK_LE(retransmitted_header_length, data_length); + QUICHE_DCHECK_LE(retransmitted_header_length, data_length); if (ack_listener_ != nullptr) { ack_listener_->OnPacketRetransmitted(data_length - @@ -952,8 +982,8 @@ QuicByteCount QuicSpdyStream::GetNumFrameHeadersInInterval( bool QuicSpdyStream::OnHeadersFrameStart(QuicByteCount header_length, QuicByteCount payload_length) { - DCHECK(VersionUsesHttp3(transport_version())); - DCHECK(!qpack_decoded_headers_accumulator_); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(!qpack_decoded_headers_accumulator_); if (spdy_session_->debug_visitor()) { spdy_session_->debug_visitor()->OnHeadersFrameReceived(id(), @@ -980,8 +1010,8 @@ bool QuicSpdyStream::OnHeadersFrameStart(QuicByteCount header_length, } bool QuicSpdyStream::OnHeadersFramePayload(absl::string_view payload) { - DCHECK(VersionUsesHttp3(transport_version())); - DCHECK(qpack_decoded_headers_accumulator_); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(qpack_decoded_headers_accumulator_); qpack_decoded_headers_accumulator_->Decode(payload); @@ -995,8 +1025,8 @@ bool QuicSpdyStream::OnHeadersFramePayload(absl::string_view payload) { } bool QuicSpdyStream::OnHeadersFrameEnd() { - DCHECK(VersionUsesHttp3(transport_version())); - DCHECK(qpack_decoded_headers_accumulator_); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(qpack_decoded_headers_accumulator_); qpack_decoded_headers_accumulator_->EndHeaderBlock(); @@ -1011,8 +1041,8 @@ bool QuicSpdyStream::OnHeadersFrameEnd() { } bool QuicSpdyStream::OnPushPromiseFrameStart(QuicByteCount header_length) { - DCHECK(VersionUsesHttp3(transport_version())); - DCHECK(!qpack_decoded_headers_accumulator_); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(!qpack_decoded_headers_accumulator_); sequencer()->MarkConsumed(body_manager_.OnNonBody(header_length)); @@ -1023,8 +1053,8 @@ bool QuicSpdyStream::OnPushPromiseFramePushId( PushId push_id, QuicByteCount push_id_length, QuicByteCount header_block_length) { - DCHECK(VersionUsesHttp3(transport_version())); - DCHECK(!qpack_decoded_headers_accumulator_); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(!qpack_decoded_headers_accumulator_); if (spdy_session_->debug_visitor()) { spdy_session_->debug_visitor()->OnPushPromiseFrameReceived( @@ -1049,7 +1079,7 @@ bool QuicSpdyStream::OnPushPromiseFramePayload(absl::string_view payload) { } bool QuicSpdyStream::OnPushPromiseFrameEnd() { - DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); return OnHeadersFrameEnd(); } diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream.h b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream.h index c460b6e5512..60d5e390b20 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream.h @@ -16,18 +16,18 @@ #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/http/http_decoder.h" -#include "net/third_party/quiche/src/quic/core/http/http_encoder.h" -#include "net/third_party/quiche/src/quic/core/http/quic_header_list.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_stream_body_manager.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_stream_sequencer.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/third_party/quiche/src/spdy/core/spdy_framer.h" +#include "quic/core/http/http_decoder.h" +#include "quic/core/http/http_encoder.h" +#include "quic/core/http/quic_header_list.h" +#include "quic/core/http/quic_spdy_stream_body_manager.h" +#include "quic/core/qpack/qpack_decoded_headers_accumulator.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_stream.h" +#include "quic/core/quic_stream_sequencer.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_socket_address.h" +#include "spdy/core/spdy_framer.h" namespace quic { @@ -207,12 +207,6 @@ class QUIC_EXPORT_PRIVATE QuicSpdyStream // read and consumed or there are no trailers. bool FinishedReadingTrailers() const; - // Called when owning session is getting deleted to avoid subsequent - // use of the spdy_session_ member. - // TODO(b/136274541): Remove this method once - // flag_quic_clean_up_spdy_session_destructor is deprecated. - void ClearSession(); - // Returns true if the sequencer has delivered the FIN, and no more body bytes // will be available. bool IsSequencerClosed() { return sequencer()->IsClosed(); } diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream_body_manager.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream_body_manager.cc index 83af51d0208..1d40e03d186 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream_body_manager.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream_body_manager.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_stream_body_manager.h" +#include "quic/core/http/quic_spdy_stream_body_manager.h" #include <algorithm> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -15,7 +15,7 @@ QuicSpdyStreamBodyManager::QuicSpdyStreamBodyManager() : total_body_bytes_received_(0) {} size_t QuicSpdyStreamBodyManager::OnNonBody(QuicByteCount length) { - DCHECK_NE(0u, length); + QUICHE_DCHECK_NE(0u, length); if (fragments_.empty()) { // Non-body bytes can be consumed immediately, because all previously @@ -29,7 +29,7 @@ size_t QuicSpdyStreamBodyManager::OnNonBody(QuicByteCount length) { } void QuicSpdyStreamBodyManager::OnBody(absl::string_view body) { - DCHECK(!body.empty()); + QUICHE_DCHECK(!body.empty()); fragments_.push_back({body, 0}); total_body_bytes_received_ += body.length(); @@ -66,8 +66,8 @@ size_t QuicSpdyStreamBodyManager::OnBodyConsumed(size_t num_bytes) { } int QuicSpdyStreamBodyManager::PeekBody(iovec* iov, size_t iov_len) const { - DCHECK(iov); - DCHECK_GT(iov_len, 0u); + QUICHE_DCHECK(iov); + QUICHE_DCHECK_GT(iov_len, 0u); // TODO(bnc): Is this really necessary? if (fragments_.empty()) { diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream_body_manager.h b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream_body_manager.h index 5e73ac7829c..7b2d9f19186 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream_body_manager.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream_body_manager.h @@ -7,11 +7,11 @@ #include "absl/base/attributes.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_circular_deque.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_iovec.h" +#include "quic/core/quic_circular_deque.h" +#include "quic/core/quic_constants.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_iovec.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream_body_manager_test.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream_body_manager_test.cc index aaa8cce8007..90e50d4813c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream_body_manager_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream_body_manager_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_stream_body_manager.h" +#include "quic/core/http/quic_spdy_stream_body_manager.h" #include <algorithm> #include <numeric> @@ -10,9 +10,9 @@ #include "absl/base/macros.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" namespace quic { @@ -260,7 +260,7 @@ TEST_F(QuicSpdyStreamBodyManagerTest, ReadBody) { std::vector<iovec> iovecs; size_t offset = 0; for (size_t iov_length : iov_lengths[call_index]) { - CHECK(offset + iov_length <= buffer.size()); + QUICHE_CHECK(offset + iov_length <= buffer.size()); iovecs.push_back({&buffer[offset], iov_length}); offset += iov_length; } diff --git a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream_test.cc b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream_test.cc index 526b987b7ed..0e35c28aa4f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/quic_spdy_stream_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_stream.h" +#include "quic/core/http/quic_spdy_stream.h" #include <cstring> #include <memory> @@ -12,28 +12,28 @@ #include "absl/base/macros.h" #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/http/http_encoder.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_stream_sequencer_buffer.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/core/quic_write_blocked_list.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_flow_controller_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_stream_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/http/http_encoder.h" +#include "quic/core/http/spdy_utils.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_stream_sequencer_buffer.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/core/quic_write_blocked_list.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_map_util.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/qpack/qpack_test_utils.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_flow_controller_peer.h" +#include "quic/test_tools/quic_session_peer.h" +#include "quic/test_tools/quic_spdy_session_peer.h" +#include "quic/test_tools/quic_spdy_stream_peer.h" +#include "quic/test_tools/quic_stream_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" using spdy::kV3HighestPriority; using spdy::kV3LowestPriority; @@ -80,7 +80,7 @@ class TestCryptoStream : public QuicCryptoStream, public QuicCryptoHandshaker { kInitialStreamFlowControlWindowForTest); session()->config()->SetInitialSessionFlowControlWindowToSend( kInitialSessionFlowControlWindowForTest); - if (session()->version().AuthenticatesHandshakeConnectionIds()) { + if (session()->version().UsesTls()) { if (session()->perspective() == Perspective::IS_CLIENT) { session()->config()->SetOriginalConnectionIdToSend( session()->connection()->connection_id()); @@ -90,8 +90,6 @@ class TestCryptoStream : public QuicCryptoStream, public QuicCryptoHandshaker { session()->config()->SetInitialSourceConnectionIdToSend( session()->connection()->client_connection_id()); } - } - if (session()->version().UsesTls()) { TransportParameters transport_parameters; EXPECT_TRUE( session()->config()->FillTransportParameters(&transport_parameters)); @@ -113,7 +111,8 @@ class TestCryptoStream : public QuicCryptoStream, public QuicCryptoHandshaker { } else { session()->SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); } - if (session()->version().HasHandshakeDone()) { + if (session()->version().UsesTls()) { + // HANDSHAKE_DONE frame. EXPECT_CALL(*this, HasPendingRetransmission()); } session()->DiscardOldEncryptionKey(ENCRYPTION_INITIAL); @@ -155,6 +154,11 @@ class TestCryptoStream : public QuicCryptoStream, public QuicCryptoHandshaker { void OnConnectionClosed(QuicErrorCode /*error*/, ConnectionCloseSource /*source*/) override {} void OnHandshakeDoneReceived() override {} + void OnNewTokenReceived(absl::string_view /*token*/) override {} + std::string GetAddressToken() const override { return ""; } + bool ValidateAddressToken(absl::string_view /*token*/) const override { + return true; + } MOCK_METHOD(void, OnCanWrite, (), (override)); @@ -389,8 +393,9 @@ class QuicSpdyStreamTest : public QuicTestWithParam<ParsedQuicVersion> { TestCryptoStream* crypto_stream = session_->GetMutableCryptoStream(); EXPECT_CALL(*crypto_stream, HasPendingRetransmission()).Times(AnyNumber()); - if (connection_->version().HasHandshakeDone() && + if (connection_->version().UsesTls() && session_->perspective() == Perspective::IS_SERVER) { + // HANDSHAKE_DONE frame. EXPECT_CALL(*connection_, SendControlFrame(_)) .WillOnce(Invoke(&ClearControlFrame)); } @@ -434,7 +439,7 @@ class QuicSpdyStreamTest : public QuicTestWithParam<ParsedQuicVersion> { &headers_buffer); absl::string_view headers_frame_header(headers_buffer.get(), headers_frame_header_length); - return quiche::QuicheStrCat(headers_frame_header, payload); + return absl::StrCat(headers_frame_header, payload); } // Construct PUSH_PROMISE frame with given payload. @@ -449,7 +454,7 @@ class QuicSpdyStreamTest : public QuicTestWithParam<ParsedQuicVersion> { frame, &push_promise_buffer); absl::string_view push_promise_frame_header( push_promise_buffer.get(), push_promise_frame_header_length); - return quiche::QuicheStrCat(push_promise_frame_header, payload); + return absl::StrCat(push_promise_frame_header, payload); } std::string DataFrame(absl::string_view payload) { @@ -458,7 +463,7 @@ class QuicSpdyStreamTest : public QuicTestWithParam<ParsedQuicVersion> { HttpEncoder::SerializeDataFrameHeader(payload.length(), &data_buffer); absl::string_view data_frame_header(data_buffer.get(), data_frame_header_length); - return quiche::QuicheStrCat(data_frame_header, payload); + return absl::StrCat(data_frame_header, payload); } std::string UnknownFrame(uint64_t frame_type, absl::string_view payload) { @@ -474,7 +479,7 @@ class QuicSpdyStreamTest : public QuicTestWithParam<ParsedQuicVersion> { // Even though integers can be encoded with different lengths, // QuicDataWriter is expected to produce an encoding in Write*() of length // promised in GetVarInt62Len(). - DCHECK_EQ(length, writer.length()); + QUICHE_DCHECK_EQ(length, writer.length()); return frame; } @@ -515,13 +520,8 @@ TEST_P(QuicSpdyStreamTest, ProcessTooLargeHeaderList) { stream_->OnStreamHeadersPriority( spdy::SpdyStreamPrecedence(kV3HighestPriority)); - if (!session_->split_up_send_rst()) { - EXPECT_CALL(*session_, - SendRstStream(stream_->id(), QUIC_HEADERS_TOO_LARGE, 0, _)); - } else { - EXPECT_CALL(*session_, MaybeSendRstStreamFrame( - stream_->id(), QUIC_HEADERS_TOO_LARGE, 0)); - } + EXPECT_CALL(*session_, MaybeSendRstStreamFrame(stream_->id(), + QUIC_HEADERS_TOO_LARGE, 0)); stream_->OnStreamHeaderList(false, 1 << 20, headers); EXPECT_THAT(stream_->stream_error(), IsStreamError(QUIC_HEADERS_TOO_LARGE)); @@ -536,15 +536,10 @@ TEST_P(QuicSpdyStreamTest, ProcessTooLargeHeaderList) { QuicStreamFrame frame(stream_->id(), false, 0, headers); - if (!session_->split_up_send_rst()) { - EXPECT_CALL(*session_, - SendRstStream(stream_->id(), QUIC_HEADERS_TOO_LARGE, 0, _)); - } else { - EXPECT_CALL(*session_, MaybeSendStopSendingFrame(stream_->id(), - QUIC_HEADERS_TOO_LARGE)); - EXPECT_CALL(*session_, MaybeSendRstStreamFrame(stream_->id(), - QUIC_HEADERS_TOO_LARGE, 0)); - } + EXPECT_CALL(*session_, + MaybeSendStopSendingFrame(stream_->id(), QUIC_HEADERS_TOO_LARGE)); + EXPECT_CALL(*session_, MaybeSendRstStreamFrame(stream_->id(), + QUIC_HEADERS_TOO_LARGE, 0)); auto qpack_decoder_stream = QuicSpdySessionPeer::GetQpackDecoderSendStream(session_.get()); @@ -674,17 +669,13 @@ TEST_P(QuicSpdyStreamTest, ProcessWrongFramesOnSpdyStream) { connection_->ReallyCloseConnection(error, error_details, connection_close_behavior); }))); - EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _)); + EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _, _)); EXPECT_CALL(*session_, OnConnectionClosed(_, _)) .WillOnce(Invoke([this](const QuicConnectionCloseFrame& frame, ConnectionCloseSource source) { session_->ReallyOnConnectionClosed(frame, source); })); - if (!session_->split_up_send_rst()) { - EXPECT_CALL(*session_, SendRstStream(_, _, _, _)).Times(2); - } else { - EXPECT_CALL(*session_, MaybeSendRstStreamFrame(_, _, _)).Times(2); - } + EXPECT_CALL(*session_, MaybeSendRstStreamFrame(_, _, _)).Times(2); stream_->OnStreamFrame(frame); } @@ -1151,10 +1142,19 @@ TEST_P(QuicSpdyStreamTest, TestHandlingQuicRstStreamNoError) { Initialize(kShouldProcessData); ProcessHeaders(false, headers_); + EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)).Times(AnyNumber()); + stream_->OnStreamReset(QuicRstStreamFrame( kInvalidControlFrameId, stream_->id(), QUIC_STREAM_NO_ERROR, 0)); - EXPECT_TRUE(stream_->write_side_closed()); - EXPECT_FALSE(stream_->reading_stopped()); + + if (GetQuicReloadableFlag(quic_fix_on_stream_reset) && UsesHttp3()) { + // RESET_STREAM should close the read side but not the write side. + EXPECT_TRUE(stream_->read_side_closed()); + EXPECT_FALSE(stream_->write_side_closed()); + } else { + EXPECT_TRUE(stream_->write_side_closed()); + EXPECT_FALSE(stream_->reading_stopped()); + } } // Tests that on if the peer sends too much data (i.e. violates the flow control @@ -2016,8 +2016,7 @@ TEST_P(QuicSpdyStreamTest, HeadersFrameOnRequestStream) { std::string trailers = HeadersFrame({std::make_pair("custom-key", "custom-value")}); - std::string stream_frame_payload = - quiche::QuicheStrCat(headers, data, trailers); + std::string stream_frame_payload = absl::StrCat(headers, data, trailers); QuicStreamFrame frame(stream_->id(), false, 0, stream_frame_payload); stream_->OnStreamFrame(frame); @@ -2051,8 +2050,7 @@ TEST_P(QuicSpdyStreamTest, ProcessBodyAfterTrailers) { std::string trailers = HeadersFrame(trailers_block); // Feed all three HTTP/3 frames in a single stream frame. - std::string stream_frame_payload = - quiche::QuicheStrCat(headers, data, trailers); + std::string stream_frame_payload = absl::StrCat(headers, data, trailers); QuicStreamFrame frame(stream_->id(), false, 0, stream_frame_payload); stream_->OnStreamFrame(frame); @@ -2092,7 +2090,7 @@ TEST_P(QuicSpdyStreamTest, MalformedHeadersStopHttpDecoder) { HeadersFrame(absl::HexStringToBytes("00002a94e7036261")); std::string data = DataFrame(kDataFramePayload); - std::string stream_frame_payload = quiche::QuicheStrCat(headers, data); + std::string stream_frame_payload = absl::StrCat(headers, data); QuicStreamFrame frame(stream_->id(), false, 0, stream_frame_payload); EXPECT_CALL( @@ -2107,17 +2105,13 @@ TEST_P(QuicSpdyStreamTest, MalformedHeadersStopHttpDecoder) { connection_->ReallyCloseConnection(error, error_details, connection_close_behavior); }))); - EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _)); + EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _, _)); EXPECT_CALL(*session_, OnConnectionClosed(_, _)) .WillOnce(Invoke([this](const QuicConnectionCloseFrame& frame, ConnectionCloseSource source) { session_->ReallyOnConnectionClosed(frame, source); })); - if (!session_->split_up_send_rst()) { - EXPECT_CALL(*session_, SendRstStream(_, _, _, _)).Times(2); - } else { - EXPECT_CALL(*session_, MaybeSendRstStreamFrame(_, _, _)).Times(2); - } + EXPECT_CALL(*session_, MaybeSendRstStreamFrame(_, _, _)).Times(2); stream_->OnStreamFrame(frame); } @@ -2148,20 +2142,15 @@ TEST_P(QuicSpdyStreamTest, DoNotMarkConsumedAfterQpackDecodingError) { connection_->ReallyCloseConnection(error, error_details, connection_close_behavior); }))); - EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _)); + EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _, _)); EXPECT_CALL(*session_, OnConnectionClosed(_, _)) .WillOnce(Invoke([this](const QuicConnectionCloseFrame& frame, ConnectionCloseSource source) { session_->ReallyOnConnectionClosed(frame, source); })); } - if (!session_->split_up_send_rst()) { - EXPECT_CALL(*session_, SendRstStream(stream_->id(), _, _, _)); - EXPECT_CALL(*session_, SendRstStream(stream2_->id(), _, _, _)); - } else { - EXPECT_CALL(*session_, MaybeSendRstStreamFrame(stream_->id(), _, _)); - EXPECT_CALL(*session_, MaybeSendRstStreamFrame(stream2_->id(), _, _)); - } + EXPECT_CALL(*session_, MaybeSendRstStreamFrame(stream_->id(), _, _)); + EXPECT_CALL(*session_, MaybeSendRstStreamFrame(stream2_->id(), _, _)); // Invalid headers: Required Insert Count is zero, but the header block // contains a dynamic table reference. @@ -2474,19 +2463,55 @@ TEST_P(QuicSpdyStreamTest, HeaderDecodingUnblockedAfterStreamClosed) { WritevData(decoder_send_stream->id(), /* write_length = */ 1, /* offset = */ 1, _, _, _)); - // Reset stream. - if (!session_->split_up_send_rst()) { - EXPECT_CALL(*session_, - SendRstStream(stream_->id(), QUIC_STREAM_CANCELLED, _, _)); - } else { - EXPECT_CALL(*session_, MaybeSendStopSendingFrame(stream_->id(), - QUIC_STREAM_CANCELLED)); - EXPECT_CALL(*session_, MaybeSendRstStreamFrame(stream_->id(), - QUIC_STREAM_CANCELLED, _)); - } + // Reset stream by this endpoint, for example, due to stream cancellation. + EXPECT_CALL(*session_, + MaybeSendStopSendingFrame(stream_->id(), QUIC_STREAM_CANCELLED)); + EXPECT_CALL(*session_, + MaybeSendRstStreamFrame(stream_->id(), QUIC_STREAM_CANCELLED, _)); stream_->Reset(QUIC_STREAM_CANCELLED); - if (!GetQuicReloadableFlag(quic_abort_qpack_on_stream_close)) { + // Deliver dynamic table entry to decoder. + session_->qpack_decoder()->OnInsertWithoutNameReference("foo", "bar"); + + EXPECT_FALSE(stream_->headers_decompressed()); +} + +TEST_P(QuicSpdyStreamTest, HeaderDecodingUnblockedAfterResetReceived) { + if (!UsesHttp3()) { + return; + } + + Initialize(kShouldProcessData); + testing::InSequence s; + session_->qpack_decoder()->OnSetDynamicTableCapacity(1024); + StrictMock<MockHttp3DebugVisitor> debug_visitor; + session_->set_debug_visitor(&debug_visitor); + + // HEADERS frame referencing first dynamic table entry. + std::string encoded_headers = absl::HexStringToBytes("020080"); + std::string headers = HeadersFrame(encoded_headers); + EXPECT_CALL(debug_visitor, + OnHeadersFrameReceived(stream_->id(), encoded_headers.length())); + stream_->OnStreamFrame(QuicStreamFrame(stream_->id(), false, 0, headers)); + + // Decoding is blocked because dynamic table entry has not been received yet. + EXPECT_FALSE(stream_->headers_decompressed()); + + // Decoder stream type and stream cancellation instruction. + auto decoder_send_stream = + QuicSpdySessionPeer::GetQpackDecoderSendStream(session_.get()); + EXPECT_CALL(*session_, + WritevData(decoder_send_stream->id(), /* write_length = */ 1, + /* offset = */ 0, _, _, _)); + EXPECT_CALL(*session_, + WritevData(decoder_send_stream->id(), /* write_length = */ 1, + /* offset = */ 1, _, _, _)); + + // OnStreamReset() is called when RESET_STREAM frame is received from peer. + stream_->OnStreamReset(QuicRstStreamFrame( + kInvalidControlFrameId, stream_->id(), QUIC_STREAM_CANCELLED, 0)); + + if (!GetQuicReloadableFlag(quic_abort_qpack_on_stream_reset)) { // Header acknowledgement. EXPECT_CALL(*session_, WritevData(decoder_send_stream->id(), /* write_length = */ 1, @@ -2497,7 +2522,7 @@ TEST_P(QuicSpdyStreamTest, HeaderDecodingUnblockedAfterStreamClosed) { // Deliver dynamic table entry to decoder. session_->qpack_decoder()->OnInsertWithoutNameReference("foo", "bar"); - if (GetQuicReloadableFlag(quic_abort_qpack_on_stream_close)) { + if (GetQuicReloadableFlag(quic_abort_qpack_on_stream_reset)) { EXPECT_FALSE(stream_->headers_decompressed()); } else { // Verify headers. @@ -2907,7 +2932,7 @@ TEST_P(QuicSpdyStreamTest, StopProcessingIfConnectionClosed) { // Combine the two frames to make sure they are processed in a single // QuicSpdyStream::OnDataAvailable() call. - std::string frames = quiche::QuicheStrCat(settings, headers); + std::string frames = absl::StrCat(settings, headers); EXPECT_EQ(0u, stream_->sequencer()->NumBytesConsumed()); @@ -2915,7 +2940,7 @@ TEST_P(QuicSpdyStreamTest, StopProcessingIfConnectionClosed) { CloseConnection(QUIC_HTTP_FRAME_UNEXPECTED_ON_SPDY_STREAM, _, _)) .WillOnce( Invoke(connection_, &MockQuicConnection::ReallyCloseConnection)); - EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _)); + EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _, _)); EXPECT_CALL(*session_, OnConnectionClosed(_, _)); stream_->OnStreamFrame(QuicStreamFrame(stream_->id(), /* fin = */ false, @@ -2943,15 +2968,10 @@ TEST_P(QuicSpdyStreamTest, StreamCancellationWhenStreamReset) { EXPECT_CALL(*session_, WritevData(qpack_decoder_stream->id(), /* write_length = */ 1, /* offset = */ 1, _, _, _)); - if (!session_->split_up_send_rst()) { - EXPECT_CALL(*session_, - SendRstStream(stream_->id(), QUIC_STREAM_CANCELLED, _, _)); - } else { - EXPECT_CALL(*session_, MaybeSendStopSendingFrame(stream_->id(), - QUIC_STREAM_CANCELLED)); - EXPECT_CALL(*session_, MaybeSendRstStreamFrame(stream_->id(), - QUIC_STREAM_CANCELLED, _)); - } + EXPECT_CALL(*session_, + MaybeSendStopSendingFrame(stream_->id(), QUIC_STREAM_CANCELLED)); + EXPECT_CALL(*session_, + MaybeSendRstStreamFrame(stream_->id(), QUIC_STREAM_CANCELLED, _)); stream_->Reset(QUIC_STREAM_CANCELLED); } @@ -3018,6 +3038,39 @@ TEST_P(QuicSpdyStreamTest, WriteHeadersReturnValue) { EXPECT_EQ(headers_frame_payload_length, write_headers_return_value); } +// Regression test for https://crbug.com/1177662. +// RESET_STREAM with QUIC_STREAM_NO_ERROR should not be treated in a special +// way: it should close the read side but not the write side. +TEST_P(QuicSpdyStreamTest, TwoResetStreamFrames) { + if (!UsesHttp3()) { + return; + } + + Initialize(kShouldProcessData); + + EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)).Times(AnyNumber()); + + QuicRstStreamFrame rst_frame1(kInvalidControlFrameId, stream_->id(), + QUIC_STREAM_CANCELLED, /* bytes_written = */ 0); + stream_->OnStreamReset(rst_frame1); + EXPECT_TRUE(stream_->read_side_closed()); + EXPECT_FALSE(stream_->write_side_closed()); + + QuicRstStreamFrame rst_frame2(kInvalidControlFrameId, stream_->id(), + QUIC_STREAM_NO_ERROR, /* bytes_written = */ 0); + if (GetQuicReloadableFlag(quic_fix_on_stream_reset)) { + stream_->OnStreamReset(rst_frame2); + EXPECT_TRUE(stream_->read_side_closed()); + EXPECT_FALSE(stream_->write_side_closed()); + } else { + EXPECT_CALL(*session_, MaybeSendRstStreamFrame( + stream_->id(), QUIC_RST_ACKNOWLEDGEMENT, _)); + EXPECT_QUIC_BUG( + stream_->OnStreamReset(rst_frame2), + "The stream should've already sent RST in response to STOP_SENDING"); + } +} + } // namespace } // namespace test } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/http/spdy_server_push_utils.cc b/chromium/net/third_party/quiche/src/quic/core/http/spdy_server_push_utils.cc index 3c89a545801..eb818101ff5 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/spdy_server_push_utils.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/spdy_server_push_utils.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/spdy_server_push_utils.h" +#include "quic/core/http/spdy_server_push_utils.h" #include "absl/strings/string_view.h" #include "url/gurl.h" diff --git a/chromium/net/third_party/quiche/src/quic/core/http/spdy_server_push_utils.h b/chromium/net/third_party/quiche/src/quic/core/http/spdy_server_push_utils.h index 99a834bd695..63cfb886e47 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/spdy_server_push_utils.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/spdy_server_push_utils.h @@ -6,8 +6,8 @@ #define QUICHE_QUIC_CORE_HTTP_SPDY_SERVER_PUSH_UTILS_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" +#include "quic/platform/api/quic_export.h" +#include "spdy/core/spdy_header_block.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/http/spdy_server_push_utils_test.cc b/chromium/net/third_party/quiche/src/quic/core/http/spdy_server_push_utils_test.cc index fa98f077c6d..df1659d683c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/spdy_server_push_utils_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/spdy_server_push_utils_test.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/spdy_server_push_utils.h" +#include "quic/core/http/spdy_server_push_utils.h" #include <memory> #include <string> #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" using spdy::SpdyHeaderBlock; diff --git a/chromium/net/third_party/quiche/src/quic/core/http/spdy_utils.cc b/chromium/net/third_party/quiche/src/quic/core/http/spdy_utils.cc index 2a888fb1af0..a3d800af5d4 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/spdy_utils.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/spdy_utils.cc @@ -2,22 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" +#include "quic/core/http/spdy_utils.h" #include <memory> #include <string> #include <vector> #include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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_map_util.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_map_util.h" +#include "common/platform/api/quiche_text_utils.h" +#include "spdy/core/spdy_protocol.h" using spdy::SpdyHeaderBlock; @@ -153,20 +153,4 @@ bool SpdyUtils::PopulateHeaderBlockFromUrl(const std::string url, return true; } -#define RETURN_STRING_LITERAL(x) \ - case x: \ - return #x; - -// static -std::string SpdyUtils::H3SettingsToString( - Http3AndQpackSettingsIdentifiers identifier) { - switch (identifier) { - RETURN_STRING_LITERAL(SETTINGS_QPACK_MAX_TABLE_CAPACITY); - RETURN_STRING_LITERAL(SETTINGS_MAX_FIELD_SECTION_SIZE); - RETURN_STRING_LITERAL(SETTINGS_QPACK_BLOCKED_STREAMS); - } - return quiche::QuicheStrCat("UNSUPPORTED_SETTINGS_TYPE(", identifier, ")"); -} - -#undef RETURN_STRING_LITERAL // undef for jumbo builds } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/http/spdy_utils.h b/chromium/net/third_party/quiche/src/quic/core/http/spdy_utils.h index 43bca5ea52e..a3b3134fe37 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/spdy_utils.h +++ b/chromium/net/third_party/quiche/src/quic/core/http/spdy_utils.h @@ -9,11 +9,11 @@ #include <cstdint> #include <string> -#include "net/third_party/quiche/src/quic/core/http/http_constants.h" -#include "net/third_party/quiche/src/quic/core/http/quic_header_list.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" +#include "quic/core/http/http_constants.h" +#include "quic/core/http/quic_header_list.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_export.h" +#include "spdy/core/spdy_header_block.h" namespace quic { @@ -51,10 +51,6 @@ class QUIC_EXPORT_PRIVATE SpdyUtils { // which must be fully-qualified. static bool PopulateHeaderBlockFromUrl(const std::string url, spdy::SpdyHeaderBlock* headers); - - // Returns HTTP/3 SETTINGS identifier as a string. - static std::string H3SettingsToString( - Http3AndQpackSettingsIdentifiers identifier); }; } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/http/spdy_utils_test.cc b/chromium/net/third_party/quiche/src/quic/core/http/spdy_utils_test.cc index 9216a538b91..5cb391dc64c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/http/spdy_utils_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/http/spdy_utils_test.cc @@ -7,9 +7,9 @@ #include "absl/base/macros.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/http/spdy_utils.h" +#include "quic/platform/api/quic_test.h" +#include "common/platform/api/quiche_text_utils.h" using spdy::SpdyHeaderBlock; using testing::Pair; diff --git a/chromium/net/third_party/quiche/src/quic/core/legacy_quic_stream_id_manager.cc b/chromium/net/third_party/quiche/src/quic/core/legacy_quic_stream_id_manager.cc index af4de8b1c8c..07403f8de08 100644 --- a/chromium/net/third_party/quiche/src/quic/core/legacy_quic_stream_id_manager.cc +++ b/chromium/net/third_party/quiche/src/quic/core/legacy_quic_stream_id_manager.cc @@ -1,14 +1,13 @@ // Copyright (c) 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/legacy_quic_stream_id_manager.h" +#include "quic/core/legacy_quic_stream_id_manager.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_map_util.h" namespace quic { @@ -36,7 +35,7 @@ LegacyQuicStreamIdManager::LegacyQuicStreamIdManager( LegacyQuicStreamIdManager::~LegacyQuicStreamIdManager() {} bool LegacyQuicStreamIdManager::CanOpenNextOutgoingStream() const { - DCHECK_LE(num_open_outgoing_streams_, max_open_outgoing_streams_); + QUICHE_DCHECK_LE(num_open_outgoing_streams_, max_open_outgoing_streams_); QUIC_DLOG_IF(INFO, num_open_outgoing_streams_ == max_open_outgoing_streams_) << "Failed to create a new outgoing stream. " << "Already " << num_open_outgoing_streams_ << " open."; diff --git a/chromium/net/third_party/quiche/src/quic/core/legacy_quic_stream_id_manager.h b/chromium/net/third_party/quiche/src/quic/core/legacy_quic_stream_id_manager.h index 01315872fb8..728d288e8af 100644 --- a/chromium/net/third_party/quiche/src/quic/core/legacy_quic_stream_id_manager.h +++ b/chromium/net/third_party/quiche/src/quic/core/legacy_quic_stream_id_manager.h @@ -4,9 +4,10 @@ #ifndef QUICHE_QUIC_CORE_LEGACY_QUIC_STREAM_ID_MANAGER_H_ #define QUICHE_QUIC_CORE_LEGACY_QUIC_STREAM_ID_MANAGER_H_ -#include "net/third_party/quiche/src/quic/core/quic_stream_id_manager.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" +#include "absl/container/flat_hash_set.h" +#include "quic/core/quic_stream_id_manager.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" namespace quic { @@ -111,7 +112,7 @@ class QUIC_EXPORT_PRIVATE LegacyQuicStreamIdManager { // Set of stream ids that are less than the largest stream id that has been // received, but are nonetheless available to be created. - QuicHashSet<QuicStreamId> available_streams_; + absl::flat_hash_set<QuicStreamId> available_streams_; QuicStreamId largest_peer_created_stream_id_; diff --git a/chromium/net/third_party/quiche/src/quic/core/legacy_quic_stream_id_manager_test.cc b/chromium/net/third_party/quiche/src/quic/core/legacy_quic_stream_id_manager_test.cc index b7ba1d27035..a91a2f0e6eb 100644 --- a/chromium/net/third_party/quiche/src/quic/core/legacy_quic_stream_id_manager_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/legacy_quic_stream_id_manager_test.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/legacy_quic_stream_id_manager.h" +#include "quic/core/legacy_quic_stream_id_manager.h" #include <utility> -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_cat.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_session_peer.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { @@ -31,7 +31,7 @@ struct TestParams { // Used by ::testing::PrintToStringParamName(). std::string PrintToString(const TestParams& p) { - return quiche::QuicheStrCat( + return absl::StrCat( ParsedQuicVersionToString(p.version), (p.perspective == Perspective::IS_CLIENT ? "Client" : "Server")); } diff --git a/chromium/net/third_party/quiche/src/quic/core/packet_number_indexed_queue.h b/chromium/net/third_party/quiche/src/quic/core/packet_number_indexed_queue.h index a0870228141..eec75dfdf0f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/packet_number_indexed_queue.h +++ b/chromium/net/third_party/quiche/src/quic/core/packet_number_indexed_queue.h @@ -5,11 +5,11 @@ #ifndef QUICHE_QUIC_CORE_PACKET_NUMBER_INDEXED_QUEUE_H_ #define QUICHE_QUIC_CORE_PACKET_NUMBER_INDEXED_QUEUE_H_ -#include "net/third_party/quiche/src/quic/core/quic_circular_deque.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_number.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" +#include "quic/core/quic_circular_deque.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_packet_number.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_bug_tracker.h" namespace quic { @@ -152,8 +152,8 @@ bool PacketNumberIndexedQueue<T>::Emplace(QuicPacketNumber packet_number, } if (IsEmpty()) { - DCHECK(entries_.empty()); - DCHECK(!first_packet_.IsInitialized()); + QUICHE_DCHECK(entries_.empty()); + QUICHE_DCHECK(!first_packet_.IsInitialized()); entries_.emplace_back(std::forward<Args>(args)...); number_of_present_entries_ = 1; @@ -174,7 +174,7 @@ bool PacketNumberIndexedQueue<T>::Emplace(QuicPacketNumber packet_number, number_of_present_entries_++; entries_.emplace_back(std::forward<Args>(args)...); - DCHECK_EQ(packet_number, last_packet()); + QUICHE_DCHECK_EQ(packet_number, last_packet()); return true; } diff --git a/chromium/net/third_party/quiche/src/quic/core/packet_number_indexed_queue_test.cc b/chromium/net/third_party/quiche/src/quic/core/packet_number_indexed_queue_test.cc index 5f6b09cdd74..cd41f9edd00 100644 --- a/chromium/net/third_party/quiche/src/quic/core/packet_number_indexed_queue_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/packet_number_indexed_queue_test.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/packet_number_indexed_queue.h" +#include "quic/core/packet_number_indexed_queue.h" #include <limits> #include <map> #include <string> -#include "net/third_party/quiche/src/quic/core/quic_packet_number.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/quic_packet_number.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace { diff --git a/chromium/net/third_party/quiche/src/quic/core/proto/cached_network_parameters_proto.h b/chromium/net/third_party/quiche/src/quic/core/proto/cached_network_parameters_proto.h index 6a37aa1845c..5714801b460 100644 --- a/chromium/net/third_party/quiche/src/quic/core/proto/cached_network_parameters_proto.h +++ b/chromium/net/third_party/quiche/src/quic/core/proto/cached_network_parameters_proto.h @@ -8,7 +8,7 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Weverything" -#include "net/third_party/quiche/src/quic/core/proto/cached_network_parameters.pb.h" +#include "quic/core/proto/cached_network_parameters.pb.h" #pragma clang diagnostic pop diff --git a/chromium/net/third_party/quiche/src/quic/core/proto/crypto_server_config_proto.h b/chromium/net/third_party/quiche/src/quic/core/proto/crypto_server_config_proto.h index 4383e8ecae3..908a289f1de 100644 --- a/chromium/net/third_party/quiche/src/quic/core/proto/crypto_server_config_proto.h +++ b/chromium/net/third_party/quiche/src/quic/core/proto/crypto_server_config_proto.h @@ -8,7 +8,7 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Weverything" -#include "net/third_party/quiche/src/quic/core/proto/crypto_server_config.pb.h" +#include "quic/core/proto/crypto_server_config.pb.h" #pragma clang diagnostic pop diff --git a/chromium/net/third_party/quiche/src/quic/core/proto/source_address_token.proto b/chromium/net/third_party/quiche/src/quic/core/proto/source_address_token.proto index 1897a256886..df12fa5c7c8 100644 --- a/chromium/net/third_party/quiche/src/quic/core/proto/source_address_token.proto +++ b/chromium/net/third_party/quiche/src/quic/core/proto/source_address_token.proto @@ -6,7 +6,7 @@ syntax = "proto2"; option optimize_for = LITE_RUNTIME; -import "cached_network_parameters.proto"; +import "quic/core/proto/cached_network_parameters.proto"; package quic; diff --git a/chromium/net/third_party/quiche/src/quic/core/proto/source_address_token_proto.h b/chromium/net/third_party/quiche/src/quic/core/proto/source_address_token_proto.h index 25f527488c0..a63bd89febf 100644 --- a/chromium/net/third_party/quiche/src/quic/core/proto/source_address_token_proto.h +++ b/chromium/net/third_party/quiche/src/quic/core/proto/source_address_token_proto.h @@ -8,7 +8,7 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Weverything" -#include "net/third_party/quiche/src/quic/core/proto/source_address_token.pb.h" +#include "quic/core/proto/source_address_token.pb.h" #pragma clang diagnostic pop diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_blocking_manager.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_blocking_manager.cc index 3544f1ca10b..3b03710b3c3 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_blocking_manager.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_blocking_manager.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_blocking_manager.h" +#include "quic/core/qpack/qpack_blocking_manager.h" #include <limits> #include <utility> @@ -17,10 +17,10 @@ bool QpackBlockingManager::OnHeaderAcknowledgement(QuicStreamId stream_id) { return false; } - DCHECK(!it->second.empty()); + QUICHE_DCHECK(!it->second.empty()); const IndexSet& indices = it->second.front(); - DCHECK(!indices.empty()); + QUICHE_DCHECK(!indices.empty()); const uint64_t required_index_count = RequiredInsertCount(indices); if (known_received_count_ < required_index_count) { @@ -62,7 +62,7 @@ bool QpackBlockingManager::OnInsertCountIncrement(uint64_t increment) { void QpackBlockingManager::OnHeaderBlockSent(QuicStreamId stream_id, IndexSet indices) { - DCHECK(!indices.empty()); + QUICHE_DCHECK(!indices.empty()); IncreaseReferenceCounts(indices); header_blocks_[stream_id].push_back(std::move(indices)); @@ -145,8 +145,8 @@ void QpackBlockingManager::IncreaseReferenceCounts(const IndexSet& indices) { void QpackBlockingManager::DecreaseReferenceCounts(const IndexSet& indices) { for (const uint64_t index : indices) { auto it = entry_reference_counts_.find(index); - DCHECK(it != entry_reference_counts_.end()); - DCHECK_NE(0u, it->second); + QUICHE_DCHECK(it != entry_reference_counts_.end()); + QUICHE_DCHECK_NE(0u, it->second); if (it->second == 1) { entry_reference_counts_.erase(it); diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_blocking_manager.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_blocking_manager.h index ecb56993381..70870a60314 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_blocking_manager.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_blocking_manager.h @@ -9,9 +9,10 @@ #include <map> #include <set> -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "absl/container/flat_hash_map.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -77,7 +78,7 @@ class QUIC_EXPORT_PRIVATE QpackBlockingManager { // same time. Use std::list instead of QuicCircularDeque because it has lower // memory footprint when holding few elements. using HeaderBlocksForStream = std::list<IndexSet>; - using HeaderBlocks = QuicHashMap<QuicStreamId, HeaderBlocksForStream>; + using HeaderBlocks = absl::flat_hash_map<QuicStreamId, HeaderBlocksForStream>; // Increase or decrease the reference count for each index in |indices|. void IncreaseReferenceCounts(const IndexSet& indices); diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_blocking_manager_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_blocking_manager_test.cc index d92dda549ef..4bc8419e0b3 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_blocking_manager_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_blocking_manager_test.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_blocking_manager.h" +#include "quic/core/qpack/qpack_blocking_manager.h" #include <limits> -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.cc index 1e66346cdb3..f5ddeee36a4 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.h" +#include "quic/core/qpack/qpack_decoded_headers_accumulator.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h" +#include "quic/core/qpack/qpack_decoder.h" +#include "quic/core/qpack/qpack_header_table.h" namespace quic { @@ -29,7 +29,7 @@ QpackDecodedHeadersAccumulator::QpackDecodedHeadersAccumulator( void QpackDecodedHeadersAccumulator::OnHeaderDecoded(absl::string_view name, absl::string_view value) { - DCHECK(!error_detected_); + QUICHE_DCHECK(!error_detected_); uncompressed_header_bytes_without_overhead_ += name.size() + value.size(); @@ -49,8 +49,8 @@ void QpackDecodedHeadersAccumulator::OnHeaderDecoded(absl::string_view name, } void QpackDecodedHeadersAccumulator::OnDecodingCompleted() { - DCHECK(!headers_decoded_); - DCHECK(!error_detected_); + QUICHE_DCHECK(!headers_decoded_); + QUICHE_DCHECK(!error_detected_); headers_decoded_ = true; @@ -64,8 +64,8 @@ void QpackDecodedHeadersAccumulator::OnDecodingCompleted() { void QpackDecodedHeadersAccumulator::OnDecodingErrorDetected( absl::string_view error_message) { - DCHECK(!error_detected_); - DCHECK(!headers_decoded_); + QUICHE_DCHECK(!error_detected_); + QUICHE_DCHECK(!headers_decoded_); error_detected_ = true; // Might destroy |this|. @@ -73,7 +73,7 @@ void QpackDecodedHeadersAccumulator::OnDecodingErrorDetected( } void QpackDecodedHeadersAccumulator::Decode(absl::string_view data) { - DCHECK(!error_detected_); + QUICHE_DCHECK(!error_detected_); compressed_header_bytes_ += data.size(); // Might destroy |this|. @@ -81,8 +81,8 @@ void QpackDecodedHeadersAccumulator::Decode(absl::string_view data) { } void QpackDecodedHeadersAccumulator::EndHeaderBlock() { - DCHECK(!error_detected_); - DCHECK(!headers_decoded_); + QUICHE_DCHECK(!error_detected_); + QUICHE_DCHECK(!headers_decoded_); // Might destroy |this|. decoder_->EndHeaderBlock(); diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.h index e194a98ebc5..b22da2a9d92 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.h @@ -9,10 +9,10 @@ #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/http/quic_header_list.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/http/quic_header_list.h" +#include "quic/core/qpack/qpack_progressive_decoder.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -90,7 +90,7 @@ class QUIC_EXPORT_PRIVATE QpackDecodedHeadersAccumulator // Input data is still fed to QpackProgressiveDecoder. bool header_list_size_limit_exceeded_; - // The following two members are only used for DCHECKs. + // The following two members are only used for QUICHE_DCHECKs. // True if headers have been completedly and successfully decoded. bool headers_decoded_; diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator_test.cc index 2a5b0da86bf..9ba7f1c511f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator_test.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.h" +#include "quic/core/qpack/qpack_decoded_headers_accumulator.h" #include <cstring> #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/qpack/qpack_decoder.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/qpack/qpack_decoder_test_utils.h" +#include "quic/test_tools/qpack/qpack_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" using ::testing::_; using ::testing::ElementsAre; diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder.cc index 86383319c33..c1ac28ca3d1 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder.cc @@ -2,14 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h" +#include "quic/core/qpack/qpack_decoder.h" #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions.h" -#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 "quic/core/qpack/qpack_index_conversions.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -21,7 +22,7 @@ QpackDecoder::QpackDecoder( encoder_stream_receiver_(this), maximum_blocked_streams_(maximum_blocked_streams), known_received_count_(0) { - DCHECK(encoder_stream_error_delegate_); + QUICHE_DCHECK(encoder_stream_error_delegate_); header_table_.SetMaximumDynamicTableCapacity(maximum_dynamic_table_capacity); } @@ -37,13 +38,13 @@ void QpackDecoder::OnStreamReset(QuicStreamId stream_id) { bool QpackDecoder::OnStreamBlocked(QuicStreamId stream_id) { auto result = blocked_streams_.insert(stream_id); - DCHECK(result.second); + QUICHE_DCHECK(result.second); return blocked_streams_.size() <= maximum_blocked_streams_; } void QpackDecoder::OnStreamUnblocked(QuicStreamId stream_id) { size_t result = blocked_streams_.erase(stream_id); - DCHECK_EQ(1u, result); + QUICHE_DCHECK_EQ(1u, result); } void QpackDecoder::OnDecodingCompleted(QuicStreamId stream_id, @@ -153,14 +154,8 @@ void QpackDecoder::OnSetDynamicTableCapacity(uint64_t capacity) { void QpackDecoder::OnErrorDetected(QuicErrorCode error_code, absl::string_view error_message) { - if (GetQuicReloadableFlag(quic_granular_qpack_error_codes)) { - QUIC_CODE_COUNT_N(quic_granular_qpack_error_codes, 2, 2); - encoder_stream_error_delegate_->OnEncoderStreamError(error_code, - error_message); - } else { - encoder_stream_error_delegate_->OnEncoderStreamError( - QUIC_QPACK_ENCODER_STREAM_ERROR, error_message); - } + encoder_stream_error_delegate_->OnEncoderStreamError(error_code, + error_message); } std::unique_ptr<QpackProgressiveDecoder> QpackDecoder::CreateProgressiveDecoder( diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h index 6e0c0ab92a1..32178bd9d7c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h @@ -10,13 +10,13 @@ #include <set> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/qpack/qpack_decoder_stream_sender.h" +#include "quic/core/qpack/qpack_encoder_stream_receiver.h" +#include "quic/core/qpack/qpack_header_table.h" +#include "quic/core/qpack/qpack_progressive_decoder.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.cc index e63d853da20..aed660ef4d3 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.h" +#include "quic/core/qpack/qpack_decoder_stream_receiver.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/http2/decoder/decode_buffer.h" -#include "net/third_party/quiche/src/http2/decoder/decode_status.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h" +#include "http2/decoder/decode_buffer.h" +#include "http2/decoder/decode_status.h" +#include "quic/core/qpack/qpack_instructions.h" namespace quic { @@ -15,7 +15,7 @@ QpackDecoderStreamReceiver::QpackDecoderStreamReceiver(Delegate* delegate) : instruction_decoder_(QpackDecoderStreamLanguage(), this), delegate_(delegate), error_detected_(false) { - DCHECK(delegate_); + QUICHE_DCHECK(delegate_); } void QpackDecoderStreamReceiver::Decode(absl::string_view data) { @@ -38,7 +38,7 @@ bool QpackDecoderStreamReceiver::OnInstructionDecoded( return true; } - DCHECK_EQ(instruction, StreamCancellationInstruction()); + QUICHE_DCHECK_EQ(instruction, StreamCancellationInstruction()); delegate_->OnStreamCancellation(instruction_decoder_.varint()); return true; } @@ -46,7 +46,7 @@ bool QpackDecoderStreamReceiver::OnInstructionDecoded( void QpackDecoderStreamReceiver::OnInstructionDecodingError( QpackInstructionDecoder::ErrorCode error_code, absl::string_view error_message) { - DCHECK(!error_detected_); + QUICHE_DCHECK(!error_detected_); error_detected_ = true; diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.h index b3b3d692cbe..026c7b96892 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.h @@ -8,11 +8,11 @@ #include <cstdint> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_stream_receiver.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/qpack/qpack_instruction_decoder.h" +#include "quic/core/qpack/qpack_stream_receiver.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver_test.cc index fd7959512c8..272597ac191 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.h" +#include "quic/core/qpack/qpack_decoder_stream_receiver.h" #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/platform/api/quic_test.h" +#include "common/platform/api/quiche_text_utils.h" using testing::Eq; using testing::StrictMock; diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.cc index bfb19e10f59..9e2488d3a72 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.h" +#include "quic/core/qpack/qpack_decoder_stream_sender.h" #include <cstddef> #include <limits> #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/qpack/qpack_instructions.h" +#include "quic/platform/api/quic_logging.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.h index eee95c131cb..c554651f6d7 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.h @@ -7,10 +7,10 @@ #include <cstdint> -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_stream_sender_delegate.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/qpack/qpack_instruction_encoder.h" +#include "quic/core/qpack/qpack_stream_sender_delegate.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender_test.cc index c412c9f78e3..275e76f3ca1 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.h" +#include "quic/core/qpack/qpack_decoder_stream_sender.h" #include "absl/strings/escaping.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/qpack/qpack_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" using ::testing::Eq; using ::testing::StrictMock; diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_test.cc index cf7c9d39a5c..3b57ca6f1c3 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_decoder_test.cc @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h" +#include "quic/core/qpack/qpack_decoder.h" #include <algorithm> #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" -#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_test.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/qpack/qpack_decoder_test_utils.h" +#include "quic/test_tools/qpack/qpack_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" +#include "spdy/core/spdy_header_block.h" using ::testing::_; using ::testing::Eq; @@ -440,12 +440,10 @@ TEST_P(QpackDecoderTest, DecreasingDynamicTableCapacityEvictsEntries) { } TEST_P(QpackDecoderTest, EncoderStreamErrorEntryTooLarge) { - EXPECT_CALL(encoder_stream_error_delegate_, - OnEncoderStreamError( - GetQuicReloadableFlag(quic_granular_qpack_error_codes) - ? QUIC_QPACK_ENCODER_STREAM_ERROR_INSERTING_LITERAL - : QUIC_QPACK_ENCODER_STREAM_ERROR, - Eq("Error inserting literal entry."))); + EXPECT_CALL( + encoder_stream_error_delegate_, + OnEncoderStreamError(QUIC_QPACK_ENCODER_STREAM_ERROR_INSERTING_LITERAL, + Eq("Error inserting literal entry."))); // Set dynamic table capacity to 34. DecodeEncoderStreamData(absl::HexStringToBytes("3f03")); @@ -454,25 +452,20 @@ TEST_P(QpackDecoderTest, EncoderStreamErrorEntryTooLarge) { } TEST_P(QpackDecoderTest, EncoderStreamErrorInvalidStaticTableEntry) { - EXPECT_CALL(encoder_stream_error_delegate_, - OnEncoderStreamError( - GetQuicReloadableFlag(quic_granular_qpack_error_codes) - ? QUIC_QPACK_ENCODER_STREAM_INVALID_STATIC_ENTRY - : QUIC_QPACK_ENCODER_STREAM_ERROR, - Eq("Invalid static table entry."))); + EXPECT_CALL( + encoder_stream_error_delegate_, + OnEncoderStreamError(QUIC_QPACK_ENCODER_STREAM_INVALID_STATIC_ENTRY, + Eq("Invalid static table entry."))); // Address invalid static table entry index 99. DecodeEncoderStreamData(absl::HexStringToBytes("ff2400")); } TEST_P(QpackDecoderTest, EncoderStreamErrorInvalidDynamicTableEntry) { - EXPECT_CALL( - encoder_stream_error_delegate_, - OnEncoderStreamError( - GetQuicReloadableFlag(quic_granular_qpack_error_codes) - ? QUIC_QPACK_ENCODER_STREAM_INSERTION_INVALID_RELATIVE_INDEX - : QUIC_QPACK_ENCODER_STREAM_ERROR, - Eq("Invalid relative index."))); + EXPECT_CALL(encoder_stream_error_delegate_, + OnEncoderStreamError( + QUIC_QPACK_ENCODER_STREAM_INSERTION_INVALID_RELATIVE_INDEX, + Eq("Invalid relative index."))); DecodeEncoderStreamData(absl::HexStringToBytes( "3fe107" // Set dynamic table capacity to 1024. @@ -483,13 +476,10 @@ TEST_P(QpackDecoderTest, EncoderStreamErrorInvalidDynamicTableEntry) { } TEST_P(QpackDecoderTest, EncoderStreamErrorDuplicateInvalidEntry) { - EXPECT_CALL( - encoder_stream_error_delegate_, - OnEncoderStreamError( - GetQuicReloadableFlag(quic_granular_qpack_error_codes) - ? QUIC_QPACK_ENCODER_STREAM_DUPLICATE_INVALID_RELATIVE_INDEX - : QUIC_QPACK_ENCODER_STREAM_ERROR, - Eq("Invalid relative index."))); + EXPECT_CALL(encoder_stream_error_delegate_, + OnEncoderStreamError( + QUIC_QPACK_ENCODER_STREAM_DUPLICATE_INVALID_RELATIVE_INDEX, + Eq("Invalid relative index."))); DecodeEncoderStreamData(absl::HexStringToBytes( "3fe107" // Set dynamic table capacity to 1024. @@ -501,11 +491,8 @@ TEST_P(QpackDecoderTest, EncoderStreamErrorDuplicateInvalidEntry) { TEST_P(QpackDecoderTest, EncoderStreamErrorTooLargeInteger) { EXPECT_CALL(encoder_stream_error_delegate_, - OnEncoderStreamError( - GetQuicReloadableFlag(quic_granular_qpack_error_codes) - ? QUIC_QPACK_ENCODER_STREAM_INTEGER_TOO_LARGE - : QUIC_QPACK_ENCODER_STREAM_ERROR, - Eq("Encoded integer too large."))); + OnEncoderStreamError(QUIC_QPACK_ENCODER_STREAM_INTEGER_TOO_LARGE, + Eq("Encoded integer too large."))); DecodeEncoderStreamData(absl::HexStringToBytes("3fffffffffffffffffffff")); } @@ -608,12 +595,10 @@ TEST_P(QpackDecoderTest, EvictedDynamicTableEntry) { } TEST_P(QpackDecoderTest, TableCapacityMustNotExceedMaximum) { - EXPECT_CALL(encoder_stream_error_delegate_, - OnEncoderStreamError( - GetQuicReloadableFlag(quic_granular_qpack_error_codes) - ? QUIC_QPACK_ENCODER_STREAM_SET_DYNAMIC_TABLE_CAPACITY - : QUIC_QPACK_ENCODER_STREAM_ERROR, - Eq("Error updating dynamic table capacity."))); + EXPECT_CALL( + encoder_stream_error_delegate_, + OnEncoderStreamError(QUIC_QPACK_ENCODER_STREAM_SET_DYNAMIC_TABLE_CAPACITY, + Eq("Error updating dynamic table capacity."))); // Try to update dynamic table capacity to 2048, which exceeds the maximum. DecodeEncoderStreamData(absl::HexStringToBytes("3fe10f")); diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.cc index bf7cdc63a3f..8138266b493 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.cc @@ -2,19 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder.h" +#include "quic/core/qpack/qpack_encoder.h" #include <algorithm> #include <utility> +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count.h" -#include "net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.h" -#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/common/platform/api/quiche_str_cat.h" +#include "quic/core/qpack/qpack_index_conversions.h" +#include "quic/core/qpack/qpack_instruction_encoder.h" +#include "quic/core/qpack/qpack_required_insert_count.h" +#include "quic/core/qpack/value_splitting_header_list.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -37,7 +38,7 @@ QpackEncoder::QpackEncoder( decoder_stream_receiver_(this), maximum_blocked_streams_(0), header_list_count_(0) { - DCHECK(decoder_stream_error_delegate_); + QUICHE_DCHECK(decoder_stream_error_delegate_); } QpackEncoder::~QpackEncoder() {} @@ -274,8 +275,8 @@ QpackEncoder::Instructions QpackEncoder::FirstPassEncode( const QuicByteCount encoder_stream_buffered_byte_count = encoder_stream_sender_.BufferedByteCount(); - DCHECK_GE(encoder_stream_buffered_byte_count, - initial_encoder_stream_buffered_byte_count); + QUICHE_DCHECK_GE(encoder_stream_buffered_byte_count, + initial_encoder_stream_buffered_byte_count); if (encoder_stream_sent_byte_count) { *encoder_stream_sent_byte_count = encoder_stream_buffered_byte_count - @@ -391,7 +392,7 @@ void QpackEncoder::SetDynamicTableCapacity(uint64_t dynamic_table_capacity) { // instructions are written. bool success = header_table_.SetDynamicTableCapacity(dynamic_table_capacity); - DCHECK(success); + QUICHE_DCHECK(success); } bool QpackEncoder::SetMaximumBlockedStreams(uint64_t maximum_blocked_streams) { @@ -416,13 +417,12 @@ void QpackEncoder::OnInsertCountIncrement(uint64_t increment) { if (blocking_manager_.known_received_count() > header_table_.inserted_entry_count()) { - OnErrorDetected( - QUIC_QPACK_DECODER_STREAM_IMPOSSIBLE_INSERT_COUNT, - quiche::QuicheStrCat("Increment value ", increment, - " raises known received count to ", - blocking_manager_.known_received_count(), - " exceeding inserted entry count ", - header_table_.inserted_entry_count())); + OnErrorDetected(QUIC_QPACK_DECODER_STREAM_IMPOSSIBLE_INSERT_COUNT, + absl::StrCat("Increment value ", increment, + " raises known received count to ", + blocking_manager_.known_received_count(), + " exceeding inserted entry count ", + header_table_.inserted_entry_count())); } } @@ -430,8 +430,8 @@ void QpackEncoder::OnHeaderAcknowledgement(QuicStreamId stream_id) { if (!blocking_manager_.OnHeaderAcknowledgement(stream_id)) { OnErrorDetected( QUIC_QPACK_DECODER_STREAM_INCORRECT_ACKNOWLEDGEMENT, - quiche::QuicheStrCat("Header Acknowledgement received for stream ", - stream_id, " with no outstanding header blocks.")); + absl::StrCat("Header Acknowledgement received for stream ", stream_id, + " with no outstanding header blocks.")); } } @@ -441,14 +441,8 @@ void QpackEncoder::OnStreamCancellation(QuicStreamId stream_id) { void QpackEncoder::OnErrorDetected(QuicErrorCode error_code, absl::string_view error_message) { - if (GetQuicReloadableFlag(quic_granular_qpack_error_codes)) { - QUIC_CODE_COUNT_N(quic_granular_qpack_error_codes, 1, 2); - decoder_stream_error_delegate_->OnDecoderStreamError(error_code, - error_message); - } else { - decoder_stream_error_delegate_->OnDecoderStreamError( - QUIC_QPACK_DECODER_STREAM_ERROR, error_message); - } + decoder_stream_error_delegate_->OnDecoderStreamError(error_code, + error_message); } } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.h index c6c8aa5d8ae..3d95f6e3249 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder.h @@ -11,16 +11,16 @@ #include <vector> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_blocking_manager.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_exported_stats.h" -#include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" +#include "quic/core/qpack/qpack_blocking_manager.h" +#include "quic/core/qpack/qpack_decoder_stream_receiver.h" +#include "quic/core/qpack/qpack_encoder_stream_sender.h" +#include "quic/core/qpack/qpack_header_table.h" +#include "quic/core/qpack/qpack_instructions.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_exported_stats.h" +#include "spdy/core/spdy_header_block.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.cc index 95260ab3e7a..bf71faf5def 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.cc @@ -2,12 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.h" +#include "quic/core/qpack/qpack_encoder_stream_receiver.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/http2/decoder/decode_buffer.h" -#include "net/third_party/quiche/src/http2/decoder/decode_status.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h" +#include "http2/decoder/decode_buffer.h" +#include "http2/decoder/decode_status.h" +#include "quic/core/qpack/qpack_instructions.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -15,7 +16,7 @@ QpackEncoderStreamReceiver::QpackEncoderStreamReceiver(Delegate* delegate) : instruction_decoder_(QpackEncoderStreamLanguage(), this), delegate_(delegate), error_detected_(false) { - DCHECK(delegate_); + QUICHE_DCHECK(delegate_); } void QpackEncoderStreamReceiver::Decode(absl::string_view data) { @@ -46,7 +47,7 @@ bool QpackEncoderStreamReceiver::OnInstructionDecoded( return true; } - DCHECK_EQ(instruction, SetDynamicTableCapacityInstruction()); + QUICHE_DCHECK_EQ(instruction, SetDynamicTableCapacityInstruction()); delegate_->OnSetDynamicTableCapacity(instruction_decoder_.varint()); return true; } @@ -54,7 +55,7 @@ bool QpackEncoderStreamReceiver::OnInstructionDecoded( void QpackEncoderStreamReceiver::OnInstructionDecodingError( QpackInstructionDecoder::ErrorCode error_code, absl::string_view error_message) { - DCHECK(!error_detected_); + QUICHE_DCHECK(!error_detected_); error_detected_ = true; diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.h index fa94a5353ee..b3e43cf94f7 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.h @@ -9,10 +9,10 @@ #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_stream_receiver.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/qpack/qpack_instruction_decoder.h" +#include "quic/core/qpack/qpack_stream_receiver.h" +#include "quic/core/quic_error_codes.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver_test.cc index 31bea896899..efe5eb90b98 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.h" +#include "quic/core/qpack/qpack_encoder_stream_receiver.h" #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/platform/api/quic_test.h" +#include "common/platform/api/quiche_text_utils.h" using testing::Eq; using testing::StrictMock; diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.cc index 88214abee17..4079ba45a85 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.h" +#include "quic/core/qpack/qpack_encoder_stream_sender.h" #include <cstddef> #include <limits> #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/qpack/qpack_instructions.h" +#include "quic/platform/api/quic_logging.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.h index dbef027e1b7..44d777d8d90 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.h @@ -8,10 +8,10 @@ #include <cstdint> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_stream_sender_delegate.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/qpack/qpack_instruction_encoder.h" +#include "quic/core/qpack/qpack_stream_sender_delegate.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender_test.cc index 08138190c84..5078c8f0d05 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.h" +#include "quic/core/qpack/qpack_encoder_stream_sender.h" #include "absl/strings/escaping.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/qpack/qpack_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" using ::testing::Eq; using ::testing::StrictMock; diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_test.cc index 08c6123fc82..5045c8fb350 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_encoder_test.cc @@ -2,21 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder.h" +#include "quic/core/qpack/qpack_encoder.h" #include <limits> #include <string> #include "absl/strings/escaping.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_header_table_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/qpack/qpack_encoder_peer.h" +#include "quic/test_tools/qpack/qpack_encoder_test_utils.h" +#include "quic/test_tools/qpack/qpack_header_table_peer.h" +#include "quic/test_tools/qpack/qpack_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" using ::testing::_; using ::testing::Eq; @@ -141,11 +141,8 @@ TEST_F(QpackEncoderTest, StaticTable) { TEST_F(QpackEncoderTest, DecoderStreamError) { EXPECT_CALL(decoder_stream_error_delegate_, - OnDecoderStreamError( - GetQuicReloadableFlag(quic_granular_qpack_error_codes) - ? QUIC_QPACK_DECODER_STREAM_INTEGER_TOO_LARGE - : QUIC_QPACK_DECODER_STREAM_ERROR, - Eq("Encoded integer too large."))); + OnDecoderStreamError(QUIC_QPACK_DECODER_STREAM_INTEGER_TOO_LARGE, + Eq("Encoded integer too large."))); QpackEncoder encoder(&decoder_stream_error_delegate_); encoder.set_qpack_stream_sender_delegate(&encoder_stream_sender_delegate_); @@ -168,12 +165,10 @@ TEST_F(QpackEncoderTest, SplitAlongNullCharacter) { TEST_F(QpackEncoderTest, ZeroInsertCountIncrement) { // Encoder receives insert count increment with forbidden value 0. - EXPECT_CALL(decoder_stream_error_delegate_, - OnDecoderStreamError( - GetQuicReloadableFlag(quic_granular_qpack_error_codes) - ? QUIC_QPACK_DECODER_STREAM_INVALID_ZERO_INCREMENT - : QUIC_QPACK_DECODER_STREAM_ERROR, - Eq("Invalid increment value 0."))); + EXPECT_CALL( + decoder_stream_error_delegate_, + OnDecoderStreamError(QUIC_QPACK_DECODER_STREAM_INVALID_ZERO_INCREMENT, + Eq("Invalid increment value 0."))); encoder_.OnInsertCountIncrement(0); } @@ -181,13 +176,11 @@ TEST_F(QpackEncoderTest, TooLargeInsertCountIncrement) { // Encoder receives insert count increment with value that increases Known // Received Count to a value (one) which is larger than the number of dynamic // table insertions sent (zero). - EXPECT_CALL(decoder_stream_error_delegate_, - OnDecoderStreamError( - GetQuicReloadableFlag(quic_granular_qpack_error_codes) - ? QUIC_QPACK_DECODER_STREAM_IMPOSSIBLE_INSERT_COUNT - : QUIC_QPACK_DECODER_STREAM_ERROR, - Eq("Increment value 1 raises known received count " - "to 1 exceeding inserted entry count 0"))); + EXPECT_CALL( + decoder_stream_error_delegate_, + OnDecoderStreamError(QUIC_QPACK_DECODER_STREAM_IMPOSSIBLE_INSERT_COUNT, + Eq("Increment value 1 raises known received count " + "to 1 exceeding inserted entry count 0"))); encoder_.OnInsertCountIncrement(1); } @@ -208,9 +201,7 @@ TEST_F(QpackEncoderTest, InsertCountIncrementOverflow) { // received count. This must result in an error instead of a crash. EXPECT_CALL(decoder_stream_error_delegate_, OnDecoderStreamError( - GetQuicReloadableFlag(quic_granular_qpack_error_codes) - ? QUIC_QPACK_DECODER_STREAM_INCREMENT_OVERFLOW - : QUIC_QPACK_DECODER_STREAM_ERROR, + QUIC_QPACK_DECODER_STREAM_INCREMENT_OVERFLOW, Eq("Insert Count Increment instruction causes overflow."))); encoder_.OnInsertCountIncrement(std::numeric_limits<uint64_t>::max()); } @@ -218,13 +209,11 @@ TEST_F(QpackEncoderTest, InsertCountIncrementOverflow) { TEST_F(QpackEncoderTest, InvalidHeaderAcknowledgement) { // Encoder receives header acknowledgement for a stream on which no header // block with dynamic table entries was ever sent. - EXPECT_CALL(decoder_stream_error_delegate_, - OnDecoderStreamError( - GetQuicReloadableFlag(quic_granular_qpack_error_codes) - ? QUIC_QPACK_DECODER_STREAM_INCORRECT_ACKNOWLEDGEMENT - : QUIC_QPACK_DECODER_STREAM_ERROR, - Eq("Header Acknowledgement received for stream 0 " - "with no outstanding header blocks."))); + EXPECT_CALL( + decoder_stream_error_delegate_, + OnDecoderStreamError(QUIC_QPACK_DECODER_STREAM_INCORRECT_ACKNOWLEDGEMENT, + Eq("Header Acknowledgement received for stream 0 " + "with no outstanding header blocks."))); encoder_.OnHeaderAcknowledgement(/* stream_id = */ 0); } @@ -251,8 +240,8 @@ TEST_F(QpackEncoderTest, DynamicTable) { "c5" // insert with name reference, static index 5 "0362617a"); // value "baz" EXPECT_CALL(encoder_stream_sender_delegate_, - WriteStreamData(Eq(quiche::QuicheStrCat( - set_dyanamic_table_capacity, insert_entries)))); + WriteStreamData(Eq( + absl::StrCat(set_dyanamic_table_capacity, insert_entries)))); EXPECT_EQ(absl::HexStringToBytes( "0400" // prefix @@ -283,8 +272,8 @@ TEST_F(QpackEncoderTest, SmallDynamicTable) { "94e7" // Huffman-encoded name "foo" "03626172"); // value "bar" EXPECT_CALL(encoder_stream_sender_delegate_, - WriteStreamData(Eq(quiche::QuicheStrCat( - set_dyanamic_table_capacity, insert_entry)))); + WriteStreamData( + Eq(absl::StrCat(set_dyanamic_table_capacity, insert_entry)))); EXPECT_EQ(absl::HexStringToBytes("0200" // prefix "80" // dynamic entry 0 @@ -315,8 +304,8 @@ TEST_F(QpackEncoderTest, BlockedStream) { "94e7" // Huffman-encoded name "foo" "03626172"); // value "bar" EXPECT_CALL(encoder_stream_sender_delegate_, - WriteStreamData(Eq(quiche::QuicheStrCat( - set_dyanamic_table_capacity, insert_entry1)))); + WriteStreamData(Eq( + absl::StrCat(set_dyanamic_table_capacity, insert_entry1)))); EXPECT_EQ(absl::HexStringToBytes("0200" // prefix "80"), // dynamic entry 0 diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table.cc index 1440ca58a1b..6171d8455a4 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h" +#include "quic/core/qpack/qpack_header_table.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_static_table.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/qpack/qpack_static_table.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -60,7 +60,7 @@ QpackHeaderTable::MatchType QpackHeaderTable::FindHeaderField( // Look for exact match in static table. auto index_it = static_index_.find(&query); if (index_it != static_index_.end()) { - DCHECK((*index_it)->IsStatic()); + QUICHE_DCHECK((*index_it)->IsStatic()); *index = (*index_it)->InsertionIndex(); *is_static = true; return MatchType::kNameAndValue; @@ -69,7 +69,7 @@ QpackHeaderTable::MatchType QpackHeaderTable::FindHeaderField( // Look for exact match in dynamic table. index_it = dynamic_index_.find(&query); if (index_it != dynamic_index_.end()) { - DCHECK(!(*index_it)->IsStatic()); + QUICHE_DCHECK(!(*index_it)->IsStatic()); *index = (*index_it)->InsertionIndex(); *is_static = false; return MatchType::kNameAndValue; @@ -78,7 +78,7 @@ QpackHeaderTable::MatchType QpackHeaderTable::FindHeaderField( // Look for name match in static table. auto name_index_it = static_name_index_.find(name); if (name_index_it != static_name_index_.end()) { - DCHECK(name_index_it->second->IsStatic()); + QUICHE_DCHECK(name_index_it->second->IsStatic()); *index = name_index_it->second->InsertionIndex(); *is_static = true; return MatchType::kName; @@ -87,7 +87,7 @@ QpackHeaderTable::MatchType QpackHeaderTable::FindHeaderField( // Look for name match in dynamic table. name_index_it = dynamic_name_index_.find(name); if (name_index_it != dynamic_name_index_.end()) { - DCHECK(!name_index_it->second->IsStatic()); + QUICHE_DCHECK(!name_index_it->second->IsStatic()); *index = name_index_it->second->InsertionIndex(); *is_static = false; return MatchType::kName; @@ -117,11 +117,11 @@ const QpackEntry* QpackHeaderTable::InsertEntry(absl::string_view name, // An entry with the same name and value already exists. It needs to be // replaced, because |dynamic_index_| tracks the most recent entry for a // given name and value. - DCHECK_GT(new_entry->InsertionIndex(), - (*index_result.first)->InsertionIndex()); + QUICHE_DCHECK_GT(new_entry->InsertionIndex(), + (*index_result.first)->InsertionIndex()); dynamic_index_.erase(index_result.first); auto result = dynamic_index_.insert(new_entry); - CHECK(result.second); + QUICHE_CHECK(result.second); } auto name_result = dynamic_name_index_.insert({new_entry->name(), new_entry}); @@ -129,11 +129,11 @@ const QpackEntry* QpackHeaderTable::InsertEntry(absl::string_view name, // An entry with the same name already exists. It needs to be replaced, // because |dynamic_name_index_| tracks the most recent entry for a given // name. - DCHECK_GT(new_entry->InsertionIndex(), - name_result.first->second->InsertionIndex()); + QUICHE_DCHECK_GT(new_entry->InsertionIndex(), + name_result.first->second->InsertionIndex()); dynamic_name_index_.erase(name_result.first); auto result = dynamic_name_index_.insert({new_entry->name(), new_entry}); - CHECK(result.second); + QUICHE_CHECK(result.second); } // Notify and deregister observers whose threshold is met, if any. @@ -152,7 +152,7 @@ const QpackEntry* QpackHeaderTable::InsertEntry(absl::string_view name, uint64_t QpackHeaderTable::MaxInsertSizeWithoutEvictingGivenEntry( uint64_t index) const { - DCHECK_LE(dropped_entry_count_, index); + QUICHE_DCHECK_LE(dropped_entry_count_, index); if (index > inserted_entry_count()) { // All entries are allowed to be evicted. @@ -180,7 +180,7 @@ bool QpackHeaderTable::SetDynamicTableCapacity(uint64_t capacity) { dynamic_table_capacity_ = capacity; EvictDownToCurrentCapacity(); - DCHECK_LE(dynamic_table_size_, dynamic_table_capacity_); + QUICHE_DCHECK_LE(dynamic_table_size_, dynamic_table_capacity_); return true; } @@ -198,7 +198,7 @@ bool QpackHeaderTable::SetMaximumDynamicTableCapacity( void QpackHeaderTable::RegisterObserver(uint64_t required_insert_count, Observer* observer) { - DCHECK_GT(required_insert_count, 0u); + QUICHE_DCHECK_GT(required_insert_count, 0u); observers_.insert({required_insert_count, observer}); } @@ -218,8 +218,8 @@ void QpackHeaderTable::UnregisterObserver(uint64_t required_insert_count, } uint64_t QpackHeaderTable::draining_index(float draining_fraction) const { - DCHECK_LE(0.0, draining_fraction); - DCHECK_LE(draining_fraction, 1.0); + QUICHE_DCHECK_LE(0.0, draining_fraction); + QUICHE_DCHECK_LE(draining_fraction, 1.0); const uint64_t required_space = draining_fraction * dynamic_table_capacity_; uint64_t space_above_draining_index = @@ -244,12 +244,12 @@ uint64_t QpackHeaderTable::draining_index(float draining_fraction) const { void QpackHeaderTable::EvictDownToCurrentCapacity() { while (dynamic_table_size_ > dynamic_table_capacity_) { - DCHECK(!dynamic_entries_.empty()); + QUICHE_DCHECK(!dynamic_entries_.empty()); QpackEntry* const entry = &dynamic_entries_.front(); const uint64_t entry_size = entry->Size(); - DCHECK_GE(dynamic_table_size_, entry_size); + QUICHE_DCHECK_GE(dynamic_table_size_, entry_size); dynamic_table_size_ -= entry_size; auto index_it = dynamic_index_.find(entry); diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h index c9aa767ac10..4f0a1b5e032 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h @@ -11,9 +11,9 @@ #include <vector> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/spdy/core/hpack/hpack_entry.h" -#include "net/third_party/quiche/src/spdy/core/hpack/hpack_header_table.h" +#include "quic/platform/api/quic_export.h" +#include "spdy/core/hpack/hpack_entry.h" +#include "spdy/core/hpack/hpack_header_table.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table_test.cc index b06786eb437..801ab8f8062 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_header_table_test.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h" +#include "quic/core/qpack/qpack_header_table.h" #include <utility> #include "absl/base/macros.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_static_table.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/spdy/core/hpack/hpack_entry.h" +#include "quic/core/qpack/qpack_static_table.h" +#include "quic/platform/api/quic_test.h" +#include "spdy/core/hpack/hpack_entry.h" using ::testing::Mock; using ::testing::StrictMock; diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions.cc index 8f1d52f6f34..66f2ea32e87 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions.cc @@ -2,25 +2,25 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions.h" +#include "quic/core/qpack/qpack_index_conversions.h" #include <limits> -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_logging.h" namespace quic { uint64_t QpackAbsoluteIndexToEncoderStreamRelativeIndex( uint64_t absolute_index, uint64_t inserted_entry_count) { - DCHECK_LT(absolute_index, inserted_entry_count); + QUICHE_DCHECK_LT(absolute_index, inserted_entry_count); return inserted_entry_count - absolute_index - 1; } uint64_t QpackAbsoluteIndexToRequestStreamRelativeIndex(uint64_t absolute_index, uint64_t base) { - DCHECK_LT(absolute_index, base); + QUICHE_DCHECK_LT(absolute_index, base); return base - absolute_index - 1; } diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions.h index 2348ac70964..101858a69c7 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions.h @@ -14,7 +14,7 @@ #include <cstdint> -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions_test.cc index 214dff5f27d..335adc42fca 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions_test.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions.h" +#include "quic/core/qpack/qpack_index_conversions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.cc index 539e3109cca..bf786a44a55 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h" +#include "quic/core/qpack/qpack_instruction_decoder.h" #include <algorithm> #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -34,8 +34,8 @@ QpackInstructionDecoder::QpackInstructionDecoder(const QpackLanguage* language, state_(State::kStartInstruction) {} bool QpackInstructionDecoder::Decode(absl::string_view data) { - DCHECK(!data.empty()); - DCHECK(!error_detected_); + QUICHE_DCHECK(!data.empty()); + QUICHE_DCHECK(!error_detected_); while (true) { bool success = true; @@ -73,9 +73,9 @@ bool QpackInstructionDecoder::Decode(absl::string_view data) { } // |success| must be false if an error is detected. - DCHECK(!error_detected_); + QUICHE_DCHECK(!error_detected_); - DCHECK_LE(bytes_consumed, data.size()); + QUICHE_DCHECK_LE(bytes_consumed, data.size()); data = absl::string_view(data.data() + bytes_consumed, data.size() - bytes_consumed); @@ -95,7 +95,7 @@ bool QpackInstructionDecoder::AtInstructionBoundary() const { } bool QpackInstructionDecoder::DoStartInstruction(absl::string_view data) { - DCHECK(!data.empty()); + QUICHE_DCHECK(!data.empty()); instruction_ = LookupOpcode(data[0]); field_ = instruction_->fields.begin(); @@ -133,7 +133,7 @@ bool QpackInstructionDecoder::DoStartField() { } bool QpackInstructionDecoder::DoReadBit(absl::string_view data) { - DCHECK(!data.empty()); + QUICHE_DCHECK(!data.empty()); switch (field_->type) { case QpackInstructionFieldType::kSbit: { @@ -148,7 +148,7 @@ bool QpackInstructionDecoder::DoReadBit(absl::string_view data) { case QpackInstructionFieldType::kName: case QpackInstructionFieldType::kValue: { const uint8_t prefix_length = field_->param; - DCHECK_GE(7, prefix_length); + QUICHE_DCHECK_GE(7, prefix_length); const uint8_t bitmask = 1 << prefix_length; is_huffman_encoded_ = (data[0] & bitmask) == bitmask; @@ -164,11 +164,11 @@ bool QpackInstructionDecoder::DoReadBit(absl::string_view data) { bool QpackInstructionDecoder::DoVarintStart(absl::string_view data, size_t* bytes_consumed) { - DCHECK(!data.empty()); - DCHECK(field_->type == QpackInstructionFieldType::kVarint || - field_->type == QpackInstructionFieldType::kVarint2 || - field_->type == QpackInstructionFieldType::kName || - field_->type == QpackInstructionFieldType::kValue); + QUICHE_DCHECK(!data.empty()); + QUICHE_DCHECK(field_->type == QpackInstructionFieldType::kVarint || + field_->type == QpackInstructionFieldType::kVarint2 || + field_->type == QpackInstructionFieldType::kName || + field_->type == QpackInstructionFieldType::kValue); http2::DecodeBuffer buffer(data.data() + 1, data.size() - 1); http2::DecodeStatus status = @@ -193,11 +193,11 @@ bool QpackInstructionDecoder::DoVarintStart(absl::string_view data, bool QpackInstructionDecoder::DoVarintResume(absl::string_view data, size_t* bytes_consumed) { - DCHECK(!data.empty()); - DCHECK(field_->type == QpackInstructionFieldType::kVarint || - field_->type == QpackInstructionFieldType::kVarint2 || - field_->type == QpackInstructionFieldType::kName || - field_->type == QpackInstructionFieldType::kValue); + QUICHE_DCHECK(!data.empty()); + QUICHE_DCHECK(field_->type == QpackInstructionFieldType::kVarint || + field_->type == QpackInstructionFieldType::kVarint2 || + field_->type == QpackInstructionFieldType::kName || + field_->type == QpackInstructionFieldType::kValue); http2::DecodeBuffer buffer(data); http2::DecodeStatus status = varint_decoder_.Resume(&buffer); @@ -208,8 +208,8 @@ bool QpackInstructionDecoder::DoVarintResume(absl::string_view data, state_ = State::kVarintDone; return true; case http2::DecodeStatus::kDecodeInProgress: - DCHECK_EQ(*bytes_consumed, data.size()); - DCHECK(buffer.Empty()); + QUICHE_DCHECK_EQ(*bytes_consumed, data.size()); + QUICHE_DCHECK(buffer.Empty()); return true; case http2::DecodeStatus::kDecodeError: OnError(ErrorCode::INTEGER_TOO_LARGE, "Encoded integer too large."); @@ -221,10 +221,10 @@ bool QpackInstructionDecoder::DoVarintResume(absl::string_view data, } bool QpackInstructionDecoder::DoVarintDone() { - DCHECK(field_->type == QpackInstructionFieldType::kVarint || - field_->type == QpackInstructionFieldType::kVarint2 || - field_->type == QpackInstructionFieldType::kName || - field_->type == QpackInstructionFieldType::kValue); + QUICHE_DCHECK(field_->type == QpackInstructionFieldType::kVarint || + field_->type == QpackInstructionFieldType::kVarint2 || + field_->type == QpackInstructionFieldType::kName || + field_->type == QpackInstructionFieldType::kValue); if (field_->type == QpackInstructionFieldType::kVarint) { varint_ = varint_decoder_.value(); @@ -266,18 +266,18 @@ bool QpackInstructionDecoder::DoVarintDone() { bool QpackInstructionDecoder::DoReadString(absl::string_view data, size_t* bytes_consumed) { - DCHECK(!data.empty()); - DCHECK(field_->type == QpackInstructionFieldType::kName || - field_->type == QpackInstructionFieldType::kValue); + QUICHE_DCHECK(!data.empty()); + QUICHE_DCHECK(field_->type == QpackInstructionFieldType::kName || + field_->type == QpackInstructionFieldType::kValue); std::string* const string = (field_->type == QpackInstructionFieldType::kName) ? &name_ : &value_; - DCHECK_LT(string->size(), string_length_); + QUICHE_DCHECK_LT(string->size(), string_length_); *bytes_consumed = std::min(string_length_ - string->size(), data.size()); string->append(data.data(), *bytes_consumed); - DCHECK_LE(string->size(), string_length_); + QUICHE_DCHECK_LE(string->size(), string_length_); if (string->size() == string_length_) { state_ = State::kReadStringDone; } @@ -285,12 +285,12 @@ bool QpackInstructionDecoder::DoReadString(absl::string_view data, } bool QpackInstructionDecoder::DoReadStringDone() { - DCHECK(field_->type == QpackInstructionFieldType::kName || - field_->type == QpackInstructionFieldType::kValue); + QUICHE_DCHECK(field_->type == QpackInstructionFieldType::kName || + field_->type == QpackInstructionFieldType::kValue); std::string* const string = (field_->type == QpackInstructionFieldType::kName) ? &name_ : &value_; - DCHECK_EQ(string->size(), string_length_); + QUICHE_DCHECK_EQ(string->size(), string_length_); if (is_huffman_encoded_) { huffman_decoder_.Reset(); @@ -319,13 +319,13 @@ const QpackInstruction* QpackInstructionDecoder::LookupOpcode( } // |language_| should be defined such that instruction opcodes cover every // possible input. - DCHECK(false); + QUICHE_DCHECK(false); return nullptr; } void QpackInstructionDecoder::OnError(ErrorCode error_code, absl::string_view error_message) { - DCHECK(!error_detected_); + QUICHE_DCHECK(!error_detected_); error_detected_ = true; delegate_->OnInstructionDecodingError(error_code, error_message); diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h index b8edfb7dbf4..fc9b96eca16 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h @@ -10,10 +10,10 @@ #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/http2/hpack/huffman/hpack_huffman_decoder.h" -#include "net/third_party/quiche/src/http2/hpack/varint/hpack_varint_decoder.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "http2/hpack/huffman/hpack_huffman_decoder.h" +#include "http2/hpack/varint/hpack_varint_decoder.h" +#include "quic/core/qpack/qpack_instructions.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -143,7 +143,7 @@ class QUIC_EXPORT_PRIVATE QpackInstructionDecoder { http2::HpackHuffmanDecoder huffman_decoder_; // True if a decoding error has been detected by QpackInstructionDecoder. - // Only used in DCHECKs. + // Only used in QUICHE_DCHECKs. bool error_detected_; // Decoding state. diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder_test.cc index 52ec38bc8c8..3f68d749f36 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder_test.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h" +#include "quic/core/qpack/qpack_instruction_decoder.h" #include <algorithm> #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/qpack/qpack_instructions.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/qpack/qpack_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" using ::testing::_; using ::testing::Eq; diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.cc index c79665447f9..527c43c82db 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.h" +#include "quic/core/qpack/qpack_instruction_encoder.h" #include <limits> +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/http2/hpack/huffman/hpack_huffman_encoder.h" -#include "net/third_party/quiche/src/http2/hpack/varint/hpack_varint_encoder.h" -#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_string_utils.h" +#include "http2/hpack/huffman/hpack_huffman_encoder.h" +#include "http2/hpack/varint/hpack_varint_encoder.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -20,25 +20,19 @@ QpackInstructionEncoder::QpackInstructionEncoder() string_length_(0), byte_(0), state_(State::kOpcode), - instruction_(nullptr), - use_fast_huffman_encoder_( - GetQuicReloadableFlag(quic_use_fast_huffman_encoder)) { - if (use_fast_huffman_encoder_) { - QUIC_RELOADABLE_FLAG_COUNT(quic_use_fast_huffman_encoder); - } -} + instruction_(nullptr) {} void QpackInstructionEncoder::Encode( const QpackInstructionWithValues& instruction_with_values, std::string* output) { - DCHECK(instruction_with_values.instruction()); + QUICHE_DCHECK(instruction_with_values.instruction()); state_ = State::kOpcode; instruction_ = instruction_with_values.instruction(); field_ = instruction_->fields.begin(); // Field list must not be empty. - DCHECK(field_ != instruction_->fields.end()); + QUICHE_DCHECK(field_ != instruction_->fields.end()); do { switch (state_) { @@ -66,11 +60,11 @@ void QpackInstructionEncoder::Encode( } } while (field_ != instruction_->fields.end()); - DCHECK(state_ == State::kStartField); + QUICHE_DCHECK(state_ == State::kStartField); } void QpackInstructionEncoder::DoOpcode() { - DCHECK_EQ(0u, byte_); + QUICHE_DCHECK_EQ(0u, byte_); byte_ = instruction_->opcode.value; @@ -94,10 +88,10 @@ void QpackInstructionEncoder::DoStartField() { } void QpackInstructionEncoder::DoSBit(bool s_bit) { - DCHECK(field_->type == QpackInstructionFieldType::kSbit); + QUICHE_DCHECK(field_->type == QpackInstructionFieldType::kSbit); if (s_bit) { - DCHECK_EQ(0, byte_ & field_->param); + QUICHE_DCHECK_EQ(0, byte_ & field_->param); byte_ |= field_->param; } @@ -109,10 +103,10 @@ void QpackInstructionEncoder::DoSBit(bool s_bit) { void QpackInstructionEncoder::DoVarintEncode(uint64_t varint, uint64_t varint2, std::string* output) { - DCHECK(field_->type == QpackInstructionFieldType::kVarint || - field_->type == QpackInstructionFieldType::kVarint2 || - field_->type == QpackInstructionFieldType::kName || - field_->type == QpackInstructionFieldType::kValue); + QUICHE_DCHECK(field_->type == QpackInstructionFieldType::kVarint || + field_->type == QpackInstructionFieldType::kVarint2 || + field_->type == QpackInstructionFieldType::kName || + field_->type == QpackInstructionFieldType::kValue); uint64_t integer_to_encode; switch (field_->type) { case QpackInstructionFieldType::kVarint: @@ -142,8 +136,8 @@ void QpackInstructionEncoder::DoVarintEncode(uint64_t varint, void QpackInstructionEncoder::DoStartString(absl::string_view name, absl::string_view value) { - DCHECK(field_->type == QpackInstructionFieldType::kName || - field_->type == QpackInstructionFieldType::kValue); + QUICHE_DCHECK(field_->type == QpackInstructionFieldType::kName || + field_->type == QpackInstructionFieldType::kValue); absl::string_view string_to_write = (field_->type == QpackInstructionFieldType::kName) ? name : value; @@ -153,7 +147,7 @@ void QpackInstructionEncoder::DoStartString(absl::string_view name, use_huffman_ = encoded_size < string_length_; if (use_huffman_) { - DCHECK_EQ(0, byte_ & (1 << field_->param)); + QUICHE_DCHECK_EQ(0, byte_ & (1 << field_->param)); byte_ |= (1 << field_->param); string_length_ = encoded_size; @@ -165,19 +159,15 @@ void QpackInstructionEncoder::DoStartString(absl::string_view name, void QpackInstructionEncoder::DoWriteString(absl::string_view name, absl::string_view value, std::string* output) { - DCHECK(field_->type == QpackInstructionFieldType::kName || - field_->type == QpackInstructionFieldType::kValue); + QUICHE_DCHECK(field_->type == QpackInstructionFieldType::kName || + field_->type == QpackInstructionFieldType::kValue); absl::string_view string_to_write = (field_->type == QpackInstructionFieldType::kName) ? name : value; if (use_huffman_) { - if (use_fast_huffman_encoder_) { - http2::HuffmanEncodeFast(string_to_write, string_length_, output); - } else { - http2::HuffmanEncode(string_to_write, string_length_, output); - } + http2::HuffmanEncodeFast(string_to_write, string_length_, output); } else { - QuicStrAppend(output, string_to_write); + absl::StrAppend(output, string_to_write); } ++field_; diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.h index 4f6fac71c6b..66a76eaded9 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.h @@ -9,8 +9,8 @@ #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/qpack/qpack_instructions.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -77,9 +77,6 @@ class QUIC_EXPORT_PRIVATE QpackInstructionEncoder { // Field currently being decoded. QpackInstructionFields::const_iterator field_; - - // Latched value of gfe2_reloadable_flag_quic_use_fast_huffman_encoder. - const bool use_fast_huffman_encoder_; }; } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder_test.cc index 893bc50670f..36b89bd01ec 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder_test.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.h" +#include "quic/core/qpack/qpack_instruction_encoder.h" #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instructions.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instructions.cc index 12db3639d39..7f95762431e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instructions.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instructions.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h" +#include "quic/core/qpack/qpack_instructions.h" #include <limits> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -19,7 +19,7 @@ namespace { void ValidateLangague(const QpackLanguage* language) { #ifndef NDEBUG for (const auto* instruction : *language) { - DCHECK_EQ(0, instruction->opcode.value & ~instruction->opcode.mask); + QUICHE_DCHECK_EQ(0, instruction->opcode.value & ~instruction->opcode.mask); } for (uint8_t byte = 0; byte < std::numeric_limits<uint8_t>::max(); ++byte) { @@ -29,7 +29,7 @@ void ValidateLangague(const QpackLanguage* language) { ++match_count; } } - DCHECK_EQ(1u, match_count) << static_cast<int>(byte); + QUICHE_DCHECK_EQ(1u, match_count) << static_cast<int>(byte); } #else (void)language; diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h index 006c9a7ab2f..fcf8f22e090 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h @@ -11,7 +11,7 @@ #include <vector> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_offline_decoder_bin.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_offline_decoder_bin.cc index 851efe73633..8cd1108a458 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_offline_decoder_bin.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_offline_decoder_bin.cc @@ -6,9 +6,9 @@ #include <iostream> #include "absl/strings/string_view.h" -#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/test_tools/qpack/qpack_offline_decoder.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/test_tools/qpack/qpack_offline_decoder.h" int main(int argc, char* argv[]) { const char* usage = diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.cc index 83c55e0b31b..ac07fedff61 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.h" +#include "quic/core/qpack/qpack_progressive_decoder.h" #include <algorithm> #include <limits> #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/qpack/qpack_index_conversions.h" +#include "quic/core/qpack/qpack_instructions.h" +#include "quic/core/qpack/qpack_required_insert_count.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -47,7 +47,7 @@ QpackProgressiveDecoder::~QpackProgressiveDecoder() { } void QpackProgressiveDecoder::Decode(absl::string_view data) { - DCHECK(decoding_); + QUICHE_DCHECK(decoding_); if (data.empty() || error_detected_) { return; @@ -56,14 +56,14 @@ void QpackProgressiveDecoder::Decode(absl::string_view data) { // Decode prefix byte by byte until the first (and only) instruction is // decoded. while (!prefix_decoded_) { - DCHECK(!blocked_); + QUICHE_DCHECK(!blocked_); if (!prefix_decoder_->Decode(data.substr(0, 1))) { return; } // |prefix_decoder_->Decode()| must return false if an error is detected. - DCHECK(!error_detected_); + QUICHE_DCHECK(!error_detected_); data = data.substr(1); if (data.empty()) { @@ -74,14 +74,14 @@ void QpackProgressiveDecoder::Decode(absl::string_view data) { if (blocked_) { buffer_.append(data.data(), data.size()); } else { - DCHECK(buffer_.empty()); + QUICHE_DCHECK(buffer_.empty()); instruction_decoder_.Decode(data); } } void QpackProgressiveDecoder::EndHeaderBlock() { - DCHECK(decoding_); + QUICHE_DCHECK(decoding_); decoding_ = false; if (!blocked_) { @@ -90,7 +90,7 @@ void QpackProgressiveDecoder::EndHeaderBlock() { } void QpackProgressiveDecoder::OnError(absl::string_view error_message) { - DCHECK(!error_detected_); + QUICHE_DCHECK(!error_detected_); error_detected_ = true; // Might destroy |this|. @@ -103,8 +103,9 @@ bool QpackProgressiveDecoder::OnInstructionDecoded( return DoPrefixInstruction(); } - DCHECK(prefix_decoded_); - DCHECK_LE(required_insert_count_, header_table_->inserted_entry_count()); + QUICHE_DCHECK(prefix_decoded_); + QUICHE_DCHECK_LE(required_insert_count_, + header_table_->inserted_entry_count()); if (instruction == QpackIndexedHeaderFieldInstruction()) { return DoIndexedHeaderFieldInstruction(); @@ -118,7 +119,7 @@ bool QpackProgressiveDecoder::OnInstructionDecoded( if (instruction == QpackLiteralHeaderFieldPostBaseInstruction()) { return DoLiteralHeaderFieldPostBaseInstruction(); } - DCHECK_EQ(instruction, QpackLiteralHeaderFieldInstruction()); + QUICHE_DCHECK_EQ(instruction, QpackLiteralHeaderFieldInstruction()); return DoLiteralHeaderFieldInstruction(); } @@ -132,7 +133,7 @@ void QpackProgressiveDecoder::OnInstructionDecodingError( } void QpackProgressiveDecoder::OnInsertCountReachedThreshold() { - DCHECK(blocked_); + QUICHE_DCHECK(blocked_); // Clear |blocked_| before calling instruction_decoder_.Decode() below, // because that might destroy |this| and ~QpackProgressiveDecoder() needs to @@ -172,7 +173,7 @@ bool QpackProgressiveDecoder::DoIndexedHeaderFieldInstruction() { return false; } - DCHECK_LT(absolute_index, std::numeric_limits<uint64_t>::max()); + QUICHE_DCHECK_LT(absolute_index, std::numeric_limits<uint64_t>::max()); required_insert_count_so_far_ = std::max(required_insert_count_so_far_, absolute_index + 1); @@ -212,7 +213,7 @@ bool QpackProgressiveDecoder::DoIndexedHeaderFieldPostBaseInstruction() { return false; } - DCHECK_LT(absolute_index, std::numeric_limits<uint64_t>::max()); + QUICHE_DCHECK_LT(absolute_index, std::numeric_limits<uint64_t>::max()); required_insert_count_so_far_ = std::max(required_insert_count_so_far_, absolute_index + 1); @@ -242,7 +243,7 @@ bool QpackProgressiveDecoder::DoLiteralHeaderFieldNameReferenceInstruction() { return false; } - DCHECK_LT(absolute_index, std::numeric_limits<uint64_t>::max()); + QUICHE_DCHECK_LT(absolute_index, std::numeric_limits<uint64_t>::max()); required_insert_count_so_far_ = std::max(required_insert_count_so_far_, absolute_index + 1); @@ -282,7 +283,7 @@ bool QpackProgressiveDecoder::DoLiteralHeaderFieldPostBaseInstruction() { return false; } - DCHECK_LT(absolute_index, std::numeric_limits<uint64_t>::max()); + QUICHE_DCHECK_LT(absolute_index, std::numeric_limits<uint64_t>::max()); required_insert_count_so_far_ = std::max(required_insert_count_so_far_, absolute_index + 1); @@ -306,7 +307,7 @@ bool QpackProgressiveDecoder::DoLiteralHeaderFieldInstruction() { } bool QpackProgressiveDecoder::DoPrefixInstruction() { - DCHECK(!prefix_decoded_); + QUICHE_DCHECK(!prefix_decoded_); if (!QpackDecodeRequiredInsertCount( prefix_decoder_->varint(), header_table_->max_entries(), @@ -337,9 +338,9 @@ bool QpackProgressiveDecoder::DoPrefixInstruction() { } void QpackProgressiveDecoder::FinishDecoding() { - DCHECK(buffer_.empty()); - DCHECK(!blocked_); - DCHECK(!decoding_); + QUICHE_DCHECK(buffer_.empty()); + QUICHE_DCHECK(!blocked_); + QUICHE_DCHECK(!decoding_); if (error_detected_) { return; diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.h index dfc25f9177d..e806ea0fd66 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.h @@ -10,11 +10,11 @@ #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/qpack/qpack_encoder_stream_receiver.h" +#include "quic/core/qpack/qpack_header_table.h" +#include "quic/core/qpack/qpack_instruction_decoder.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.cc index c7291f7d779..65e290f380d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.h" +#include "quic/core/qpack/qpack_receive_stream.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" +#include "quic/core/quic_session.h" namespace quic { QpackReceiveStream::QpackReceiveStream(PendingStream* pending, @@ -23,7 +23,7 @@ void QpackReceiveStream::OnStreamReset(const QuicRstStreamFrame& /*frame*/) { void QpackReceiveStream::OnDataAvailable() { iovec iov; while (!reading_stopped() && sequencer()->GetReadableRegion(&iov)) { - DCHECK(!sequencer()->IsClosed()); + QUICHE_DCHECK(!sequencer()->IsClosed()); receiver_->Decode(absl::string_view( reinterpret_cast<const char*>(iov.iov_base), iov.iov_len)); diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.h index 0814985760c..c9d2a775e57 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.h @@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_CORE_QPACK_QPACK_RECEIVE_STREAM_H_ #define QUICHE_QUIC_CORE_QPACK_QPACK_RECEIVE_STREAM_H_ -#include "net/third_party/quiche/src/quic/core/qpack/qpack_stream_receiver.h" -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/qpack/qpack_stream_receiver.h" +#include "quic/core/quic_stream.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream_test.cc index 88cb589a67e..cc0e2513956 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream_test.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.h" +#include "quic/core/qpack/qpack_receive_stream.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_spdy_session_peer.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count.cc index 22541e6ee07..6e17b24d577 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count.h" +#include "quic/core/qpack/qpack_required_insert_count.h" #include <limits> -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -30,17 +30,18 @@ bool QpackDecodeRequiredInsertCount(uint64_t encoded_required_insert_count, // |max_entries| is calculated by dividing an unsigned 64-bit integer by 32, // precluding all calculations in this method from overflowing. - DCHECK_LE(max_entries, std::numeric_limits<uint64_t>::max() / 32); + QUICHE_DCHECK_LE(max_entries, std::numeric_limits<uint64_t>::max() / 32); if (encoded_required_insert_count > 2 * max_entries) { return false; } *required_insert_count = encoded_required_insert_count - 1; - DCHECK_LT(*required_insert_count, std::numeric_limits<uint64_t>::max() / 16); + QUICHE_DCHECK_LT(*required_insert_count, + std::numeric_limits<uint64_t>::max() / 16); uint64_t current_wrapped = total_number_of_inserts % (2 * max_entries); - DCHECK_LT(current_wrapped, std::numeric_limits<uint64_t>::max() / 16); + QUICHE_DCHECK_LT(current_wrapped, std::numeric_limits<uint64_t>::max() / 16); if (current_wrapped >= *required_insert_count + max_entries) { // Required Insert Count wrapped around 1 extra time. diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count.h index 7f489bcdf3c..60b1f83370b 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count.h @@ -7,7 +7,7 @@ #include <cstdint> -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count_test.cc index fca16c04745..3fa71468931 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count_test.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count.h" +#include "quic/core/qpack/qpack_required_insert_count.h" #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_round_trip_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_round_trip_test.cc index 46e7e887a15..35530d01771 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_round_trip_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_round_trip_test.cc @@ -6,11 +6,11 @@ #include <tuple> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" -#include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/qpack/qpack_decoder_test_utils.h" +#include "quic/test_tools/qpack/qpack_encoder_test_utils.h" +#include "quic/test_tools/qpack/qpack_test_utils.h" +#include "spdy/core/spdy_header_block.h" using ::testing::Values; diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.cc index d6919d73600..636f4b477b3 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.h" +#include "quic/core/qpack/qpack_send_stream.h" #include "absl/base/macros.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" +#include "quic/core/quic_session.h" namespace quic { QpackSendStream::QpackSendStream(QuicStreamId id, diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.h index d7f68ee887b..fad159c30fe 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.h @@ -8,9 +8,9 @@ #include <cstdint> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_stream_sender_delegate.h" -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/qpack/qpack_stream_sender_delegate.h" +#include "quic/core/quic_stream.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream_test.cc index 80c89863062..df4668b07b2 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_send_stream_test.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.h" +#include "quic/core/qpack/qpack_send_stream.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/http/http_constants.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/http/http_constants.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_spdy_session_peer.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { @@ -40,7 +40,7 @@ struct TestParams { // Used by ::testing::PrintToStringParamName(). std::string PrintToString(const TestParams& tp) { - return quiche::QuicheStrCat( + return absl::StrCat( ParsedQuicVersionToString(tp.version), "_", (tp.perspective == Perspective::IS_CLIENT ? "client" : "server")); } diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table.cc index e88abe00026..869d09c2cf2 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_static_table.h" +#include "quic/core/qpack/qpack_static_table.h" #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -130,7 +130,7 @@ const QpackStaticTable& ObtainQpackStaticTable() { auto* table = new QpackStaticTable(); table->Initialize(QpackStaticTableVector().data(), QpackStaticTableVector().size()); - CHECK(table->IsInitialized()); + QUICHE_CHECK(table->IsInitialized()); return table; }(); return *shared_static_table; diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table.h index d8c255568a4..7f03cf92448 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table.h @@ -7,9 +7,9 @@ #include <vector> -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/spdy/core/hpack/hpack_constants.h" -#include "net/third_party/quiche/src/spdy/core/hpack/hpack_static_table.h" +#include "quic/platform/api/quic_export.h" +#include "spdy/core/hpack/hpack_constants.h" +#include "spdy/core/hpack/hpack_static_table.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table_test.cc index a771cf3862d..734d25320df 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_static_table_test.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/qpack_static_table.h" +#include "quic/core/qpack/qpack_static_table.h" #include <set> #include "absl/base/macros.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_stream_receiver.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_stream_receiver.h index d7c4b550b1b..a543496de0c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_stream_receiver.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_stream_receiver.h @@ -6,7 +6,7 @@ #define QUICHE_QUIC_CORE_QPACK_QPACK_STREAM_RECEIVER_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_stream_sender_delegate.h b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_stream_sender_delegate.h index 9f3faf80bb1..4bd1a3ae72d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_stream_sender_delegate.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_stream_sender_delegate.h @@ -6,7 +6,7 @@ #define QUICHE_QUIC_CORE_QPACK_QPACK_STREAM_SENDER_DELEGATE_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.cc index c18610939f1..9d4231d0801 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.cc @@ -2,8 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.h" +#include "quic/core/qpack/value_splitting_header_list.h" + #include "absl/strings/string_view.h" +#include "quic/platform/api/quic_logging.h" namespace quic { namespace { @@ -61,7 +63,7 @@ const ValueSplittingHeaderList::value_type* } void ValueSplittingHeaderList::const_iterator::UpdateHeaderField() { - DCHECK(value_start_ != absl::string_view::npos); + QUICHE_DCHECK(value_start_ != absl::string_view::npos); if (header_list_iterator_ == header_list_->end()) { return; @@ -91,7 +93,7 @@ void ValueSplittingHeaderList::const_iterator::UpdateHeaderField() { ValueSplittingHeaderList::ValueSplittingHeaderList( const spdy::Http2HeaderBlock* header_list) : header_list_(header_list) { - DCHECK(header_list_); + QUICHE_DCHECK(header_list_); } ValueSplittingHeaderList::const_iterator ValueSplittingHeaderList::begin() diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.h b/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.h index 06518a59075..939a4cee56b 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.h +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.h @@ -6,8 +6,8 @@ #define QUICHE_QUIC_CORE_QPACK_VALUE_SPLITTING_HEADER_LIST_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" +#include "quic/platform/api/quic_export.h" +#include "spdy/core/spdy_header_block.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list_test.cc b/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list_test.cc index 0fc04ccbf56..bc3072a049e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list_test.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.h" +#include "quic/core/qpack/value_splitting_header_list.h" #include "absl/base/macros.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_ack_listener_interface.cc b/chromium/net/third_party/quiche/src/quic/core/quic_ack_listener_interface.cc index fc25a313980..4a8548174c4 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_ack_listener_interface.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_ack_listener_interface.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_ack_listener_interface.h" +#include "quic/core/quic_ack_listener_interface.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_ack_listener_interface.h b/chromium/net/third_party/quiche/src/quic/core/quic_ack_listener_interface.h index 0a9c69425a8..abfb217b7ed 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_ack_listener_interface.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_ack_listener_interface.h @@ -5,10 +5,10 @@ #ifndef QUICHE_QUIC_CORE_QUIC_ACK_LISTENER_INTERFACE_H_ #define QUICHE_QUIC_CORE_QUIC_ACK_LISTENER_INTERFACE_H_ -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_reference_counted.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_reference_counted.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_alarm.cc b/chromium/net/third_party/quiche/src/quic/core/quic_alarm.cc index e31c7aa145a..bfef316ff62 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_alarm.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_alarm.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_alarm.h" +#include "quic/core/quic_alarm.h" namespace quic { @@ -12,8 +12,8 @@ QuicAlarm::QuicAlarm(QuicArenaScopedPtr<Delegate> delegate) QuicAlarm::~QuicAlarm() {} void QuicAlarm::Set(QuicTime new_deadline) { - DCHECK(!IsSet()); - DCHECK(new_deadline.IsInitialized()); + QUICHE_DCHECK(!IsSet()); + QUICHE_DCHECK(new_deadline.IsInitialized()); deadline_ = new_deadline; SetImpl(); } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_alarm.h b/chromium/net/third_party/quiche/src/quic/core/quic_alarm.h index df2ce623095..527d2e3c662 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_alarm.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_alarm.h @@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_CORE_QUIC_ALARM_H_ #define QUICHE_QUIC_CORE_QUIC_ALARM_H_ -#include "net/third_party/quiche/src/quic/core/quic_arena_scoped_ptr.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_arena_scoped_ptr.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_alarm_factory.h b/chromium/net/third_party/quiche/src/quic/core/quic_alarm_factory.h index 0e0ce332b99..57505ef6474 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_alarm_factory.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_alarm_factory.h @@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_CORE_QUIC_ALARM_FACTORY_H_ #define QUICHE_QUIC_CORE_QUIC_ALARM_FACTORY_H_ -#include "net/third_party/quiche/src/quic/core/quic_alarm.h" -#include "net/third_party/quiche/src/quic/core/quic_one_block_arena.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_alarm.h" +#include "quic/core/quic_one_block_arena.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_alarm_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_alarm_test.cc index 87cbd699dff..8f7296c8e10 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_alarm_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_alarm_test.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_alarm.h" +#include "quic/core/quic_alarm.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" using testing::Invoke; @@ -24,7 +24,7 @@ class DestructiveDelegate : public QuicAlarm::Delegate { void set_alarm(QuicAlarm* alarm) { alarm_ = alarm; } void OnAlarm() override { - DCHECK(alarm_); + QUICHE_DCHECK(alarm_); delete alarm_; } @@ -46,12 +46,12 @@ class TestAlarm : public QuicAlarm { protected: void SetImpl() override { - DCHECK(deadline().IsInitialized()); + QUICHE_DCHECK(deadline().IsInitialized()); scheduled_ = true; } void CancelImpl() override { - DCHECK(!deadline().IsInitialized()); + QUICHE_DCHECK(!deadline().IsInitialized()); scheduled_ = false; } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_arena_scoped_ptr.h b/chromium/net/third_party/quiche/src/quic/core/quic_arena_scoped_ptr.h index fdd0c2928b7..19b89a3ca27 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_arena_scoped_ptr.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_arena_scoped_ptr.h @@ -13,8 +13,8 @@ #include <cstdint> // for uintptr_t -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -185,14 +185,14 @@ void QuicArenaScopedPtr<T>::reset(T* value) { delete get(); } } - DCHECK_EQ(0u, reinterpret_cast<uintptr_t>(value) & kFromArenaMask); + QUICHE_DCHECK_EQ(0u, reinterpret_cast<uintptr_t>(value) & kFromArenaMask); value_ = value; } template <typename T> QuicArenaScopedPtr<T>::QuicArenaScopedPtr(void* value, ConstructFrom from_arena) : value_(value) { - DCHECK_EQ(0u, reinterpret_cast<uintptr_t>(value_) & kFromArenaMask); + QUICHE_DCHECK_EQ(0u, reinterpret_cast<uintptr_t>(value_) & kFromArenaMask); switch (from_arena) { case ConstructFrom::kHeap: break; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_arena_scoped_ptr_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_arena_scoped_ptr_test.cc index 5b7548a5c53..6388cf366da 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_arena_scoped_ptr_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_arena_scoped_ptr_test.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_arena_scoped_ptr.h" +#include "quic/core/quic_arena_scoped_ptr.h" -#include "net/third_party/quiche/src/quic/core/quic_one_block_arena.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/quic_one_block_arena.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace { @@ -29,7 +29,7 @@ std::string PrintToString(const TestParam& p) { case TestParam::kFromArena: return "arena"; } - DCHECK(false); + QUICHE_DCHECK(false); return "?"; } @@ -40,11 +40,11 @@ class QuicArenaScopedPtrParamTest : public QuicTestWithParam<TestParam> { switch (GetParam()) { case TestParam::kFromHeap: ptr = QuicArenaScopedPtr<TestObject>(new TestObject(value)); - CHECK(!ptr.is_from_arena()); + QUICHE_CHECK(!ptr.is_from_arena()); break; case TestParam::kFromArena: ptr = arena_.New<TestObject>(value); - CHECK(ptr.is_from_arena()); + QUICHE_CHECK(ptr.is_from_arena()); break; } return ptr; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_bandwidth.cc b/chromium/net/third_party/quiche/src/quic/core/quic_bandwidth.cc index 144a1765d62..b4108bea510 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_bandwidth.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_bandwidth.cc @@ -2,21 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" +#include "quic/core/quic_bandwidth.h" #include <cinttypes> #include <string> +#include "absl/strings/str_format.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" namespace quic { std::string QuicBandwidth::ToDebuggingValue() const { if (bits_per_second_ < 80000) { - return quiche::QuicheStringPrintf("%" PRId64 " bits/s (%" PRId64 - " bytes/s)", - bits_per_second_, bits_per_second_ / 8); + return absl::StrFormat("%d bits/s (%d bytes/s)", bits_per_second_, + bits_per_second_ / 8); } double divisor; @@ -34,9 +33,9 @@ std::string QuicBandwidth::ToDebuggingValue() const { double bits_per_second_with_unit = bits_per_second_ / divisor; double bytes_per_second_with_unit = bits_per_second_with_unit / 8; - return quiche::QuicheStringPrintf("%.2f %cbits/s (%.2f %cbytes/s)", - bits_per_second_with_unit, unit, - bytes_per_second_with_unit, unit); + return absl::StrFormat("%.2f %cbits/s (%.2f %cbytes/s)", + bits_per_second_with_unit, unit, + bytes_per_second_with_unit, unit); } } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_bandwidth.h b/chromium/net/third_party/quiche/src/quic/core/quic_bandwidth.h index 97de22c9dcf..949c264e31e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_bandwidth.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_bandwidth.h @@ -13,11 +13,11 @@ #include <ostream> #include <string> -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_flag_utils.h" namespace quic { @@ -55,11 +55,6 @@ class QUIC_EXPORT_PRIVATE QuicBandwidth { // Create a new QuicBandwidth based on the bytes per the elapsed delta. static inline QuicBandwidth FromBytesAndTimeDelta(QuicByteCount bytes, QuicTime::Delta delta) { - if (!GetQuicReloadableFlag(quic_round_up_tiny_bandwidth)) { - return QuicBandwidth((8 * bytes * kNumMicrosPerSecond) / - delta.ToMicroseconds()); - } - if (bytes == 0) { return QuicBandwidth(0); } @@ -67,7 +62,6 @@ class QUIC_EXPORT_PRIVATE QuicBandwidth { // 1 bit is 1000000 micro bits. int64_t num_micro_bits = 8 * bytes * kNumMicrosPerSecond; if (num_micro_bits < delta.ToMicroseconds()) { - QUIC_RELOADABLE_FLAG_COUNT(quic_round_up_tiny_bandwidth); return QuicBandwidth(1); } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_bandwidth_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_bandwidth_test.cc index 0a32e4e9104..7811b47e445 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_bandwidth_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_bandwidth_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" +#include "quic/core/quic_bandwidth.h" #include <limits> -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { @@ -62,14 +62,9 @@ TEST_F(QuicBandwidthTest, TimeDelta) { EXPECT_EQ(QuicBandwidth::Zero(), QuicBandwidth::FromBytesAndTimeDelta( 0, QuicTime::Delta::FromSeconds(9))); - if (GetQuicReloadableFlag(quic_round_up_tiny_bandwidth)) { - EXPECT_EQ(QuicBandwidth::FromBitsPerSecond(1), - QuicBandwidth::FromBytesAndTimeDelta( - 1, QuicTime::Delta::FromSeconds(9))); - } else { - EXPECT_EQ(QuicBandwidth::Zero(), QuicBandwidth::FromBytesAndTimeDelta( - 1, QuicTime::Delta::FromSeconds(9))); - } + EXPECT_EQ( + QuicBandwidth::FromBitsPerSecond(1), + QuicBandwidth::FromBytesAndTimeDelta(1, QuicTime::Delta::FromSeconds(9))); } TEST_F(QuicBandwidthTest, Scale) { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_blocked_writer_interface.h b/chromium/net/third_party/quiche/src/quic/core/quic_blocked_writer_interface.h index 8193b252244..b441d926c3f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_blocked_writer_interface.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_blocked_writer_interface.h @@ -9,7 +9,7 @@ #ifndef QUICHE_QUIC_CORE_QUIC_BLOCKED_WRITER_INTERFACE_H_ #define QUICHE_QUIC_CORE_QUIC_BLOCKED_WRITER_INTERFACE_H_ -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_buffer_allocator.cc b/chromium/net/third_party/quiche/src/quic/core/quic_buffer_allocator.cc index c3802743cc6..41491d97c72 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_buffer_allocator.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_buffer_allocator.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_buffer_allocator.h" +#include "quic/core/quic_buffer_allocator.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_buffer_allocator.h b/chromium/net/third_party/quiche/src/quic/core/quic_buffer_allocator.h index 4b0abf44568..a661a7ee76b 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_buffer_allocator.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_buffer_allocator.h @@ -9,7 +9,7 @@ #include <memory> -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_buffered_packet_store.cc b/chromium/net/third_party/quiche/src/quic/core/quic_buffered_packet_store.cc index 6de1ab0cfe0..b9e3d10c69b 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_buffered_packet_store.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_buffered_packet_store.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_buffered_packet_store.h" +#include "quic/core/quic_buffered_packet_store.h" #include <string> -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_map_util.h" namespace quic { @@ -110,7 +110,7 @@ EnqueuePacketResult QuicBufferedPacketStore::EnqueuePacket( undecryptable_packets_.back().second.ietf_quic = ietf_quic; undecryptable_packets_.back().second.version = version; } - CHECK(QuicContainsKey(undecryptable_packets_, connection_id)); + QUICHE_CHECK(QuicContainsKey(undecryptable_packets_, connection_id)); BufferedPacketList& queue = undecryptable_packets_.find(connection_id)->second; @@ -243,7 +243,7 @@ BufferedPacketList QuicBufferedPacketStore::DeliverPacketsForNextConnection( connections_with_chlo_.pop_front(); BufferedPacketList packets = DeliverPackets(*connection_id); - DCHECK(!packets.buffered_packets.empty()) + QUICHE_DCHECK(!packets.buffered_packets.empty()) << "Try to deliver connectons without CHLO"; return packets; } @@ -258,8 +258,8 @@ bool QuicBufferedPacketStore::IngestPacketForTlsChloExtraction( const ParsedQuicVersion& version, const QuicReceivedPacket& packet, std::vector<std::string>* out_alpns) { - DCHECK_NE(out_alpns, nullptr); - DCHECK_EQ(version.handshake_protocol, PROTOCOL_TLS1_3); + QUICHE_DCHECK_NE(out_alpns, nullptr); + QUICHE_DCHECK_EQ(version.handshake_protocol, PROTOCOL_TLS1_3); auto it = undecryptable_packets_.find(connection_id); if (it == undecryptable_packets_.end()) { QUIC_BUG << "Cannot ingest packet for unknown connection ID " diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_buffered_packet_store.h b/chromium/net/third_party/quiche/src/quic/core/quic_buffered_packet_store.h index 7cb179d6d95..c8f6375a30e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_buffered_packet_store.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_buffered_packet_store.h @@ -8,15 +8,15 @@ #include <list> #include <string> -#include "net/third_party/quiche/src/quic/core/quic_alarm.h" -#include "net/third_party/quiche/src/quic/core/quic_alarm_factory.h" -#include "net/third_party/quiche/src/quic/core/quic_clock.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/tls_chlo_extractor.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/quic_alarm.h" +#include "quic/core/quic_alarm_factory.h" +#include "quic/core/quic_clock.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_time.h" +#include "quic/core/tls_chlo_extractor.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_buffered_packet_store_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_buffered_packet_store_test.cc index ffb7b5f196b..1d9cce7647f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_buffered_packet_store_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_buffered_packet_store_test.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_buffered_packet_store.h" +#include "quic/core/quic_buffered_packet_store.h" #include <list> #include <string> -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.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/quic_buffered_packet_store_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" +#include "quic/test_tools/quic_buffered_packet_store_peer.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { static const size_t kDefaultMaxConnectionsInStore = 100; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_circular_deque.h b/chromium/net/third_party/quiche/src/quic/core/quic_circular_deque.h index 1949d85f79e..44637abcbd6 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_circular_deque.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_circular_deque.h @@ -13,8 +13,8 @@ #include <ostream> #include <type_traits> -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -163,23 +163,23 @@ class QUIC_NO_EXPORT QuicCircularDeque { : deque_(deque), index_(index) {} void Increment() { - DCHECK_LE(ExternalPosition() + 1, deque_->size()); + QUICHE_DCHECK_LE(ExternalPosition() + 1, deque_->size()); index_ = deque_->index_next(index_); } void Decrement() { - DCHECK_GE(ExternalPosition(), 1u); + QUICHE_DCHECK_GE(ExternalPosition(), 1u); index_ = deque_->index_prev(index_); } void IncrementBy(difference_type delta) { if (delta >= 0) { // After increment we are before or at end(). - DCHECK_LE(static_cast<size_type>(ExternalPosition() + delta), - deque_->size()); + QUICHE_DCHECK_LE(static_cast<size_type>(ExternalPosition() + delta), + deque_->size()); } else { // After decrement we are after or at begin(). - DCHECK_GE(ExternalPosition(), static_cast<size_type>(-delta)); + QUICHE_DCHECK_GE(ExternalPosition(), static_cast<size_type>(-delta)); } index_ = deque_->index_increment_by(index_, delta); } @@ -324,7 +324,7 @@ class QUIC_NO_EXPORT QuicCircularDeque { } reference at(size_type pos) { - DCHECK(pos < size()) << "pos:" << pos << ", size():" << size(); + QUICHE_DCHECK(pos < size()) << "pos:" << pos << ", size():" << size(); size_type index = begin_ + pos; if (index < data_capacity()) { return *index_to_address(index); @@ -341,7 +341,7 @@ class QUIC_NO_EXPORT QuicCircularDeque { const_reference operator[](size_type pos) const { return at(pos); } reference front() { - DCHECK(!empty()); + QUICHE_DCHECK(!empty()); return *index_to_address(begin_); } @@ -350,7 +350,7 @@ class QUIC_NO_EXPORT QuicCircularDeque { } reference back() { - DCHECK(!empty()); + QUICHE_DCHECK(!empty()); return *(index_to_address(end_ == 0 ? data_capacity() - 1 : end_ - 1)); } @@ -429,7 +429,7 @@ class QUIC_NO_EXPORT QuicCircularDeque { } void pop_front() { - DCHECK(!empty()); + QUICHE_DCHECK(!empty()); DestroyByIndex(begin_); begin_ = index_next(begin_); MaybeShrinkCapacity(); @@ -445,7 +445,7 @@ class QUIC_NO_EXPORT QuicCircularDeque { } void pop_back() { - DCHECK(!empty()); + QUICHE_DCHECK(!empty()); end_ = index_prev(end_); DestroyByIndex(end_); MaybeShrinkCapacity(); @@ -471,7 +471,7 @@ class QUIC_NO_EXPORT QuicCircularDeque { // When propagate_on_container_swap is false, it is undefined behavior, by // c++ standard, to swap between two AllocatorAwareContainer(s) with // unequal allocators. - DCHECK(get_allocator() == other.get_allocator()) + QUICHE_DCHECK(get_allocator() == other.get_allocator()) << "Undefined swap behavior"; swap(allocator_and_data_.data, other.allocator_and_data_.data); swap(allocator_and_data_.data_capacity, @@ -558,7 +558,7 @@ class QUIC_NO_EXPORT QuicCircularDeque { DestroyRange(begin_, end_); if (data_capacity() > 0) { - DCHECK_NE(nullptr, allocator_and_data_.data); + QUICHE_DCHECK_NE(nullptr, allocator_and_data_.data); AllocatorTraits::deallocate(allocator_and_data_.allocator(), allocator_and_data_.data, data_capacity()); } @@ -590,7 +590,7 @@ class QUIC_NO_EXPORT QuicCircularDeque { void Relocate(size_t new_capacity) { const size_t num_elements = size(); - DCHECK_GT(new_capacity, num_elements) + QUICHE_DCHECK_GT(new_capacity, num_elements) << "new_capacity:" << new_capacity << ", num_elements:" << num_elements; size_t new_data_capacity = new_capacity + 1; @@ -621,9 +621,9 @@ class QUIC_NO_EXPORT QuicCircularDeque { template <typename T_ = T> typename std::enable_if<std::is_trivially_copyable<T_>::value, void>::type RelocateUnwrappedRange(size_type begin, size_type end, pointer dest) const { - DCHECK_LE(begin, end) << "begin:" << begin << ", end:" << end; + QUICHE_DCHECK_LE(begin, end) << "begin:" << begin << ", end:" << end; pointer src = index_to_address(begin); - DCHECK_NE(src, nullptr); + QUICHE_DCHECK_NE(src, nullptr); memcpy(dest, src, sizeof(T) * (end - begin)); DestroyRange(begin, end); } @@ -633,7 +633,7 @@ class QUIC_NO_EXPORT QuicCircularDeque { std::is_move_constructible<T_>::value, void>::type RelocateUnwrappedRange(size_type begin, size_type end, pointer dest) const { - DCHECK_LE(begin, end) << "begin:" << begin << ", end:" << end; + QUICHE_DCHECK_LE(begin, end) << "begin:" << begin << ", end:" << end; pointer src = index_to_address(begin); pointer src_end = index_to_address(end); while (src != src_end) { @@ -649,7 +649,7 @@ class QUIC_NO_EXPORT QuicCircularDeque { !std::is_move_constructible<T_>::value, void>::type RelocateUnwrappedRange(size_type begin, size_type end, pointer dest) const { - DCHECK_LE(begin, end) << "begin:" << begin << ", end:" << end; + QUICHE_DCHECK_LE(begin, end) << "begin:" << begin << ", end:" << end; pointer src = index_to_address(begin); pointer src_end = index_to_address(end); while (src != src_end) { @@ -692,7 +692,7 @@ class QUIC_NO_EXPORT QuicCircularDeque { // Should only be called from DestroyRange. void DestroyUnwrappedRange(size_type begin, size_type end) const { - DCHECK_LE(begin, end) << "begin:" << begin << ", end:" << end; + QUICHE_DCHECK_LE(begin, end) << "begin:" << begin << ", end:" << end; for (; begin != end; ++begin) { DestroyByIndex(begin); } @@ -728,7 +728,7 @@ class QUIC_NO_EXPORT QuicCircularDeque { return index; } - DCHECK_LT(static_cast<size_type>(std::abs(delta)), data_capacity()); + QUICHE_DCHECK_LT(static_cast<size_type>(std::abs(delta)), data_capacity()); return (index + data_capacity() + delta) % data_capacity(); } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_circular_deque_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_circular_deque_test.cc index f2e14a26530..25aa78e709a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_circular_deque_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_circular_deque_test.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_circular_deque.h" +#include "quic/core/quic_circular_deque.h" #include <cstddef> #include <cstdint> #include <memory> #include <type_traits> -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" using testing::ElementsAre; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_clock.cc b/chromium/net/third_party/quiche/src/quic/core/quic_clock.cc index e2287e9137a..4d865b5b30d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_clock.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_clock.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_clock.h" +#include "quic/core/quic_clock.h" #include <limits> -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -38,7 +38,7 @@ QuicTime::Delta QuicClock::ComputeCalibrationOffset() const { } void QuicClock::SetCalibrationOffset(QuicTime::Delta offset) { - DCHECK(!is_calibrated_) << "A clock should only be calibrated once"; + QUICHE_DCHECK(!is_calibrated_) << "A clock should only be calibrated once"; calibration_offset_ = offset; is_calibrated_ = true; } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_clock.h b/chromium/net/third_party/quiche/src/quic/core/quic_clock.h index cef36dc8e3a..6164cafaa5a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_clock.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_clock.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_CORE_QUIC_CLOCK_H_ #define QUICHE_QUIC_CORE_QUIC_CLOCK_H_ -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_export.h" /* API_DESCRIPTION QuicClock is used by QUIC core to get current time. Its instance is created by diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_coalesced_packet.cc b/chromium/net/third_party/quiche/src/quic/core/quic_coalesced_packet.cc index e266a768030..2ae9b41aeff 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_coalesced_packet.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_coalesced_packet.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_coalesced_packet.h" +#include "quic/core/quic_coalesced_packet.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_cat.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_ptr_util.h" namespace quic { @@ -30,10 +30,10 @@ bool QuicCoalescedPacket::MaybeCoalescePacket( if (length_ == 0) { #ifndef NDEBUG for (const auto& buffer : encrypted_buffers_) { - DCHECK(buffer.empty()); + QUICHE_DCHECK(buffer.empty()); } #endif - DCHECK(initial_packet_ == nullptr); + QUICHE_DCHECK(initial_packet_ == nullptr); // This is the first packet, set max_packet_length and self/peer // addresses. max_packet_length_ = current_max_packet_length; @@ -154,20 +154,19 @@ TransmissionType QuicCoalescedPacket::TransmissionTypeOfPacket( std::string QuicCoalescedPacket::ToString(size_t serialized_length) const { // Total length and padding size. - std::string info = quiche::QuicheStrCat( + std::string info = absl::StrCat( "total_length: ", serialized_length, " padding_size: ", serialized_length - length_, " packets: {"); // Packets' encryption levels. bool first_packet = true; for (int8_t i = ENCRYPTION_INITIAL; i < NUM_ENCRYPTION_LEVELS; ++i) { if (ContainsPacketOfEncryptionLevel(static_cast<EncryptionLevel>(i))) { - info = quiche::QuicheStrCat( - info, first_packet ? "" : ", ", - EncryptionLevelToString(static_cast<EncryptionLevel>(i))); + absl::StrAppend(&info, first_packet ? "" : ", ", + EncryptionLevelToString(static_cast<EncryptionLevel>(i))); first_packet = false; } } - info = quiche::QuicheStrCat(info, "}"); + absl::StrAppend(&info, "}"); return info; } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_coalesced_packet.h b/chromium/net/third_party/quiche/src/quic/core/quic_coalesced_packet.h index 64275f64acc..e3f674e239f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_coalesced_packet.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_coalesced_packet.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_CORE_QUIC_COALESCED_PACKET_H_ #define QUICHE_QUIC_CORE_QUIC_COALESCED_PACKET_H_ -#include "net/third_party/quiche/src/quic/core/quic_packets.h" +#include "quic/core/quic_packets.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_coalesced_packet_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_coalesced_packet_test.cc index dd1db44d8e2..1d629ae135a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_coalesced_packet_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_coalesced_packet_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_coalesced_packet.h" +#include "quic/core/quic_coalesced_packet.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/test_tools/quiche_test_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_config.cc b/chromium/net/third_party/quiche/src/quic/core/quic_config.cc index 20dcb902318..893d82233f1 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_config.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_config.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_config.h" +#include "quic/core/quic_config.h" #include <algorithm> #include <cstring> @@ -12,18 +12,19 @@ #include "absl/base/attributes.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_socket_address_coder.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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_socket_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h" +#include "quic/core/crypto/crypto_handshake_message.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_socket_address_coder.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_uint128.h" namespace quic { @@ -36,7 +37,7 @@ QuicErrorCode ReadUint32(const CryptoHandshakeMessage& msg, uint32_t default_value, uint32_t* out, std::string* error_details) { - DCHECK(error_details != nullptr); + QUICHE_DCHECK(error_details != nullptr); QuicErrorCode error = msg.GetUint32(tag, out); switch (error) { case QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND: @@ -111,7 +112,7 @@ QuicErrorCode QuicFixedUint32::ProcessPeerHello( const CryptoHandshakeMessage& peer_hello, HelloType /*hello_type*/, std::string* error_details) { - DCHECK(error_details != nullptr); + QUICHE_DCHECK(error_details != nullptr); if (tag_ == 0) { *error_details = "This parameter does not support reading from CryptoHandshakeMessage"; @@ -200,7 +201,7 @@ QuicErrorCode QuicFixedUint62::ProcessPeerHello( const CryptoHandshakeMessage& peer_hello, HelloType /*hello_type*/, std::string* error_details) { - DCHECK(error_details != nullptr); + QUICHE_DCHECK(error_details != nullptr); uint32_t receive_value32; QuicErrorCode error = peer_hello.GetUint32(tag_, &receive_value32); // GetUint32 is guaranteed to always initialize receive_value32. @@ -268,7 +269,7 @@ QuicErrorCode QuicFixedUint128::ProcessPeerHello( const CryptoHandshakeMessage& peer_hello, HelloType /*hello_type*/, std::string* error_details) { - DCHECK(error_details != nullptr); + QUICHE_DCHECK(error_details != nullptr); QuicErrorCode error = peer_hello.GetUint128(tag_, &receive_value_); switch (error) { case QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND: @@ -338,7 +339,7 @@ QuicErrorCode QuicFixedTagVector::ProcessPeerHello( const CryptoHandshakeMessage& peer_hello, HelloType /*hello_type*/, std::string* error_details) { - DCHECK(error_details != nullptr); + QUICHE_DCHECK(error_details != nullptr); QuicTagVector values; QuicErrorCode error = peer_hello.GetTaglist(tag_, &values); switch (error) { @@ -447,7 +448,6 @@ QuicConfig::QuicConfig() initial_stream_flow_control_window_bytes_(kSFCW, PRESENCE_OPTIONAL), initial_session_flow_control_window_bytes_(kCFCW, PRESENCE_OPTIONAL), connection_migration_disabled_(kNCMR, PRESENCE_OPTIONAL), - support_handshake_done_(0, PRESENCE_OPTIONAL), key_update_supported_remotely_(false), key_update_supported_locally_(false), alternate_server_address_ipv6_(kASAD, PRESENCE_OPTIONAL), @@ -852,19 +852,6 @@ bool QuicConfig::DisableConnectionMigration() const { return connection_migration_disabled_.HasReceivedValue(); } -void QuicConfig::SetSupportHandshakeDone() { - support_handshake_done_.SetSendValue(1); -} - -bool QuicConfig::HandshakeDoneSupported() const { - return support_handshake_done_.HasSendValue() && - support_handshake_done_.GetSendValue() > 0; -} - -bool QuicConfig::PeerSupportsHandshakeDone() const { - return support_handshake_done_.HasReceivedValue(); -} - void QuicConfig::SetKeyUpdateSupportedLocally() { key_update_supported_locally_ = true; } @@ -891,6 +878,20 @@ void QuicConfig::SetIPv6AlternateServerAddressToSend( alternate_server_address_ipv6_.SetSendValue(alternate_server_address_ipv6); } +void QuicConfig::SetIPv6AlternateServerAddressToSend( + const QuicSocketAddress& alternate_server_address_ipv6, + const QuicConnectionId& connection_id, + QuicUint128 stateless_reset_token) { + if (!alternate_server_address_ipv6.host().IsIPv6()) { + QUIC_BUG << "Cannot use SetIPv6AlternateServerAddressToSend with " + << alternate_server_address_ipv6; + return; + } + alternate_server_address_ipv6_.SetSendValue(alternate_server_address_ipv6); + preferred_address_connection_id_and_token_ = + std::make_pair(connection_id, stateless_reset_token); +} + bool QuicConfig::HasReceivedIPv6AlternateServerAddress() const { return alternate_server_address_ipv6_.HasReceivedValue(); } @@ -910,6 +911,20 @@ void QuicConfig::SetIPv4AlternateServerAddressToSend( alternate_server_address_ipv4_.SetSendValue(alternate_server_address_ipv4); } +void QuicConfig::SetIPv4AlternateServerAddressToSend( + const QuicSocketAddress& alternate_server_address_ipv4, + const QuicConnectionId& connection_id, + QuicUint128 stateless_reset_token) { + if (!alternate_server_address_ipv4.host().IsIPv4()) { + QUIC_BUG << "Cannot use SetIPv4AlternateServerAddressToSend with " + << alternate_server_address_ipv4; + return; + } + alternate_server_address_ipv4_.SetSendValue(alternate_server_address_ipv4); + preferred_address_connection_id_and_token_ = + std::make_pair(connection_id, stateless_reset_token); +} + bool QuicConfig::HasReceivedIPv4AlternateServerAddress() const { return alternate_server_address_ipv4_.HasReceivedValue(); } @@ -919,6 +934,18 @@ const QuicSocketAddress& QuicConfig::ReceivedIPv4AlternateServerAddress() return alternate_server_address_ipv4_.GetReceivedValue(); } +bool QuicConfig::HasReceivedPreferredAddressConnectionIdAndToken() const { + return (HasReceivedIPv6AlternateServerAddress() || + HasReceivedIPv4AlternateServerAddress()) && + preferred_address_connection_id_and_token_.has_value(); +} + +const std::pair<QuicConnectionId, QuicUint128>& +QuicConfig::ReceivedPreferredAddressConnectionIdAndToken() const { + QUICHE_DCHECK(HasReceivedPreferredAddressConnectionIdAndToken()); + return *preferred_address_connection_id_and_token_; +} + void QuicConfig::SetOriginalConnectionIdToSend( const QuicConnectionId& original_destination_connection_id) { original_destination_connection_id_to_send_ = @@ -1065,7 +1092,7 @@ QuicErrorCode QuicConfig::ProcessPeerHello( const CryptoHandshakeMessage& peer_hello, HelloType hello_type, std::string* error_details) { - DCHECK(error_details != nullptr); + QUICHE_DCHECK(error_details != nullptr); QuicErrorCode error = QUIC_NO_ERROR; if (error == QUIC_NO_ERROR) { @@ -1204,7 +1231,6 @@ bool QuicConfig::FillTransportParameters(TransportParameters* params) const { params->disable_active_migration = connection_migration_disabled_.HasSendValue() && connection_migration_disabled_.GetSendValue() != 0; - params->support_handshake_done = HandshakeDoneSupported(); if (alternate_server_address_ipv6_.HasSendValue() || alternate_server_address_ipv4_.HasSendValue()) { @@ -1217,6 +1243,15 @@ bool QuicConfig::FillTransportParameters(TransportParameters* params) const { preferred_address.ipv4_socket_address = alternate_server_address_ipv4_.GetSendValue(); } + if (preferred_address_connection_id_and_token_) { + preferred_address.connection_id = + preferred_address_connection_id_and_token_->first; + auto* begin = reinterpret_cast<const char*>( + &preferred_address_connection_id_and_token_->second); + auto* end = + begin + sizeof(preferred_address_connection_id_and_token_->second); + preferred_address.stateless_reset_token.assign(begin, end); + } params->preferred_address = std::make_unique<TransportParameters::PreferredAddress>( preferred_address); @@ -1335,27 +1370,30 @@ QuicErrorCode QuicConfig::ProcessTransportParameters( alternate_server_address_ipv4_.SetReceivedValue( params.preferred_address->ipv4_socket_address); } + // TODO(haoyuewang) Treat 0 length connection ID sent in preferred_address + // as a connection error of type TRANSPORT_PARAMETER_ERROR when server + // fully supports it. + if (!params.preferred_address->connection_id.IsEmpty()) { + preferred_address_connection_id_and_token_ = std::make_pair( + params.preferred_address->connection_id, + *reinterpret_cast<const QuicUint128*>( + ¶ms.preferred_address->stateless_reset_token.front())); + } } - if (GetQuicReloadableFlag(quic_record_received_min_ack_delay)) { - if (params.min_ack_delay_us.value() != 0) { - if (params.min_ack_delay_us.value() > - params.max_ack_delay.value() * kNumMicrosPerMilli) { - *error_details = "MinAckDelay is greater than MaxAckDelay."; - return IETF_QUIC_PROTOCOL_VIOLATION; - } - QUIC_RELOADABLE_FLAG_COUNT(quic_record_received_min_ack_delay); - min_ack_delay_ms_.SetReceivedValue(params.min_ack_delay_us.value() / - kNumMicrosPerMilli); + if (params.min_ack_delay_us.value() != 0) { + if (params.min_ack_delay_us.value() > + params.max_ack_delay.value() * kNumMicrosPerMilli) { + *error_details = "MinAckDelay is greater than MaxAckDelay."; + return IETF_QUIC_PROTOCOL_VIOLATION; } + min_ack_delay_ms_.SetReceivedValue(params.min_ack_delay_us.value() / + kNumMicrosPerMilli); } } if (params.disable_active_migration) { connection_migration_disabled_.SetReceivedValue(1u); } - if (params.support_handshake_done) { - support_handshake_done_.SetReceivedValue(1u); - } if (!is_resumption && !params.key_update_not_yet_supported) { key_update_supported_remotely_ = true; } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_config.h b/chromium/net/third_party/quiche/src/quic/core/quic_config.h index 6e9eee12807..d0fa2c79200 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_config.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_config.h @@ -10,12 +10,12 @@ #include <string> #include "absl/types/optional.h" -#include "net/third_party/quiche/src/quic/core/crypto/transport_parameters.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h" +#include "quic/core/crypto/transport_parameters.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_uint128.h" namespace quic { @@ -382,11 +382,6 @@ class QUIC_EXPORT_PRIVATE QuicConfig { void SetDisableConnectionMigration(); bool DisableConnectionMigration() const; - // Support handshake done. - void SetSupportHandshakeDone(); - bool HandshakeDoneSupported() const; - bool PeerSupportsHandshakeDone() const; - // Key update support. void SetKeyUpdateSupportedLocally(); bool KeyUpdateSupportedForConnection() const; @@ -396,15 +391,28 @@ class QUIC_EXPORT_PRIVATE QuicConfig { // IPv6 alternate server address. void SetIPv6AlternateServerAddressToSend( const QuicSocketAddress& alternate_server_address_ipv6); + void SetIPv6AlternateServerAddressToSend( + const QuicSocketAddress& alternate_server_address_ipv6, + const QuicConnectionId& connection_id, + QuicUint128 stateless_reset_token); bool HasReceivedIPv6AlternateServerAddress() const; const QuicSocketAddress& ReceivedIPv6AlternateServerAddress() const; // IPv4 alternate server address. void SetIPv4AlternateServerAddressToSend( const QuicSocketAddress& alternate_server_address_ipv4); + void SetIPv4AlternateServerAddressToSend( + const QuicSocketAddress& alternate_server_address_ipv4, + const QuicConnectionId& connection_id, + QuicUint128 stateless_reset_token); bool HasReceivedIPv4AlternateServerAddress() const; const QuicSocketAddress& ReceivedIPv4AlternateServerAddress() const; + // Preferred Address Connection ID and Token. + bool HasReceivedPreferredAddressConnectionIdAndToken() const; + const std::pair<QuicConnectionId, QuicUint128>& + ReceivedPreferredAddressConnectionIdAndToken() const; + // Original destination connection ID. void SetOriginalConnectionIdToSend( const QuicConnectionId& original_destination_connection_id); @@ -582,10 +590,6 @@ class QUIC_EXPORT_PRIVATE QuicConfig { // Uses the disable_active_migration transport parameter in IETF QUIC. QuicFixedUint32 connection_migration_disabled_; - // Whether handshake done is supported. Only used in T050. - // Uses the support_handshake_done transport parameter in IETF QUIC. - QuicFixedUint32 support_handshake_done_; - // Whether key update is supported by the peer. Uses key_update_not_yet // supported transport parameter in IETF QUIC. bool key_update_supported_remotely_; @@ -598,6 +602,10 @@ class QUIC_EXPORT_PRIVATE QuicConfig { // Note that when QUIC_CRYPTO is in use, only one of the addresses is sent. QuicFixedSocketAddress alternate_server_address_ipv6_; QuicFixedSocketAddress alternate_server_address_ipv4_; + // Connection Id data to send from the server or receive at the client as part + // of the preferred address transport parameter. + absl::optional<std::pair<QuicConnectionId, QuicUint128>> + preferred_address_connection_id_and_token_; // Stateless reset token used in IETF public reset packet. // Uses the stateless_reset_token transport parameter in IETF QUIC. diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_config_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_config_test.cc index f7f1618fe03..2f3783510fd 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_config_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_config_test.cc @@ -2,22 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_config.h" +#include "quic/core/quic_config.h" +#include <memory> #include <string> -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/crypto/crypto_handshake_message.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/transport_parameters.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_uint128.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { @@ -437,7 +439,6 @@ TEST_P(QuicConfigTest, ReceivedInvalidMinAckDelayInTransportParameter) { // TransportParameters are only used for QUIC+TLS. return; } - SetQuicReloadableFlag(quic_record_received_min_ack_delay, true); TransportParameters params; params.max_ack_delay.set_value(25 /*ms*/); @@ -476,6 +477,15 @@ TEST_P(QuicConfigTest, FillTransportParams) { config_.SetRetrySourceConnectionIdToSend(TestConnectionId(0x3333)); config_.SetMinAckDelayMs(kDefaultMinAckDelayTimeMs); + QuicIpAddress host; + host.FromString("127.0.3.1"); + QuicSocketAddress kTestServerAddress = QuicSocketAddress(host, 1234); + QuicConnectionId new_connection_id = TestConnectionId(5); + QuicUint128 new_stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(new_connection_id); + config_.SetIPv4AlternateServerAddressToSend( + kTestServerAddress, new_connection_id, new_stateless_reset_token); + TransportParameters params; config_.FillTransportParameters(¶ms); @@ -509,6 +519,12 @@ TEST_P(QuicConfigTest, FillTransportParams) { static_cast<uint64_t>(kDefaultMinAckDelayTimeMs) * kNumMicrosPerMilli, params.min_ack_delay_us.value()); EXPECT_TRUE(params.key_update_not_yet_supported); + + EXPECT_EQ(params.preferred_address->ipv4_socket_address, kTestServerAddress); + EXPECT_EQ(params.preferred_address->connection_id, new_connection_id); + EXPECT_EQ(*reinterpret_cast<QuicUint128*>( + ¶ms.preferred_address->stateless_reset_token.front()), + new_stateless_reset_token); } TEST_P(QuicConfigTest, ProcessTransportParametersServer) { @@ -570,7 +586,6 @@ TEST_P(QuicConfigTest, ProcessTransportParametersServer) { config_.ReceivedMaxBidirectionalStreams()); EXPECT_FALSE(config_.DisableConnectionMigration()); - EXPECT_FALSE(config_.PeerSupportsHandshakeDone()); // The following config shouldn't be processed because of resumption. EXPECT_FALSE(config_.HasReceivedStatelessResetToken()); @@ -595,7 +610,6 @@ TEST_P(QuicConfigTest, ProcessTransportParametersServer) { params.initial_max_streams_bidi.set_value(2 * kDefaultMaxStreamsPerConnection); params.disable_active_migration = true; - params.support_handshake_done = true; EXPECT_THAT(config_.ProcessTransportParameters( params, /* is_resumption = */ false, &error_details), @@ -630,20 +644,15 @@ TEST_P(QuicConfigTest, ProcessTransportParametersServer) { config_.ReceivedMaxBidirectionalStreams()); EXPECT_TRUE(config_.DisableConnectionMigration()); - EXPECT_TRUE(config_.PeerSupportsHandshakeDone()); ASSERT_TRUE(config_.HasReceivedStatelessResetToken()); ASSERT_TRUE(config_.HasReceivedMaxAckDelayMs()); EXPECT_EQ(config_.ReceivedMaxAckDelayMs(), kMaxAckDelayForTest); - if (GetQuicReloadableFlag(quic_record_received_min_ack_delay)) { - ASSERT_TRUE(config_.HasReceivedMinAckDelayMs()); - EXPECT_EQ(config_.ReceivedMinAckDelayMs(), - kMinAckDelayUsForTest / kNumMicrosPerMilli); - } else { - ASSERT_FALSE(config_.HasReceivedMinAckDelayMs()); - } + ASSERT_TRUE(config_.HasReceivedMinAckDelayMs()); + EXPECT_EQ(config_.ReceivedMinAckDelayMs(), + kMinAckDelayUsForTest / kNumMicrosPerMilli); ASSERT_TRUE(config_.HasReceivedAckDelayExponent()); EXPECT_EQ(config_.ReceivedAckDelayExponent(), kAckDelayExponentForTest); @@ -753,6 +762,47 @@ TEST_P(QuicConfigTest, KeyUpdateSupported) { EXPECT_TRUE(config_.KeyUpdateSupportedRemotely()); } +TEST_P(QuicConfigTest, SendPreferredIPv4Address) { + if (!version_.UsesTls()) { + // TransportParameters are only used for QUIC+TLS. + return; + } + + EXPECT_FALSE(config_.HasReceivedPreferredAddressConnectionIdAndToken()); + + TransportParameters params; + QuicIpAddress host; + host.FromString("::ffff:192.0.2.128"); + QuicSocketAddress kTestServerAddress = QuicSocketAddress(host, 1234); + QuicConnectionId new_connection_id = TestConnectionId(5); + QuicUint128 new_stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(new_connection_id); + auto preferred_address = + std::make_unique<TransportParameters::PreferredAddress>(); + preferred_address->ipv6_socket_address = kTestServerAddress; + preferred_address->connection_id = new_connection_id; + preferred_address->stateless_reset_token.assign( + reinterpret_cast<const char*>(&new_stateless_reset_token), + reinterpret_cast<const char*>(&new_stateless_reset_token) + + sizeof(new_stateless_reset_token)); + params.preferred_address = std::move(preferred_address); + + std::string error_details; + EXPECT_THAT(config_.ProcessTransportParameters( + params, /* is_resumption = */ false, &error_details), + IsQuicNoError()); + + EXPECT_TRUE(config_.HasReceivedIPv6AlternateServerAddress()); + EXPECT_EQ(config_.ReceivedIPv6AlternateServerAddress(), kTestServerAddress); + EXPECT_TRUE(config_.HasReceivedPreferredAddressConnectionIdAndToken()); + const std::pair<QuicConnectionId, QuicUint128>& + preferred_address_connection_id_and_token = + config_.ReceivedPreferredAddressConnectionIdAndToken(); + EXPECT_EQ(preferred_address_connection_id_and_token.first, new_connection_id); + EXPECT_EQ(preferred_address_connection_id_and_token.second, + new_stateless_reset_token); +} + } // namespace } // namespace test } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_connection.cc b/chromium/net/third_party/quiche/src/quic/core/quic_connection.cc index 845e07871b6..471331b3f6d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_connection.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_connection.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_connection.h" +#include "quic/core/quic_connection.h" #include <string.h> #include <sys/types.h> @@ -11,40 +11,44 @@ #include <iterator> #include <limits> #include <memory> +#include <optional> #include <set> #include <string> #include <utility> #include "absl/strings/escaping.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/proto/cached_network_parameters_proto.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_legacy_version_encapsulator.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_creator.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_client_stats.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_error_code_wrappers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_exported_stats.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_hostname_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/congestion_control/rtt_stats.h" +#include "quic/core/congestion_control/send_algorithm_interface.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/crypto_utils.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/proto/cached_network_parameters_proto.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_legacy_version_encapsulator.h" +#include "quic/core/quic_packet_creator.h" +#include "quic/core/quic_packet_writer.h" +#include "quic/core/quic_path_validator.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_client_stats.h" +#include "quic/platform/api/quic_error_code_wrappers.h" +#include "quic/platform/api/quic_exported_stats.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_hostname_utils.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_map_util.h" +#include "quic/platform/api/quic_server_stats.h" +#include "quic/platform/api/quic_socket_address.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { @@ -68,8 +72,8 @@ class AckAlarmDelegate : public QuicAlarm::Delegate { AckAlarmDelegate& operator=(const AckAlarmDelegate&) = delete; void OnAlarm() override { - DCHECK(connection_->ack_frame_updated()); - DCHECK(connection_->connected()); + QUICHE_DCHECK(connection_->ack_frame_updated()); + QUICHE_DCHECK(connection_->connected()); QuicConnection::ScopedPacketFlusher flusher(connection_); if (connection_->SupportsMultiplePacketNumberSpaces()) { connection_->SendAllPendingAcks(); @@ -94,7 +98,7 @@ class RetransmissionAlarmDelegate : public QuicAlarm::Delegate { delete; void OnAlarm() override { - DCHECK(connection_->connected()); + QUICHE_DCHECK(connection_->connected()); connection_->OnRetransmissionTimeout(); } @@ -112,7 +116,7 @@ class SendAlarmDelegate : public QuicAlarm::Delegate { SendAlarmDelegate& operator=(const SendAlarmDelegate&) = delete; void OnAlarm() override { - DCHECK(connection_->connected()); + QUICHE_DCHECK(connection_->connected()); connection_->WriteAndBundleAcksIfNotBlocked(); } @@ -128,7 +132,7 @@ class PingAlarmDelegate : public QuicAlarm::Delegate { PingAlarmDelegate& operator=(const PingAlarmDelegate&) = delete; void OnAlarm() override { - DCHECK(connection_->connected()); + QUICHE_DCHECK(connection_->connected()); connection_->OnPingTimeout(); } @@ -145,7 +149,7 @@ class MtuDiscoveryAlarmDelegate : public QuicAlarm::Delegate { delete; void OnAlarm() override { - DCHECK(connection_->connected()); + QUICHE_DCHECK(connection_->connected()); connection_->DiscoverMtu(); } @@ -163,7 +167,7 @@ class ProcessUndecryptablePacketsAlarmDelegate : public QuicAlarm::Delegate { const ProcessUndecryptablePacketsAlarmDelegate&) = delete; void OnAlarm() override { - DCHECK(connection_->connected()); + QUICHE_DCHECK(connection_->connected()); QuicConnection::ScopedPacketFlusher flusher(connection_); connection_->MaybeProcessUndecryptablePackets(); } @@ -182,7 +186,7 @@ class DiscardPreviousOneRttKeysAlarmDelegate : public QuicAlarm::Delegate { const DiscardPreviousOneRttKeysAlarmDelegate&) = delete; void OnAlarm() override { - DCHECK(connection_->connected()); + QUICHE_DCHECK(connection_->connected()); connection_->DiscardPreviousOneRttKeys(); } @@ -190,6 +194,25 @@ class DiscardPreviousOneRttKeysAlarmDelegate : public QuicAlarm::Delegate { QuicConnection* connection_; }; +class DiscardZeroRttDecryptionKeysAlarmDelegate : public QuicAlarm::Delegate { + public: + explicit DiscardZeroRttDecryptionKeysAlarmDelegate(QuicConnection* connection) + : connection_(connection) {} + DiscardZeroRttDecryptionKeysAlarmDelegate( + const DiscardZeroRttDecryptionKeysAlarmDelegate&) = delete; + DiscardZeroRttDecryptionKeysAlarmDelegate& operator=( + const DiscardZeroRttDecryptionKeysAlarmDelegate&) = delete; + + void OnAlarm() override { + QUICHE_DCHECK(connection_->connected()); + QUIC_DLOG(INFO) << "0-RTT discard alarm fired"; + connection_->RemoveDecrypter(ENCRYPTION_ZERO_RTT); + } + + private: + QuicConnection* connection_; +}; + // When the clearer goes out of scope, the coalesced packet gets cleared. class ScopedCoalescedPacketClearer { public: @@ -258,16 +281,10 @@ QuicConnection::QuicConnection( server_connection_id_(server_connection_id), client_connection_id_(EmptyQuicConnectionId()), client_connection_id_is_set_(false), - self_address_( - GetQuicReloadableFlag(quic_connection_set_initial_self_address) - ? initial_self_address - : QuicSocketAddress()), - peer_address_(initial_peer_address), direct_peer_address_(initial_peer_address), + default_path_(initial_self_address, QuicSocketAddress()), active_effective_peer_migration_type_(NO_CHANGE), support_key_update_for_connection_(false), - enable_aead_limits_(GetQuicReloadableFlag(quic_enable_aead_limits) && - version().UsesTls()), last_packet_decrypted_(false), last_size_(0), current_packet_data_(nullptr), @@ -307,6 +324,9 @@ QuicConnection::QuicConnection( discard_previous_one_rtt_keys_alarm_(alarm_factory_->CreateAlarm( arena_.New<DiscardPreviousOneRttKeysAlarmDelegate>(this), &arena_)), + discard_zero_rtt_decryption_keys_alarm_(alarm_factory_->CreateAlarm( + arena_.New<DiscardZeroRttDecryptionKeysAlarmDelegate>(this), + &arena_)), visitor_(nullptr), debug_visitor_(nullptr), packet_creator_(server_connection_id_, &framer_, random_generator_, this), @@ -325,8 +345,7 @@ QuicConnection::QuicConnection( peer_max_packet_size_(kDefaultMaxPacketSizeTransportParam), largest_received_packet_size_(0), write_error_occurred_(false), - no_stop_waiting_frames_( - VersionHasIetfInvariantHeader(transport_version())), + no_stop_waiting_frames_(version().HasIetfInvariantHeader()), consecutive_num_packets_with_no_retransmittable_frames_(0), max_consecutive_num_packets_with_no_retransmittable_frames_( kMaxConsecutiveNonRetransmittablePackets), @@ -340,31 +359,29 @@ QuicConnection::QuicConnection( processing_ack_frame_(false), supports_release_time_(false), release_time_into_future_(QuicTime::Delta::Zero()), - drop_incoming_retry_packets_(false), - bytes_received_before_address_validation_(0), - bytes_sent_before_address_validation_(0), - address_validated_(false), blackhole_detector_(this, &arena_, alarm_factory_), idle_network_detector_(this, clock_->ApproximateNow(), &arena_, alarm_factory_), - support_handshake_done_(version().HasHandshakeDone()), encrypted_control_frames_( - GetQuicReloadableFlag(quic_encrypted_control_frames) && - packet_creator_.let_connection_handle_pings()), + GetQuicReloadableFlag(quic_encrypted_control_frames)), use_encryption_level_context_( encrypted_control_frames_ && - GetQuicReloadableFlag(quic_use_encryption_level_context)) { + GetQuicReloadableFlag(quic_use_encryption_level_context)), + path_validator_(alarm_factory_, &arena_, this, random_generator_), + alternative_path_(QuicSocketAddress(), QuicSocketAddress()), + most_recent_frame_type_(NUM_FRAME_TYPES), + validate_client_addresses_( + framer_.version().HasIetfQuicFrames() && use_path_validator_ && + count_bytes_on_alternative_path_separately_ && + update_packet_content_returns_connected_ && + GetQuicReloadableFlag(quic_server_reverse_validate_new_path)) { QUIC_BUG_IF(!start_peer_migration_earlier_ && send_path_response_); - if (GetQuicReloadableFlag(quic_connection_set_initial_self_address)) { - DCHECK(perspective_ == Perspective::IS_CLIENT || - self_address_.IsInitialized()); - QUIC_RELOADABLE_FLAG_COUNT(quic_connection_set_initial_self_address); - } - if (enable_aead_limits_) { - QUIC_RELOADABLE_FLAG_COUNT(quic_enable_aead_limits); - } + + QUICHE_DCHECK(perspective_ == Perspective::IS_CLIENT || + default_path_.self_address.IsInitialized()); + if (use_encryption_level_context_) { QUIC_RELOADABLE_FLAG_COUNT(quic_use_encryption_level_context); } @@ -375,15 +392,12 @@ QuicConnection::QuicConnection( QUIC_BUG_IF(!QuicUtils::IsConnectionIdValidForVersion(server_connection_id, transport_version())) << "QuicConnection: attempted to use server connection ID " - << server_connection_id << " which is invalid with version " - << QuicVersionToString(transport_version()); + << server_connection_id << " which is invalid with version " << version(); framer_.set_visitor(this); stats_.connection_creation_time = clock_->ApproximateNow(); // TODO(ianswett): Supply the NetworkChangeVisitor as a constructor argument // and make it required non-null, because it's always used. sent_packet_manager_.SetNetworkChangeVisitor(this); - sent_packet_manager_.ReserveUnackedPacketsInitialCapacity( - GetUnackedMapInitialCapacity()); if (GetQuicRestartFlag(quic_offload_pacing_to_usps2)) { sent_packet_manager_.SetPacingAlarmGranularity(QuicTime::Delta::Zero()); release_time_into_future_ = @@ -396,8 +410,8 @@ QuicConnection::QuicConnection( : kDefaultMaxPacketSize); uber_received_packet_manager_.set_max_ack_ranges(255); MaybeEnableMultiplePacketNumberSpacesSupport(); - DCHECK(perspective_ == Perspective::IS_CLIENT || - supported_versions.size() == 1); + QUICHE_DCHECK(perspective_ == Perspective::IS_CLIENT || + supported_versions.size() == 1); InstallInitialCrypters(server_connection_id_); // On the server side, version negotiation has been done by the dispatcher, @@ -433,63 +447,29 @@ QuicConnection::~QuicConnection() { delete writer_; } ClearQueuedPackets(); + if (stats_ + .num_tls_server_zero_rtt_packets_received_after_discarding_decrypter > + 0) { + QUIC_CODE_COUNT_N( + quic_server_received_tls_zero_rtt_packet_after_discarding_decrypter, 2, + 3); + } else { + QUIC_CODE_COUNT_N( + quic_server_received_tls_zero_rtt_packet_after_discarding_decrypter, 3, + 3); + } } void QuicConnection::ClearQueuedPackets() { buffered_packets_.clear(); } -bool QuicConnection::ValidateConfigConnectionIdsOld(const QuicConfig& config) { - // This function validates connection IDs as defined in IETF draft-27 and - // earlier. - DCHECK(config.negotiated()); - DCHECK(!version().AuthenticatesHandshakeConnectionIds()); - if (original_destination_connection_id_.has_value() && - retry_source_connection_id_.has_value()) { - DCHECK_EQ(perspective_, Perspective::IS_CLIENT); - // We received a RETRY packet, validate that the original destination - // connection ID from the config matches the one from the RETRY. - if (!config.HasReceivedOriginalConnectionId() || - config.ReceivedOriginalConnectionId() != - original_destination_connection_id_.value()) { - std::string received_value; - if (config.HasReceivedOriginalConnectionId()) { - received_value = config.ReceivedOriginalConnectionId().ToString(); - } else { - received_value = "none"; - } - std::string error_details = quiche::QuicheStrCat( - "Bad original_connection_id: expected ", - original_destination_connection_id_.value().ToString(), ", received ", - received_value, ", RETRY used ", server_connection_id_.ToString()); - CloseConnection(IETF_QUIC_PROTOCOL_VIOLATION, error_details, - ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); - return false; - } - } else { - // We did not receive a RETRY packet, make sure we did not receive the - // original_destination_connection_id transport parameter. - if (config.HasReceivedOriginalConnectionId()) { - std::string error_details = quiche::QuicheStrCat( - "Bad original_connection_id: did not receive RETRY but received ", - config.ReceivedOriginalConnectionId().ToString()); - CloseConnection(IETF_QUIC_PROTOCOL_VIOLATION, error_details, - ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); - return false; - } - } - return true; -} - bool QuicConnection::ValidateConfigConnectionIds(const QuicConfig& config) { - DCHECK(config.negotiated()); + QUICHE_DCHECK(config.negotiated()); if (!version().UsesTls()) { // QUIC+TLS is required to transmit connection ID transport parameters. return true; } - if (!version().AuthenticatesHandshakeConnectionIds()) { - return ValidateConfigConnectionIdsOld(config); - } // This function validates connection IDs as defined in IETF draft-28 and // later. @@ -510,9 +490,9 @@ bool QuicConnection::ValidateConfigConnectionIds(const QuicConfig& config) { received_value = "none"; } std::string error_details = - quiche::QuicheStrCat("Bad initial_source_connection_id: expected ", - expected_initial_source_connection_id.ToString(), - ", received ", received_value); + absl::StrCat("Bad initial_source_connection_id: expected ", + expected_initial_source_connection_id.ToString(), + ", received ", received_value); CloseConnection(IETF_QUIC_PROTOCOL_VIOLATION, error_details, ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); return false; @@ -528,10 +508,10 @@ bool QuicConnection::ValidateConfigConnectionIds(const QuicConfig& config) { } else { received_value = "none"; } - std::string error_details = quiche::QuicheStrCat( - "Bad original_destination_connection_id: expected ", - GetOriginalDestinationConnectionId().ToString(), ", received ", - received_value); + std::string error_details = + absl::StrCat("Bad original_destination_connection_id: expected ", + GetOriginalDestinationConnectionId().ToString(), + ", received ", received_value); CloseConnection(IETF_QUIC_PROTOCOL_VIOLATION, error_details, ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); return false; @@ -550,9 +530,9 @@ bool QuicConnection::ValidateConfigConnectionIds(const QuicConfig& config) { received_value = "none"; } std::string error_details = - quiche::QuicheStrCat("Bad retry_source_connection_id: expected ", - retry_source_connection_id_.value().ToString(), - ", received ", received_value); + absl::StrCat("Bad retry_source_connection_id: expected ", + retry_source_connection_id_.value().ToString(), + ", received ", received_value); CloseConnection(IETF_QUIC_PROTOCOL_VIOLATION, error_details, ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); return false; @@ -561,7 +541,7 @@ bool QuicConnection::ValidateConfigConnectionIds(const QuicConfig& config) { // We did not receive a RETRY packet, make sure we did not receive the // retry_source_connection_id transport parameter. if (config.HasReceivedRetrySourceConnectionId()) { - std::string error_details = quiche::QuicheStrCat( + std::string error_details = absl::StrCat( "Bad retry_source_connection_id: did not receive RETRY but " "received ", config.ReceivedRetrySourceConnectionId().ToString()); @@ -600,9 +580,6 @@ void QuicConnection::SetFromConfig(const QuicConfig& config) { SetNetworkTimeouts(config.max_time_before_crypto_handshake(), config.max_idle_time_before_crypto_handshake()); } - if (config.HandshakeDoneSupported()) { - support_handshake_done_ = true; - } sent_packet_manager_.SetFromConfig(config); if (perspective_ == Perspective::IS_SERVER && @@ -660,6 +637,14 @@ void QuicConnection::SetFromConfig(const QuicConfig& config) { anti_amplification_factor_ = 10; } + if (GetQuicReloadableFlag(quic_enable_server_on_wire_ping) && + perspective_ == Perspective::IS_SERVER && + config.HasClientSentConnectionOption(kSRWP, perspective_)) { + QUIC_RELOADABLE_FLAG_COUNT(quic_enable_server_on_wire_ping); + set_initial_retransmittable_on_wire_timeout( + QuicTime::Delta::FromMilliseconds(200)); + } + if (debug_visitor_ != nullptr) { debug_visitor_->OnSetFromConfig(config); } @@ -693,6 +678,11 @@ void QuicConnection::SetFromConfig(const QuicConfig& config) { if (config.HasClientSentConnectionOption(kEACK, perspective_)) { bundle_retransmittable_with_pto_ack_ = true; } + if (GetQuicReloadableFlag(quic_dont_defer_sending) && + config.HasClientSentConnectionOption(kDFER, perspective_)) { + QUIC_RELOADABLE_FLAG_COUNT(quic_dont_defer_sending); + defer_send_in_response_to_packets_ = false; + } if (config.HasReceivedMaxPacketSize()) { peer_max_packet_size_ = config.ReceivedMaxPacketSize(); MaybeUpdatePacketCreatorMaxPacketLengthAndPadding(); @@ -735,6 +725,7 @@ void QuicConnection::EnableLegacyVersionEncapsulation( } bool QuicConnection::MaybeTestLiveness() { + QUICHE_DCHECK_EQ(perspective_, Perspective::IS_CLIENT); if (encryption_level_ != ENCRYPTION_FORWARD_SECURE) { return false; } @@ -757,7 +748,7 @@ bool QuicConnection::MaybeTestLiveness() { if (!sent_packet_manager_.IsLessThanThreePTOs(timeout)) { return false; } - SendConnectivityProbingPacket(writer_, peer_address_); + SendConnectivityProbingPacket(writer_, peer_address()); return true; } @@ -851,20 +842,20 @@ void QuicConnection::OnPublicResetPacket(const QuicPublicResetPacket& packet) { // Check that any public reset packet with a different connection ID that was // routed to this QuicConnection has been redirected before control reaches // here. (Check for a bug regression.) - DCHECK_EQ(server_connection_id_, packet.connection_id); - DCHECK_EQ(perspective_, Perspective::IS_CLIENT); - DCHECK(!VersionHasIetfInvariantHeader(transport_version())); + QUICHE_DCHECK_EQ(server_connection_id_, packet.connection_id); + QUICHE_DCHECK_EQ(perspective_, Perspective::IS_CLIENT); + QUICHE_DCHECK(!version().HasIetfInvariantHeader()); if (debug_visitor_ != nullptr) { debug_visitor_->OnPublicResetPacket(packet); } std::string error_details = "Received public reset."; if (perspective_ == Perspective::IS_CLIENT && !packet.endpoint_id.empty()) { - QuicStrAppend(&error_details, " From ", packet.endpoint_id, "."); + absl::StrAppend(&error_details, " From ", packet.endpoint_id, "."); } QUIC_DLOG(INFO) << ENDPOINT << error_details; QUIC_CODE_COUNT(quic_tear_down_local_connection_on_public_reset); - TearDownLocalConnectionState(QUIC_PUBLIC_RESET, error_details, - ConnectionCloseSource::FROM_PEER); + TearDownLocalConnectionState(QUIC_PUBLIC_RESET, NO_IETF_QUIC_ERROR, + error_details, ConnectionCloseSource::FROM_PEER); } bool QuicConnection::OnProtocolVersionMismatch( @@ -889,7 +880,7 @@ void QuicConnection::OnVersionNegotiationPacket( // Check that any public reset packet with a different connection ID that was // routed to this QuicConnection has been redirected before control reaches // here. (Check for a bug regression.) - DCHECK_EQ(server_connection_id_, packet.connection_id); + QUICHE_DCHECK_EQ(server_connection_id_, packet.connection_id); if (perspective_ == Perspective::IS_SERVER) { const std::string error_details = "Server received version negotiation packet."; @@ -909,7 +900,7 @@ void QuicConnection::OnVersionNegotiationPacket( } if (QuicContainsValue(packet.versions, version())) { - const std::string error_details = quiche::QuicheStrCat( + const std::string error_details = absl::StrCat( "Server already supports client's version ", ParsedQuicVersionToString(version()), " and should have accepted the connection instead of sending {", @@ -923,7 +914,7 @@ void QuicConnection::OnVersionNegotiationPacket( server_supported_versions_ = packet.versions; CloseConnection( QUIC_INVALID_VERSION, - quiche::QuicheStrCat( + absl::StrCat( "Client may support one of the versions in the server's list, but " "it's going to close the connection anyway. Supported versions: {", ParsedQuicVersionVectorToString(framer_.supported_versions()), @@ -938,8 +929,8 @@ void QuicConnection::OnRetryPacket(QuicConnectionId original_connection_id, absl::string_view retry_token, absl::string_view retry_integrity_tag, absl::string_view retry_without_tag) { - DCHECK_EQ(Perspective::IS_CLIENT, perspective_); - if (version().HasRetryIntegrityTag()) { + QUICHE_DCHECK_EQ(Perspective::IS_CLIENT, perspective_); + if (version().UsesTls()) { if (!CryptoUtils::ValidateRetryIntegrityTag( version(), server_connection_id_, retry_without_tag, retry_integrity_tag)) { @@ -955,12 +946,7 @@ void QuicConnection::OnRetryPacket(QuicConnectionId original_connection_id, return; } } - if (drop_incoming_retry_packets_) { - QUIC_DLOG(ERROR) << "Ignoring RETRY with token " - << absl::BytesToHexString(retry_token); - return; - } - drop_incoming_retry_packets_ = true; + framer_.set_drop_incoming_retry_packets(true); stats_.retry_packet_processed = true; QUIC_DLOG(INFO) << "Received RETRY, replacing connection ID " << server_connection_id_ << " with " << new_connection_id @@ -968,7 +954,7 @@ void QuicConnection::OnRetryPacket(QuicConnectionId original_connection_id, if (!original_destination_connection_id_.has_value()) { original_destination_connection_id_ = server_connection_id_; } - DCHECK(!retry_source_connection_id_.has_value()) + QUICHE_DCHECK(!retry_source_connection_id_.has_value()) << retry_source_connection_id_.value(); retry_source_connection_id_ = new_connection_id; server_connection_id_ = new_connection_id; @@ -977,6 +963,8 @@ void QuicConnection::OnRetryPacket(QuicConnectionId original_connection_id, // Reinstall initial crypters because the connection ID changed. InstallInitialCrypters(server_connection_id_); + + sent_packet_manager_.MarkInitialPacketsForRetransmission(); } bool QuicConnection::HasIncomingConnectionId(QuicConnectionId connection_id) { @@ -995,12 +983,12 @@ void QuicConnection::SetOriginalDestinationConnectionId( << original_destination_connection_id << " on connection with server_connection_id " << server_connection_id_; - DCHECK_NE(original_destination_connection_id, server_connection_id_); + QUICHE_DCHECK_NE(original_destination_connection_id, server_connection_id_); if (!HasIncomingConnectionId(original_destination_connection_id)) { incoming_connection_ids_.push_back(original_destination_connection_id); } InstallInitialCrypters(original_destination_connection_id); - DCHECK(!original_destination_connection_id_.has_value()) + QUICHE_DCHECK(!original_destination_connection_id_.has_value()) << original_destination_connection_id_.value(); original_destination_connection_id_ = original_destination_connection_id; } @@ -1016,7 +1004,7 @@ bool QuicConnection::OnUnauthenticatedPublicHeader( const QuicPacketHeader& header) { // As soon as we receive an initial we start ignoring subsequent retries. if (header.version_flag && header.long_packet_type == INITIAL) { - drop_incoming_retry_packets_ = true; + framer_.set_drop_incoming_retry_packets(true); } QuicConnectionId server_connection_id = @@ -1042,7 +1030,7 @@ bool QuicConnection::OnUnauthenticatedPublicHeader( // If this is a server, the dispatcher routes each packet to the // QuicConnection responsible for the packet's connection ID. So if control // arrives here and this is a server, the dispatcher must be malfunctioning. - DCHECK_NE(Perspective::IS_SERVER, perspective_); + QUICHE_DCHECK_NE(Perspective::IS_SERVER, perspective_); return false; } @@ -1081,11 +1069,11 @@ bool QuicConnection::OnUnauthenticatedHeader(const QuicPacketHeader& header) { // Check that any public reset packet with a different connection ID that was // routed to this QuicConnection has been redirected before control reaches // here. - DCHECK(GetServerConnectionIdAsRecipient(header, perspective_) == - server_connection_id_ || - HasIncomingConnectionId( - GetServerConnectionIdAsRecipient(header, perspective_)) || - PacketCanReplaceConnectionId(header, perspective_)); + QUICHE_DCHECK(GetServerConnectionIdAsRecipient(header, perspective_) == + server_connection_id_ || + HasIncomingConnectionId( + GetServerConnectionIdAsRecipient(header, perspective_)) || + PacketCanReplaceConnectionId(header, perspective_)); if (packet_creator_.HasPendingFrames()) { // Incoming packets may change a queued ACK frame. @@ -1108,15 +1096,22 @@ void QuicConnection::OnSuccessfulVersionNegotiation() { } } -void QuicConnection::OnSuccessfulMigrationAfterProbing() { - DCHECK_EQ(perspective_, Perspective::IS_CLIENT); +void QuicConnection::OnSuccessfulMigration(bool is_port_change) { + QUICHE_DCHECK_EQ(perspective_, Perspective::IS_CLIENT); if (IsPathDegrading()) { // If path was previously degrading, and migration is successful after // probing, restart the path degrading and blackhole detection. OnForwardProgressMade(); } - // TODO(b/159074035): notify SentPacketManger with RTT sample from probing and - // reset cwnd if this is a successful network migration. + if (IsAlternativePath(default_path_.self_address, + default_path_.peer_address)) { + // Reset alternative path state even if it is still under validation. + alternative_path_.Clear(); + } + // TODO(b/159074035): notify SentPacketManger with RTT sample from probing. + if (version().HasIetfQuicFrames() && !is_port_change) { + sent_packet_manager_.OnConnectionMigration(/*reset_send_algorithm=*/true); + } } void QuicConnection::OnTransportParametersSent( @@ -1144,24 +1139,32 @@ bool QuicConnection::HasPendingAcks() const { return ack_alarm_->IsSet(); } -void QuicConnection::OnDecryptedPacket(EncryptionLevel level) { +void QuicConnection::OnDecryptedPacket(size_t /*length*/, + EncryptionLevel level) { last_decrypted_packet_level_ = level; last_packet_decrypted_ = true; - if (EnforceAntiAmplificationLimit()) { - bool address_validated = - last_decrypted_packet_level_ >= ENCRYPTION_HANDSHAKE; - if (GetQuicReloadableFlag(quic_fix_address_validation)) { - QUIC_RELOADABLE_FLAG_COUNT(quic_fix_address_validation); - address_validated = - (last_decrypted_packet_level_ == ENCRYPTION_HANDSHAKE || - last_decrypted_packet_level_ == ENCRYPTION_FORWARD_SECURE); - } - if (address_validated) { - // Address is validated by successfully processing a HANDSHAKE or 1-RTT - // packet. - address_validated_ = true; + if (level == ENCRYPTION_FORWARD_SECURE && + !have_decrypted_first_one_rtt_packet_) { + have_decrypted_first_one_rtt_packet_ = true; + if (version().UsesTls() && perspective_ == Perspective::IS_SERVER) { + // Servers MAY temporarily retain 0-RTT keys to allow decrypting reordered + // packets without requiring their contents to be retransmitted with 1-RTT + // keys. After receiving a 1-RTT packet, servers MUST discard 0-RTT keys + // within a short time; the RECOMMENDED time period is three times the + // Probe Timeout. + // https://quicwg.org/base-drafts/draft-ietf-quic-tls.html#name-discarding-0-rtt-keys + discard_zero_rtt_decryption_keys_alarm_->Set( + clock_->ApproximateNow() + sent_packet_manager_.GetPtoDelay() * 3); } } + if (EnforceAntiAmplificationLimit() && !IsHandshakeConfirmed() && + (last_decrypted_packet_level_ == ENCRYPTION_HANDSHAKE || + last_decrypted_packet_level_ == ENCRYPTION_FORWARD_SECURE)) { + // Address is validated by successfully processing a HANDSHAKE or 1-RTT + // packet. + default_path_.validated = true; + stats_.address_validated_via_decrypting_packet = true; + } idle_network_detector_.OnPacketReceived(time_of_last_received_packet_); visitor_->OnPacketDecrypted(level); @@ -1188,6 +1191,7 @@ bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) { } // Initialize the current packet content state. + most_recent_frame_type_ = NUM_FRAME_TYPES; current_packet_content_ = NO_FRAMES_RECEIVED; is_current_packet_connectivity_probing_ = false; has_path_challenge_in_current_packet_ = false; @@ -1196,12 +1200,12 @@ bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) { if (perspective_ == Perspective::IS_CLIENT) { if (!GetLargestReceivedPacket().IsInitialized() || header.packet_number > GetLargestReceivedPacket()) { - // Update peer_address_ and effective_peer_address_ immediately for - // client connections. + // Update direct_peer_address_ and default path peer_address immediately + // for client connections. // TODO(fayang): only change peer addresses in application data packet // number space. UpdatePeerAddress(last_packet_source_address_); - effective_peer_address_ = GetEffectivePeerAddressFromCurrentPacket(); + default_path_.peer_address = GetEffectivePeerAddressFromCurrentPacket(); } } else { // At server, remember the address change type of effective_peer_address @@ -1217,12 +1221,12 @@ bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) { // even if there is an active migration underway. current_effective_peer_migration_type_ = QuicUtils::DetermineAddressChangeType( - effective_peer_address_, + default_path_.peer_address, GetEffectivePeerAddressFromCurrentPacket()); QUIC_DLOG_IF(INFO, current_effective_peer_migration_type_ != NO_CHANGE) << ENDPOINT << "Effective peer's ip:port changed from " - << effective_peer_address_.ToString() << " to " + << default_path_.peer_address.ToString() << " to " << GetEffectivePeerAddressFromCurrentPacket().ToString() << ", active_effective_peer_migration_type is " << active_effective_peer_migration_type_; @@ -1240,16 +1244,32 @@ bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) { uber_received_packet_manager_.RecordPacketReceived( last_decrypted_packet_level_, last_header_, idle_network_detector_.time_of_last_received_packet()); - DCHECK(connected_); + if (GetQuicReloadableFlag(quic_enable_token_based_address_validation)) { + QUIC_RELOADABLE_FLAG_COUNT_N(quic_enable_token_based_address_validation, 2, + 2); + if (EnforceAntiAmplificationLimit() && !IsHandshakeConfirmed() && + !header.retry_token.empty() && + visitor_->ValidateToken(header.retry_token)) { + QUIC_DLOG(INFO) << ENDPOINT << "Address validated via token."; + QUIC_CODE_COUNT(quic_address_validated_via_token); + default_path_.validated = true; + stats_.address_validated_via_token = true; + } + } + QUICHE_DCHECK(connected_); return true; } bool QuicConnection::OnStreamFrame(const QuicStreamFrame& frame) { - DCHECK(connected_); + QUIC_BUG_IF(!connected_) + << "Processing STREAM frame when connection is closed. Last frame: " + << most_recent_frame_type_; // Since a stream frame was received, this is not a connectivity probe. // A probe only contains a PING and full padding. - UpdatePacketContent(STREAM_FRAME); + if (!UpdatePacketContent(STREAM_FRAME)) { + return false; + } if (debug_visitor_ != nullptr) { debug_visitor_->OnStreamFrame(frame); @@ -1281,11 +1301,15 @@ bool QuicConnection::OnStreamFrame(const QuicStreamFrame& frame) { } bool QuicConnection::OnCryptoFrame(const QuicCryptoFrame& frame) { - DCHECK(connected_); + QUIC_BUG_IF(!connected_) + << "Processing CRYPTO frame when connection is closed. Last frame: " + << most_recent_frame_type_; // Since a CRYPTO frame was received, this is not a connectivity probe. // A probe only contains a PING and full padding. - UpdatePacketContent(CRYPTO_FRAME); + if (!UpdatePacketContent(CRYPTO_FRAME)) { + return false; + } if (debug_visitor_ != nullptr) { debug_visitor_->OnCryptoFrame(frame); @@ -1297,7 +1321,9 @@ bool QuicConnection::OnCryptoFrame(const QuicCryptoFrame& frame) { bool QuicConnection::OnAckFrameStart(QuicPacketNumber largest_acked, QuicTime::Delta ack_delay_time) { - DCHECK(connected_); + QUIC_BUG_IF(!connected_) + << "Processing ACK frame start when connection is closed. Last frame: " + << most_recent_frame_type_; if (processing_ack_frame_) { CloseConnection(QUIC_INVALID_ACK_DATA, @@ -1308,7 +1334,9 @@ bool QuicConnection::OnAckFrameStart(QuicPacketNumber largest_acked, // Since an ack frame was received, this is not a connectivity probe. // A probe only contains a PING and full padding. - UpdatePacketContent(ACK_FRAME); + if (!UpdatePacketContent(ACK_FRAME)) { + return false; + } QUIC_DVLOG(1) << ENDPOINT << "OnAckFrameStart, largest_acked: " << largest_acked; @@ -1341,7 +1369,9 @@ bool QuicConnection::OnAckFrameStart(QuicPacketNumber largest_acked, } bool QuicConnection::OnAckRange(QuicPacketNumber start, QuicPacketNumber end) { - DCHECK(connected_); + QUIC_BUG_IF(!connected_) + << "Processing ACK frame range when connection is closed. Last frame: " + << most_recent_frame_type_; QUIC_DVLOG(1) << ENDPOINT << "OnAckRange: [" << start << ", " << end << ")"; if (GetLargestReceivedPacketWithAck().IsInitialized() && @@ -1356,7 +1386,9 @@ bool QuicConnection::OnAckRange(QuicPacketNumber start, QuicPacketNumber end) { bool QuicConnection::OnAckTimestamp(QuicPacketNumber packet_number, QuicTime timestamp) { - DCHECK(connected_); + QUIC_BUG_IF(!connected_) << "Processing ACK frame time stamp when connection " + "is closed. Last frame: " + << most_recent_frame_type_; QUIC_DVLOG(1) << ENDPOINT << "OnAckTimestamp: [" << packet_number << ", " << timestamp.ToDebuggingValue() << ")"; @@ -1371,7 +1403,9 @@ bool QuicConnection::OnAckTimestamp(QuicPacketNumber packet_number, } bool QuicConnection::OnAckFrameEnd(QuicPacketNumber start) { - DCHECK(connected_); + QUIC_BUG_IF(!connected_) + << "Processing ACK frame end when connection is closed. Last frame: " + << most_recent_frame_type_; QUIC_DVLOG(1) << ENDPOINT << "OnAckFrameEnd, start: " << start; if (GetLargestReceivedPacketWithAck().IsInitialized() && @@ -1426,16 +1460,19 @@ bool QuicConnection::OnAckFrameEnd(QuicPacketNumber start) { PostProcessAfterAckFrame(send_stop_waiting, ack_result == PACKETS_NEWLY_ACKED); processing_ack_frame_ = false; - return connected_; } bool QuicConnection::OnStopWaitingFrame(const QuicStopWaitingFrame& frame) { - DCHECK(connected_); + QUIC_BUG_IF(!connected_) + << "Processing STOP_WAITING frame when connection is closed. Last frame: " + << most_recent_frame_type_; // Since a stop waiting frame was received, this is not a connectivity probe. // A probe only contains a PING and full padding. - UpdatePacketContent(STOP_WAITING_FRAME); + if (!UpdatePacketContent(STOP_WAITING_FRAME)) { + return false; + } if (no_stop_waiting_frames_) { return true; @@ -1465,8 +1502,12 @@ bool QuicConnection::OnStopWaitingFrame(const QuicStopWaitingFrame& frame) { } bool QuicConnection::OnPaddingFrame(const QuicPaddingFrame& frame) { - DCHECK(connected_); - UpdatePacketContent(PADDING_FRAME); + QUIC_BUG_IF(!connected_) + << "Processing PADDING frame when connection is closed. Last frame: " + << most_recent_frame_type_; + if (!UpdatePacketContent(PADDING_FRAME)) { + return false; + } if (debug_visitor_ != nullptr) { debug_visitor_->OnPaddingFrame(frame); @@ -1475,8 +1516,12 @@ bool QuicConnection::OnPaddingFrame(const QuicPaddingFrame& frame) { } bool QuicConnection::OnPingFrame(const QuicPingFrame& frame) { - DCHECK(connected_); - UpdatePacketContent(PING_FRAME); + QUIC_BUG_IF(!connected_) + << "Processing PING frame when connection is closed. Last frame: " + << most_recent_frame_type_; + if (!UpdatePacketContent(PING_FRAME)) { + return false; + } if (debug_visitor_ != nullptr) { QuicTime::Delta ping_received_delay = QuicTime::Delta::Zero(); @@ -1515,11 +1560,15 @@ const char* QuicConnection::ValidateStopWaitingFrame( } bool QuicConnection::OnRstStreamFrame(const QuicRstStreamFrame& frame) { - DCHECK(connected_); + QUIC_BUG_IF(!connected_) + << "Processing RST_STREAM frame when connection is closed. Last frame: " + << most_recent_frame_type_; // Since a reset stream frame was received, this is not a connectivity probe. // A probe only contains a PING and full padding. - UpdatePacketContent(RST_STREAM_FRAME); + if (!UpdatePacketContent(RST_STREAM_FRAME)) { + return false; + } if (debug_visitor_ != nullptr) { debug_visitor_->OnRstStreamFrame(frame); @@ -1534,11 +1583,15 @@ bool QuicConnection::OnRstStreamFrame(const QuicRstStreamFrame& frame) { } bool QuicConnection::OnStopSendingFrame(const QuicStopSendingFrame& frame) { - DCHECK(connected_); + QUIC_BUG_IF(!connected_) + << "Processing STOP_SENDING frame when connection is closed. Last frame: " + << most_recent_frame_type_; // Since a reset stream frame was received, this is not a connectivity probe. // A probe only contains a PING and full padding. - UpdatePacketContent(STOP_SENDING_FRAME); + if (!UpdatePacketContent(STOP_SENDING_FRAME)) { + return false; + } if (debug_visitor_ != nullptr) { debug_visitor_->OnStopSendingFrame(frame); @@ -1552,14 +1605,57 @@ bool QuicConnection::OnStopSendingFrame(const QuicStopSendingFrame& frame) { return connected_; } +class ReversePathValidationContext : public QuicPathValidationContext { + public: + ReversePathValidationContext(const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address, + const QuicSocketAddress& effective_peer_address, + QuicConnection* connection) + : QuicPathValidationContext(self_address, + peer_address, + effective_peer_address), + connection_(connection) {} + + QuicPacketWriter* WriterToUse() override { return connection_->writer(); } + + private: + QuicConnection* connection_; +}; + bool QuicConnection::OnPathChallengeFrame(const QuicPathChallengeFrame& frame) { + QUIC_BUG_IF(!connected_) << "Processing PATH_CHALLENGE frame when connection " + "is closed. Last frame: " + << most_recent_frame_type_; if (has_path_challenge_in_current_packet_) { - DCHECK(send_path_response_); + QUICHE_DCHECK(send_path_response_); QUIC_RELOADABLE_FLAG_COUNT_N(quic_send_path_response, 2, 5); - // Only respond to the 1st PATH_CHALLENGE. + // Only respond to the 1st PATH_CHALLENGE in the packet. return true; } - UpdatePacketContent(PATH_CHALLENGE_FRAME); + if (!validate_client_addresses_) { + return OnPathChallengeFrameInternal(frame); + } + { + // UpdatePacketStateAndReplyPathChallenge() may start reverse path + // validation, if so bundle the PATH_CHALLENGE together with the + // PATH_RESPONSE. This context needs to be out of scope before returning. + // TODO(danzh) inline OnPathChallengeFrameInternal() once + // support_reverse_path_validation_ is deprecated. + QuicPacketCreator::ScopedPeerAddressContext context( + &packet_creator_, last_packet_source_address_); + if (!OnPathChallengeFrameInternal(frame)) { + return false; + } + } + return connected_; +} + +bool QuicConnection::OnPathChallengeFrameInternal( + const QuicPathChallengeFrame& frame) { + // UpdatePacketContent() may start reverse path validation. + if (!UpdatePacketContent(PATH_CHALLENGE_FRAME)) { + return false; + } if (debug_visitor_ != nullptr) { debug_visitor_->OnPathChallengeFrame(frame); } @@ -1575,9 +1671,9 @@ bool QuicConnection::OnPathChallengeFrame(const QuicPathChallengeFrame& frame) { QUIC_RELOADABLE_FLAG_COUNT_N(quic_send_path_response, 3, 5); has_path_challenge_in_current_packet_ = true; MaybeUpdateAckTimeout(); - // Queue or send PATH_RESPONSE. No matter where the pending data are supposed - // to sent, PATH_RESPONSE should always be sent to the source address of the - // current incoming packet. + // Queue or send PATH_RESPONSE. Send PATH_RESPONSE to the source address of + // the current incoming packet, even if it's not the default path or the + // alternative path. if (!SendPathResponse(frame.data_buffer, last_packet_source_address_)) { // Queue the payloads to re-try later. pending_path_challenge_payloads_.push_back( @@ -1592,28 +1688,42 @@ bool QuicConnection::OnPathChallengeFrame(const QuicPathChallengeFrame& frame) { } bool QuicConnection::OnPathResponseFrame(const QuicPathResponseFrame& frame) { - UpdatePacketContent(PATH_RESPONSE_FRAME); + QUIC_BUG_IF(!connected_) << "Processing PATH_RESPONSE frame when connection " + "is closed. Last frame: " + << most_recent_frame_type_; + if (!UpdatePacketContent(PATH_RESPONSE_FRAME)) { + return false; + } if (debug_visitor_ != nullptr) { debug_visitor_->OnPathResponseFrame(frame); } MaybeUpdateAckTimeout(); - if (!transmitted_connectivity_probe_payload_ || - *transmitted_connectivity_probe_payload_ != frame.data_buffer) { - // Is not for the probe we sent, ignore it. - return true; + if (use_path_validator_) { + path_validator_.OnPathResponse(frame.data_buffer, + last_packet_destination_address_); + } else { + if (!transmitted_connectivity_probe_payload_ || + *transmitted_connectivity_probe_payload_ != frame.data_buffer) { + // Is not for the probe we sent, ignore it. + return true; + } + // Have received the matching PATH RESPONSE, saved payload no longer valid. + transmitted_connectivity_probe_payload_ = nullptr; } - // Have received the matching PATH RESPONSE, saved payload no longer valid. - transmitted_connectivity_probe_payload_ = nullptr; - return true; + return connected_; } bool QuicConnection::OnConnectionCloseFrame( const QuicConnectionCloseFrame& frame) { - DCHECK(connected_); + QUIC_BUG_IF(!connected_) << "Processing CONNECTION_CLOSE frame when " + "connection is closed. Last frame: " + << most_recent_frame_type_; // Since a connection close frame was received, this is not a connectivity // probe. A probe only contains a PING and full padding. - UpdatePacketContent(CONNECTION_CLOSE_FRAME); + if (!UpdatePacketContent(CONNECTION_CLOSE_FRAME)) { + return false; + } if (debug_visitor_ != nullptr) { debug_visitor_->OnConnectionCloseFrame(frame); @@ -1655,7 +1765,13 @@ bool QuicConnection::OnConnectionCloseFrame( } bool QuicConnection::OnMaxStreamsFrame(const QuicMaxStreamsFrame& frame) { - UpdatePacketContent(MAX_STREAMS_FRAME); + QUIC_BUG_IF(!connected_) + << "Processing MAX_STREAMS frame when connection is closed. Last frame: " + << most_recent_frame_type_; + if (!UpdatePacketContent(MAX_STREAMS_FRAME)) { + return false; + } + if (debug_visitor_ != nullptr) { debug_visitor_->OnMaxStreamsFrame(frame); } @@ -1664,7 +1780,13 @@ bool QuicConnection::OnMaxStreamsFrame(const QuicMaxStreamsFrame& frame) { bool QuicConnection::OnStreamsBlockedFrame( const QuicStreamsBlockedFrame& frame) { - UpdatePacketContent(STREAMS_BLOCKED_FRAME); + QUIC_BUG_IF(!connected_) << "Processing STREAMS_BLOCKED frame when " + "connection is closed. Last frame: " + << most_recent_frame_type_; + if (!UpdatePacketContent(STREAMS_BLOCKED_FRAME)) { + return false; + } + if (debug_visitor_ != nullptr) { debug_visitor_->OnStreamsBlockedFrame(frame); } @@ -1672,11 +1794,15 @@ bool QuicConnection::OnStreamsBlockedFrame( } bool QuicConnection::OnGoAwayFrame(const QuicGoAwayFrame& frame) { - DCHECK(connected_); + QUIC_BUG_IF(!connected_) + << "Processing GOAWAY frame when connection is closed. Last frame: " + << most_recent_frame_type_; // Since a go away frame was received, this is not a connectivity probe. // A probe only contains a PING and full padding. - UpdatePacketContent(GOAWAY_FRAME); + if (!UpdatePacketContent(GOAWAY_FRAME)) { + return false; + } if (debug_visitor_ != nullptr) { debug_visitor_->OnGoAwayFrame(frame); @@ -1691,11 +1817,15 @@ bool QuicConnection::OnGoAwayFrame(const QuicGoAwayFrame& frame) { } bool QuicConnection::OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) { - DCHECK(connected_); + QUIC_BUG_IF(!connected_) << "Processing WINDOW_UPDATE frame when connection " + "is closed. Last frame: " + << most_recent_frame_type_; // Since a window update frame was received, this is not a connectivity probe. // A probe only contains a PING and full padding. - UpdatePacketContent(WINDOW_UPDATE_FRAME); + if (!UpdatePacketContent(WINDOW_UPDATE_FRAME)) { + return false; + } if (debug_visitor_ != nullptr) { debug_visitor_->OnWindowUpdateFrame( @@ -1709,7 +1839,13 @@ bool QuicConnection::OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) { bool QuicConnection::OnNewConnectionIdFrame( const QuicNewConnectionIdFrame& frame) { - UpdatePacketContent(NEW_CONNECTION_ID_FRAME); + QUIC_BUG_IF(!connected_) << "Processing NEW_CONNECTION_ID frame when " + "connection is closed. Last frame: " + << most_recent_frame_type_; + if (!UpdatePacketContent(NEW_CONNECTION_ID_FRAME)) { + return false; + } + if (debug_visitor_ != nullptr) { debug_visitor_->OnNewConnectionIdFrame(frame); } @@ -1718,7 +1854,13 @@ bool QuicConnection::OnNewConnectionIdFrame( bool QuicConnection::OnRetireConnectionIdFrame( const QuicRetireConnectionIdFrame& frame) { - UpdatePacketContent(RETIRE_CONNECTION_ID_FRAME); + QUIC_BUG_IF(!connected_) << "Processing RETIRE_CONNECTION_ID frame when " + "connection is closed. Last frame: " + << most_recent_frame_type_; + if (!UpdatePacketContent(RETIRE_CONNECTION_ID_FRAME)) { + return false; + } + if (debug_visitor_ != nullptr) { debug_visitor_->OnRetireConnectionIdFrame(frame); } @@ -1726,19 +1868,40 @@ bool QuicConnection::OnRetireConnectionIdFrame( } bool QuicConnection::OnNewTokenFrame(const QuicNewTokenFrame& frame) { - UpdatePacketContent(NEW_TOKEN_FRAME); + QUIC_BUG_IF(!connected_) + << "Processing NEW_TOKEN frame when connection is closed. Last frame: " + << most_recent_frame_type_; + if (!UpdatePacketContent(NEW_TOKEN_FRAME)) { + return false; + } + if (debug_visitor_ != nullptr) { debug_visitor_->OnNewTokenFrame(frame); } + if (GetQuicReloadableFlag(quic_enable_token_based_address_validation)) { + if (perspective_ == Perspective::IS_SERVER) { + CloseConnection(QUIC_INVALID_NEW_TOKEN, + "Server received new token frame.", + ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); + return false; + } + // NEW_TOKEN frame should insitgate ACKs. + MaybeUpdateAckTimeout(); + visitor_->OnNewTokenReceived(frame.token); + } return true; } bool QuicConnection::OnMessageFrame(const QuicMessageFrame& frame) { - DCHECK(connected_); + QUIC_BUG_IF(!connected_) + << "Processing MESSAGE frame when connection is closed. Last frame: " + << most_recent_frame_type_; // Since a message frame was received, this is not a connectivity probe. // A probe only contains a PING and full padding. - UpdatePacketContent(MESSAGE_FRAME); + if (!UpdatePacketContent(MESSAGE_FRAME)) { + return false; + } if (debug_visitor_ != nullptr) { debug_visitor_->OnMessageFrame(frame); @@ -1750,8 +1913,10 @@ bool QuicConnection::OnMessageFrame(const QuicMessageFrame& frame) { } bool QuicConnection::OnHandshakeDoneFrame(const QuicHandshakeDoneFrame& frame) { - DCHECK(connected_); - if (!support_handshake_done_) { + QUIC_BUG_IF(!connected_) << "Processing HANDSHAKE_DONE frame when connection " + "is closed. Last frame: " + << most_recent_frame_type_; + if (!version().UsesTls()) { CloseConnection(IETF_QUIC_PROTOCOL_VIOLATION, "Handshake done frame is unsupported", ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); @@ -1767,7 +1932,9 @@ bool QuicConnection::OnHandshakeDoneFrame(const QuicHandshakeDoneFrame& frame) { // Since a handshake done frame was received, this is not a connectivity // probe. A probe only contains a PING and full padding. - UpdatePacketContent(HANDSHAKE_DONE_FRAME); + if (!UpdatePacketContent(HANDSHAKE_DONE_FRAME)) { + return false; + } if (debug_visitor_ != nullptr) { debug_visitor_->OnHandshakeDoneFrame(frame); @@ -1778,10 +1945,16 @@ bool QuicConnection::OnHandshakeDoneFrame(const QuicHandshakeDoneFrame& frame) { } bool QuicConnection::OnAckFrequencyFrame(const QuicAckFrequencyFrame& frame) { + QUIC_BUG_IF(!connected_) << "Processing ACK_FREQUENCY frame when connection " + "is closed. Last frame: " + << most_recent_frame_type_; if (debug_visitor_ != nullptr) { debug_visitor_->OnAckFrequencyFrame(frame); } - UpdatePacketContent(ACK_FREQUENCY_FRAME); + if (!UpdatePacketContent(ACK_FREQUENCY_FRAME)) { + return false; + } + if (!can_receive_ack_frequency_frame_) { QUIC_LOG_EVERY_N_SEC(ERROR, 120) << "Get unexpected AckFrequencyFrame."; return false; @@ -1800,11 +1973,15 @@ bool QuicConnection::OnAckFrequencyFrame(const QuicAckFrequencyFrame& frame) { } bool QuicConnection::OnBlockedFrame(const QuicBlockedFrame& frame) { - DCHECK(connected_); + QUIC_BUG_IF(!connected_) + << "Processing BLOCKED frame when connection is closed. Last frame was " + << most_recent_frame_type_; // Since a blocked frame was received, this is not a connectivity probe. // A probe only contains a PING and full padding. - UpdatePacketContent(BLOCKED_FRAME); + if (!UpdatePacketContent(BLOCKED_FRAME)) { + return false; + } if (debug_visitor_ != nullptr) { debug_visitor_->OnBlockedFrame(frame); @@ -1825,7 +2002,7 @@ void QuicConnection::OnPacketComplete() { } if (IsCurrentPacketConnectivityProbing()) { - DCHECK(!version().HasIetfQuicFrames()); + QUICHE_DCHECK(!version().HasIetfQuicFrames()); ++stats_.num_connectivity_probing_received; } @@ -1930,22 +2107,38 @@ void QuicConnection::OnAuthenticatedIetfStatelessResetPacket( const QuicIetfStatelessResetPacket& /*packet*/) { // TODO(fayang): Add OnAuthenticatedIetfStatelessResetPacket to // debug_visitor_. - DCHECK(VersionHasIetfInvariantHeader(transport_version())); - DCHECK_EQ(perspective_, Perspective::IS_CLIENT); - if (!visitor_->ValidateStatelessReset(last_packet_destination_address_, - last_packet_source_address_)) { + QUICHE_DCHECK(version().HasIetfInvariantHeader()); + QUICHE_DCHECK_EQ(perspective_, Perspective::IS_CLIENT); + + if (use_path_validator_) { + if (!IsDefaultPath(last_packet_destination_address_, + last_packet_source_address_)) { + // This packet is received on a probing path. Do not close connection. + if (IsAlternativePath(last_packet_destination_address_, + GetEffectivePeerAddressFromCurrentPacket())) { + QUIC_BUG_IF(alternative_path_.validated) + << "STATELESS_RESET received on alternate path after it's " + "validated."; + path_validator_.CancelPathValidation(); + } else { + QUIC_BUG << "Received Stateless Reset on unknown socket."; + } + return; + } + } else if (!visitor_->ValidateStatelessReset(last_packet_destination_address_, + last_packet_source_address_)) { // This packet is received on a probing path. Do not close connection. return; } const std::string error_details = "Received stateless reset."; QUIC_CODE_COUNT(quic_tear_down_local_connection_on_stateless_reset); - TearDownLocalConnectionState(QUIC_PUBLIC_RESET, error_details, - ConnectionCloseSource::FROM_PEER); + TearDownLocalConnectionState(QUIC_PUBLIC_RESET, NO_IETF_QUIC_ERROR, + error_details, ConnectionCloseSource::FROM_PEER); } void QuicConnection::OnKeyUpdate(KeyUpdateReason reason) { - DCHECK(support_key_update_for_connection_); + QUICHE_DCHECK(support_key_update_for_connection_); QUIC_DLOG(INFO) << ENDPOINT << "Key phase updated for " << reason; lowest_packet_sent_in_current_key_phase_.Clear(); @@ -1988,25 +2181,38 @@ void QuicConnection::ClearLastFrames() { } void QuicConnection::CloseIfTooManyOutstandingSentPackets() { + bool should_close; + if (GetQuicReloadableFlag( + quic_close_connection_with_too_many_outstanding_packets)) { + QUIC_RELOADABLE_FLAG_COUNT( + quic_close_connection_with_too_many_outstanding_packets); + should_close = + sent_packet_manager_.GetLargestSentPacket().IsInitialized() && + sent_packet_manager_.GetLargestSentPacket() > + sent_packet_manager_.GetLeastUnacked() + max_tracked_packets_; + } else { + should_close = + sent_packet_manager_.GetLargestObserved().IsInitialized() && + sent_packet_manager_.GetLargestObserved() > + sent_packet_manager_.GetLeastUnacked() + max_tracked_packets_; + } // This occurs if we don't discard old packets we've seen fast enough. It's // possible largest observed is less than leaset unacked. - if (sent_packet_manager_.GetLargestObserved().IsInitialized() && - sent_packet_manager_.GetLargestObserved() > - sent_packet_manager_.GetLeastUnacked() + max_tracked_packets_) { + if (should_close) { CloseConnection( QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS, - quiche::QuicheStrCat( - "More than ", max_tracked_packets_, " outstanding, least_unacked: ", - sent_packet_manager_.GetLeastUnacked().ToUint64(), - ", packets_processed: ", stats_.packets_processed, - ", last_decrypted_packet_level: ", - EncryptionLevelToString(last_decrypted_packet_level_)), + absl::StrCat("More than ", max_tracked_packets_, + " outstanding, least_unacked: ", + sent_packet_manager_.GetLeastUnacked().ToUint64(), + ", packets_processed: ", stats_.packets_processed, + ", last_decrypted_packet_level: ", + EncryptionLevelToString(last_decrypted_packet_level_)), ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); } } const QuicFrame QuicConnection::GetUpdatedAckFrame() { - DCHECK(!uber_received_packet_manager_.IsAckFrameEmpty( + QUICHE_DCHECK(!uber_received_packet_manager_.IsAckFrameEmpty( QuicUtils::GetPacketNumberSpace(encryption_level_))) << "Try to retrieve an empty ACK frame"; return uber_received_packet_manager_.GetUpdatedAckFrame( @@ -2057,7 +2263,7 @@ void QuicConnection::MaybeActivateLegacyVersionEncapsulation() { if (!legacy_version_encapsulation_enabled_) { return; } - DCHECK(!legacy_version_encapsulation_in_progress_); + QUICHE_DCHECK(!legacy_version_encapsulation_in_progress_); QUIC_BUG_IF(!packet_creator_.CanSetMaxPacketLength()) << "Cannot activate Legacy Version Encapsulation mid-packet"; QUIC_BUG_IF(coalesced_packet_.length() != 0u) @@ -2071,7 +2277,7 @@ void QuicConnection::MaybeDisactivateLegacyVersionEncapsulation() { } // Flush any remaining packet before disactivating encapsulation. packet_creator_.FlushCurrentPacket(); - DCHECK(legacy_version_encapsulation_enabled_); + QUICHE_DCHECK(legacy_version_encapsulation_enabled_); legacy_version_encapsulation_in_progress_ = false; MaybeUpdatePacketCreatorMaxPacketLengthAndPadding(); } @@ -2147,6 +2353,7 @@ bool QuicConnection::SendControlFrame(const QuicFrame& frame) { if (frame.type == PING_FRAME) { // Flush PING frame immediately. packet_creator_.FlushCurrentPacket(); + stats_.ping_frames_sent++; if (debug_visitor_ != nullptr) { debug_visitor_->OnPingSent(); } @@ -2207,7 +2414,7 @@ void QuicConnection::OnUndecryptablePacket(const QuicEncryptedPacket& packet, << decryption_level << " while connection is at encryption level " << encryption_level_; - DCHECK(EncryptionLevelIsValid(decryption_level)); + QUICHE_DCHECK(EncryptionLevelIsValid(decryption_level)); if (encryption_level_ != ENCRYPTION_FORWARD_SECURE) { ++stats_.undecryptable_packets_received_before_handshake_complete; } @@ -2225,9 +2432,9 @@ void QuicConnection::OnUndecryptablePacket(const QuicEncryptedPacket& packet, if (has_decryption_key) { stats_.num_failed_authentication_packets_received++; - if (enable_aead_limits_) { + if (version().UsesTls()) { // Should always be non-null if has_decryption_key is true. - DCHECK(framer_.GetDecrypter(decryption_level)); + QUICHE_DCHECK(framer_.GetDecrypter(decryption_level)); const QuicPacketCount integrity_limit = framer_.GetDecrypter(decryption_level)->GetIntegrityLimit(); QUIC_DVLOG(2) << ENDPOINT << "Checking AEAD integrity limits:" @@ -2236,7 +2443,7 @@ void QuicConnection::OnUndecryptablePacket(const QuicEncryptedPacket& packet, << " integrity_limit=" << integrity_limit; if (stats_.num_failed_authentication_packets_received >= integrity_limit) { - const std::string error_details = quiche::QuicheStrCat( + const std::string error_details = absl::StrCat( "decrypter integrity limit reached:" " num_failed_authentication_packets_received=", stats_.num_failed_authentication_packets_received, @@ -2246,6 +2453,16 @@ void QuicConnection::OnUndecryptablePacket(const QuicEncryptedPacket& packet, } } } + + if (version().UsesTls() && perspective_ == Perspective::IS_SERVER && + decryption_level == ENCRYPTION_ZERO_RTT && !has_decryption_key && + had_zero_rtt_decrypter_) { + QUIC_CODE_COUNT_N( + quic_server_received_tls_zero_rtt_packet_after_discarding_decrypter, 1, + 3); + stats_ + .num_tls_server_zero_rtt_packets_received_after_discarding_decrypter++; + } } bool QuicConnection::ShouldEnqueueUnDecryptablePacket( @@ -2274,21 +2491,21 @@ bool QuicConnection::ShouldEnqueueUnDecryptablePacket( } std::string QuicConnection::UndecryptablePacketsInfo() const { - std::string info = quiche::QuicheStrCat( + std::string info = absl::StrCat( "num_undecryptable_packets: ", undecryptable_packets_.size(), " {"); for (const auto& packet : undecryptable_packets_) { - info = quiche::QuicheStrCat( - info, "[", EncryptionLevelToString(packet.encryption_level), ", ", - packet.packet->length(), ", ", packet.processed, "]"); + absl::StrAppend(&info, "[", + EncryptionLevelToString(packet.encryption_level), ", ", + packet.packet->length(), "]"); } - info = quiche::QuicheStrCat(info, "}"); + absl::StrAppend(&info, "}"); return info; } void QuicConnection::MaybeUpdatePacketCreatorMaxPacketLengthAndPadding() { QuicByteCount max_packet_length = GetLimitedMaxPacketSize(long_term_mtu_); if (legacy_version_encapsulation_in_progress_) { - DCHECK(legacy_version_encapsulation_enabled_); + QUICHE_DCHECK(legacy_version_encapsulation_enabled_); const QuicByteCount minimum_overhead = QuicLegacyVersionEncapsulator::GetMinimumOverhead( legacy_version_encapsulation_sni_); @@ -2321,35 +2538,44 @@ void QuicConnection::ProcessUdpPacket(const QuicSocketAddress& self_address, if (debug_visitor_ != nullptr) { debug_visitor_->OnPacketReceived(self_address, peer_address, packet); } + current_incoming_packet_received_bytes_counted_ = false; last_size_ = packet.length(); current_packet_data_ = packet.data(); last_packet_destination_address_ = self_address; last_packet_source_address_ = peer_address; - if (!self_address_.IsInitialized()) { - self_address_ = last_packet_destination_address_; + if (!default_path_.self_address.IsInitialized()) { + default_path_.self_address = last_packet_destination_address_; } if (!direct_peer_address_.IsInitialized()) { UpdatePeerAddress(last_packet_source_address_); } - if (!effective_peer_address_.IsInitialized()) { + if (!default_path_.peer_address.IsInitialized()) { const QuicSocketAddress effective_peer_addr = GetEffectivePeerAddressFromCurrentPacket(); - // effective_peer_address_ must be initialized at the beginning of the + // The default path peer_address must be initialized at the beginning of the // first packet processed(here). If effective_peer_addr is uninitialized, // just set effective_peer_address_ to the direct peer address. - effective_peer_address_ = effective_peer_addr.IsInitialized() - ? effective_peer_addr - : direct_peer_address_; + default_path_.peer_address = effective_peer_addr.IsInitialized() + ? effective_peer_addr + : direct_peer_address_; } stats_.bytes_received += packet.length(); ++stats_.packets_received; - if (EnforceAntiAmplificationLimit()) { - bytes_received_before_address_validation_ += last_size_; + if (!count_bytes_on_alternative_path_separately_) { + if (EnforceAntiAmplificationLimit()) { + default_path_.bytes_received_before_address_validation += last_size_; + } + } else if (IsDefaultPath(last_packet_destination_address_, + last_packet_source_address_) && + EnforceAntiAmplificationLimit()) { + QUIC_CODE_COUNT_N(quic_count_bytes_on_alternative_path_seperately, 1, 5); + current_incoming_packet_received_bytes_counted_ = true; + default_path_.bytes_received_before_address_validation += last_size_; } // Ensure the time coming from the packet reader is within 2 minutes of now. @@ -2362,7 +2588,8 @@ void QuicConnection::ProcessUdpPacket(const QuicSocketAddress& self_address, } time_of_last_received_packet_ = packet.receipt_time(); QUIC_DVLOG(1) << ENDPOINT << "time of last received packet: " - << packet.receipt_time().ToDebuggingValue(); + << packet.receipt_time().ToDebuggingValue() << " from peer " + << last_packet_source_address_; ScopedPacketFlusher flusher(this); if (!framer_.ProcessPacket(packet)) { @@ -2385,7 +2612,8 @@ void QuicConnection::ProcessUdpPacket(const QuicSocketAddress& self_address, << sent_packet_manager_.GetLargestObserved() << ", highest_packet_sent_before_effective_peer_migration_ = " << highest_packet_sent_before_effective_peer_migration_; - if (active_effective_peer_migration_type_ != NO_CHANGE && + if (!validate_client_addresses_ && + active_effective_peer_migration_type_ != NO_CHANGE && sent_packet_manager_.GetLargestObserved().IsInitialized() && (!highest_packet_sent_before_effective_peer_migration_.IsInitialized() || sent_packet_manager_.GetLargestObserved() > @@ -2412,20 +2640,13 @@ void QuicConnection::OnCanWrite() { if (!connected_) { return; } - if (GetQuicReloadableFlag( - quic_close_connection_in_on_can_write_with_blocked_writer)) { - QUIC_RELOADABLE_FLAG_COUNT( - quic_close_connection_in_on_can_write_with_blocked_writer); - if (writer_->IsWriteBlocked()) { - const std::string error_details = - "Writer is blocked while calling OnCanWrite."; - QUIC_BUG << ENDPOINT << error_details; - CloseConnection(QUIC_INTERNAL_ERROR, error_details, - ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); - return; - } - } else { - DCHECK(!writer_->IsWriteBlocked()); + if (writer_->IsWriteBlocked()) { + const std::string error_details = + "Writer is blocked while calling OnCanWrite."; + QUIC_BUG << ENDPOINT << error_details; + CloseConnection(QUIC_INTERNAL_ERROR, error_details, + ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); + return; } // Add a flusher to ensure the connection is marked app-limited. @@ -2449,9 +2670,10 @@ void QuicConnection::OnCanWrite() { // evaluate if it's worth to send them before sending ACKs. while (!pending_path_challenge_payloads_.empty()) { QUIC_RELOADABLE_FLAG_COUNT_N(quic_send_path_response, 4, 5); - std::pair<QuicPathFrameBuffer, QuicSocketAddress> pair = + const PendingPathChallenge& pending_path_challenge = pending_path_challenge_payloads_.front(); - if (!SendPathResponse(pair.first, pair.second)) { + if (!SendPathResponse(pending_path_challenge.received_path_challenge, + pending_path_challenge.peer_address)) { break; } pending_path_challenge_payloads_.pop_front(); @@ -2498,12 +2720,14 @@ void QuicConnection::WriteAndBundleAcksIfNotBlocked() { } bool QuicConnection::ProcessValidatedPacket(const QuicPacketHeader& header) { - if (perspective_ == Perspective::IS_SERVER && self_address_.IsInitialized() && + if (perspective_ == Perspective::IS_SERVER && + default_path_.self_address.IsInitialized() && last_packet_destination_address_.IsInitialized() && - self_address_ != last_packet_destination_address_) { + default_path_.self_address != last_packet_destination_address_) { // Allow change between pure IPv4 and equivalent mapped IPv4 address. - if (self_address_.port() != last_packet_destination_address_.port() || - self_address_.host().Normalized() != + if (default_path_.self_address.port() != + last_packet_destination_address_.port() || + default_path_.self_address.host().Normalized() != last_packet_destination_address_.host().Normalized()) { if (!visitor_->AllowSelfAddressChange()) { CloseConnection( @@ -2513,7 +2737,7 @@ bool QuicConnection::ProcessValidatedPacket(const QuicPacketHeader& header) { return false; } } - self_address_ = last_packet_destination_address_; + default_path_.self_address = last_packet_destination_address_; } if (PacketCanReplaceConnectionId(header, perspective_) && @@ -2534,8 +2758,8 @@ bool QuicConnection::ProcessValidatedPacket(const QuicPacketHeader& header) { if (!version_negotiated_) { if (perspective_ == Perspective::IS_CLIENT) { - DCHECK(!header.version_flag || header.form != GOOGLE_QUIC_PACKET); - if (!VersionHasIetfInvariantHeader(framer_.transport_version())) { + QUICHE_DCHECK(!header.version_flag || header.form != GOOGLE_QUIC_PACKET); + if (!version().HasIetfInvariantHeader()) { // If the client gets a packet without the version flag from the server // it should stop sending version since the version negotiation is done. // IETF QUIC stops sending version once encryption level switches to @@ -2579,7 +2803,7 @@ bool QuicConnection::ValidateReceivedPacketNumber( } void QuicConnection::WriteQueuedPackets() { - DCHECK(!writer_->IsWriteBlocked()); + QUICHE_DCHECK(!writer_->IsWriteBlocked()); QUIC_CLIENT_HISTOGRAM_COUNTS("QuicSession.NumQueuedPacketsBeforeWrite", buffered_packets_.size(), 1, 1000, 50, ""); @@ -2638,9 +2862,6 @@ void QuicConnection::MarkZeroRttPacketsForRetransmission(int reject_reason) { void QuicConnection::NeuterUnencryptedPackets() { sent_packet_manager_.NeuterUnencryptedPackets(); - if (!fix_missing_initial_keys_ && version().CanSendCoalescedPackets()) { - coalesced_packet_.NeuterInitialPacket(); - } // This may have changed the retransmission timer, so re-arm it. SetRetransmissionAlarm(); if (default_enable_5rto_blackhole_detection_) { @@ -2662,11 +2883,23 @@ void QuicConnection::NeuterUnencryptedPackets() { bool QuicConnection::ShouldGeneratePacket( HasRetransmittableData retransmittable, IsHandshake handshake) { - DCHECK(handshake != IS_HANDSHAKE || - QuicVersionUsesCryptoFrames(transport_version())) + QUICHE_DCHECK(handshake != IS_HANDSHAKE || + QuicVersionUsesCryptoFrames(transport_version())) << ENDPOINT << "Handshake in STREAM frames should not check ShouldGeneratePacket"; - return CanWrite(retransmittable); + if (!count_bytes_on_alternative_path_separately_) { + return CanWrite(retransmittable); + } + QUIC_CODE_COUNT_N(quic_count_bytes_on_alternative_path_seperately, 4, 5); + if (IsDefaultPath(default_path_.self_address, + packet_creator_.peer_address())) { + return CanWrite(retransmittable); + } + // This is checking on the alternative path with a different peer address. The + // self address and the writer used are the same as the default path. In the + // case of different self address and writer, writing packet would use a + // differnt code path without checking the states of the default writer. + return connected_ && !HandleWriteBlocked(); } const QuicFrames QuicConnection::MaybeBundleAckOpportunistically() { @@ -2722,7 +2955,12 @@ bool QuicConnection::CanWrite(HasRetransmittableData retransmittable) { if (LimitedByAmplificationFactor()) { // Server is constrained by the amplification restriction. QUIC_CODE_COUNT(quic_throttled_by_amplification_limit); - QUIC_DVLOG(1) << ENDPOINT << "Constrained by amplification restriction"; + QUIC_DVLOG(1) << ENDPOINT + << "Constrained by amplification restriction to peer address " + << default_path_.peer_address << " bytes received " + << default_path_.bytes_received_before_address_validation + << ", bytes sent" + << default_path_.bytes_sent_before_address_validation; ++stats_.num_amplification_throttling; return false; } @@ -2736,7 +2974,7 @@ bool QuicConnection::CanWrite(HasRetransmittableData retransmittable) { return false; } - // Allow acks to be sent immediately. + // Allow acks and probing frames to be sent immediately. if (retransmittable == NO_RETRANSMITTABLE_DATA) { return true; } @@ -2813,7 +3051,7 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) { termination_packets_->emplace_back( new QuicEncryptedPacket(buffer_copy, encrypted_length, true)); if (error_code == QUIC_SILENT_IDLE_TIMEOUT) { - DCHECK_EQ(Perspective::IS_SERVER, perspective_); + QUICHE_DCHECK_EQ(Perspective::IS_SERVER, perspective_); // TODO(fayang): populate histogram indicating the time elapsed from this // connection gets closed to following client packets get received. QUIC_DVLOG(1) << ENDPOINT @@ -2824,19 +3062,19 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) { } } - DCHECK_LE(encrypted_length, kMaxOutgoingPacketSize); - DCHECK(is_mtu_discovery || - encrypted_length <= packet_creator_.max_packet_length()) + QUICHE_DCHECK_LE(encrypted_length, kMaxOutgoingPacketSize); + QUICHE_DCHECK(is_mtu_discovery || + encrypted_length <= packet_creator_.max_packet_length()) << " encrypted_length=" << encrypted_length << " > packet_creator max_packet_length=" << packet_creator_.max_packet_length(); QUIC_DVLOG(1) << ENDPOINT << "Sending packet " << packet_number << " : " << (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA ? "data bearing " - : " ack only ") + : " ack or probing only ") << ", encryption level: " << packet->encryption_level << ", encrypted length:" << encrypted_length - << ", fate: " << fate; + << ", fate: " << fate << " to peer " << packet->peer_address; QUIC_DVLOG(2) << ENDPOINT << packet->encryption_level << " packet number " << packet_number << " of length " << encrypted_length << ": " << std::endl @@ -2850,13 +3088,14 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) { WriteResult result(WRITE_STATUS_OK, encrypted_length); QuicSocketAddress send_to_address = (send_path_response_) ? packet->peer_address : peer_address(); + // Self address is always the default self address on this code path. + bool send_on_current_path = send_to_address == peer_address(); switch (fate) { case DISCARD: ++stats_.packets_discarded; return true; case COALESCE: - QUIC_BUG_IF(!version().CanSendCoalescedPackets()); - QUIC_BUG_IF(fix_out_of_order_sending_ && coalescing_done_); + QUIC_BUG_IF(!version().CanSendCoalescedPackets() || coalescing_done_); if (!coalesced_packet_.MaybeCoalescePacket( *packet, self_address(), send_to_address, helper_->GetStreamSendBufferAllocator(), @@ -2866,19 +3105,6 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) { // Failed to flush coalesced packet, write error has been handled. return false; } - if (!fix_missing_initial_keys_ && - GetQuicReloadableFlag( - quic_discard_initial_packet_with_key_dropped)) { - QUIC_RELOADABLE_FLAG_COUNT( - quic_discard_initial_packet_with_key_dropped); - if (packet->encryption_level == ENCRYPTION_INITIAL && - !framer_.HasEncrypterOfEncryptionLevel(ENCRYPTION_INITIAL)) { - // Discard initial packet since flush of coalesce packet could - // cause initial keys to be dropped. - ++stats_.packets_discarded; - return true; - } - } if (!coalesced_packet_.MaybeCoalescePacket( *packet, self_address(), send_to_address, helper_->GetStreamSendBufferAllocator(), @@ -2904,10 +3130,8 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) { buffered_packets_.emplace_back(*packet, self_address(), send_to_address); break; case SEND_TO_WRITER: - if (fix_out_of_order_sending_ && !coalescing_done_) { - // Stop using coalsecer from now on. - coalescing_done_ = true; - } + // Stop using coalescer from now on. + coalescing_done_ = true; // At this point, packet->release_encrypted_buffer is either nullptr, // meaning |packet->encrypted_buffer| is a stack buffer, or not-nullptr, /// meaning it's a writer-allocated buffer. Note that connectivity probing @@ -2931,11 +3155,11 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) { } break; case LEGACY_VERSION_ENCAPSULATE: { - DCHECK(!is_mtu_discovery); - DCHECK_EQ(perspective_, Perspective::IS_CLIENT); - DCHECK_EQ(packet->encryption_level, ENCRYPTION_INITIAL); - DCHECK(legacy_version_encapsulation_enabled_); - DCHECK(legacy_version_encapsulation_in_progress_); + QUICHE_DCHECK(!is_mtu_discovery); + QUICHE_DCHECK_EQ(perspective_, Perspective::IS_CLIENT); + QUICHE_DCHECK_EQ(packet->encryption_level, ENCRYPTION_INITIAL); + QUICHE_DCHECK(legacy_version_encapsulation_enabled_); + QUICHE_DCHECK(legacy_version_encapsulation_in_progress_); QuicPacketLength encapsulated_length = QuicLegacyVersionEncapsulator::Encapsulate( legacy_version_encapsulation_sni_, @@ -2974,7 +3198,7 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) { } } break; default: - DCHECK(false); + QUICHE_DCHECK(false); break; } @@ -2986,7 +3210,7 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) { if (IsWriteBlockedStatus(result.status)) { // Ensure the writer is still write blocked, otherwise QUIC may continue // trying to write when it will not be able to. - DCHECK(writer_->IsWriteBlocked()); + QUICHE_DCHECK(writer_->IsWriteBlocked()); visitor_->OnWriteBlocked(); // If the socket buffers the data, then the packet should not // be queued and sent again, which would result in an unnecessary @@ -3001,17 +3225,23 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) { // In some cases, an MTU probe can cause EMSGSIZE. This indicates that the // MTU discovery is permanently unsuccessful. - if (IsMsgTooBig(result) && is_mtu_discovery) { - // When MSG_TOO_BIG is returned, the system typically knows what the - // actual MTU is, so there is no need to probe further. - // TODO(wub): Reduce max packet size to a safe default, or the actual MTU. - QUIC_DVLOG(1) << ENDPOINT - << " MTU probe packet too big, size:" << encrypted_length - << ", long_term_mtu_:" << long_term_mtu_; - mtu_discoverer_.Disable(); - mtu_discovery_alarm_->Cancel(); - // The write failed, but the writer is not blocked, so return true. - return true; + if (IsMsgTooBig(result)) { + if (is_mtu_discovery) { + // When MSG_TOO_BIG is returned, the system typically knows what the + // actual MTU is, so there is no need to probe further. + // TODO(wub): Reduce max packet size to a safe default, or the actual MTU. + QUIC_DVLOG(1) << ENDPOINT + << " MTU probe packet too big, size:" << encrypted_length + << ", long_term_mtu_:" << long_term_mtu_; + mtu_discoverer_.Disable(); + mtu_discovery_alarm_->Cancel(); + // The write failed, but the writer is not blocked, so return true. + return true; + } + if (use_path_validator_ && !send_on_current_path) { + // Only handle MSG_TOO_BIG as error on current path. + return true; + } } if (IsWriteError(result.status)) { @@ -3037,12 +3267,6 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) { packet_send_time = packet_send_time + result.send_time_offset; } - if (!sent_packet_manager_.give_sent_packet_to_debug_visitor_after_sent() && - debug_visitor_ != nullptr) { - // Pass the write result to the visitor. - debug_visitor_->OnPacketSent(*packet, packet->transmission_type, - packet_send_time); - } if (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA && !is_termination_packet) { // Start blackhole/path degrading detections if the sent packet is not @@ -3066,30 +3290,39 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) { QUIC_DVLOG(1) << ENDPOINT << "time we began writing last sent packet: " << packet_send_time.ToDebuggingValue(); - if (EnforceAntiAmplificationLimit()) { - // Include bytes sent even if they are not in flight. - bytes_sent_before_address_validation_ += encrypted_length; + if (!count_bytes_on_alternative_path_separately_) { + if (EnforceAntiAmplificationLimit()) { + // Include bytes sent even if they are not in flight. + default_path_.bytes_sent_before_address_validation += encrypted_length; + } + } else { + QUIC_CODE_COUNT_N(quic_count_bytes_on_alternative_path_seperately, 2, 5); + if (IsDefaultPath(default_path_.self_address, send_to_address)) { + if (EnforceAntiAmplificationLimit()) { + // Include bytes sent even if they are not in flight. + default_path_.bytes_sent_before_address_validation += encrypted_length; + } + } else { + MaybeUpdateBytesSentToAlternativeAddress(send_to_address, + encrypted_length); + } } // Do not measure rtt of this packet if it's not sent on current path. - const bool measure_rtt = send_to_address == peer_address(); - QUIC_DLOG_IF(INFO, !measure_rtt) + QUIC_DLOG_IF(INFO, !send_on_current_path) << ENDPOINT << " Sent packet " << packet->packet_number << " on a different path with remote address " << send_to_address << " while current path has peer address " << peer_address(); const bool in_flight = sent_packet_manager_.OnPacketSent( packet, packet_send_time, packet->transmission_type, - IsRetransmittable(*packet), measure_rtt); + IsRetransmittable(*packet), /*measure_rtt=*/send_on_current_path); QUIC_BUG_IF(default_enable_5rto_blackhole_detection_ && blackhole_detector_.IsDetectionInProgress() && !sent_packet_manager_.HasInFlightPackets()) << ENDPOINT << "Trying to start blackhole detection without no bytes in flight"; - if (sent_packet_manager_.give_sent_packet_to_debug_visitor_after_sent() && - debug_visitor_ != nullptr) { - QUIC_RELOADABLE_FLAG_COUNT_N( - quic_give_sent_packet_to_debug_visitor_after_sent, 1, 2); + if (debug_visitor_ != nullptr) { if (sent_packet_manager_.unacked_packets().empty()) { QUIC_BUG << "Unacked map is empty right after packet is sent"; } else { @@ -3143,7 +3376,7 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) { bool QuicConnection::MaybeHandleAeadConfidentialityLimits( const SerializedPacket& packet) { - if (!enable_aead_limits_) { + if (!version().UsesTls()) { return false; } @@ -3163,10 +3396,10 @@ bool QuicConnection::MaybeHandleAeadConfidentialityLimits( // sparse, so this might overcount, but doing a key update earlier than // necessary would only improve security and has negligible cost. if (packet.packet_number < lowest_packet_sent_in_current_key_phase_) { - const std::string error_details = quiche::QuicheStrCat( - "packet_number(", packet.packet_number.ToString(), - ") < lowest_packet_sent_in_current_key_phase_ (", - lowest_packet_sent_in_current_key_phase_.ToString(), ")"); + const std::string error_details = + absl::StrCat("packet_number(", packet.packet_number.ToString(), + ") < lowest_packet_sent_in_current_key_phase_ (", + lowest_packet_sent_in_current_key_phase_.ToString(), ")"); QUIC_BUG << error_details; CloseConnection(QUIC_INTERNAL_ERROR, error_details, ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); @@ -3205,7 +3438,7 @@ bool QuicConnection::MaybeHandleAeadConfidentialityLimits( if (num_packets_encrypted_in_current_key_phase >= confidentiality_limit) { // Reached the confidentiality limit without initiating a key update, // must close the connection. - const std::string error_details = quiche::QuicheStrCat( + const std::string error_details = absl::StrCat( "encrypter confidentiality limit reached: " "num_packets_encrypted_in_current_key_phase=", num_packets_encrypted_in_current_key_phase, @@ -3269,7 +3502,7 @@ void QuicConnection::FlushPackets() { "QuicConnection::FlushPackets."); if (HandleWriteBlocked()) { - DCHECK_EQ(WRITE_STATUS_BLOCKED, result.status) + QUICHE_DCHECK_EQ(WRITE_STATUS_BLOCKED, result.status) << "Unexpected flush result:" << result; QUIC_DLOG(INFO) << ENDPOINT << "Write blocked in FlushPackets."; return; @@ -3336,7 +3569,7 @@ void QuicConnection::OnWriteError(int error_code) { } write_error_occurred_ = true; - const std::string error_details = quiche::QuicheStrCat( + const std::string error_details = absl::StrCat( "Write failed with error: ", error_code, " (", strerror(error_code), ")"); QUIC_LOG_FIRST_N(ERROR, 2) << ENDPOINT << error_details; switch (error_code) { @@ -3346,7 +3579,7 @@ void QuicConnection::OnWriteError(int error_code) { break; default: // We can't send an error as the socket is presumably borked. - if (VersionHasIetfInvariantHeader(transport_version())) { + if (version().HasIetfInvariantHeader()) { QUIC_CODE_COUNT(quic_tear_down_local_connection_on_write_error_ietf); } else { QUIC_CODE_COUNT( @@ -3358,16 +3591,9 @@ void QuicConnection::OnWriteError(int error_code) { } QuicPacketBuffer QuicConnection::GetPacketBuffer() { - if (fix_out_of_order_sending_) { - if (version().CanSendCoalescedPackets() && !coalescing_done_) { - // Do not use writer's packet buffer for coalesced packets which may - // contain - // multiple QUIC packets. - return {nullptr, nullptr}; - } - } else if (version().CanSendCoalescedPackets() && !IsHandshakeConfirmed()) { - // Do not use writer's packet buffer for coalesced packets which may contain - // multiple QUIC packets. + if (version().CanSendCoalescedPackets() && !coalescing_done_) { + // Do not use writer's packet buffer for coalesced packets which may + // contain multiple QUIC packets. return {nullptr, nullptr}; } return writer_->GetNextWriteLocation(self_address().host(), peer_address()); @@ -3380,7 +3606,7 @@ void QuicConnection::OnSerializedPacket(SerializedPacket serialized_packet) { // loop here. // TODO(ianswett): This is actually an internal error, not an // encryption failure. - if (VersionHasIetfInvariantHeader(transport_version())) { + if (version().HasIetfInvariantHeader()) { QUIC_CODE_COUNT( quic_tear_down_local_connection_on_serialized_packet_ietf); } else { @@ -3407,7 +3633,7 @@ void QuicConnection::OnUnrecoverableError(QuicErrorCode error, const std::string& error_details) { // The packet creator or generator encountered an unrecoverable error: tear // down local connection state immediately. - if (VersionHasIetfInvariantHeader(transport_version())) { + if (version().HasIetfInvariantHeader()) { QUIC_CODE_COUNT( quic_tear_down_local_connection_on_unrecoverable_error_ietf); } else { @@ -3488,17 +3714,13 @@ void QuicConnection::OnPingTimeout() { !visitor_->ShouldKeepConnectionAlive()) { return; } - if (packet_creator_.let_connection_handle_pings()) { - SendPingAtLevel(use_encryption_level_context_ - ? framer().GetEncryptionLevelToSendApplicationData() - : encryption_level_); - } else { - visitor_->SendPing(); - } + SendPingAtLevel(use_encryption_level_context_ + ? framer().GetEncryptionLevelToSendApplicationData() + : encryption_level_); } void QuicConnection::SendAck() { - DCHECK(!SupportsMultiplePacketNumberSpaces()); + QUICHE_DCHECK(!SupportsMultiplePacketNumberSpaces()); QUIC_DVLOG(1) << ENDPOINT << "Sending an ACK proactively"; QuicFrames frames; frames.push_back(GetUpdatedAckFrame()); @@ -3527,8 +3749,8 @@ void QuicConnection::SendAck() { void QuicConnection::OnRetransmissionTimeout() { #ifndef NDEBUG if (sent_packet_manager_.unacked_packets().empty()) { - DCHECK(sent_packet_manager_.handshake_mode_disabled()); - DCHECK(!IsHandshakeComplete()); + QUICHE_DCHECK(sent_packet_manager_.handshake_mode_disabled()); + QUICHE_DCHECK(!IsHandshakeComplete()); } #endif if (!connected_) { @@ -3559,7 +3781,7 @@ void QuicConnection::OnRetransmissionTimeout() { !sent_packet_manager_.HasInFlightPackets() && blackhole_detector_.IsDetectionInProgress()) { // Stop detection in quiescence. - DCHECK_EQ(QuicSentPacketManager::LOSS_MODE, retransmission_mode); + QUICHE_DCHECK_EQ(QuicSentPacketManager::LOSS_MODE, retransmission_mode); blackhole_detector_.StopDetection(); } WriteIfNotBlocked(); @@ -3589,20 +3811,17 @@ void QuicConnection::OnRetransmissionTimeout() { QUIC_DLOG(INFO) << ENDPOINT << "No packet gets sent when timer fires in mode " << retransmission_mode << ", send PING"; - DCHECK_LT(0u, sent_packet_manager_.pending_timer_transmission_count()); - if (packet_creator_.let_connection_handle_pings()) { - EncryptionLevel level = encryption_level_; - PacketNumberSpace packet_number_space = NUM_PACKET_NUMBER_SPACES; - if (SupportsMultiplePacketNumberSpaces() && - sent_packet_manager_ - .GetEarliestPacketSentTimeForPto(&packet_number_space) - .IsInitialized()) { - level = QuicUtils::GetEncryptionLevel(packet_number_space); - } - SendPingAtLevel(level); - } else { - visitor_->SendPing(); + QUICHE_DCHECK_LT(0u, + sent_packet_manager_.pending_timer_transmission_count()); + EncryptionLevel level = encryption_level_; + PacketNumberSpace packet_number_space = NUM_PACKET_NUMBER_SPACES; + if (SupportsMultiplePacketNumberSpaces() && + sent_packet_manager_ + .GetEarliestPacketSentTimeForPto(&packet_number_space) + .IsInitialized()) { + level = QuicUtils::GetEncryptionLevel(packet_number_space); } + SendPingAtLevel(level); } if (retransmission_mode == QuicSentPacketManager::PTO_MODE) { sent_packet_manager_.AdjustPendingTimerTransmissions(); @@ -3644,7 +3863,7 @@ void QuicConnection::RemoveEncrypter(EncryptionLevel level) { void QuicConnection::SetDiversificationNonce( const DiversificationNonce& nonce) { - DCHECK_EQ(Perspective::IS_SERVER, perspective_); + QUICHE_DCHECK_EQ(Perspective::IS_SERVER, perspective_); packet_creator_.SetDiversificationNonce(nonce); } @@ -3698,6 +3917,9 @@ void QuicConnection::SetAlternativeDecrypter( void QuicConnection::InstallDecrypter( EncryptionLevel level, std::unique_ptr<QuicDecrypter> decrypter) { + if (level == ENCRYPTION_ZERO_RTT) { + had_zero_rtt_decrypter_ = true; + } framer_.InstallDecrypter(level, std::move(decrypter)); if (!undecryptable_packets_.empty() && !process_undecryptable_packets_alarm_->IsSet()) { @@ -3771,11 +3993,6 @@ void QuicConnection::MaybeProcessUndecryptablePackets() { encryption_level_ == ENCRYPTION_INITIAL) { return; } - const bool fix_undecryptable_packets = - GetQuicReloadableFlag(quic_fix_undecryptable_packets2); - if (fix_undecryptable_packets) { - QUIC_RELOADABLE_FLAG_COUNT(quic_fix_undecryptable_packets2); - } auto iter = undecryptable_packets_.begin(); while (connected_ && iter != undecryptable_packets_.end()) { @@ -3786,12 +4003,6 @@ void QuicConnection::MaybeProcessUndecryptablePackets() { return; } UndecryptablePacket* undecryptable_packet = &*iter; - if (!fix_undecryptable_packets) { - ++iter; - if (undecryptable_packet->processed) { - continue; - } - } QUIC_DVLOG(1) << ENDPOINT << "Attempting to process undecryptable packet"; if (debug_visitor_ != nullptr) { debug_visitor_->OnAttemptingToProcessUndecryptablePacket( @@ -3799,11 +4010,7 @@ void QuicConnection::MaybeProcessUndecryptablePackets() { } if (framer_.ProcessPacket(*undecryptable_packet->packet)) { QUIC_DVLOG(1) << ENDPOINT << "Processed undecryptable packet!"; - if (fix_undecryptable_packets) { - iter = undecryptable_packets_.erase(iter); - } else { - undecryptable_packet->processed = true; - } + iter = undecryptable_packets_.erase(iter); ++stats_.packets_processed; continue; } @@ -3816,25 +4023,10 @@ void QuicConnection::MaybeProcessUndecryptablePackets() { QUIC_DVLOG(1) << ENDPOINT << "Need to attempt to process this undecryptable packet later"; - if (fix_undecryptable_packets) { - ++iter; - } + ++iter; continue; } - if (fix_undecryptable_packets) { - iter = undecryptable_packets_.erase(iter); - } else { - undecryptable_packet->processed = true; - } - } - // Remove processed packets. We cannot remove elements in the while loop - // above because currently QuicCircularDeque does not support removing - // mid elements. - while (!fix_undecryptable_packets && !undecryptable_packets_.empty()) { - if (!undecryptable_packets_.front().processed) { - break; - } - undecryptable_packets_.pop_front(); + iter = undecryptable_packets_.erase(iter); } // Once forward secure encryption is in use, there will be no @@ -3890,28 +4082,46 @@ void QuicConnection::MaybeProcessCoalescedPackets() { void QuicConnection::CloseConnection( QuicErrorCode error, + const std::string& details, + ConnectionCloseBehavior connection_close_behavior) { + CloseConnection(error, NO_IETF_QUIC_ERROR, details, + connection_close_behavior); +} + +void QuicConnection::CloseConnection( + QuicErrorCode error, + QuicIetfTransportErrorCodes ietf_error, const std::string& error_details, ConnectionCloseBehavior connection_close_behavior) { - DCHECK(!error_details.empty()); + QUICHE_DCHECK(!error_details.empty()); if (!connected_) { QUIC_DLOG(INFO) << "Connection is already closed."; return; } - QUIC_DLOG(INFO) << ENDPOINT << "Closing connection: " << connection_id() - << ", with error: " << QuicErrorCodeToString(error) << " (" - << error << "), and details: " << error_details; + if (ietf_error != NO_IETF_QUIC_ERROR) { + QUIC_DLOG(INFO) << ENDPOINT << "Closing connection: " << connection_id() + << ", with wire error: " << ietf_error + << ", error: " << QuicErrorCodeToString(error) + << ", and details: " << error_details; + } else { + QUIC_DLOG(INFO) << ENDPOINT << "Closing connection: " << connection_id() + << ", with error: " << QuicErrorCodeToString(error) << " (" + << error << "), and details: " << error_details; + } if (connection_close_behavior != ConnectionCloseBehavior::SILENT_CLOSE) { - SendConnectionClosePacket(error, error_details); + SendConnectionClosePacket(error, ietf_error, error_details); } - TearDownLocalConnectionState(error, error_details, + TearDownLocalConnectionState(error, ietf_error, error_details, ConnectionCloseSource::FROM_SELF); } -void QuicConnection::SendConnectionClosePacket(QuicErrorCode error, - const std::string& details) { +void QuicConnection::SendConnectionClosePacket( + QuicErrorCode error, + QuicIetfTransportErrorCodes ietf_error, + const std::string& details) { // Always use the current path to send CONNECTION_CLOSE. QuicPacketCreator::ScopedPeerAddressContext context(&packet_creator_, peer_address()); @@ -3930,14 +4140,20 @@ void QuicConnection::SendConnectionClosePacket(QuicErrorCode error, // If there was a packet write error, write the smallest close possible. ScopedPacketFlusher flusher(this); // Always bundle an ACK with connection close for debugging purpose. - if (error != QUIC_PACKET_WRITE_ERROR && - !uber_received_packet_manager_.IsAckFrameEmpty( - QuicUtils::GetPacketNumberSpace(encryption_level_))) { + bool send_ack = error != QUIC_PACKET_WRITE_ERROR && + !uber_received_packet_manager_.IsAckFrameEmpty( + QuicUtils::GetPacketNumberSpace(encryption_level_)); + if (GetQuicReloadableFlag(quic_single_ack_in_packet2)) { + QUIC_RELOADABLE_FLAG_COUNT_N(quic_single_ack_in_packet2, 1, 2); + send_ack = !packet_creator_.has_ack() && send_ack; + } + if (send_ack) { SendAck(); } QuicConnectionCloseFrame* frame; - frame = new QuicConnectionCloseFrame(transport_version(), error, details, + frame = new QuicConnectionCloseFrame(transport_version(), error, ietf_error, + details, framer_.current_received_frame_type()); packet_creator_.ConsumeRetransmittableControlFrame(QuicFrame(frame)); packet_creator_.FlushCurrentPacket(); @@ -3972,9 +4188,14 @@ void QuicConnection::SendConnectionClosePacket(QuicErrorCode error, use_encryption_level_context_ ? this : nullptr, level); // Bundle an ACK of the corresponding packet number space for debugging // purpose. - if (error != QUIC_PACKET_WRITE_ERROR && - !uber_received_packet_manager_.IsAckFrameEmpty( - QuicUtils::GetPacketNumberSpace(encryption_level_))) { + bool send_ack = error != QUIC_PACKET_WRITE_ERROR && + !uber_received_packet_manager_.IsAckFrameEmpty( + QuicUtils::GetPacketNumberSpace(encryption_level_)); + if (GetQuicReloadableFlag(quic_single_ack_in_packet2)) { + QUIC_RELOADABLE_FLAG_COUNT_N(quic_single_ack_in_packet2, 2, 2); + send_ack = !packet_creator_.has_ack() && send_ack; + } + if (send_ack) { QuicFrames frames; frames.push_back(GetUpdatedAckFrame()); packet_creator_.FlushAckFrame(frames); @@ -3985,9 +4206,9 @@ void QuicConnection::SendConnectionClosePacket(QuicErrorCode error, visitor_->BeforeConnectionCloseSent(); } - auto* frame = - new QuicConnectionCloseFrame(transport_version(), error, details, - framer_.current_received_frame_type()); + auto* frame = new QuicConnectionCloseFrame( + transport_version(), error, ietf_error, details, + framer_.current_received_frame_type()); packet_creator_.ConsumeRetransmittableControlFrame(QuicFrame(frame)); packet_creator_.FlushCurrentPacket(); } @@ -4004,9 +4225,11 @@ void QuicConnection::SendConnectionClosePacket(QuicErrorCode error, void QuicConnection::TearDownLocalConnectionState( QuicErrorCode error, + QuicIetfTransportErrorCodes ietf_error, const std::string& error_details, ConnectionCloseSource source) { - QuicConnectionCloseFrame frame(transport_version(), error, error_details, + QuicConnectionCloseFrame frame(transport_version(), error, ietf_error, + error_details, framer_.current_received_frame_type()); return TearDownLocalConnectionState(frame, source); } @@ -4022,7 +4245,7 @@ void QuicConnection::TearDownLocalConnectionState( // If we are using a batch writer, flush packets queued in it, if any. FlushPackets(); connected_ = false; - DCHECK(visitor_ != nullptr); + QUICHE_DCHECK(visitor_ != nullptr); visitor_->OnConnectionClosed(frame, source); // LossDetectionTunerInterface::Finish() may be called from // sent_packet_manager_.OnConnectionClosed. Which may require the session to @@ -4034,6 +4257,9 @@ void QuicConnection::TearDownLocalConnectionState( // Cancel the alarms so they don't trigger any action now that the // connection is closed. CancelAllAlarms(); + if (use_path_validator_) { + CancelPathValidation(); + } } void QuicConnection::CancelAllAlarms() { @@ -4046,6 +4272,7 @@ void QuicConnection::CancelAllAlarms() { mtu_discovery_alarm_->Cancel(); process_undecryptable_packets_alarm_->Cancel(); discard_previous_one_rtt_keys_alarm_->Cancel(); + discard_zero_rtt_decryption_keys_alarm_->Cancel(); blackhole_detector_.StopDetection(); idle_network_detector_.StopDetection(); } @@ -4079,8 +4306,13 @@ void QuicConnection::SetNetworkTimeouts(QuicTime::Delta handshake_timeout, } void QuicConnection::SetPingAlarm() { - if (perspective_ == Perspective::IS_SERVER) { - // Only clients send pings to avoid NATs from timing out. + if (perspective_ == Perspective::IS_SERVER && + initial_retransmittable_on_wire_timeout_.IsInfinite()) { + // The PING alarm exists to support two features: + // 1) clients send PINGs every 15s to prevent NAT timeouts, + // 2) both clients and servers can send retransmittable on the wire PINGs + // (ROWP) while ShouldKeepConnectionAlive is true and there is no packets in + // flight. return; } if (!visitor_->ShouldKeepConnectionAlive()) { @@ -4093,17 +4325,22 @@ void QuicConnection::SetPingAlarm() { sent_packet_manager_.HasInFlightPackets() || retransmittable_on_wire_ping_count_ > GetQuicFlag(FLAGS_quic_max_retransmittable_on_wire_ping_count)) { - // Extend the ping alarm. - ping_alarm_->Update(clock_->ApproximateNow() + ping_timeout_, - QuicTime::Delta::FromSeconds(1)); + if (perspective_ == Perspective::IS_CLIENT) { + // Clients send 15s PINGs to avoid NATs from timing out. + ping_alarm_->Update(clock_->ApproximateNow() + ping_timeout_, + QuicTime::Delta::FromSeconds(1)); + } else { + // Servers do not send 15s PINGs. + ping_alarm_->Cancel(); + } return; } - DCHECK_LT(initial_retransmittable_on_wire_timeout_, ping_timeout_); + QUICHE_DCHECK_LT(initial_retransmittable_on_wire_timeout_, ping_timeout_); QuicTime::Delta retransmittable_on_wire_timeout = initial_retransmittable_on_wire_timeout_; int max_aggressive_retransmittable_on_wire_ping_count = GetQuicFlag(FLAGS_quic_max_aggressive_retransmittable_on_wire_ping_count); - DCHECK_LE(0, max_aggressive_retransmittable_on_wire_ping_count); + QUICHE_DCHECK_LE(0, max_aggressive_retransmittable_on_wire_ping_count); if (consecutive_retransmittable_on_wire_ping_count_ > max_aggressive_retransmittable_on_wire_ping_count) { // Exponentially back off the timeout if the number of consecutive @@ -4224,9 +4461,7 @@ QuicConnection::ScopedPacketFlusher::~ScopedPacketFlusher() { connection_->FlushCoalescedPacket(); } connection_->FlushPackets(); - if (connection_->fix_missing_initial_keys_ && !handshake_packet_sent_ && - connection_->handshake_packet_sent_) { - QUIC_RELOADABLE_FLAG_COUNT_N(quic_fix_missing_initial_keys2, 1, 2); + if (!handshake_packet_sent_ && connection_->handshake_packet_sent_) { // This would cause INITIAL key to be dropped. Drop keys here to avoid // missing the write keys in the middle of writing. connection_->visitor_->OnHandshakePacketSent(); @@ -4259,8 +4494,8 @@ QuicConnection::ScopedPacketFlusher::~ScopedPacketFlusher() { connection_->pending_retransmission_alarm_ = false; } } - DCHECK_EQ(flush_and_set_pending_retransmission_alarm_on_delete_, - !connection_->packet_creator_.PacketFlusherAttached()); + QUICHE_DCHECK_EQ(flush_and_set_pending_retransmission_alarm_on_delete_, + !connection_->packet_creator_.PacketFlusherAttached()); } QuicConnection::ScopedEncryptionLevelContext::ScopedEncryptionLevelContext( @@ -4337,7 +4572,7 @@ void QuicConnection::SetMtuDiscoveryTarget(QuicByteCount target) { QuicByteCount QuicConnection::GetLimitedMaxPacketSize( QuicByteCount suggested_max_packet_size) { - if (!peer_address_.IsInitialized()) { + if (!peer_address().IsInitialized()) { QUIC_BUG << "Attempted to use a connection without a valid peer address"; return suggested_max_packet_size; } @@ -4359,7 +4594,7 @@ QuicByteCount QuicConnection::GetLimitedMaxPacketSize( void QuicConnection::SendMtuDiscoveryPacket(QuicByteCount target_mtu) { // Currently, this limit is ensured by the caller. - DCHECK_EQ(target_mtu, GetLimitedMaxPacketSize(target_mtu)); + QUICHE_DCHECK_EQ(target_mtu, GetLimitedMaxPacketSize(target_mtu)); // Send the probe. packet_creator_.GenerateMtuDiscoveryPacket(target_mtu); @@ -4385,7 +4620,7 @@ bool QuicConnection::SendGenericPathProbePacket( QuicPacketWriter* probing_writer, const QuicSocketAddress& peer_address, bool is_response) { - DCHECK(peer_address.IsInitialized()); + QUICHE_DCHECK(peer_address.IsInitialized()); if (!connected_) { QUIC_BUG << "Not sending connectivity probing packet as connection is " << "disconnected."; @@ -4395,7 +4630,7 @@ bool QuicConnection::SendGenericPathProbePacket( // Server can use default packet writer to write packet. probing_writer = writer_; } - DCHECK(probing_writer); + QUICHE_DCHECK(probing_writer); if (probing_writer->IsWriteBlocked()) { QUIC_DLOG(INFO) @@ -4419,7 +4654,7 @@ bool QuicConnection::SendGenericPathProbePacket( // request or a response. probing_packet = packet_creator_.SerializeConnectivityProbingPacket(); } else if (is_response) { - DCHECK(!send_path_response_); + QUICHE_DCHECK(!send_path_response_); // IETF QUIC path response. // Respond to path probe request using IETF QUIC PATH_RESPONSE frame. probing_packet = @@ -4432,14 +4667,16 @@ bool QuicConnection::SendGenericPathProbePacket( // Send a path probe request using IETF QUIC PATH_CHALLENGE frame. transmitted_connectivity_probe_payload_ = std::make_unique<QuicPathFrameBuffer>(); + random_generator_->RandBytes(transmitted_connectivity_probe_payload_.get(), + sizeof(QuicPathFrameBuffer)); probing_packet = packet_creator_.SerializePathChallengeConnectivityProbingPacket( - transmitted_connectivity_probe_payload_.get()); + *transmitted_connectivity_probe_payload_); if (!probing_packet) { transmitted_connectivity_probe_payload_ = nullptr; } } - DCHECK_EQ(IsRetransmittable(*probing_packet), NO_RETRANSMITTABLE_DATA); + QUICHE_DCHECK_EQ(IsRetransmittable(*probing_packet), NO_RETRANSMITTABLE_DATA); return WritePacketUsingWriter(std::move(probing_packet), probing_writer, self_address(), peer_address, /*measure_rtt=*/true); @@ -4475,21 +4712,12 @@ bool QuicConnection::WritePacketUsingWriter( return false; } - if (!sent_packet_manager_.give_sent_packet_to_debug_visitor_after_sent() && - debug_visitor_ != nullptr) { - debug_visitor_->OnPacketSent(*packet, packet->transmission_type, - packet_send_time); - } - // Send in currrent path. Call OnPacketSent regardless of the write result. sent_packet_manager_.OnPacketSent(packet.get(), packet_send_time, packet->transmission_type, NO_RETRANSMITTABLE_DATA, measure_rtt); - if (sent_packet_manager_.give_sent_packet_to_debug_visitor_after_sent() && - debug_visitor_ != nullptr) { - QUIC_RELOADABLE_FLAG_COUNT_N( - quic_give_sent_packet_to_debug_visitor_after_sent, 2, 2); + if (debug_visitor_ != nullptr) { if (sent_packet_manager_.unacked_packets().empty()) { QUIC_BUG << "Unacked map is empty right after packet is sent"; } else { @@ -4524,7 +4752,7 @@ void QuicConnection::DisableMtuDiscovery() { } void QuicConnection::DiscoverMtu() { - DCHECK(!mtu_discovery_alarm_->IsSet()); + QUICHE_DCHECK(!mtu_discovery_alarm_->IsSet()); const QuicPacketNumber largest_sent_packet = sent_packet_manager_.GetLargestSentPacket(); @@ -4533,7 +4761,7 @@ void QuicConnection::DiscoverMtu() { SendMtuDiscoveryPacket( mtu_discoverer_.GetUpdatedMtuProbeSize(largest_sent_packet)); } - DCHECK(!mtu_discovery_alarm_->IsSet()); + QUICHE_DCHECK(!mtu_discovery_alarm_->IsSet()); } void QuicConnection::OnEffectivePeerMigrationValidated() { @@ -4542,42 +4770,219 @@ void QuicConnection::OnEffectivePeerMigrationValidated() { return; } highest_packet_sent_before_effective_peer_migration_.Clear(); + const bool send_address_token = + active_effective_peer_migration_type_ != PORT_CHANGE; active_effective_peer_migration_type_ = NO_CHANGE; + ++stats_.num_validated_peer_migration; + if (!validate_client_addresses_) { + return; + } + // Lift anti-amplification limit. + default_path_.validated = true; + alternative_path_.Clear(); + if (send_address_token) { + visitor_->MaybeSendAddressToken(); + } } void QuicConnection::StartEffectivePeerMigration(AddressChangeType type) { // TODO(fayang): Currently, all peer address change type are allowed. Need to // add a method ShouldAllowPeerAddressChange(PeerAddressChangeType type) to // determine whether |type| is allowed. + if (!validate_client_addresses_) { + if (type == NO_CHANGE) { + QUIC_BUG << "EffectivePeerMigration started without address change."; + return; + } + QUIC_DLOG(INFO) << ENDPOINT << "Effective peer's ip:port changed from " + << default_path_.peer_address.ToString() << " to " + << GetEffectivePeerAddressFromCurrentPacket().ToString() + << ", address change type is " << type + << ", migrating connection."; + + highest_packet_sent_before_effective_peer_migration_ = + sent_packet_manager_.GetLargestSentPacket(); + default_path_.peer_address = GetEffectivePeerAddressFromCurrentPacket(); + active_effective_peer_migration_type_ = type; + + OnConnectionMigration(); + return; + } + if (type == NO_CHANGE) { + UpdatePeerAddress(last_packet_source_address_); QUIC_BUG << "EffectivePeerMigration started without address change."; return; } + + // Action items: + // 1. Switch congestion controller; + // 2. Update default_path_ (addresses, validation and bytes accounting); + // 3. Save previous default path if needed; + // 4. Kick off reverse path validation if needed. + // Items 1 and 2 are must-to-do. Items 3 and 4 depends on if the new address + // is validated or not and which path the incoming packet is on. + + const QuicSocketAddress current_effective_peer_address = + GetEffectivePeerAddressFromCurrentPacket(); QUIC_DLOG(INFO) << ENDPOINT << "Effective peer's ip:port changed from " - << effective_peer_address_.ToString() << " to " - << GetEffectivePeerAddressFromCurrentPacket().ToString() + << default_path_.peer_address.ToString() << " to " + << current_effective_peer_address.ToString() << ", address change type is " << type << ", migrating connection."; - highest_packet_sent_before_effective_peer_migration_ = - sent_packet_manager_.GetLargestSentPacket(); - effective_peer_address_ = GetEffectivePeerAddressFromCurrentPacket(); + const QuicSocketAddress previous_direct_peer_address = direct_peer_address_; + PathState previous_default_path = std::move(default_path_); active_effective_peer_migration_type_ = type; + OnConnectionMigration(); + + // Update congestion controller if the address change type is not PORT_CHANGE. + if (type == PORT_CHANGE) { + QUICHE_DCHECK(previous_default_path.validated || + (alternative_path_.validated && + alternative_path_.send_algorithm != nullptr)); + // No need to store previous congestion controller because either the new + // default path is validated or the alternative path is validated and + // already has associated congestion controller. + } else { + previous_default_path.rtt_stats.emplace(); + previous_default_path.rtt_stats->CloneFrom( + *sent_packet_manager_.GetRttStats()); + // If the new peer address share the same IP with the alternative path, the + // connection should switch to the congestion controller of the alternative + // path. Otherwise, the connection should use a brand new one. + // In order to re-use existing code in sent_packet_manager_, reset + // congestion controller to initial state first and then change to the one + // on alternative path. + // TODO(danzh) combine these two steps into one after deprecating gQUIC. + previous_default_path.send_algorithm = + sent_packet_manager_.OnConnectionMigration( + /*reset_send_algorithm=*/true); + // OnConnectionMigration() might have marked in-flight packets to be + // retransmitted if there is any. + QUICHE_DCHECK(!sent_packet_manager_.HasInFlightPackets()); + // Stop detections in quiecense. + blackhole_detector_.StopDetection(); + + if (alternative_path_.peer_address.host() == + current_effective_peer_address.host() && + alternative_path_.send_algorithm != nullptr) { + // Update the default path with the congestion controller of the + // alternative path. + sent_packet_manager_.SetSendAlgorithm( + alternative_path_.send_algorithm.release()); + sent_packet_manager_.SetRttStats( + std::move(alternative_path_.rtt_stats).value()); + } + } - // TODO(wub): Move these calls to OnEffectivePeerMigrationValidated. - OnConnectionMigration(type); + // Update to the new peer address. + UpdatePeerAddress(last_packet_source_address_); + // Update the default path. + if (IsAlternativePath(last_packet_destination_address_, + current_effective_peer_address)) { + default_path_ = std::move(alternative_path_); + } else { + default_path_ = PathState(last_packet_destination_address_, + current_effective_peer_address); + // The path is considered validated if its peer IP address matches any + // validated path's peer IP address. + default_path_.validated = + (alternative_path_.peer_address.host() == + current_effective_peer_address.host() && + alternative_path_.validated) || + (previous_default_path.validated && type == PORT_CHANGE); + } + if (!current_incoming_packet_received_bytes_counted_) { + // Increment bytes counting on the new default path. + default_path_.bytes_received_before_address_validation += last_size_; + current_incoming_packet_received_bytes_counted_ = true; + } + + if (!previous_default_path.validated) { + // If the old address is under validation, cancel and fail it. Failing to + // validate the old path shouldn't take any effect. + QUIC_DVLOG(1) << "Cancel validation of previous peer address change to " + << previous_default_path.peer_address + << " upon peer migration to " << default_path_.peer_address; + path_validator_.CancelPathValidation(); + ++stats_.num_peer_migration_while_validating_default_path; + } + + // Clear alternative path if the new default path shares the same IP as the + // alternative path. + if (alternative_path_.peer_address.host() == + default_path_.peer_address.host()) { + alternative_path_.Clear(); + } + + if (default_path_.validated) { + QUIC_DVLOG(1) << "Peer migrated to a validated address."; + // No need to save previous default path, validate new peer address or + // update bytes sent/received. + if (!(previous_default_path.validated && type == PORT_CHANGE)) { + // The alternative path was validated because of proactive reverse path + // validation. + ++stats_.num_peer_migration_to_proactively_validated_address; + } + OnEffectivePeerMigrationValidated(); + return; + } + + // The new default address is not validated yet. Anti-amplification limit is + // enforced. + QUICHE_DCHECK(EnforceAntiAmplificationLimit()); + QUIC_DVLOG(1) << "Apply anti-amplification limit to effective peer address " + << default_path_.peer_address << " with " + << default_path_.bytes_sent_before_address_validation + << " bytes sent and " + << default_path_.bytes_received_before_address_validation + << " bytes received."; + + QUICHE_DCHECK(!alternative_path_.peer_address.IsInitialized() || + alternative_path_.peer_address.host() != + default_path_.peer_address.host()); + + // Save previous default path to the altenative path. + if (previous_default_path.validated) { + // The old path is a validated path which the connection might revert back + // to later. Store it as the alternative path. + alternative_path_ = std::move(previous_default_path); + QUICHE_DCHECK(alternative_path_.send_algorithm != nullptr); + } + + // If the new address is not validated and the connection is not already + // validating that address, a new reverse path validation is needed. + if (!path_validator_.IsValidatingPeerAddress( + current_effective_peer_address)) { + ++stats_.num_reverse_path_validtion_upon_migration; + ValidatePath(std::make_unique<ReversePathValidationContext>( + default_path_.self_address, peer_address(), + default_path_.peer_address, this), + std::make_unique<ReversePathValidationResultDelegate>( + this, previous_direct_peer_address)); + } else { + QUIC_DVLOG(1) << "Peer address " << default_path_.peer_address + << " is already under validation, wait for result."; + ++stats_.num_peer_migration_to_proactively_validated_address; + } } -void QuicConnection::OnConnectionMigration(AddressChangeType addr_change_type) { +void QuicConnection::OnConnectionMigration() { if (debug_visitor_ != nullptr) { const QuicTime now = clock_->ApproximateNow(); if (now >= stats_.handshake_completion_time) { debug_visitor_->OnPeerAddressChange( - addr_change_type, now - stats_.handshake_completion_time); + active_effective_peer_migration_type_, + now - stats_.handshake_completion_time); } } - visitor_->OnConnectionMigration(addr_change_type); - sent_packet_manager_.OnConnectionMigration(addr_change_type); + visitor_->OnConnectionMigration(active_effective_peer_migration_type_); + if (active_effective_peer_migration_type_ != PORT_CHANGE && + active_effective_peer_migration_type_ != IPV4_SUBNET_CHANGE && + !validate_client_addresses_) { + sent_packet_manager_.OnConnectionMigration(/*reset_send_algorithm=*/false); + } } bool QuicConnection::IsCurrentPacketConnectivityProbing() const { @@ -4620,7 +5025,7 @@ bool QuicConnection::MaybeConsiderAsMemoryCorruption( } void QuicConnection::MaybeSendProbingRetransmissions() { - DCHECK(fill_up_link_during_probing_); + QUICHE_DCHECK(fill_up_link_during_probing_); // Don't send probing retransmissions until the handshake has completed. if (!IsHandshakeComplete() || @@ -4661,10 +5066,69 @@ void QuicConnection::CheckIfApplicationLimited() { sent_packet_manager_.OnApplicationLimited(); } -void QuicConnection::UpdatePacketContent(QuicFrameType type) { +bool QuicConnection::UpdatePacketContent(QuicFrameType type) { + if (update_packet_content_returns_connected_) { + QUIC_RELOADABLE_FLAG_COUNT(quic_update_packet_content_returns_connected); + } + most_recent_frame_type_ = type; if (version().HasIetfQuicFrames()) { - MaybeStartIetfPeerMigration(type); - return; + if (!QuicUtils::IsProbingFrame(type)) { + MaybeStartIetfPeerMigration(); + return !update_packet_content_returns_connected_ || connected_; + } + QuicSocketAddress current_effective_peer_address = + GetEffectivePeerAddressFromCurrentPacket(); + if (!count_bytes_on_alternative_path_separately_ || + IsDefaultPath(last_packet_destination_address_, + last_packet_source_address_)) { + return !update_packet_content_returns_connected_ || connected_; + } + QUIC_CODE_COUNT_N(quic_count_bytes_on_alternative_path_seperately, 3, 5); + if (type == PATH_CHALLENGE_FRAME && + !IsAlternativePath(last_packet_destination_address_, + current_effective_peer_address)) { + QUIC_DVLOG(1) + << "The peer is probing a new path with effective peer address " + << current_effective_peer_address << ", self address " + << last_packet_destination_address_; + if (!validate_client_addresses_) { + alternative_path_ = PathState(last_packet_destination_address_, + current_effective_peer_address); + } else if (!default_path_.validated) { + // Skip reverse path validation because either handshake hasn't + // completed or the connection is validating the default path. Using + // PATH_CHALLENGE to validate alternative client address before + // handshake gets comfirmed is meaningless because anyone can respond to + // it. If the connection is validating the default path, this + // alternative path is currently the only validated path which shouldn't + // be overridden. + QUIC_DVLOG(1) << "The connection hasn't finished handshake or is " + "validating a recent peer address change."; + QUIC_BUG_IF(IsHandshakeConfirmed() && !alternative_path_.validated) + << "No validated peer address to send after handshake comfirmed."; + } else if (!IsReceivedPeerAddressValidated()) { + // Only override alternative path state upon receiving a PATH_CHALLENGE + // from an unvalidated peer address, and the connection isn't validating + // a recent peer migration. + alternative_path_ = PathState(last_packet_destination_address_, + current_effective_peer_address); + // Conditions to proactively validate peer address: + // The perspective is server + // The PATH_CHALLENGE is received on an unvalidated alternative path. + // The connection isn't validating migrated peer address, which is of + // higher prority. + QUIC_DVLOG(1) << "Proactively validate the effective peer address " + << current_effective_peer_address; + ValidatePath( + std::make_unique<ReversePathValidationContext>( + default_path_.self_address, current_effective_peer_address, + current_effective_peer_address, this), + std::make_unique<ReversePathValidationResultDelegate>( + this, peer_address())); + } + } + MaybeUpdateBytesReceivedFromAlternativeAddress(last_size_); + return !update_packet_content_returns_connected_ || connected_; } // Packet content is tracked to identify connectivity probe in non-IETF // version, where a connectivity probe is defined as @@ -4675,13 +5139,13 @@ void QuicConnection::UpdatePacketContent(QuicFrameType type) { // We have already learned the current packet is not a connectivity // probing packet. Peer migration should have already been started earlier // if needed. - return; + return !update_packet_content_returns_connected_ || connected_; } if (type == PING_FRAME) { if (current_packet_content_ == NO_FRAMES_RECEIVED) { current_packet_content_ = FIRST_FRAME_IS_PING; - return; + return !update_packet_content_returns_connected_ || connected_; } } @@ -4700,18 +5164,18 @@ void QuicConnection::UpdatePacketContent(QuicFrameType type) { << current_effective_peer_migration_type_; } else { is_current_packet_connectivity_probing_ = - (last_packet_source_address_ != peer_address_) || - (last_packet_destination_address_ != self_address_); + (last_packet_source_address_ != peer_address()) || + (last_packet_destination_address_ != default_path_.self_address); QUIC_DLOG_IF(INFO, is_current_packet_connectivity_probing_) << ENDPOINT << "Detected connectivity probing packet. " "last_packet_source_address_:" - << last_packet_source_address_ << ", peer_address_:" << peer_address_ + << last_packet_source_address_ << ", peer_address_:" << peer_address() << ", last_packet_destination_address_:" << last_packet_destination_address_ - << ", self_address_:" << self_address_; + << ", default path self_address :" << default_path_.self_address; } - return; + return !update_packet_content_returns_connected_ || connected_; } current_packet_content_ = NOT_PADDED_PING; @@ -4725,23 +5189,46 @@ void QuicConnection::UpdatePacketContent(QuicFrameType type) { } } current_effective_peer_migration_type_ = NO_CHANGE; + return !update_packet_content_returns_connected_ || connected_; } -void QuicConnection::MaybeStartIetfPeerMigration(QuicFrameType type) { - DCHECK(version().HasIetfQuicFrames()); - if (!start_peer_migration_earlier_ || QuicUtils::IsProbingFrame(type)) { +void QuicConnection::MaybeStartIetfPeerMigration() { + QUICHE_DCHECK(version().HasIetfQuicFrames()); + if (!start_peer_migration_earlier_) { return; } QUIC_CODE_COUNT(quic_start_peer_migration_earlier); + if (current_effective_peer_migration_type_ != NO_CHANGE && + !IsHandshakeConfirmed()) { + QUIC_LOG_EVERY_N_SEC(INFO, 60) + << ENDPOINT << "Effective peer's ip:port changed from " + << default_path_.peer_address.ToString() << " to " + << GetEffectivePeerAddressFromCurrentPacket().ToString() + << " before handshake confirmed, " + "current_effective_peer_migration_type_: " + << current_effective_peer_migration_type_; + // Peer migrated before handshake gets confirmed. + CloseConnection((current_effective_peer_migration_type_ == PORT_CHANGE + ? QUIC_PEER_PORT_CHANGE_HANDSHAKE_UNCONFIRMED + : QUIC_CONNECTION_MIGRATION_HANDSHAKE_UNCONFIRMED), + "Peer address changed before handshake is confirmed.", + ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); + return; + } + if (GetLargestReceivedPacket().IsInitialized() && last_header_.packet_number == GetLargestReceivedPacket()) { - UpdatePeerAddress(last_packet_source_address_); if (current_effective_peer_migration_type_ != NO_CHANGE) { // Start effective peer migration when the current packet contains a // non-probing frame. // TODO(fayang): When multiple packet number spaces is supported, only // start peer migration for the application data. + if (!validate_client_addresses_) { + UpdatePeerAddress(last_packet_source_address_); + } StartEffectivePeerMigration(current_effective_peer_migration_type_); + } else { + UpdatePeerAddress(last_packet_source_address_); } } current_effective_peer_migration_type_ = NO_CHANGE; @@ -4793,7 +5280,7 @@ void QuicConnection::SetTransmissionType(TransmissionType type) { } void QuicConnection::UpdateReleaseTimeIntoFuture() { - DCHECK(supports_release_time_); + QUICHE_DCHECK(supports_release_time_); const QuicTime::Delta prior_max_release_time = release_time_into_future_; release_time_into_future_ = std::max( @@ -4860,7 +5347,7 @@ EncryptionLevel QuicConnection::GetConnectionCloseEncryptionLevel() const { } if (framer_.HasEncrypterOfEncryptionLevel(ENCRYPTION_ZERO_RTT)) { if (encryption_level_ != ENCRYPTION_ZERO_RTT) { - if (VersionHasIetfInvariantHeader(transport_version())) { + if (version().HasIetfInvariantHeader()) { QUIC_CODE_COUNT(quic_wrong_encryption_level_connection_close_ietf); } else { QUIC_CODE_COUNT(quic_wrong_encryption_level_connection_close); @@ -4872,7 +5359,7 @@ EncryptionLevel QuicConnection::GetConnectionCloseEncryptionLevel() const { } void QuicConnection::MaybeBundleCryptoDataWithAcks() { - DCHECK(SupportsMultiplePacketNumberSpaces()); + QUICHE_DCHECK(SupportsMultiplePacketNumberSpaces()); if (IsHandshakeConfirmed()) { return; } @@ -4897,21 +5384,18 @@ void QuicConnection::MaybeBundleCryptoDataWithAcks() { return; } - if (check_keys_before_writing_) { - QUIC_RELOADABLE_FLAG_COUNT_N(quic_check_keys_before_writing, 1, 2); - if (!framer_.HasAnEncrypterForSpace(space)) { - QUIC_BUG << ENDPOINT - << "Try to bundle crypto with ACK with missing key of space " - << PacketNumberSpaceToString(space); - return; - } + if (!framer_.HasAnEncrypterForSpace(space)) { + QUIC_BUG << ENDPOINT + << "Try to bundle crypto with ACK with missing key of space " + << PacketNumberSpaceToString(space); + return; } sent_packet_manager_.RetransmitDataOfSpaceIfAny(space); } void QuicConnection::SendAllPendingAcks() { - DCHECK(SupportsMultiplePacketNumberSpaces()); + QUICHE_DCHECK(SupportsMultiplePacketNumberSpaces()); QUIC_DVLOG(1) << ENDPOINT << "Trying to send all pending ACKs"; ack_alarm_->Cancel(); QuicTime earliest_ack_timeout = @@ -4930,12 +5414,9 @@ void QuicConnection::SendAllPendingAcks() { if (!ack_timeout.IsInitialized()) { continue; } - if (check_keys_before_writing_) { - QUIC_RELOADABLE_FLAG_COUNT_N(quic_check_keys_before_writing, 2, 2); - if (!framer_.HasAnEncrypterForSpace(static_cast<PacketNumberSpace>(i))) { - // The key has been dropped. - continue; - } + if (!framer_.HasAnEncrypterForSpace(static_cast<PacketNumberSpace>(i))) { + // The key has been dropped. + continue; } if (ack_timeout > clock_->ApproximateNow() && ack_timeout > earliest_ack_timeout) { @@ -5051,17 +5532,14 @@ bool QuicConnection::FlushCoalescedPacket() { QUIC_BUG_IF(coalesced_packet_.length() > 0); return true; } - if (fix_missing_initial_keys_) { - QUIC_RELOADABLE_FLAG_COUNT_N(quic_fix_missing_initial_keys2, 2, 2); - if (coalesced_packet_.ContainsPacketOfEncryptionLevel(ENCRYPTION_INITIAL) && - !framer_.HasEncrypterOfEncryptionLevel(ENCRYPTION_INITIAL)) { - // Initial packet will be re-serialized. Neuter it in case initial key has - // been dropped. - QUIC_BUG << ENDPOINT - << "Coalescer contains initial packet while initial key has " - "been dropped."; - coalesced_packet_.NeuterInitialPacket(); - } + if (coalesced_packet_.ContainsPacketOfEncryptionLevel(ENCRYPTION_INITIAL) && + !framer_.HasEncrypterOfEncryptionLevel(ENCRYPTION_INITIAL)) { + // Initial packet will be re-serialized. Neuter it in case initial key has + // been dropped. + QUIC_BUG << ENDPOINT + << "Coalescer contains initial packet while initial key has " + "been dropped."; + coalesced_packet_.NeuterInitialPacket(); } if (coalesced_packet_.length() == 0) { return true; @@ -5085,13 +5563,6 @@ bool QuicConnection::FlushCoalescedPacket() { if (debug_visitor_ != nullptr) { debug_visitor_->OnCoalescedPacketSent(coalesced_packet_, length); } - if (!fix_missing_initial_keys_ && - coalesced_packet_.ContainsPacketOfEncryptionLevel( - ENCRYPTION_HANDSHAKE)) { - // This is only called in coalescer because all ENCRYPTION_HANDSHAKE - // packets go through the coalescer. - visitor_->OnHandshakePacketSent(); - } return true; } @@ -5115,17 +5586,25 @@ bool QuicConnection::FlushCoalescedPacket() { if (debug_visitor_ != nullptr) { debug_visitor_->OnCoalescedPacketSent(coalesced_packet_, length); } - if (!fix_missing_initial_keys_ && - coalesced_packet_.ContainsPacketOfEncryptionLevel(ENCRYPTION_HANDSHAKE)) { - // This is only called in coalescer because all ENCRYPTION_HANDSHAKE - // packets go through the coalescer. - visitor_->OnHandshakePacketSent(); - } // Account for added padding. if (length > coalesced_packet_.length()) { size_t padding_size = length - coalesced_packet_.length(); - if (EnforceAntiAmplificationLimit()) { - bytes_sent_before_address_validation_ += padding_size; + if (!count_bytes_on_alternative_path_separately_) { + if (EnforceAntiAmplificationLimit()) { + default_path_.bytes_sent_before_address_validation += padding_size; + } + } else { + QUIC_CODE_COUNT_N(quic_count_bytes_on_alternative_path_seperately, 5, 5); + if (IsDefaultPath(coalesced_packet_.self_address(), + coalesced_packet_.peer_address())) { + if (EnforceAntiAmplificationLimit()) { + // Include bytes sent even if they are not in flight. + default_path_.bytes_sent_before_address_validation += padding_size; + } + } else { + MaybeUpdateBytesSentToAlternativeAddress( + coalesced_packet_.peer_address(), padding_size); + } } stats_.bytes_sent += padding_size; if (coalesced_packet_.initial_packet() != nullptr && @@ -5207,14 +5686,16 @@ QuicPacketNumber QuicConnection::GetLargestReceivedPacket() const { bool QuicConnection::EnforceAntiAmplificationLimit() const { return version().SupportsAntiAmplificationLimit() && - perspective_ == Perspective::IS_SERVER && !address_validated_; + perspective_ == Perspective::IS_SERVER && !default_path_.validated; } +// TODO(danzh) Pass in path object or its reference of some sort to use this +// method to check anti-amplification limit on non-default path. bool QuicConnection::LimitedByAmplificationFactor() const { return EnforceAntiAmplificationLimit() && - bytes_sent_before_address_validation_ >= + default_path_.bytes_sent_before_address_validation >= anti_amplification_factor_ * - bytes_received_before_address_validation_; + default_path_.bytes_received_before_address_validation; } SerializedPacketFate QuicConnection::GetSerializedPacketFate( @@ -5224,7 +5705,7 @@ SerializedPacketFate QuicConnection::GetSerializedPacketFate( return DISCARD; } if (legacy_version_encapsulation_in_progress_) { - DCHECK(!is_mtu_discovery); + QUICHE_DCHECK(!is_mtu_discovery); return LEGACY_VERSION_ENCAPSULATE; } if (version().CanSendCoalescedPackets() && !coalescing_done_ && @@ -5234,13 +5715,10 @@ SerializedPacketFate QuicConnection::GetSerializedPacketFate( // packet (except MTU discovery packet). return COALESCE; } - if (fix_out_of_order_sending_) { - QUIC_RELOADABLE_FLAG_COUNT(quic_fix_out_of_order_sending2); - if (coalesced_packet_.length() > 0) { - // If the coalescer is not empty, let this packet go through coalescer - // to avoid potential out of order sending. - return COALESCE; - } + if (coalesced_packet_.length() > 0) { + // If the coalescer is not empty, let this packet go through coalescer + // to avoid potential out of order sending. + return COALESCE; } } if (!buffered_packets_.empty() || HandleWriteBlocked()) { @@ -5254,7 +5732,7 @@ bool QuicConnection::IsHandshakeComplete() const { } bool QuicConnection::IsHandshakeConfirmed() const { - DCHECK_EQ(PROTOCOL_TLS1_3, version().handshake_protocol); + QUICHE_DCHECK_EQ(PROTOCOL_TLS1_3, version().handshake_protocol); return visitor_->GetHandshakeState() == HANDSHAKE_CONFIRMED; } @@ -5318,13 +5796,12 @@ void QuicConnection::OnPathMtuReductionDetected() { void QuicConnection::OnHandshakeTimeout() { const QuicTime::Delta duration = clock_->ApproximateNow() - stats_.connection_creation_time; - std::string error_details = quiche::QuicheStrCat( + std::string error_details = absl::StrCat( "Handshake timeout expired after ", duration.ToDebuggingValue(), ". Timeout:", idle_network_detector_.handshake_timeout().ToDebuggingValue()); if (perspective() == Perspective::IS_CLIENT && version().UsesTls()) { - error_details = - quiche::QuicheStrCat(error_details, UndecryptablePacketsInfo()); + absl::StrAppend(&error_details, UndecryptablePacketsInfo()); } QUIC_DVLOG(1) << ENDPOINT << error_details; CloseConnection(QUIC_HANDSHAKE_TIMEOUT, error_details, @@ -5335,7 +5812,7 @@ void QuicConnection::OnIdleNetworkDetected() { const QuicTime::Delta duration = clock_->ApproximateNow() - idle_network_detector_.last_network_activity_time(); - std::string error_details = quiche::QuicheStrCat( + std::string error_details = absl::StrCat( "No recent network activity after ", duration.ToDebuggingValue(), ". Timeout:", idle_network_detector_.idle_network_timeout().ToDebuggingValue()); @@ -5349,8 +5826,8 @@ void QuicConnection::OnIdleNetworkDetected() { !has_consecutive_pto) { // Include stream information in error detail if there are open streams. QUIC_RELOADABLE_FLAG_COUNT(quic_add_stream_info_to_idle_close_detail); - error_details = quiche::QuicheStrCat( - error_details, ", ", visitor_->GetStreamsInfoForLogging()); + absl::StrAppend(&error_details, ", ", + visitor_->GetStreamsInfoForLogging()); } CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, error_details, ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); @@ -5400,7 +5877,7 @@ QuicTime QuicConnection::GetNetworkBlackholeDeadline() const { if (!ShouldDetectBlackhole()) { return QuicTime::Zero(); } - DCHECK_LT(0u, num_rtos_for_blackhole_detection_); + QUICHE_DCHECK_LT(0u, num_rtos_for_blackhole_detection_); return clock_->ApproximateNow() + sent_packet_manager_.GetNetworkBlackholeDelay( num_rtos_for_blackhole_detection_); @@ -5437,24 +5914,59 @@ QuicTime QuicConnection::GetRetransmissionDeadline() const { return sent_packet_manager_.GetRetransmissionTime(); } -void QuicConnection::SendPathChallenge(QuicPathFrameBuffer* data_buffer, - const QuicSocketAddress& self_address, - const QuicSocketAddress& peer_address, - QuicPacketWriter* writer) { +bool QuicConnection::SendPathChallenge( + const QuicPathFrameBuffer& data_buffer, + const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address, + const QuicSocketAddress& /*effective_peer_address*/, + QuicPacketWriter* writer) { if (writer == writer_) { - // It's on current path, add the PATH_CHALLENGE the same way as other - // frames. - QuicPacketCreator::ScopedPeerAddressContext context(&packet_creator_, - peer_address); - packet_creator_.AddPathChallengeFrame(data_buffer); - return; + { + // It's on current path, add the PATH_CHALLENGE the same way as other + // frames. + QuicPacketCreator::ScopedPeerAddressContext context(&packet_creator_, + peer_address); + // This may cause connection to be closed. + packet_creator_.AddPathChallengeFrame(data_buffer); + } + // Return outside of the scope so that the flush result can be reflected. + return connected_; } std::unique_ptr<SerializedPacket> probing_packet = packet_creator_.SerializePathChallengeConnectivityProbingPacket( data_buffer); - DCHECK_EQ(IsRetransmittable(*probing_packet), NO_RETRANSMITTABLE_DATA); + QUICHE_DCHECK_EQ(IsRetransmittable(*probing_packet), NO_RETRANSMITTABLE_DATA); + QUICHE_DCHECK_EQ(self_address, alternative_path_.self_address); WritePacketUsingWriter(std::move(probing_packet), writer, self_address, peer_address, /*measure_rtt=*/false); + return true; +} + +QuicTime QuicConnection::GetRetryTimeout( + const QuicSocketAddress& peer_address_to_use, + QuicPacketWriter* writer_to_use) const { + if (writer_to_use == writer_ && peer_address_to_use == peer_address()) { + return clock_->ApproximateNow() + sent_packet_manager_.GetPtoDelay(); + } + return clock_->ApproximateNow() + + QuicTime::Delta::FromMilliseconds(3 * kInitialRttMs); +} + +void QuicConnection::ValidatePath( + std::unique_ptr<QuicPathValidationContext> context, + std::unique_ptr<QuicPathValidator::ResultDelegate> result_delegate) { + QUICHE_DCHECK(use_path_validator_); + if (perspective_ == Perspective::IS_CLIENT && + !IsDefaultPath(context->self_address(), context->peer_address())) { + alternative_path_ = + PathState(context->self_address(), context->peer_address()); + } + if (path_validator_.HasPendingPathValidation()) { + // Cancel and fail any earlier validation. + path_validator_.CancelPathValidation(); + } + path_validator_.StartPathValidation(std::move(context), + std::move(result_delegate)); } bool QuicConnection::SendPathResponse(const QuicPathFrameBuffer& data_buffer, @@ -5462,10 +5974,40 @@ bool QuicConnection::SendPathResponse(const QuicPathFrameBuffer& data_buffer, // Send PATH_RESPONSE using the provided peer address. If the creator has been // using a different peer address, it will flush before and after serializing // the current PATH_RESPONSE. - QUIC_DVLOG(1) << ENDPOINT << "Send PATH_RESPONSE to " << peer_address_to_send; QuicPacketCreator::ScopedPeerAddressContext context(&packet_creator_, peer_address_to_send); - return packet_creator_.AddPathResponseFrame(data_buffer); + QUIC_DVLOG(1) << ENDPOINT << "Send PATH_RESPONSE to " << peer_address_to_send; + if (default_path_.self_address == last_packet_destination_address_) { + // The PATH_CHALLENGE is received on the default socket. Respond on the same + // socket. + return packet_creator_.AddPathResponseFrame(data_buffer); + } + + QUICHE_DCHECK_EQ(Perspective::IS_CLIENT, perspective_); + // This PATH_CHALLENGE is received on an alternative socket which should be + // used to send PATH_RESPONSE. + if (!path_validator_.HasPendingPathValidation() || + path_validator_.GetContext()->self_address() != + last_packet_destination_address_) { + // Ignore this PATH_CHALLENGE if it's received from an uninteresting socket. + return true; + } + QuicPacketWriter* writer = path_validator_.GetContext()->WriterToUse(); + + std::unique_ptr<SerializedPacket> probing_packet = + packet_creator_.SerializePathResponseConnectivityProbingPacket( + {data_buffer}, /*is_padded=*/true); + QUICHE_DCHECK_EQ(IsRetransmittable(*probing_packet), NO_RETRANSMITTABLE_DATA); + QUIC_DVLOG(1) << ENDPOINT + << "Send PATH_RESPONSE from alternative socket with address " + << last_packet_destination_address_; + // Ignore the return value to treat write error on the alternative writer as + // part of network error. If the writer becomes blocked, wait for the peer to + // send another PATH_CHALLENGE. + WritePacketUsingWriter(std::move(probing_packet), writer, + last_packet_destination_address_, peer_address_to_send, + /*measure_rtt=*/false); + return true; } void QuicConnection::UpdatePeerAddress(QuicSocketAddress peer_address) { @@ -5474,10 +6016,253 @@ void QuicConnection::UpdatePeerAddress(QuicSocketAddress peer_address) { } void QuicConnection::SendPingAtLevel(EncryptionLevel level) { - DCHECK(packet_creator_.let_connection_handle_pings()); ScopedEncryptionLevelContext context(this, level); SendControlFrame(QuicFrame(QuicPingFrame())); } +bool QuicConnection::HasPendingPathValidation() const { + QUICHE_DCHECK(use_path_validator_); + return path_validator_.HasPendingPathValidation(); +} + +QuicPathValidationContext* QuicConnection::GetPathValidationContext() const { + QUICHE_DCHECK(use_path_validator_); + return path_validator_.GetContext(); +} + +void QuicConnection::CancelPathValidation() { + QUICHE_DCHECK(use_path_validator_); + path_validator_.CancelPathValidation(); +} + +void QuicConnection::MigratePath(const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address, + QuicPacketWriter* writer, + bool owns_writer) { + if (!connected_) { + return; + } + const bool is_port_change = + QuicUtils::DetermineAddressChangeType(default_path_.self_address, + self_address) == PORT_CHANGE && + QuicUtils::DetermineAddressChangeType(default_path_.peer_address, + peer_address) == PORT_CHANGE; + SetSelfAddress(self_address); + UpdatePeerAddress(peer_address); + SetQuicPacketWriter(writer, owns_writer); + OnSuccessfulMigration(is_port_change); +} + +std::vector<QuicConnectionId> QuicConnection::GetActiveServerConnectionIds() + const { + return {server_connection_id_}; +} + +void QuicConnection::SetUnackedMapInitialCapacity() { + sent_packet_manager_.ReserveUnackedPacketsInitialCapacity( + GetUnackedMapInitialCapacity()); +} + +void QuicConnection::SetSourceAddressTokenToSend(absl::string_view token) { + QUICHE_DCHECK_EQ(perspective_, Perspective::IS_CLIENT); + if (!packet_creator_.HasRetryToken()) { + // Ignore received tokens (via NEW_TOKEN frame) from previous connections + // when a RETRY token has been received. + packet_creator_.SetRetryToken(std::string(token.data(), token.length())); + } +} + +void QuicConnection::MaybeUpdateBytesSentToAlternativeAddress( + const QuicSocketAddress& peer_address, + QuicByteCount sent_packet_size) { + if (!version().SupportsAntiAmplificationLimit() || + perspective_ != Perspective::IS_SERVER) { + return; + } + QUICHE_DCHECK(!IsDefaultPath(default_path_.self_address, peer_address)); + if (!IsAlternativePath(default_path_.self_address, peer_address)) { + QUIC_DLOG(INFO) << "Wrote to uninteresting peer address: " << peer_address + << " default direct_peer_address_ " << direct_peer_address_ + << " alternative path peer address " + << alternative_path_.peer_address; + return; + } + if (alternative_path_.validated) { + return; + } + if (alternative_path_.bytes_sent_before_address_validation >= + anti_amplification_factor_ * + alternative_path_.bytes_received_before_address_validation) { + QUIC_LOG_FIRST_N(WARNING, 100) + << "Server sent more data than allowed to unverified alternative " + "peer address " + << peer_address << " bytes sent " + << alternative_path_.bytes_sent_before_address_validation + << ", bytes received " + << alternative_path_.bytes_received_before_address_validation; + } + alternative_path_.bytes_sent_before_address_validation += sent_packet_size; +} + +void QuicConnection::MaybeUpdateBytesReceivedFromAlternativeAddress( + QuicByteCount received_packet_size) { + if (!version().SupportsAntiAmplificationLimit() || + perspective_ != Perspective::IS_SERVER || + !IsAlternativePath(last_packet_destination_address_, + GetEffectivePeerAddressFromCurrentPacket()) || + current_incoming_packet_received_bytes_counted_) { + return; + } + // Only update bytes received if this probing frame is received on the most + // recent alternative path. + QUICHE_DCHECK(!IsDefaultPath(last_packet_destination_address_, + GetEffectivePeerAddressFromCurrentPacket())); + if (!alternative_path_.validated) { + alternative_path_.bytes_received_before_address_validation += + received_packet_size; + } + current_incoming_packet_received_bytes_counted_ = true; +} + +bool QuicConnection::IsDefaultPath( + const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address) const { + return direct_peer_address_ == peer_address && + default_path_.self_address == self_address; +} + +bool QuicConnection::IsAlternativePath( + const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address) const { + return alternative_path_.peer_address == peer_address && + alternative_path_.self_address == self_address; +} + +void QuicConnection::PathState::Clear() { + self_address = QuicSocketAddress(); + peer_address = QuicSocketAddress(); + validated = false; + bytes_received_before_address_validation = 0; + bytes_sent_before_address_validation = 0; + send_algorithm = nullptr; + rtt_stats = absl::nullopt; +} + +QuicConnection::PathState::PathState(PathState&& other) { + *this = std::move(other); +} + +QuicConnection::PathState& QuicConnection::PathState::operator=( + QuicConnection::PathState&& other) { + if (this != &other) { + self_address = other.self_address; + peer_address = other.peer_address; + validated = other.validated; + bytes_received_before_address_validation = + other.bytes_received_before_address_validation; + bytes_sent_before_address_validation = + other.bytes_sent_before_address_validation; + send_algorithm = std::move(other.send_algorithm); + if (other.rtt_stats.has_value()) { + rtt_stats.emplace(); + rtt_stats->CloneFrom(other.rtt_stats.value()); + } else { + rtt_stats.reset(); + } + other.Clear(); + } + return *this; +} + +bool QuicConnection::IsReceivedPeerAddressValidated() const { + QuicSocketAddress current_effective_peer_address = + GetEffectivePeerAddressFromCurrentPacket(); + QUICHE_DCHECK(current_effective_peer_address.IsInitialized()); + return (alternative_path_.peer_address.host() == + current_effective_peer_address.host() && + alternative_path_.validated) || + (default_path_.validated && default_path_.peer_address.host() == + current_effective_peer_address.host()); +} + +QuicConnection::ReversePathValidationResultDelegate:: + ReversePathValidationResultDelegate( + QuicConnection* connection, + const QuicSocketAddress& direct_peer_address) + : QuicPathValidator::ResultDelegate(), + connection_(connection), + original_direct_peer_address_(direct_peer_address) {} + +void QuicConnection::ReversePathValidationResultDelegate:: + OnPathValidationSuccess( + std::unique_ptr<QuicPathValidationContext> context) { + QUIC_DLOG(INFO) << "Successfully validated new path " << *context; + if (connection_->IsDefaultPath(context->self_address(), + context->peer_address())) { + connection_->OnEffectivePeerMigrationValidated(); + } else { + QUICHE_DCHECK(connection_->IsAlternativePath( + context->self_address(), context->effective_peer_address())); + QUIC_DVLOG(1) << "Mark alternative peer address " + << context->effective_peer_address() << " validated."; + connection_->alternative_path_.validated = true; + } +} + +void QuicConnection::ReversePathValidationResultDelegate:: + OnPathValidationFailure( + std::unique_ptr<QuicPathValidationContext> context) { + if (!connection_->connected()) { + return; + } + QUIC_DLOG(INFO) << "Fail to validate new path " << *context; + if (connection_->IsDefaultPath(context->self_address(), + context->peer_address())) { + // Only act upon validation failure on the default path. + connection_->RestoreToLastValidatedPath(original_direct_peer_address_); + } else if (connection_->IsAlternativePath( + context->self_address(), context->effective_peer_address())) { + connection_->alternative_path_.Clear(); + } +} + +void QuicConnection::RestoreToLastValidatedPath( + QuicSocketAddress original_direct_peer_address) { + QUIC_DLOG(INFO) << "Switch back to use the old peer address " + << alternative_path_.peer_address; + if (!alternative_path_.validated) { + // If not validated by now, close connection silently so that the following + // packets received will be rejected. + CloseConnection(QUIC_INTERNAL_ERROR, + "No validated peer address to use after reverse path " + "validation failure.", + ConnectionCloseBehavior::SILENT_CLOSE); + return; + } + + // Revert congestion control context to old state. + sent_packet_manager_.OnConnectionMigration(true); + QUICHE_DCHECK(!sent_packet_manager_.HasInFlightPackets()); + // Stop detections in quiecense. + blackhole_detector_.StopDetection(); + + if (alternative_path_.send_algorithm != nullptr) { + sent_packet_manager_.SetSendAlgorithm( + alternative_path_.send_algorithm.release()); + sent_packet_manager_.SetRttStats(alternative_path_.rtt_stats.value()); + } else { + QUIC_BUG << "Fail to store congestion controller before migration."; + } + + UpdatePeerAddress(original_direct_peer_address); + default_path_ = std::move(alternative_path_); + + active_effective_peer_migration_type_ = NO_CHANGE; + ++stats_.num_invalid_peer_migration; + // The reverse path validation failed because of alarm firing, flush all the + // pending writes previously throttled by anti-amplification limit. + WriteIfNotBlocked(); +} + #undef ENDPOINT // undef for jumbo builds } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_connection.h b/chromium/net/third_party/quiche/src/quic/core/quic_connection.h index 35d15ffee92..33cf33b32c0 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_connection.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_connection.h @@ -26,35 +26,36 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/transport_parameters.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_max_streams_frame.h" -#include "net/third_party/quiche/src/quic/core/proto/cached_network_parameters_proto.h" -#include "net/third_party/quiche/src/quic/core/quic_alarm.h" -#include "net/third_party/quiche/src/quic/core/quic_alarm_factory.h" -#include "net/third_party/quiche/src/quic/core/quic_blocked_writer_interface.h" -#include "net/third_party/quiche/src/quic/core/quic_circular_deque.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_stats.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_idle_network_detector.h" -#include "net/third_party/quiche/src/quic/core/quic_mtu_discovery.h" -#include "net/third_party/quiche/src/quic/core/quic_network_blackhole_detector.h" -#include "net/third_party/quiche/src/quic/core/quic_one_block_arena.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_creator.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_sent_packet_manager.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/uber_received_packet_manager.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/crypto/transport_parameters.h" +#include "quic/core/frames/quic_ack_frequency_frame.h" +#include "quic/core/frames/quic_max_streams_frame.h" +#include "quic/core/proto/cached_network_parameters_proto.h" +#include "quic/core/quic_alarm.h" +#include "quic/core/quic_alarm_factory.h" +#include "quic/core/quic_blocked_writer_interface.h" +#include "quic/core/quic_circular_deque.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_connection_stats.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_idle_network_detector.h" +#include "quic/core/quic_mtu_discovery.h" +#include "quic/core/quic_network_blackhole_detector.h" +#include "quic/core/quic_one_block_arena.h" +#include "quic/core/quic_packet_creator.h" +#include "quic/core/quic_packet_writer.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_path_validator.h" +#include "quic/core/quic_sent_packet_manager.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/core/uber_received_packet_manager.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { @@ -99,6 +100,9 @@ class QUIC_EXPORT_PRIVATE QuicConnectionVisitorInterface { // Called when a HANDSHAKE_DONE frame has been received. virtual void OnHandshakeDoneReceived() = 0; + // Called when a NEW_TOKEN frame has been received. + virtual void OnNewTokenReceived(absl::string_view token) = 0; + // Called when a MAX_STREAMS frame has been received from the peer. virtual bool OnMaxStreamsFrame(const QuicMaxStreamsFrame& frame) = 0; @@ -157,9 +161,6 @@ class QUIC_EXPORT_PRIVATE QuicConnectionVisitorInterface { // retransmittable frame needs to be added. virtual void OnAckNeedsRetransmittableFrame() = 0; - // Called when a ping needs to be sent. - virtual void SendPing() = 0; - // Called when an AckFrequency frame need to be sent. virtual void SendAckFrequency(const QuicAckFrequencyFrame& frame) = 0; @@ -213,6 +214,15 @@ class QUIC_EXPORT_PRIVATE QuicConnectionVisitorInterface { // frame is serialized, but only on the server and only if forward secure // encryption has already been established. virtual void BeforeConnectionCloseSent() = 0; + + // Called by the server to validate |token| in received INITIAL packets. + // Consider the client address gets validated (and therefore remove + // amplification factor) once the |token| gets successfully validated. + virtual bool ValidateToken(absl::string_view token) const = 0; + + // Called by the server to send another token. + // Return false if the crypto stream fail to generate one. + virtual void MaybeSendAddressToken() = 0; }; // Interface which gets callbacks from the QuicConnection at interesting @@ -224,12 +234,6 @@ class QUIC_EXPORT_PRIVATE QuicConnectionDebugVisitor ~QuicConnectionDebugVisitor() override {} // Called when a packet has been sent. - // TODO(wub): Delete when deprecating - // --quic_give_sent_packet_to_debug_visitor_after_sent. - virtual void OnPacketSent(const SerializedPacket& /*serialized_packet*/, - TransmissionType /*transmission_type*/, - QuicTime /*sent_time*/) {} - virtual void OnPacketSent(QuicPacketNumber /*packet_number*/, QuicPacketLength /*packet_length*/, bool /*has_crypto_handshake*/, @@ -432,7 +436,8 @@ class QUIC_EXPORT_PRIVATE QuicConnection public QuicPacketCreator::DelegateInterface, public QuicSentPacketManager::NetworkChangeVisitor, public QuicNetworkBlackholeDetector::Delegate, - public QuicIdleNetworkDetector::Delegate { + public QuicIdleNetworkDetector::Delegate, + public QuicPathValidator::SendDelegate { public: // Constructs a new QuicConnection for |connection_id| and // |initial_peer_address| using |writer| to write packets. |owns_writer| @@ -524,6 +529,13 @@ class QUIC_EXPORT_PRIVATE QuicConnection QuicErrorCode error, const std::string& details, ConnectionCloseBehavior connection_close_behavior); + // Closes the connection, specifying the wire error code |ietf_error| + // explicitly. + virtual void CloseConnection( + QuicErrorCode error, + QuicIetfTransportErrorCodes ietf_error, + const std::string& details, + ConnectionCloseBehavior connection_close_behavior); QuicConnectionStats& mutable_stats() { return stats_; } @@ -570,7 +582,7 @@ class QUIC_EXPORT_PRIVATE QuicConnection // Set the packet writer. void SetQuicPacketWriter(QuicPacketWriter* writer, bool owns_writer) { - DCHECK(writer != nullptr); + QUICHE_DCHECK(writer != nullptr); if (writer_ != nullptr && owns_writer_) { delete writer_; } @@ -579,7 +591,9 @@ class QUIC_EXPORT_PRIVATE QuicConnection } // Set self address. - void SetSelfAddress(QuicSocketAddress address) { self_address_ = address; } + void SetSelfAddress(QuicSocketAddress address) { + default_path_.self_address = address; + } // The version of the protocol this connection is using. QuicTransportVersion transport_version() const { @@ -616,7 +630,7 @@ class QUIC_EXPORT_PRIVATE QuicConnection absl::string_view retry_without_tag) override; bool OnUnauthenticatedPublicHeader(const QuicPacketHeader& header) override; bool OnUnauthenticatedHeader(const QuicPacketHeader& header) override; - void OnDecryptedPacket(EncryptionLevel level) override; + void OnDecryptedPacket(size_t length, EncryptionLevel level) override; bool OnPacketHeader(const QuicPacketHeader& header) override; void OnCoalescedPacket(const QuicEncryptedPacket& packet) override; void OnUndecryptablePacket(const QuicEncryptedPacket& packet, @@ -706,16 +720,15 @@ class QUIC_EXPORT_PRIVATE QuicConnection // Used in Chromium, but not internally. // Must only be called before ping_alarm_ is set. void set_ping_timeout(QuicTime::Delta ping_timeout) { - DCHECK(!ping_alarm_->IsSet()); + QUICHE_DCHECK(!ping_alarm_->IsSet()); ping_timeout_ = ping_timeout; } const QuicTime::Delta ping_timeout() const { return ping_timeout_; } - // Used in Chromium, but not internally. // Sets an initial timeout for the ping alarm when there is no retransmittable // data in flight, allowing for a more aggressive ping alarm in that case. void set_initial_retransmittable_on_wire_timeout( QuicTime::Delta retransmittable_on_wire_timeout) { - DCHECK(!ping_alarm_->IsSet()); + QUICHE_DCHECK(!ping_alarm_->IsSet()); initial_retransmittable_on_wire_timeout_ = retransmittable_on_wire_timeout; } const QuicTime::Delta initial_retransmittable_on_wire_timeout() const { @@ -725,10 +738,12 @@ class QUIC_EXPORT_PRIVATE QuicConnection void set_creator_debug_delegate(QuicPacketCreator::DebugDelegate* visitor) { packet_creator_.set_debug_delegate(visitor); } - const QuicSocketAddress& self_address() const { return self_address_; } + const QuicSocketAddress& self_address() const { + return default_path_.self_address; + } const QuicSocketAddress& peer_address() const { return direct_peer_address_; } const QuicSocketAddress& effective_peer_address() const { - return effective_peer_address_; + return default_path_.peer_address; } QuicConnectionId connection_id() const { return server_connection_id_; } QuicConnectionId client_connection_id() const { @@ -746,7 +761,7 @@ class QUIC_EXPORT_PRIVATE QuicConnection // Must only be called on client connections. const ParsedQuicVersionVector& server_supported_versions() const { - DCHECK_EQ(Perspective::IS_CLIENT, perspective_); + QUICHE_DCHECK_EQ(Perspective::IS_CLIENT, perspective_); return server_supported_versions_; } @@ -798,10 +813,10 @@ class QUIC_EXPORT_PRIVATE QuicConnection void SetDefaultEncryptionLevel(EncryptionLevel level); // SetDecrypter sets the primary decrypter, replacing any that already exists. - // If an alternative decrypter is in place then the function DCHECKs. This is - // intended for cases where one knows that future packets will be using the - // new decrypter and the previous decrypter is now obsolete. |level| indicates - // the encryption level of the new decrypter. + // If an alternative decrypter is in place then the function QUICHE_DCHECKs. + // This is intended for cases where one knows that future packets will be + // using the new decrypter and the previous decrypter is now obsolete. |level| + // indicates the encryption level of the new decrypter. void SetDecrypter(EncryptionLevel level, std::unique_ptr<QuicDecrypter> decrypter); @@ -950,6 +965,8 @@ class QUIC_EXPORT_PRIVATE QuicConnection // connection ID lengths do not change. QuicPacketLength GetGuaranteedLargestMessagePayload() const; + void SetUnackedMapInitialCapacity(); + virtual int GetUnackedMapInitialCapacity() const { return kDefaultUnackedPacketsInitialCapacity; } @@ -1078,7 +1095,7 @@ class QUIC_EXPORT_PRIVATE QuicConnection void OnSuccessfulVersionNegotiation(); // Called when self migration succeeds after probing. - void OnSuccessfulMigrationAfterProbing(); + void OnSuccessfulMigration(bool is_port_change); // Called for QUIC+TLS versions when we send transport parameters. void OnTransportParametersSent( @@ -1104,21 +1121,40 @@ class QUIC_EXPORT_PRIVATE QuicConnection bool send_path_response() const { return send_path_response_; } + bool use_path_validator() const { return use_path_validator_; } + // If now is close to idle timeout, returns true and sends a connectivity // probing packet to test the connection for liveness. Otherwise, returns // false. bool MaybeTestLiveness(); + // QuicPathValidator::SendDelegate // Send PATH_CHALLENGE using the given path information. If |writer| is the // default writer, PATH_CHALLENGE can be bundled with other frames, and the // containing packet can be buffered if the writer is blocked. Otherwise, // PATH_CHALLENGE will be written in an individual packet and it will be // dropped if write fails. |data_buffer| will be populated with the payload // for future validation. - void SendPathChallenge(QuicPathFrameBuffer* data_buffer, + // Return false if the connection is closed thus the caller will not continue + // the validation, otherwise return true. + bool SendPathChallenge(const QuicPathFrameBuffer& data_buffer, const QuicSocketAddress& self_address, const QuicSocketAddress& peer_address, - QuicPacketWriter* writer); + const QuicSocketAddress& effective_peer_address, + QuicPacketWriter* writer) override; + // If |writer| is the default writer and |peer_address| is the same as + // peer_address(), return the PTO of this connection. Otherwise, return 3 * + // kInitialRtt. + QuicTime GetRetryTimeout(const QuicSocketAddress& peer_address_to_use, + QuicPacketWriter* writer_to_use) const override; + + // Start vaildating the path defined by |context| asynchronously and call the + // |result_delegate| after validation finishes. If the connection is + // validating another path, cancel and fail that validation before starting + // this one. + void ValidatePath( + std::unique_ptr<QuicPathValidationContext> context, + std::unique_ptr<QuicPathValidator::ResultDelegate> result_delegate); bool can_receive_ack_frequency_frame() const { return can_receive_ack_frequency_frame_; @@ -1128,8 +1164,6 @@ class QUIC_EXPORT_PRIVATE QuicConnection can_receive_ack_frequency_frame_ = true; } - bool check_keys_before_writing() const { return check_keys_before_writing_; } - bool is_processing_packet() const { return framer_.is_processing_packet(); } bool encrypted_control_frames() const { return encrypted_control_frames_; } @@ -1138,6 +1172,29 @@ class QUIC_EXPORT_PRIVATE QuicConnection return use_encryption_level_context_; } + bool HasPendingPathValidation() const; + + QuicPathValidationContext* GetPathValidationContext() const; + + void CancelPathValidation(); + + void MigratePath(const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address, + QuicPacketWriter* writer, + bool owns_writer); + + void SetSourceAddressTokenToSend(absl::string_view token); + + void SendPing() { + SendPingAtLevel(use_encryption_level_context_ + ? framer().GetEncryptionLevelToSendApplicationData() + : encryption_level_); + } + + virtual std::vector<QuicConnectionId> GetActiveServerConnectionIds() const; + + bool validate_client_address() const { return validate_client_addresses_; } + protected: // Calls cancel() on all the alarms owned by this connection. void CancelAllAlarms(); @@ -1187,7 +1244,11 @@ class QUIC_EXPORT_PRIVATE QuicConnection // Sends a connection close packet to the peer and includes an ACK if the ACK // is not empty, the |error| is not PACKET_WRITE_ERROR, and it fits. + // |ietf_error| may optionally be be used to directly specify the wire + // error code. Otherwise if |ietf_error| is NO_IETF_QUIC_ERROR, the + // QuicErrorCodeToTransportErrorCode mapping of |error| will be used. virtual void SendConnectionClosePacket(QuicErrorCode error, + QuicIetfTransportErrorCodes ietf_error, const std::string& details); // Returns true if the packet should be discarded and not sent. @@ -1200,9 +1261,9 @@ class QUIC_EXPORT_PRIVATE QuicConnection // Decides whether to send probing retransmissions, and does so if required. void MaybeSendProbingRetransmissions(); - // Notify various components(SendPacketManager, Session etc.) that this - // connection has been migrated. - virtual void OnConnectionMigration(AddressChangeType addr_change_type); + // Notify various components(Session etc.) that this connection has been + // migrated. + virtual void OnConnectionMigration(); // Return whether the packet being processed is a connectivity probing. // A packet is a connectivity probing if it is a padded ping packet with self @@ -1214,9 +1275,52 @@ class QUIC_EXPORT_PRIVATE QuicConnection // list. bool HandleWriteBlocked(); + // Whether connection enforces anti-amplification limit. + bool EnforceAntiAmplificationLimit() const; + + void AddBytesReceivedBeforeAddressValidation(size_t length) { + default_path_.bytes_received_before_address_validation += length; + } + private: friend class test::QuicConnectionPeer; + struct QUIC_EXPORT_PRIVATE PendingPathChallenge { + QuicPathFrameBuffer received_path_challenge; + QuicSocketAddress peer_address; + }; + + struct QUIC_EXPORT_PRIVATE PathState { + PathState(const QuicSocketAddress& alternative_self_address, + const QuicSocketAddress& alternative_peer_address) + : self_address(alternative_self_address), + peer_address(alternative_peer_address) {} + + PathState(PathState&& other); + + PathState& operator=(PathState&& other); + + // Reset all the members. + void Clear(); + + QuicSocketAddress self_address; + // The actual peer address behind the proxy if there is any. + QuicSocketAddress peer_address; + // True if the peer address has been validated. Address is considered + // validated when 1) an address token of the peer address is received and + // validated, or 2) a HANDSHAKE packet has been successfully processed on + // this path, or 3) a path validation on this path has succeeded. + bool validated = false; + // Used by the sever to apply anti-amplification limit after this path + // becomes the default path if |peer_address| hasn't been validated. + QuicByteCount bytes_received_before_address_validation = 0; + QuicByteCount bytes_sent_before_address_validation = 0; + // Points to the send algorithm on the old default path while connection is + // validating migrated peer address. Nullptr otherwise. + std::unique_ptr<SendAlgorithmInterface> send_algorithm; + absl::optional<RttStats> rtt_stats; + }; + using QueuedPacketList = std::list<SerializedPacket>; // BufferedPacket stores necessary information (encrypted buffer and self/peer @@ -1248,25 +1352,42 @@ class QUIC_EXPORT_PRIVATE QuicConnection struct QUIC_EXPORT_PRIVATE UndecryptablePacket { UndecryptablePacket(const QuicEncryptedPacket& packet, EncryptionLevel encryption_level) - : packet(packet.Clone()), - encryption_level(encryption_level), - processed(false) {} + : packet(packet.Clone()), encryption_level(encryption_level) {} std::unique_ptr<QuicEncryptedPacket> packet; EncryptionLevel encryption_level; - // This gets set to true if 1) connection sucessfully processed the packet - // or 2) connection failed to process the packet and will not try to process - // it later. - // TODO(fayang): Remove this when deprecating - // quic_fix_undecryptable_packets2. - bool processed; + }; + + // Handles the reverse path validation result depending on connection state: + // whether the connection is validating a migrated peer address or is + // validating an alternative path. + class ReversePathValidationResultDelegate + : public QuicPathValidator::ResultDelegate { + public: + ReversePathValidationResultDelegate( + QuicConnection* connection, + const QuicSocketAddress& direct_peer_address); + + void OnPathValidationSuccess( + std::unique_ptr<QuicPathValidationContext> context) override; + + void OnPathValidationFailure( + std::unique_ptr<QuicPathValidationContext> context) override; + + private: + QuicConnection* connection_; + QuicSocketAddress original_direct_peer_address_; }; // Notifies the visitor of the close and marks the connection as disconnected. // Does not send a connection close frame to the peer. It should only be // called by CloseConnection or OnConnectionCloseFrame, OnPublicResetPacket, // and OnAuthenticatedIetfStatelessResetPacket. + // |ietf_error| may optionally be be used to directly specify the wire + // error code. Otherwise if |ietf_error| is NO_IETF_QUIC_ERROR, the + // QuicErrorCodeToTransportErrorCode mapping of |error| will be used. void TearDownLocalConnectionState(QuicErrorCode error, + QuicIetfTransportErrorCodes ietf_error, const std::string& details, ConnectionCloseSource source); void TearDownLocalConnectionState(const QuicConnectionCloseFrame& frame, @@ -1370,7 +1491,8 @@ class QUIC_EXPORT_PRIVATE QuicConnection // starts effective peer migration if current packet is confirmed not a // connectivity probe and |current_effective_peer_migration_type_| indicates // effective peer address change. - void UpdatePacketContent(QuicFrameType type); + // Returns true if connection is still alive. + ABSL_MUST_USE_RESULT bool UpdatePacketContent(QuicFrameType type); // Called when last received ack frame has been processed. // |send_stop_waiting| indicates whether a stop waiting needs to be sent. @@ -1436,9 +1558,6 @@ class QUIC_EXPORT_PRIVATE QuicConnection // Whether incoming_connection_ids_ contains connection_id. bool HasIncomingConnectionId(QuicConnectionId connection_id); - // Whether connection enforces anti-amplification limit. - bool EnforceAntiAmplificationLimit() const; - // Whether connection is limited by amplification factor. bool LimitedByAmplificationFactor() const; @@ -1476,7 +1595,6 @@ class QUIC_EXPORT_PRIVATE QuicConnection // Validate connection IDs used during the handshake. Closes the connection // on validation failure. bool ValidateConfigConnectionIds(const QuicConfig& config); - bool ValidateConfigConnectionIdsOld(const QuicConfig& config); // Called when ACK alarm goes off. Try to bundle crypto data with ACKs. void MaybeBundleCryptoDataWithAcks(); @@ -1507,7 +1625,7 @@ class QUIC_EXPORT_PRIVATE QuicConnection // Called in IETF QUIC. Start peer migration if a non-probing frame is // received and the current packet number is largest received so far. - void MaybeStartIetfPeerMigration(QuicFrameType type); + void MaybeStartIetfPeerMigration(); // Send PATH_RESPONSE to the given peer address. bool SendPathResponse(const QuicPathFrameBuffer& data_buffer, @@ -1526,6 +1644,42 @@ class QUIC_EXPORT_PRIVATE QuicConnection const QuicSocketAddress& self_address, const QuicSocketAddress& peer_address, bool measure_rtt); + + // Increment bytes sent/received on the alternative path if the current packet + // is sent/received on that path. + void MaybeUpdateBytesSentToAlternativeAddress( + const QuicSocketAddress& peer_address, + QuicByteCount sent_packet_size); + void MaybeUpdateBytesReceivedFromAlternativeAddress( + QuicByteCount received_packet_size); + + // TODO(danzh) pass in PathState of the incoming packet or the packet sent + // once PathState is used in packet creator. Return true if the given self + // address and peer address is the same as the self address and peer address + // of the default path. + bool IsDefaultPath(const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address) const; + + // Return true if the |self_address| and |peer_address| is the same as the + // self address and peer address of the alternative path. + bool IsAlternativePath(const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address) const; + + // Restore connection default path and congestion control state to the last + // validated path and its state. Called after fail to validate peer address + // upon detecting a peer migration. + void RestoreToLastValidatedPath( + QuicSocketAddress original_direct_peer_address); + + // Return true if the current incoming packet is from a peer address that is + // validated. + bool IsReceivedPeerAddressValidated() const; + + // Called after receiving PATH_CHALLENGE. Update packet content and + // alternative path state if the current packet is from a non-default path. + // Return true if framer should continue processing the packet. + bool OnPathChallengeFrameInternal(const QuicPathChallengeFrame& frame); + QuicFramer framer_; // Contents received in the current packet, especially used to identify @@ -1560,19 +1714,14 @@ class QUIC_EXPORT_PRIVATE QuicConnection bool client_connection_id_is_set_; // Address on the last successfully processed packet received from the // direct peer. - QuicSocketAddress self_address_; - QuicSocketAddress peer_address_; // Other than initialization, do not modify it directly, use // UpdatePeerAddress() instead. QuicSocketAddress direct_peer_address_; - // Address of the endpoint behind the proxy if the connection is proxied. - // Otherwise it is the same as |peer_address_|. - // NOTE: Currently |effective_peer_address_| and |peer_address_| are always - // the same(the address of the direct peer), but soon we'll change - // |effective_peer_address_| to be the address of the endpoint behind the - // proxy if the connection is proxied. - QuicSocketAddress effective_peer_address_; + // The default path on which the endpoint sends non-probing packets. + // The send algorithm and RTT stats of this path are stored in + // |sent_packet_manager_| instead of in this object. + PathState default_path_; // Records change type when the effective peer initiates migration to a new // address. Reset to NO_CHANGE after effective peer migration is validated. @@ -1590,10 +1739,6 @@ class QUIC_EXPORT_PRIVATE QuicConnection // key update but before the first packet has been sent. QuicPacketNumber lowest_packet_sent_in_current_key_phase_; - // Honor the AEAD confidentiality and integrity limits by initiating key - // update (if allowed) and/or closing the connection, as necessary. - bool enable_aead_limits_; - // True if the last packet has gotten far enough in the framer to be // decrypted. bool last_packet_decrypted_; @@ -1697,6 +1842,10 @@ class QUIC_EXPORT_PRIVATE QuicConnection // An alarm that fires to discard keys for the previous key phase some time // after a key update has completed. QuicArenaScopedPtr<QuicAlarm> discard_previous_one_rtt_keys_alarm_; + // An alarm that fires to discard 0-RTT decryption keys some time after the + // first 1-RTT packet has been decrypted. Only used on server connections with + // TLS handshaker. + QuicArenaScopedPtr<QuicAlarm> discard_zero_rtt_decryption_keys_alarm_; // Neither visitor is owned by this class. QuicConnectionVisitorInterface* visitor_; QuicConnectionDebugVisitor* debug_visitor_; @@ -1831,8 +1980,7 @@ class QUIC_EXPORT_PRIVATE QuicConnection // Buffer outstanding PATH_CHALLENGEs if socket write is blocked, future // OnCanWrite will attempt to respond with PATH_RESPONSEs using the retained // payload and peer addresses. - QuicCircularDeque<std::pair<QuicPathFrameBuffer, QuicSocketAddress>> - pending_path_challenge_payloads_; + QuicCircularDeque<PendingPathChallenge> pending_path_challenge_payloads_; // Set of connection IDs that should be accepted as destination on // received packets. This is conceptually a set but is implemented as a @@ -1849,23 +1997,6 @@ class QUIC_EXPORT_PRIVATE QuicConnection // the source connection ID from that packet. absl::optional<QuicConnectionId> retry_source_connection_id_; - // Indicates whether received RETRY packets should be dropped. - bool drop_incoming_retry_packets_; - - // Bytes received before address validation. Only used when - // EnforceAntiAmplificationLimit returns true. - size_t bytes_received_before_address_validation_; - - // Bytes sent before address validation. Only used when - // EnforceAntiAmplificationLimit returns true. - size_t bytes_sent_before_address_validation_; - - // True if peer address has been validated. Address is considered validated - // when 1) an address token is received and validated, or 2) a HANDSHAKE - // packet has been successfully processed. Only used when - // EnforceAntiAmplificationLimit returns true. - bool address_validated_; - // Used to store content of packets which cannot be sent because of write // blocked. Packets' encrypted buffers are copied and owned by // buffered_packets_. From unacked_packet_map (and congestion control)'s @@ -1885,9 +2016,6 @@ class QUIC_EXPORT_PRIVATE QuicConnection bool blackhole_detection_disabled_ = false; - // True if this connection supports handshake done frame. - bool support_handshake_done_; - const bool default_enable_5rto_blackhole_detection_ = GetQuicReloadableFlag(quic_default_enable_5rto_blackhole_detection2); @@ -1912,6 +2040,11 @@ class QUIC_EXPORT_PRIVATE QuicConnection // --gfe2_reloadable_flag_quic_start_peer_migration_earlier. bool send_path_response_ = start_peer_migration_earlier_ && GetQuicReloadableFlag(quic_send_path_response); + + bool use_path_validator_ = + send_path_response_ && + GetQuicReloadableFlag(quic_pass_path_response_to_validator); + // True if AckFrequencyFrame is supported. bool can_receive_ack_frequency_frame_ = false; @@ -1929,18 +2062,44 @@ class QUIC_EXPORT_PRIVATE QuicConnection // Indicate whether AckFrequency frame has been sent. bool ack_frequency_sent_ = false; - const bool fix_missing_initial_keys_ = - GetQuicReloadableFlag(quic_fix_missing_initial_keys2); + // True if a 0-RTT decrypter was or is installed at some point in the + // connection's lifetime. + bool had_zero_rtt_decrypter_ = false; - const bool fix_out_of_order_sending_ = - GetQuicReloadableFlag(quic_fix_out_of_order_sending2); - - const bool check_keys_before_writing_ = - GetQuicReloadableFlag(quic_check_keys_before_writing); + // True after the first 1-RTT packet has successfully decrypted. + bool have_decrypted_first_one_rtt_packet_ = false; const bool encrypted_control_frames_; const bool use_encryption_level_context_; + + QuicPathValidator path_validator_; + + // Stores information of a path which maybe used as default path in the + // future. On the client side, it gets created when the client starts + // validating a new path and gets cleared once it becomes the default path or + // the path validation fails or replaced by a newer path of interest. On the + // server side, alternative_path gets created when server: 1) receives + // PATH_CHALLENGE on non-default path, or 2) switches to a not yet validated + // default path such that it needs to store the previous validated default + // path. + // Note that if alternative_path_ stores a validated path information (case + // 2), do not override it on receiving PATH_CHALLENGE (case 1). + PathState alternative_path_; + + // This field is used to debug b/177312785. + QuicFrameType most_recent_frame_type_; + + bool current_incoming_packet_received_bytes_counted_ = false; + + bool count_bytes_on_alternative_path_separately_ = + GetQuicReloadableFlag(quic_count_bytes_on_alternative_path_seperately); + + bool update_packet_content_returns_connected_ = + GetQuicReloadableFlag(quic_update_packet_content_returns_connected); + + // If true, upon seeing a new client address, validate the client address. + const bool validate_client_addresses_; }; } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_connection_id.cc b/chromium/net/third_party/quiche/src/quic/core/quic_connection_id.cc index e682ee32c6a..303db8f2069 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_connection_id.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_connection_id.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" +#include "quic/core/quic_connection_id.h" #include <cstddef> #include <cstdint> @@ -12,14 +12,14 @@ #include "absl/strings/escaping.h" #include "third_party/boringssl/src/include/openssl/siphash.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/quiche_endian.h" namespace quic { @@ -68,7 +68,7 @@ QuicConnectionId::QuicConnectionId(const char* data, uint8_t length) { return; } data_long_ = reinterpret_cast<char*>(malloc(length_)); - CHECK_NE(nullptr, data_long_); + QUICHE_CHECK_NE(nullptr, data_long_); memcpy(data_long_, data, length_); } @@ -113,13 +113,13 @@ void QuicConnectionId::set_length(uint8_t length) { // Copy data from data_short_ to data_long_. memcpy(temporary_data, data_short_, length_); data_long_ = reinterpret_cast<char*>(malloc(length)); - CHECK_NE(nullptr, data_long_); + QUICHE_CHECK_NE(nullptr, data_long_); memcpy(data_long_, temporary_data, length_); } else { // Resize data_long_. char* realloc_result = reinterpret_cast<char*>(realloc(data_long_, length)); - CHECK_NE(nullptr, realloc_result); + QUICHE_CHECK_NE(nullptr, realloc_result); data_long_ = realloc_result; } } else if (length_ > sizeof(data_short_)) { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_connection_id.h b/chromium/net/third_party/quiche/src/quic/core/quic_connection_id.h index d3706c83020..771203314ad 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_connection_id.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_connection_id.h @@ -8,8 +8,8 @@ #include <string> #include <vector> -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_uint128.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_connection_id_manager.cc b/chromium/net/third_party/quiche/src/quic/core/quic_connection_id_manager.cc new file mode 100644 index 00000000000..adf8ebae71f --- /dev/null +++ b/chromium/net/third_party/quiche/src/quic/core/quic_connection_id_manager.cc @@ -0,0 +1,389 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "quic/core/quic_connection_id_manager.h" +#include <cstdio> + +#include "quic/core/quic_clock.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_uint128.h" + +namespace quic { + +QuicConnectionIdData::QuicConnectionIdData( + const QuicConnectionId& connection_id, + uint64_t sequence_number, + QuicUint128 stateless_reset_token) + : connection_id(connection_id), + sequence_number(sequence_number), + stateless_reset_token(stateless_reset_token) {} + +namespace { + +class RetirePeerIssuedConnectionIdAlarm : public QuicAlarm::Delegate { + public: + explicit RetirePeerIssuedConnectionIdAlarm( + QuicConnectionIdManagerVisitorInterface* visitor) + : visitor_(visitor) {} + RetirePeerIssuedConnectionIdAlarm(const RetirePeerIssuedConnectionIdAlarm&) = + delete; + RetirePeerIssuedConnectionIdAlarm& operator=( + const RetirePeerIssuedConnectionIdAlarm&) = delete; + + void OnAlarm() override { visitor_->OnPeerIssuedConnectionIdRetired(); } + + private: + QuicConnectionIdManagerVisitorInterface* visitor_; +}; + +std::vector<QuicConnectionIdData>::const_iterator FindConnectionIdData( + const std::vector<QuicConnectionIdData>& cid_data_vector, + const QuicConnectionId& cid) { + return std::find_if(cid_data_vector.begin(), cid_data_vector.end(), + [&cid](const QuicConnectionIdData& cid_data) { + return cid == cid_data.connection_id; + }); +} + +std::vector<QuicConnectionIdData>::iterator FindConnectionIdData( + std::vector<QuicConnectionIdData>* cid_data_vector, + const QuicConnectionId& cid) { + return std::find_if(cid_data_vector->begin(), cid_data_vector->end(), + [&cid](const QuicConnectionIdData& cid_data) { + return cid == cid_data.connection_id; + }); +} + +} // namespace + +QuicPeerIssuedConnectionIdManager::QuicPeerIssuedConnectionIdManager( + size_t active_connection_id_limit, + const QuicConnectionId& initial_peer_issued_connection_id, + const QuicClock* clock, + QuicAlarmFactory* alarm_factory, + QuicConnectionIdManagerVisitorInterface* visitor) + : active_connection_id_limit_(active_connection_id_limit), + clock_(clock), + retire_connection_id_alarm_(alarm_factory->CreateAlarm( + new RetirePeerIssuedConnectionIdAlarm(visitor))) { + QUICHE_DCHECK_GE(active_connection_id_limit_, 2u); + QUICHE_DCHECK(!initial_peer_issued_connection_id.IsEmpty()); + active_connection_id_data_.emplace_back(initial_peer_issued_connection_id, + /*sequence_number=*/0u, + QuicUint128()); + recent_new_connection_id_sequence_numbers_.Add(0u, 1u); +} + +QuicPeerIssuedConnectionIdManager::~QuicPeerIssuedConnectionIdManager() { + retire_connection_id_alarm_->Cancel(); +} + +bool QuicPeerIssuedConnectionIdManager::IsConnectionIdNew( + const QuicNewConnectionIdFrame& frame) { + auto is_old_connection_id = [&frame](const QuicConnectionIdData& cid_data) { + return cid_data.connection_id == frame.connection_id; + }; + if (std::any_of(active_connection_id_data_.begin(), + active_connection_id_data_.end(), is_old_connection_id)) { + return false; + } + if (std::any_of(unused_connection_id_data_.begin(), + unused_connection_id_data_.end(), is_old_connection_id)) { + return false; + } + if (std::any_of(to_be_retired_connection_id_data_.begin(), + to_be_retired_connection_id_data_.end(), + is_old_connection_id)) { + return false; + } + return true; +} + +void QuicPeerIssuedConnectionIdManager::PrepareToRetireConnectionIdPriorTo( + uint64_t retire_prior_to, + std::vector<QuicConnectionIdData>* cid_data_vector) { + auto it2 = cid_data_vector->begin(); + for (auto it = cid_data_vector->begin(); it != cid_data_vector->end(); ++it) { + if (it->sequence_number >= retire_prior_to) { + *it2++ = *it; + } else { + to_be_retired_connection_id_data_.push_back(*it); + if (!retire_connection_id_alarm_->IsSet()) { + retire_connection_id_alarm_->Set(clock_->ApproximateNow()); + } + } + } + cid_data_vector->erase(it2, cid_data_vector->end()); +} + +QuicErrorCode QuicPeerIssuedConnectionIdManager::OnNewConnectionIdFrame( + const QuicNewConnectionIdFrame& frame, + std::string* error_detail) { + if (recent_new_connection_id_sequence_numbers_.Contains( + frame.sequence_number)) { + // This frame has a recently seen sequence number. Ignore. + return QUIC_NO_ERROR; + } + if (!IsConnectionIdNew(frame)) { + *error_detail = + "Received a NEW_CONNECTION_ID frame that reuses a previously seen Id."; + return IETF_QUIC_PROTOCOL_VIOLATION; + } + + recent_new_connection_id_sequence_numbers_.AddOptimizedForAppend( + frame.sequence_number, frame.sequence_number + 1); + + if (recent_new_connection_id_sequence_numbers_.Size() > + kMaxNumConnectionIdSequenceNumberIntervals) { + *error_detail = + "Too many disjoint connection Id sequence number intervals."; + return IETF_QUIC_PROTOCOL_VIOLATION; + } + + // QuicFramer::ProcessNewConnectionIdFrame guarantees that + // frame.sequence_number >= frame.retire_prior_to, and hence there is no need + // to check that. + if (frame.sequence_number < max_new_connection_id_frame_retire_prior_to_) { + // Later frames have asked for retirement of the current frame. + to_be_retired_connection_id_data_.emplace_back(frame.connection_id, + frame.sequence_number, + frame.stateless_reset_token); + if (!retire_connection_id_alarm_->IsSet()) { + retire_connection_id_alarm_->Set(clock_->ApproximateNow()); + } + return QUIC_NO_ERROR; + } + if (frame.retire_prior_to > max_new_connection_id_frame_retire_prior_to_) { + max_new_connection_id_frame_retire_prior_to_ = frame.retire_prior_to; + PrepareToRetireConnectionIdPriorTo(frame.retire_prior_to, + &active_connection_id_data_); + PrepareToRetireConnectionIdPriorTo(frame.retire_prior_to, + &unused_connection_id_data_); + } + + if (active_connection_id_data_.size() + unused_connection_id_data_.size() >= + active_connection_id_limit_) { + *error_detail = "Peer provides more connection IDs than the limit."; + return QUIC_CONNECTION_ID_LIMIT_ERROR; + } + + unused_connection_id_data_.emplace_back( + frame.connection_id, frame.sequence_number, frame.stateless_reset_token); + return QUIC_NO_ERROR; +} + +const QuicConnectionIdData* +QuicPeerIssuedConnectionIdManager::ConsumeOneUnusedConnectionId() { + if (unused_connection_id_data_.empty()) { + return nullptr; + } + active_connection_id_data_.push_back(unused_connection_id_data_.back()); + unused_connection_id_data_.pop_back(); + return &active_connection_id_data_.back(); +} + +void QuicPeerIssuedConnectionIdManager::PrepareToRetireActiveConnectionId( + const QuicConnectionId& cid) { + auto it = FindConnectionIdData(active_connection_id_data_, cid); + if (it == active_connection_id_data_.end()) { + // The cid has already been retired. + return; + } + to_be_retired_connection_id_data_.push_back(*it); + active_connection_id_data_.erase(it); + if (!retire_connection_id_alarm_->IsSet()) { + retire_connection_id_alarm_->Set(clock_->ApproximateNow()); + } +} + +bool QuicPeerIssuedConnectionIdManager::IsConnectionIdActive( + const QuicConnectionId& cid) const { + return FindConnectionIdData(active_connection_id_data_, cid) != + active_connection_id_data_.end(); +} + +std::vector<uint64_t> QuicPeerIssuedConnectionIdManager:: + ConsumeToBeRetiredConnectionIdSequenceNumbers() { + std::vector<uint64_t> result; + for (auto const& cid_data : to_be_retired_connection_id_data_) { + result.push_back(cid_data.sequence_number); + } + to_be_retired_connection_id_data_.clear(); + return result; +} + +void QuicPeerIssuedConnectionIdManager::ReplaceConnectionId( + const QuicConnectionId& old_connection_id, + const QuicConnectionId& new_connection_id) { + auto it1 = + FindConnectionIdData(&active_connection_id_data_, old_connection_id); + if (it1 != active_connection_id_data_.end()) { + it1->connection_id = new_connection_id; + return; + } + auto it2 = FindConnectionIdData(&to_be_retired_connection_id_data_, + old_connection_id); + if (it2 != to_be_retired_connection_id_data_.end()) { + it2->connection_id = new_connection_id; + } +} + +namespace { + +class RetireSelfIssuedConnectionIdAlarmDelegate : public QuicAlarm::Delegate { + public: + explicit RetireSelfIssuedConnectionIdAlarmDelegate( + QuicSelfIssuedConnectionIdManager* connection_id_manager) + : connection_id_manager_(connection_id_manager) {} + RetireSelfIssuedConnectionIdAlarmDelegate( + const RetireSelfIssuedConnectionIdAlarmDelegate&) = delete; + RetireSelfIssuedConnectionIdAlarmDelegate& operator=( + const RetireSelfIssuedConnectionIdAlarmDelegate&) = delete; + + void OnAlarm() override { connection_id_manager_->RetireConnectionId(); } + + private: + QuicSelfIssuedConnectionIdManager* connection_id_manager_; +}; + +} // namespace + +QuicSelfIssuedConnectionIdManager::QuicSelfIssuedConnectionIdManager( + size_t active_connection_id_limit, + const QuicConnectionId& initial_connection_id, + const QuicClock* clock, + QuicAlarmFactory* alarm_factory, + QuicConnectionIdManagerVisitorInterface* visitor) + : active_connection_id_limit_(active_connection_id_limit), + clock_(clock), + visitor_(visitor), + retire_connection_id_alarm_(alarm_factory->CreateAlarm( + new RetireSelfIssuedConnectionIdAlarmDelegate(this))), + last_connection_id_(initial_connection_id), + next_connection_id_sequence_number_(1u) { + active_connection_ids_.emplace_back(initial_connection_id, 0u); +} + +QuicSelfIssuedConnectionIdManager::~QuicSelfIssuedConnectionIdManager() { + retire_connection_id_alarm_->Cancel(); +} + +QuicConnectionId QuicSelfIssuedConnectionIdManager::GenerateNewConnectionId( + const QuicConnectionId& old_connection_id) const { + return QuicUtils::CreateReplacementConnectionId(old_connection_id); +} + +QuicNewConnectionIdFrame +QuicSelfIssuedConnectionIdManager::IssueNewConnectionId() { + QuicNewConnectionIdFrame frame; + frame.connection_id = GenerateNewConnectionId(last_connection_id_); + frame.sequence_number = next_connection_id_sequence_number_++; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(frame.connection_id); + visitor_->OnNewConnectionIdIssued(frame.connection_id); + active_connection_ids_.emplace_back(frame.connection_id, + frame.sequence_number); + frame.retire_prior_to = active_connection_ids_.front().second; + last_connection_id_ = frame.connection_id; + return frame; +} + +QuicNewConnectionIdFrame +QuicSelfIssuedConnectionIdManager::IssueNewConnectionIdForPreferredAddress() { + QuicNewConnectionIdFrame frame = IssueNewConnectionId(); + QUICHE_DCHECK_EQ(frame.sequence_number, 1u); + return frame; +} + +QuicErrorCode QuicSelfIssuedConnectionIdManager::OnRetireConnectionIdFrame( + const QuicRetireConnectionIdFrame& frame, + QuicTime::Delta pto_delay, + std::string* error_detail) { + QUICHE_DCHECK(!active_connection_ids_.empty()); + if (frame.sequence_number > active_connection_ids_.back().second) { + *error_detail = "To be retired connecton ID is never issued."; + return IETF_QUIC_PROTOCOL_VIOLATION; + } + + auto it = + std::find_if(active_connection_ids_.begin(), active_connection_ids_.end(), + [&frame](const std::pair<QuicConnectionId, uint64_t>& p) { + return p.second == frame.sequence_number; + }); + // The corresponding connection ID has been retired. Ignore. + if (it == active_connection_ids_.end()) { + return QUIC_NO_ERROR; + } + + if (to_be_retired_connection_ids_.size() + active_connection_ids_.size() >= + kMaxNumConnectonIdsInUse) { + // Close connection if the number of connection IDs in use will exeed the + // limit, i.e., peer retires connection ID too fast. + *error_detail = "There are too many connection IDs in use."; + return QUIC_TOO_MANY_CONNECTION_ID_WAITING_TO_RETIRE; + } + + QuicTime retirement_time = clock_->ApproximateNow() + 3 * pto_delay; + if (!to_be_retired_connection_ids_.empty()) { + retirement_time = + std::max(retirement_time, to_be_retired_connection_ids_.back().second); + } + + to_be_retired_connection_ids_.emplace_back(it->first, retirement_time); + if (!retire_connection_id_alarm_->IsSet()) { + retire_connection_id_alarm_->Set(retirement_time); + } + + active_connection_ids_.erase(it); + MaybeSendNewConnectionIds(); + + return QUIC_NO_ERROR; +} + +std::vector<QuicConnectionId> +QuicSelfIssuedConnectionIdManager::GetUnretiredConnectionIds() const { + std::vector<QuicConnectionId> unretired_ids; + for (const auto& cid_pair : to_be_retired_connection_ids_) { + unretired_ids.push_back(cid_pair.first); + } + for (const auto& cid_pair : active_connection_ids_) { + unretired_ids.push_back(cid_pair.first); + } + return unretired_ids; +} + +void QuicSelfIssuedConnectionIdManager::RetireConnectionId() { + if (to_be_retired_connection_ids_.empty()) { + QUIC_BUG + << "retire_connection_id_alarm fired but there is no connection ID " + "to be retired."; + return; + } + QuicTime now = clock_->ApproximateNow(); + auto it = to_be_retired_connection_ids_.begin(); + do { + visitor_->OnSelfIssuedConnectionIdRetired(it->first); + ++it; + } while (it != to_be_retired_connection_ids_.end() && it->second <= now); + to_be_retired_connection_ids_.erase(to_be_retired_connection_ids_.begin(), + it); + // Set the alarm again if there is another connection ID to be removed. + if (!to_be_retired_connection_ids_.empty()) { + retire_connection_id_alarm_->Set( + to_be_retired_connection_ids_.front().second); + } +} + +void QuicSelfIssuedConnectionIdManager::MaybeSendNewConnectionIds() { + while (active_connection_ids_.size() < active_connection_id_limit_) { + QuicNewConnectionIdFrame frame = IssueNewConnectionId(); + if (!visitor_->SendNewConnectionId(frame)) { + break; + } + } +} + +} // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_connection_id_manager.h b/chromium/net/third_party/quiche/src/quic/core/quic_connection_id_manager.h new file mode 100644 index 00000000000..3f29cd4932c --- /dev/null +++ b/chromium/net/third_party/quiche/src/quic/core/quic_connection_id_manager.h @@ -0,0 +1,164 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// QuicPeerIssuedConnectionIdManager handles the states associated with receving +// and retiring peer issued connection Ids. +// QuicSelfIssuedConnectionIdManager handles the states associated with +// connection Ids issued by the current end point. + +#ifndef QUICHE_QUIC_CORE_QUIC_CONNECTION_ID_MANAGER_H_ +#define QUICHE_QUIC_CORE_QUIC_CONNECTION_ID_MANAGER_H_ + +#include <cstddef> +#include <memory> +#include "quic/core/frames/quic_new_connection_id_frame.h" +#include "quic/core/frames/quic_retire_connection_id_frame.h" +#include "quic/core/quic_alarm.h" +#include "quic/core/quic_alarm_factory.h" +#include "quic/core/quic_clock.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_interval_set.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_uint128.h" + +namespace quic { + +struct QUIC_EXPORT_PRIVATE QuicConnectionIdData { + QuicConnectionIdData(const QuicConnectionId& connection_id, + uint64_t sequence_number, + QuicUint128 stateless_reset_token); + + QuicConnectionId connection_id; + uint64_t sequence_number; + QuicUint128 stateless_reset_token; +}; + +// Used by QuicSelfIssuedConnectionIdManager +// and QuicPeerIssuedConnectionIdManager. +class QUIC_EXPORT_PRIVATE QuicConnectionIdManagerVisitorInterface { + public: + virtual ~QuicConnectionIdManagerVisitorInterface() = default; + virtual void OnPeerIssuedConnectionIdRetired() = 0; + virtual bool SendNewConnectionId(const QuicNewConnectionIdFrame& frame) = 0; + virtual void OnNewConnectionIdIssued( + const QuicConnectionId& connection_id) = 0; + virtual void OnSelfIssuedConnectionIdRetired( + const QuicConnectionId& connection_id) = 0; +}; + +class QUIC_EXPORT_PRIVATE QuicPeerIssuedConnectionIdManager { + public: + // QuicPeerIssuedConnectionIdManager should be instantiated only when a peer + // issued-non empty connection ID is received. + QuicPeerIssuedConnectionIdManager( + size_t active_connection_id_limit, + const QuicConnectionId& initial_peer_issued_connection_id, + const QuicClock* clock, + QuicAlarmFactory* alarm_factory, + QuicConnectionIdManagerVisitorInterface* visitor); + + ~QuicPeerIssuedConnectionIdManager(); + + QuicErrorCode OnNewConnectionIdFrame(const QuicNewConnectionIdFrame& frame, + std::string* error_detail); + + // Returns the data associated with an unused connection Id. After the call, + // the Id is marked as used. Returns nullptr if there is no unused connection + // Id. + const QuicConnectionIdData* ConsumeOneUnusedConnectionId(); + + // Add the connection Id to the pending retirement connection Id list. + void PrepareToRetireActiveConnectionId(const QuicConnectionId& cid); + + bool IsConnectionIdActive(const QuicConnectionId& cid) const; + + // Get the sequence numbers of all the connection Ids pending retirement when + // it is safe to retires these Ids. + std::vector<uint64_t> ConsumeToBeRetiredConnectionIdSequenceNumbers(); + + // If old_connection_id is still tracked by QuicPeerIssuedConnectionIdManager, + // replace it with new_connection_id. Otherwise, this is a no-op. + void ReplaceConnectionId(const QuicConnectionId& old_connection_id, + const QuicConnectionId& new_connection_id); + + private: + friend class QuicConnectionIdManagerPeer; + + bool IsConnectionIdNew(const QuicNewConnectionIdFrame& frame); + + void PrepareToRetireConnectionIdPriorTo( + uint64_t retire_prior_to, + std::vector<QuicConnectionIdData>* cid_data_vector); + + size_t active_connection_id_limit_; + const QuicClock* clock_; + std::unique_ptr<QuicAlarm> retire_connection_id_alarm_; + std::vector<QuicConnectionIdData> active_connection_id_data_; + std::vector<QuicConnectionIdData> unused_connection_id_data_; + std::vector<QuicConnectionIdData> to_be_retired_connection_id_data_; + // Track sequence numbers of recent NEW_CONNECTION_ID frames received from + // the peer. + QuicIntervalSet<uint64_t> recent_new_connection_id_sequence_numbers_; + uint64_t max_new_connection_id_frame_retire_prior_to_ = 0u; +}; + +class QUIC_EXPORT_PRIVATE QuicSelfIssuedConnectionIdManager { + public: + QuicSelfIssuedConnectionIdManager( + size_t active_connection_id_limit, + const QuicConnectionId& initial_connection_id, + const QuicClock* clock, + QuicAlarmFactory* alarm_factory, + QuicConnectionIdManagerVisitorInterface* visitor); + + virtual ~QuicSelfIssuedConnectionIdManager(); + + QuicNewConnectionIdFrame IssueNewConnectionIdForPreferredAddress(); + + QuicErrorCode OnRetireConnectionIdFrame( + const QuicRetireConnectionIdFrame& frame, + QuicTime::Delta pto_delay, + std::string* error_detail); + + std::vector<QuicConnectionId> GetUnretiredConnectionIds() const; + + // Called when the retire_connection_id alarm_ fires. Removes the to be + // retired connection ID locally. + void RetireConnectionId(); + + // Sends new connection IDs if more can be sent. + void MaybeSendNewConnectionIds(); + + virtual QuicConnectionId GenerateNewConnectionId( + const QuicConnectionId& old_connection_id) const; + + private: + friend class QuicConnectionIdManagerPeer; + + QuicNewConnectionIdFrame IssueNewConnectionId(); + + // This should be set to the min of: + // (1) # of connection atcive IDs that peer can maintain. + // (2) maximum # of active connection IDs self plans to issue. + size_t active_connection_id_limit_; + const QuicClock* clock_; + QuicConnectionIdManagerVisitorInterface* visitor_; + // This tracks connection IDs issued to the peer but not retired by the peer. + // Each pair is a connection ID and its sequence number. + std::vector<std::pair<QuicConnectionId, uint64_t>> active_connection_ids_; + // This tracks connection IDs retired by the peer but has not been retired + // locally. Each pair is a connection ID and the time by which it should be + // retired. + std::vector<std::pair<QuicConnectionId, QuicTime>> + to_be_retired_connection_ids_; + // An alarm that fires when a connection ID should be retired. + std::unique_ptr<QuicAlarm> retire_connection_id_alarm_; + // State of the last issued connection Id. + QuicConnectionId last_connection_id_; + uint64_t next_connection_id_sequence_number_; +}; + +} // namespace quic + +#endif // QUICHE_QUIC_CORE_QUIC_CONNECTION_ID_MANAGER_H_ diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_connection_id_manager_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_connection_id_manager_test.cc new file mode 100644 index 00000000000..b9ca45f5472 --- /dev/null +++ b/chromium/net/third_party/quiche/src/quic/core/quic_connection_id_manager_test.cc @@ -0,0 +1,961 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "quic/core/quic_connection_id_manager.h" +#include <cstddef> + +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_error_codes.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" +#include "quic/test_tools/quic_test_utils.h" + +namespace quic { + +class QuicConnectionIdManagerPeer { + public: + static QuicAlarm* GetRetirePeerIssuedConnectionIdAlarm( + QuicPeerIssuedConnectionIdManager* manager) { + return manager->retire_connection_id_alarm_.get(); + } + + static QuicAlarm* GetRetireSelfIssuedConnectionIdAlarm( + QuicSelfIssuedConnectionIdManager* manager) { + return manager->retire_connection_id_alarm_.get(); + } +}; + +namespace { + +using ::quic::test::IsError; +using ::quic::test::IsQuicNoError; +using ::quic::test::TestConnectionId; +using ::testing::_; +using ::testing::ElementsAre; +using ::testing::IsNull; +using ::testing::Return; +using ::testing::StrictMock; + +class TestPeerIssuedConnectionIdManagerVisitor + : public QuicConnectionIdManagerVisitorInterface { + public: + void SetPeerIssuedConnectionIdManager( + QuicPeerIssuedConnectionIdManager* peer_issued_connection_id_manager) { + peer_issued_connection_id_manager_ = peer_issued_connection_id_manager; + } + + void OnPeerIssuedConnectionIdRetired() override { + // Replace current connection Id if it has been retired. + if (!peer_issued_connection_id_manager_->IsConnectionIdActive( + current_peer_issued_connection_id_)) { + current_peer_issued_connection_id_ = + peer_issued_connection_id_manager_->ConsumeOneUnusedConnectionId() + ->connection_id; + } + // Retire all the to-be-retired connection Ids. + most_recent_retired_connection_id_sequence_numbers_ = + peer_issued_connection_id_manager_ + ->ConsumeToBeRetiredConnectionIdSequenceNumbers(); + } + + const std::vector<uint64_t>& + most_recent_retired_connection_id_sequence_numbers() { + return most_recent_retired_connection_id_sequence_numbers_; + } + + void SetCurrentPeerConnectionId(QuicConnectionId cid) { + current_peer_issued_connection_id_ = cid; + } + + const QuicConnectionId& GetCurrentPeerConnectionId() { + return current_peer_issued_connection_id_; + } + + bool SendNewConnectionId(const QuicNewConnectionIdFrame& /*frame*/) override { + return false; + } + void OnNewConnectionIdIssued( + const QuicConnectionId& /*connection_id*/) override {} + void OnSelfIssuedConnectionIdRetired( + const QuicConnectionId& /*connection_id*/) override {} + + private: + QuicPeerIssuedConnectionIdManager* peer_issued_connection_id_manager_ = + nullptr; + QuicConnectionId current_peer_issued_connection_id_; + std::vector<uint64_t> most_recent_retired_connection_id_sequence_numbers_; +}; + +class QuicPeerIssuedConnectionIdManagerTest : public QuicTest { + public: + QuicPeerIssuedConnectionIdManagerTest() + : peer_issued_cid_manager_(/*active_connection_id_limit=*/2, + initial_connection_id_, + &clock_, + &alarm_factory_, + &cid_manager_visitor_) { + clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(10)); + cid_manager_visitor_.SetPeerIssuedConnectionIdManager( + &peer_issued_cid_manager_); + cid_manager_visitor_.SetCurrentPeerConnectionId(initial_connection_id_); + retire_peer_issued_cid_alarm_ = + QuicConnectionIdManagerPeer::GetRetirePeerIssuedConnectionIdAlarm( + &peer_issued_cid_manager_); + } + + protected: + MockClock clock_; + test::MockAlarmFactory alarm_factory_; + TestPeerIssuedConnectionIdManagerVisitor cid_manager_visitor_; + QuicConnectionId initial_connection_id_ = TestConnectionId(0); + QuicPeerIssuedConnectionIdManager peer_issued_cid_manager_; + QuicAlarm* retire_peer_issued_cid_alarm_ = nullptr; + std::string error_details_; +}; + +TEST_F(QuicPeerIssuedConnectionIdManagerTest, + ConnectionIdSequenceWhenMigrationSucceed) { + { + // Receives CID #1 from peer. + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(1); + frame.sequence_number = 1u; + frame.retire_prior_to = 0u; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(frame.connection_id); + ASSERT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsQuicNoError()); + + // Start to use CID #1 for alternative path. + const QuicConnectionIdData* aternative_connection_id_data = + peer_issued_cid_manager_.ConsumeOneUnusedConnectionId(); + ASSERT_THAT(aternative_connection_id_data, testing::NotNull()); + EXPECT_EQ(aternative_connection_id_data->connection_id, + TestConnectionId(1)); + EXPECT_EQ(aternative_connection_id_data->stateless_reset_token, + frame.stateless_reset_token); + + // Connection migration succeed. Prepares to retire CID #0. + peer_issued_cid_manager_.PrepareToRetireActiveConnectionId( + TestConnectionId(0)); + cid_manager_visitor_.SetCurrentPeerConnectionId(TestConnectionId(1)); + ASSERT_TRUE(retire_peer_issued_cid_alarm_->IsSet()); + alarm_factory_.FireAlarm(retire_peer_issued_cid_alarm_); + EXPECT_THAT(cid_manager_visitor_ + .most_recent_retired_connection_id_sequence_numbers(), + ElementsAre(0u)); + } + + { + // Receives CID #2 from peer since CID #0 is retired. + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(2); + frame.sequence_number = 2u; + frame.retire_prior_to = 1u; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(frame.connection_id); + ASSERT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsQuicNoError()); + // Start to use CID #2 for alternative path. + peer_issued_cid_manager_.ConsumeOneUnusedConnectionId(); + // Connection migration succeed. Prepares to retire CID #1. + peer_issued_cid_manager_.PrepareToRetireActiveConnectionId( + TestConnectionId(1)); + cid_manager_visitor_.SetCurrentPeerConnectionId(TestConnectionId(2)); + ASSERT_TRUE(retire_peer_issued_cid_alarm_->IsSet()); + alarm_factory_.FireAlarm(retire_peer_issued_cid_alarm_); + EXPECT_THAT(cid_manager_visitor_ + .most_recent_retired_connection_id_sequence_numbers(), + ElementsAre(1u)); + } + + { + // Receives CID #3 from peer since CID #1 is retired. + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(3); + frame.sequence_number = 3u; + frame.retire_prior_to = 2u; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(frame.connection_id); + ASSERT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsQuicNoError()); + // Start to use CID #3 for alternative path. + peer_issued_cid_manager_.ConsumeOneUnusedConnectionId(); + // Connection migration succeed. Prepares to retire CID #2. + peer_issued_cid_manager_.PrepareToRetireActiveConnectionId( + TestConnectionId(2)); + cid_manager_visitor_.SetCurrentPeerConnectionId(TestConnectionId(3)); + ASSERT_TRUE(retire_peer_issued_cid_alarm_->IsSet()); + alarm_factory_.FireAlarm(retire_peer_issued_cid_alarm_); + EXPECT_THAT(cid_manager_visitor_ + .most_recent_retired_connection_id_sequence_numbers(), + ElementsAre(2u)); + } + + { + // Receives CID #4 from peer since CID #2 is retired. + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(4); + frame.sequence_number = 4u; + frame.retire_prior_to = 3u; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(frame.connection_id); + ASSERT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsQuicNoError()); + } +} + +TEST_F(QuicPeerIssuedConnectionIdManagerTest, + ConnectionIdSequenceWhenMigrationFail) { + { + // Receives CID #1 from peer. + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(1); + frame.sequence_number = 1u; + frame.retire_prior_to = 0u; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(frame.connection_id); + ASSERT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsQuicNoError()); + // Start to use CID #1 for alternative path. + peer_issued_cid_manager_.ConsumeOneUnusedConnectionId(); + // Connection migration fails. Prepares to retire CID #1. + peer_issued_cid_manager_.PrepareToRetireActiveConnectionId( + TestConnectionId(1)); + // Actually retires CID #1. + ASSERT_TRUE(retire_peer_issued_cid_alarm_->IsSet()); + alarm_factory_.FireAlarm(retire_peer_issued_cid_alarm_); + EXPECT_THAT(cid_manager_visitor_ + .most_recent_retired_connection_id_sequence_numbers(), + ElementsAre(1u)); + } + + { + // Receives CID #2 from peer since CID #1 is retired. + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(2); + frame.sequence_number = 2u; + frame.retire_prior_to = 0u; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(frame.connection_id); + ASSERT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsQuicNoError()); + // Start to use CID #2 for alternative path. + peer_issued_cid_manager_.ConsumeOneUnusedConnectionId(); + // Connection migration fails again. Prepares to retire CID #2. + peer_issued_cid_manager_.PrepareToRetireActiveConnectionId( + TestConnectionId(2)); + // Actually retires CID #2. + ASSERT_TRUE(retire_peer_issued_cid_alarm_->IsSet()); + alarm_factory_.FireAlarm(retire_peer_issued_cid_alarm_); + EXPECT_THAT(cid_manager_visitor_ + .most_recent_retired_connection_id_sequence_numbers(), + ElementsAre(2u)); + } + + { + // Receives CID #3 from peer since CID #2 is retired. + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(3); + frame.sequence_number = 3u; + frame.retire_prior_to = 0u; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(frame.connection_id); + ASSERT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsQuicNoError()); + // Start to use CID #3 for alternative path. + peer_issued_cid_manager_.ConsumeOneUnusedConnectionId(); + // Connection migration succeed. Prepares to retire CID #0. + peer_issued_cid_manager_.PrepareToRetireActiveConnectionId( + TestConnectionId(0)); + // After CID #3 is default (i.e., when there is no pending frame to write + // associated with CID #0), #0 can actually be retired. + cid_manager_visitor_.SetCurrentPeerConnectionId(TestConnectionId(3)); + ASSERT_TRUE(retire_peer_issued_cid_alarm_->IsSet()); + alarm_factory_.FireAlarm(retire_peer_issued_cid_alarm_); + EXPECT_THAT(cid_manager_visitor_ + .most_recent_retired_connection_id_sequence_numbers(), + ElementsAre(0u)); + } + + { + // Receives CID #4 from peer since CID #0 is retired. + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(4); + frame.sequence_number = 4u; + frame.retire_prior_to = 3u; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(frame.connection_id); + EXPECT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsQuicNoError()); + EXPECT_FALSE(retire_peer_issued_cid_alarm_->IsSet()); + } +} + +TEST_F(QuicPeerIssuedConnectionIdManagerTest, + ReceivesNewConnectionIdOutOfOrder) { + { + // Receives new CID #1 that retires prior to #0. + // Outcome: (active: #0 unused: #1) + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(1); + frame.sequence_number = 1u; + frame.retire_prior_to = 0u; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(frame.connection_id); + ASSERT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsQuicNoError()); + // Start to use CID #1 for alternative path. + // Outcome: (active: #0 #1 unused: None) + peer_issued_cid_manager_.ConsumeOneUnusedConnectionId(); + } + + { + // Receives new CID #3 that retires prior to #2. + // Outcome: (active: None unused: #3) + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(3); + frame.sequence_number = 3u; + frame.retire_prior_to = 2u; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(frame.connection_id); + ASSERT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsQuicNoError()); + } + + { + // Receives new CID #2 that retires prior to #1. + // Outcome: (active: None unused: #3, #2) + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(2); + frame.sequence_number = 2u; + frame.retire_prior_to = 1u; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(frame.connection_id); + ASSERT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsQuicNoError()); + } + + { + EXPECT_FALSE( + peer_issued_cid_manager_.IsConnectionIdActive(TestConnectionId(0))); + EXPECT_FALSE( + peer_issued_cid_manager_.IsConnectionIdActive(TestConnectionId(1))); + // When there is no frame associated with #0 and #1 to write, replace the + // in-use CID with an unused CID (#2) and retires #0 & #1. + ASSERT_TRUE(retire_peer_issued_cid_alarm_->IsSet()); + alarm_factory_.FireAlarm(retire_peer_issued_cid_alarm_); + EXPECT_THAT(cid_manager_visitor_ + .most_recent_retired_connection_id_sequence_numbers(), + ElementsAre(0u, 1u)); + EXPECT_EQ(cid_manager_visitor_.GetCurrentPeerConnectionId(), + TestConnectionId(2)); + // Get another unused CID for path validation. + EXPECT_EQ( + peer_issued_cid_manager_.ConsumeOneUnusedConnectionId()->connection_id, + TestConnectionId(3)); + } +} + +TEST_F(QuicPeerIssuedConnectionIdManagerTest, + VisitedNewConnectionIdFrameIsIgnored) { + // Receives new CID #1 that retires prior to #0. + // Outcome: (active: #0 unused: #1) + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(1); + frame.sequence_number = 1u; + frame.retire_prior_to = 0u; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(frame.connection_id); + ASSERT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsQuicNoError()); + // Start to use CID #1 for alternative path. + // Outcome: (active: #0 #1 unused: None) + peer_issued_cid_manager_.ConsumeOneUnusedConnectionId(); + // Prepare to retire CID #1 as path validation fails. + peer_issued_cid_manager_.PrepareToRetireActiveConnectionId( + TestConnectionId(1)); + // Actually retires CID #1. + ASSERT_TRUE(retire_peer_issued_cid_alarm_->IsSet()); + alarm_factory_.FireAlarm(retire_peer_issued_cid_alarm_); + EXPECT_THAT( + cid_manager_visitor_.most_recent_retired_connection_id_sequence_numbers(), + ElementsAre(1u)); + // Receives the same frame again. Should be a no-op. + ASSERT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsQuicNoError()); + EXPECT_THAT(peer_issued_cid_manager_.ConsumeOneUnusedConnectionId(), + testing::IsNull()); +} + +TEST_F(QuicPeerIssuedConnectionIdManagerTest, + ErrorWhenActiveConnectionIdLimitExceeded) { + { + // Receives new CID #1 that retires prior to #0. + // Outcome: (active: #0 unused: #1) + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(1); + frame.sequence_number = 1u; + frame.retire_prior_to = 0u; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(frame.connection_id); + ASSERT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsQuicNoError()); + } + + { + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(2); + frame.sequence_number = 2u; + frame.retire_prior_to = 0u; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(frame.connection_id); + ASSERT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsError(QUIC_CONNECTION_ID_LIMIT_ERROR)); + } +} + +TEST_F(QuicPeerIssuedConnectionIdManagerTest, + ErrorWhenTheSameConnectionIdIsSeenWithDifferentSequenceNumbers) { + { + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(1); + frame.sequence_number = 1u; + frame.retire_prior_to = 0u; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(frame.connection_id); + ASSERT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsQuicNoError()); + } + + { + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(1); + frame.sequence_number = 2u; + frame.retire_prior_to = 1u; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(TestConnectionId(2)); + ASSERT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsError(IETF_QUIC_PROTOCOL_VIOLATION)); + } +} + +TEST_F(QuicPeerIssuedConnectionIdManagerTest, + NewConnectionIdFrameWithTheSameSequenceNumberIsIgnored) { + { + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(1); + frame.sequence_number = 1u; + frame.retire_prior_to = 0u; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(frame.connection_id); + ASSERT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsQuicNoError()); + } + + { + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(2); + frame.sequence_number = 1u; + frame.retire_prior_to = 0u; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(TestConnectionId(2)); + EXPECT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsQuicNoError()); + EXPECT_EQ( + peer_issued_cid_manager_.ConsumeOneUnusedConnectionId()->connection_id, + TestConnectionId(1)); + EXPECT_THAT(peer_issued_cid_manager_.ConsumeOneUnusedConnectionId(), + IsNull()); + } +} + +TEST_F(QuicPeerIssuedConnectionIdManagerTest, + ErrorWhenThereAreTooManyGapsInIssuedConnectionIdSequenceNumbers) { + // Add 20 intervals: [0, 1), [2, 3), ..., [38,39) + for (int i = 2; i <= 38; i += 2) { + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(i); + frame.sequence_number = i; + frame.retire_prior_to = i; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(frame.connection_id); + ASSERT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsQuicNoError()); + } + + // Interval [40, 41) goes over the limit. + QuicNewConnectionIdFrame frame; + frame.connection_id = TestConnectionId(40); + frame.sequence_number = 40u; + frame.retire_prior_to = 40u; + frame.stateless_reset_token = + QuicUtils::GenerateStatelessResetToken(frame.connection_id); + ASSERT_THAT( + peer_issued_cid_manager_.OnNewConnectionIdFrame(frame, &error_details_), + IsError(IETF_QUIC_PROTOCOL_VIOLATION)); +} + +TEST_F(QuicPeerIssuedConnectionIdManagerTest, ReplaceConnectionId) { + ASSERT_TRUE( + peer_issued_cid_manager_.IsConnectionIdActive(initial_connection_id_)); + peer_issued_cid_manager_.ReplaceConnectionId(initial_connection_id_, + TestConnectionId(1)); + EXPECT_FALSE( + peer_issued_cid_manager_.IsConnectionIdActive(initial_connection_id_)); + EXPECT_TRUE( + peer_issued_cid_manager_.IsConnectionIdActive(TestConnectionId(1))); +} + +class TestSelfIssuedConnectionIdManagerVisitor + : public QuicConnectionIdManagerVisitorInterface { + public: + void OnPeerIssuedConnectionIdRetired() override {} + + MOCK_METHOD(bool, + SendNewConnectionId, + (const QuicNewConnectionIdFrame& frame), + (override)); + MOCK_METHOD(void, + OnNewConnectionIdIssued, + (const QuicConnectionId& connection_id), + (override)); + MOCK_METHOD(void, + OnSelfIssuedConnectionIdRetired, + (const QuicConnectionId& connection_id), + (override)); +}; + +class QuicSelfIssuedConnectionIdManagerTest : public QuicTest { + public: + QuicSelfIssuedConnectionIdManagerTest() + : cid_manager_(/*active_connection_id_limit*/ 2, + initial_connection_id_, + &clock_, + &alarm_factory_, + &cid_manager_visitor_) { + clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(10)); + retire_self_issued_cid_alarm_ = + QuicConnectionIdManagerPeer::GetRetireSelfIssuedConnectionIdAlarm( + &cid_manager_); + } + + protected: + MockClock clock_; + test::MockAlarmFactory alarm_factory_; + TestSelfIssuedConnectionIdManagerVisitor cid_manager_visitor_; + QuicConnectionId initial_connection_id_ = TestConnectionId(0); + StrictMock<QuicSelfIssuedConnectionIdManager> cid_manager_; + QuicAlarm* retire_self_issued_cid_alarm_ = nullptr; + std::string error_details_; + QuicTime::Delta pto_delay_ = QuicTime::Delta::FromMilliseconds(10); +}; + +MATCHER_P3(ExpectedNewConnectionIdFrame, + connection_id, + sequence_number, + retire_prior_to, + "") { + return (arg.connection_id == connection_id) && + (arg.sequence_number == sequence_number) && + (arg.retire_prior_to == retire_prior_to); +} + +TEST_F(QuicSelfIssuedConnectionIdManagerTest, + RetireSelfIssuedConnectionIdInOrder) { + QuicConnectionId cid0 = initial_connection_id_; + QuicConnectionId cid1 = cid_manager_.GenerateNewConnectionId(cid0); + QuicConnectionId cid2 = cid_manager_.GenerateNewConnectionId(cid1); + QuicConnectionId cid3 = cid_manager_.GenerateNewConnectionId(cid2); + QuicConnectionId cid4 = cid_manager_.GenerateNewConnectionId(cid3); + QuicConnectionId cid5 = cid_manager_.GenerateNewConnectionId(cid4); + + // Sends CID #1 to peer. + EXPECT_CALL(cid_manager_visitor_, OnNewConnectionIdIssued(cid1)); + EXPECT_CALL(cid_manager_visitor_, + SendNewConnectionId(ExpectedNewConnectionIdFrame(cid1, 1u, 0u))) + .WillOnce(Return(true)); + cid_manager_.MaybeSendNewConnectionIds(); + + { + // Peer retires CID #0; + // Sends CID #2 and asks peer to retire CIDs prior to #1. + // Outcome: (#1, #2) are active. + EXPECT_CALL(cid_manager_visitor_, OnNewConnectionIdIssued(cid2)); + EXPECT_CALL(cid_manager_visitor_, + SendNewConnectionId(ExpectedNewConnectionIdFrame(cid2, 2u, 1u))) + .WillOnce(Return(true)); + QuicRetireConnectionIdFrame retire_cid_frame; + retire_cid_frame.sequence_number = 0u; + ASSERT_THAT(cid_manager_.OnRetireConnectionIdFrame( + retire_cid_frame, pto_delay_, &error_details_), + IsQuicNoError()); + } + + { + // Peer retires CID #1; + // Sends CID #3 and asks peer to retire CIDs prior to #2. + // Outcome: (#2, #3) are active. + EXPECT_CALL(cid_manager_visitor_, OnNewConnectionIdIssued(cid3)); + EXPECT_CALL(cid_manager_visitor_, + SendNewConnectionId(ExpectedNewConnectionIdFrame(cid3, 3u, 2u))) + .WillOnce(Return(true)); + QuicRetireConnectionIdFrame retire_cid_frame; + retire_cid_frame.sequence_number = 1u; + ASSERT_THAT(cid_manager_.OnRetireConnectionIdFrame( + retire_cid_frame, pto_delay_, &error_details_), + IsQuicNoError()); + } + + { + // Peer retires CID #2; + // Sends CID #4 and asks peer to retire CIDs prior to #3. + // Outcome: (#3, #4) are active. + EXPECT_CALL(cid_manager_visitor_, OnNewConnectionIdIssued(cid4)); + EXPECT_CALL(cid_manager_visitor_, + SendNewConnectionId(ExpectedNewConnectionIdFrame(cid4, 4u, 3u))) + .WillOnce(Return(true)); + QuicRetireConnectionIdFrame retire_cid_frame; + retire_cid_frame.sequence_number = 2u; + ASSERT_THAT(cid_manager_.OnRetireConnectionIdFrame( + retire_cid_frame, pto_delay_, &error_details_), + IsQuicNoError()); + } + + { + // Peer retires CID #3; + // Sends CID #5 and asks peer to retire CIDs prior to #4. + // Outcome: (#4, #5) are active. + EXPECT_CALL(cid_manager_visitor_, OnNewConnectionIdIssued(cid5)); + EXPECT_CALL(cid_manager_visitor_, + SendNewConnectionId(ExpectedNewConnectionIdFrame(cid5, 5u, 4u))) + .WillOnce(Return(true)); + QuicRetireConnectionIdFrame retire_cid_frame; + retire_cid_frame.sequence_number = 3u; + ASSERT_THAT(cid_manager_.OnRetireConnectionIdFrame( + retire_cid_frame, pto_delay_, &error_details_), + IsQuicNoError()); + } +} + +TEST_F(QuicSelfIssuedConnectionIdManagerTest, + RetireSelfIssuedConnectionIdOutOfOrder) { + QuicConnectionId cid0 = initial_connection_id_; + QuicConnectionId cid1 = cid_manager_.GenerateNewConnectionId(cid0); + QuicConnectionId cid2 = cid_manager_.GenerateNewConnectionId(cid1); + QuicConnectionId cid3 = cid_manager_.GenerateNewConnectionId(cid2); + QuicConnectionId cid4 = cid_manager_.GenerateNewConnectionId(cid3); + + // Sends CID #1 to peer. + EXPECT_CALL(cid_manager_visitor_, OnNewConnectionIdIssued(cid1)); + EXPECT_CALL(cid_manager_visitor_, + SendNewConnectionId(ExpectedNewConnectionIdFrame(cid1, 1u, 0u))) + .WillOnce(Return(true)); + cid_manager_.MaybeSendNewConnectionIds(); + + { + // Peer retires CID #1; + // Sends CID #2 and asks peer to retire CIDs prior to #0. + // Outcome: (#0, #2) are active. + EXPECT_CALL(cid_manager_visitor_, OnNewConnectionIdIssued(cid2)); + EXPECT_CALL(cid_manager_visitor_, + SendNewConnectionId(ExpectedNewConnectionIdFrame(cid2, 2u, 0u))) + .WillOnce(Return(true)); + QuicRetireConnectionIdFrame retire_cid_frame; + retire_cid_frame.sequence_number = 1u; + ASSERT_THAT(cid_manager_.OnRetireConnectionIdFrame( + retire_cid_frame, pto_delay_, &error_details_), + IsQuicNoError()); + } + + { + // Peer retires CID #1 again. This is a no-op. + QuicRetireConnectionIdFrame retire_cid_frame; + retire_cid_frame.sequence_number = 1u; + ASSERT_THAT(cid_manager_.OnRetireConnectionIdFrame( + retire_cid_frame, pto_delay_, &error_details_), + IsQuicNoError()); + } + + { + // Peer retires CID #0; + // Sends CID #3 and asks peer to retire CIDs prior to #2. + // Outcome: (#2, #3) are active. + EXPECT_CALL(cid_manager_visitor_, OnNewConnectionIdIssued(cid3)); + EXPECT_CALL(cid_manager_visitor_, + SendNewConnectionId(ExpectedNewConnectionIdFrame(cid3, 3u, 2u))) + .WillOnce(Return(true)); + QuicRetireConnectionIdFrame retire_cid_frame; + retire_cid_frame.sequence_number = 0u; + ASSERT_THAT(cid_manager_.OnRetireConnectionIdFrame( + retire_cid_frame, pto_delay_, &error_details_), + IsQuicNoError()); + } + + { + // Peer retires CID #3; + // Sends CID #4 and asks peer to retire CIDs prior to #2. + // Outcome: (#2, #4) are active. + EXPECT_CALL(cid_manager_visitor_, OnNewConnectionIdIssued(cid4)); + EXPECT_CALL(cid_manager_visitor_, + SendNewConnectionId(ExpectedNewConnectionIdFrame(cid4, 4u, 2u))) + .WillOnce(Return(true)); + QuicRetireConnectionIdFrame retire_cid_frame; + retire_cid_frame.sequence_number = 3u; + ASSERT_THAT(cid_manager_.OnRetireConnectionIdFrame( + retire_cid_frame, pto_delay_, &error_details_), + IsQuicNoError()); + } + + { + // Peer retires CID #0 again. This is a no-op. + QuicRetireConnectionIdFrame retire_cid_frame; + retire_cid_frame.sequence_number = 0u; + ASSERT_THAT(cid_manager_.OnRetireConnectionIdFrame( + retire_cid_frame, pto_delay_, &error_details_), + IsQuicNoError()); + } +} + +TEST_F(QuicSelfIssuedConnectionIdManagerTest, + ScheduleConnectionIdRetirementOneAtATime) { + QuicConnectionId cid0 = initial_connection_id_; + QuicConnectionId cid1 = cid_manager_.GenerateNewConnectionId(cid0); + QuicConnectionId cid2 = cid_manager_.GenerateNewConnectionId(cid1); + QuicConnectionId cid3 = cid_manager_.GenerateNewConnectionId(cid2); + EXPECT_CALL(cid_manager_visitor_, OnNewConnectionIdIssued(_)).Times(3); + EXPECT_CALL(cid_manager_visitor_, SendNewConnectionId(_)) + .Times(3) + .WillRepeatedly(Return(true)); + QuicTime::Delta connection_id_expire_timeout = 3 * pto_delay_; + QuicRetireConnectionIdFrame retire_cid_frame; + + // CID #1 is sent to peer. + cid_manager_.MaybeSendNewConnectionIds(); + + // CID #0's retirement is scheduled and CID #2 is sent to peer. + retire_cid_frame.sequence_number = 0u; + ASSERT_THAT(cid_manager_.OnRetireConnectionIdFrame( + retire_cid_frame, pto_delay_, &error_details_), + IsQuicNoError()); + // While CID #0's retirement is scheduled, it is not retired yet. + EXPECT_THAT(cid_manager_.GetUnretiredConnectionIds(), + ElementsAre(cid0, cid1, cid2)); + EXPECT_TRUE(retire_self_issued_cid_alarm_->IsSet()); + EXPECT_EQ(retire_self_issued_cid_alarm_->deadline(), + clock_.ApproximateNow() + connection_id_expire_timeout); + + // CID #0 is actually retired. + EXPECT_CALL(cid_manager_visitor_, OnSelfIssuedConnectionIdRetired(cid0)); + clock_.AdvanceTime(connection_id_expire_timeout); + alarm_factory_.FireAlarm(retire_self_issued_cid_alarm_); + EXPECT_THAT(cid_manager_.GetUnretiredConnectionIds(), + ElementsAre(cid1, cid2)); + EXPECT_FALSE(retire_self_issued_cid_alarm_->IsSet()); + + // CID #1's retirement is scheduled and CID #3 is sent to peer. + retire_cid_frame.sequence_number = 1u; + ASSERT_THAT(cid_manager_.OnRetireConnectionIdFrame( + retire_cid_frame, pto_delay_, &error_details_), + IsQuicNoError()); + // While CID #1's retirement is scheduled, it is not retired yet. + EXPECT_THAT(cid_manager_.GetUnretiredConnectionIds(), + ElementsAre(cid1, cid2, cid3)); + EXPECT_TRUE(retire_self_issued_cid_alarm_->IsSet()); + EXPECT_EQ(retire_self_issued_cid_alarm_->deadline(), + clock_.ApproximateNow() + connection_id_expire_timeout); + + // CID #1 is actually retired. + EXPECT_CALL(cid_manager_visitor_, OnSelfIssuedConnectionIdRetired(cid1)); + clock_.AdvanceTime(connection_id_expire_timeout); + alarm_factory_.FireAlarm(retire_self_issued_cid_alarm_); + EXPECT_THAT(cid_manager_.GetUnretiredConnectionIds(), + ElementsAre(cid2, cid3)); + EXPECT_FALSE(retire_self_issued_cid_alarm_->IsSet()); +} + +TEST_F(QuicSelfIssuedConnectionIdManagerTest, + ScheduleMultipleConnectionIdRetirement) { + QuicConnectionId cid0 = initial_connection_id_; + QuicConnectionId cid1 = cid_manager_.GenerateNewConnectionId(cid0); + QuicConnectionId cid2 = cid_manager_.GenerateNewConnectionId(cid1); + QuicConnectionId cid3 = cid_manager_.GenerateNewConnectionId(cid2); + EXPECT_CALL(cid_manager_visitor_, OnNewConnectionIdIssued(_)).Times(3); + EXPECT_CALL(cid_manager_visitor_, SendNewConnectionId(_)) + .Times(3) + .WillRepeatedly(Return(true)); + QuicTime::Delta connection_id_expire_timeout = 3 * pto_delay_; + QuicRetireConnectionIdFrame retire_cid_frame; + + // CID #1 is sent to peer. + cid_manager_.MaybeSendNewConnectionIds(); + + // CID #0's retirement is scheduled and CID #2 is sent to peer. + retire_cid_frame.sequence_number = 0u; + ASSERT_THAT(cid_manager_.OnRetireConnectionIdFrame( + retire_cid_frame, pto_delay_, &error_details_), + IsQuicNoError()); + + clock_.AdvanceTime(connection_id_expire_timeout * 0.25); + + // CID #1's retirement is scheduled and CID #3 is sent to peer. + retire_cid_frame.sequence_number = 1u; + ASSERT_THAT(cid_manager_.OnRetireConnectionIdFrame( + retire_cid_frame, pto_delay_, &error_details_), + IsQuicNoError()); + + // While CID #0, #1s retirement is scheduled, they are not retired yet. + EXPECT_THAT(cid_manager_.GetUnretiredConnectionIds(), + ElementsAre(cid0, cid1, cid2, cid3)); + EXPECT_TRUE(retire_self_issued_cid_alarm_->IsSet()); + EXPECT_EQ(retire_self_issued_cid_alarm_->deadline(), + clock_.ApproximateNow() + connection_id_expire_timeout * 0.75); + + // CID #0 is actually retired. + EXPECT_CALL(cid_manager_visitor_, OnSelfIssuedConnectionIdRetired(cid0)); + clock_.AdvanceTime(connection_id_expire_timeout * 0.75); + alarm_factory_.FireAlarm(retire_self_issued_cid_alarm_); + EXPECT_THAT(cid_manager_.GetUnretiredConnectionIds(), + ElementsAre(cid1, cid2, cid3)); + EXPECT_TRUE(retire_self_issued_cid_alarm_->IsSet()); + EXPECT_EQ(retire_self_issued_cid_alarm_->deadline(), + clock_.ApproximateNow() + connection_id_expire_timeout * 0.25); + + // CID #1 is actually retired. + EXPECT_CALL(cid_manager_visitor_, OnSelfIssuedConnectionIdRetired(cid1)); + clock_.AdvanceTime(connection_id_expire_timeout * 0.25); + alarm_factory_.FireAlarm(retire_self_issued_cid_alarm_); + EXPECT_THAT(cid_manager_.GetUnretiredConnectionIds(), + ElementsAre(cid2, cid3)); + EXPECT_FALSE(retire_self_issued_cid_alarm_->IsSet()); +} + +TEST_F(QuicSelfIssuedConnectionIdManagerTest, + AllExpiredConnectionIdsAreRetiredInOneBatch) { + QuicConnectionId cid0 = initial_connection_id_; + QuicConnectionId cid1 = cid_manager_.GenerateNewConnectionId(cid0); + QuicConnectionId cid2 = cid_manager_.GenerateNewConnectionId(cid1); + QuicConnectionId cid3 = cid_manager_.GenerateNewConnectionId(cid2); + EXPECT_CALL(cid_manager_visitor_, OnNewConnectionIdIssued(_)).Times(3); + EXPECT_CALL(cid_manager_visitor_, SendNewConnectionId(_)) + .Times(3) + .WillRepeatedly(Return(true)); + QuicTime::Delta connection_id_expire_timeout = 3 * pto_delay_; + QuicRetireConnectionIdFrame retire_cid_frame; + + // CID #1 is sent to peer. + cid_manager_.MaybeSendNewConnectionIds(); + + // CID #0's retirement is scheduled and CID #2 is sent to peer. + retire_cid_frame.sequence_number = 0u; + cid_manager_.OnRetireConnectionIdFrame(retire_cid_frame, pto_delay_, + &error_details_); + + clock_.AdvanceTime(connection_id_expire_timeout * 0.1); + + // CID #1's retirement is scheduled and CID #3 is sent to peer. + retire_cid_frame.sequence_number = 1u; + cid_manager_.OnRetireConnectionIdFrame(retire_cid_frame, pto_delay_, + &error_details_); + + { + // CID #0 & #1 are retired in a single alarm fire. + clock_.AdvanceTime(connection_id_expire_timeout); + testing::InSequence s; + EXPECT_CALL(cid_manager_visitor_, OnSelfIssuedConnectionIdRetired(cid0)); + EXPECT_CALL(cid_manager_visitor_, OnSelfIssuedConnectionIdRetired(cid1)); + alarm_factory_.FireAlarm(retire_self_issued_cid_alarm_); + EXPECT_THAT(cid_manager_.GetUnretiredConnectionIds(), + ElementsAre(cid2, cid3)); + EXPECT_FALSE(retire_self_issued_cid_alarm_->IsSet()); + } +} + +TEST_F(QuicSelfIssuedConnectionIdManagerTest, + ErrorWhenRetireConnectionIdNeverIssued) { + QuicConnectionId cid0 = initial_connection_id_; + QuicConnectionId cid1 = cid_manager_.GenerateNewConnectionId(cid0); + + // CID #1 is sent to peer. + EXPECT_CALL(cid_manager_visitor_, OnNewConnectionIdIssued(_)).Times(1); + EXPECT_CALL(cid_manager_visitor_, SendNewConnectionId(_)) + .WillOnce(Return(true)); + cid_manager_.MaybeSendNewConnectionIds(); + + // CID #2 is never issued. + QuicRetireConnectionIdFrame retire_cid_frame; + retire_cid_frame.sequence_number = 2u; + ASSERT_THAT(cid_manager_.OnRetireConnectionIdFrame( + retire_cid_frame, pto_delay_, &error_details_), + IsError(IETF_QUIC_PROTOCOL_VIOLATION)); +} + +TEST_F(QuicSelfIssuedConnectionIdManagerTest, + ErrorWhenTooManyConnectionIdWaitingToBeRetired) { + // CID #0 & #1 are issued. + EXPECT_CALL(cid_manager_visitor_, OnNewConnectionIdIssued(_)); + EXPECT_CALL(cid_manager_visitor_, SendNewConnectionId(_)) + .WillOnce(Return(true)); + cid_manager_.MaybeSendNewConnectionIds(); + + // Add 8 connection IDs to the to-be-retired list. + QuicConnectionId last_connection_id = + cid_manager_.GenerateNewConnectionId(initial_connection_id_); + for (int i = 0; i < 8; ++i) { + EXPECT_CALL(cid_manager_visitor_, OnNewConnectionIdIssued(_)); + EXPECT_CALL(cid_manager_visitor_, SendNewConnectionId(_)); + QuicRetireConnectionIdFrame retire_cid_frame; + retire_cid_frame.sequence_number = i; + ASSERT_THAT(cid_manager_.OnRetireConnectionIdFrame( + retire_cid_frame, pto_delay_, &error_details_), + IsQuicNoError()); + last_connection_id = + cid_manager_.GenerateNewConnectionId(last_connection_id); + } + QuicRetireConnectionIdFrame retire_cid_frame; + retire_cid_frame.sequence_number = 8u; + // This would have push the number of to-be-retired connection IDs over its + // limit. + ASSERT_THAT(cid_manager_.OnRetireConnectionIdFrame( + retire_cid_frame, pto_delay_, &error_details_), + IsError(QUIC_TOO_MANY_CONNECTION_ID_WAITING_TO_RETIRE)); +} + +TEST_F(QuicSelfIssuedConnectionIdManagerTest, + DoNotIssueConnectionIdVoluntarilyIfOneHasIssuedForPerferredAddress) { + QuicConnectionId cid0 = initial_connection_id_; + QuicConnectionId cid1 = cid_manager_.GenerateNewConnectionId(cid0); + EXPECT_CALL(cid_manager_visitor_, OnNewConnectionIdIssued(cid1)); + ASSERT_THAT(cid_manager_.IssueNewConnectionIdForPreferredAddress(), + ExpectedNewConnectionIdFrame(cid1, 1u, 0u)); + EXPECT_THAT(cid_manager_.GetUnretiredConnectionIds(), + ElementsAre(cid0, cid1)); + + EXPECT_CALL(cid_manager_visitor_, OnNewConnectionIdIssued(_)).Times(0); + EXPECT_CALL(cid_manager_visitor_, SendNewConnectionId(_)).Times(0); + cid_manager_.MaybeSendNewConnectionIds(); +} + +} // namespace +} // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_connection_id_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_connection_id_test.cc index 84d30900551..3effb3483c1 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_connection_id_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_connection_id_test.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" +#include "quic/core/quic_connection_id.h" #include <cstdint> #include <cstring> #include <string> #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_connection_stats.cc b/chromium/net/third_party/quiche/src/quic/core/quic_connection_stats.cc index d7440b4589b..3d1b3c422a8 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_connection_stats.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_connection_stats.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_connection_stats.h" +#include "quic/core/quic_connection_stats.h" namespace quic { @@ -58,6 +58,11 @@ std::ostream& operator<<(std::ostream& os, const QuicConnectionStats& s) { os << " key_update_count: " << s.key_update_count; os << " num_failed_authentication_packets_received: " << s.num_failed_authentication_packets_received; + os << " num_tls_server_zero_rtt_packets_received_after_discarding_decrypter: " + << s.num_tls_server_zero_rtt_packets_received_after_discarding_decrypter; + os << " address_validated_via_decrypting_packet: " + << s.address_validated_via_decrypting_packet; + os << " address_validated_via_token: " << s.address_validated_via_token; os << " }"; return os; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_connection_stats.h b/chromium/net/third_party/quiche/src/quic/core/quic_connection_stats.h index 95cf61eed5a..0cf348953b8 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_connection_stats.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_connection_stats.h @@ -8,11 +8,11 @@ #include <cstdint> #include <ostream> -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_time_accumulator.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_time_accumulator.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -178,6 +178,37 @@ struct QUIC_EXPORT_PRIVATE QuicConnectionStats { // Counts the number of undecryptable packets received across all keys. Does // not include packets where a decryption key for that level was absent. QuicPacketCount num_failed_authentication_packets_received = 0; + + // Counts the number of QUIC+TLS 0-RTT packets received after 0-RTT decrypter + // was discarded, only on server connections. + QuicPacketCount + num_tls_server_zero_rtt_packets_received_after_discarding_decrypter = 0; + + // True if address is validated via decrypting HANDSHAKE or 1-RTT packet. + bool address_validated_via_decrypting_packet = false; + + // True if address is validated via validating token received in INITIAL + // packet. + bool address_validated_via_token = false; + + size_t ping_frames_sent = 0; + + // Number of detected peer address changes which changes to a peer address + // validated by earlier path validation. + size_t num_peer_migration_to_proactively_validated_address = 0; + // Number of detected peer address changes which triggers reverse path + // validation. + size_t num_reverse_path_validtion_upon_migration = 0; + // Number of detected peer migrations which either succeed reverse path + // validation or no need to be validated. + size_t num_validated_peer_migration = 0; + // Number of detected peer migrations which triggered reverse path validation + // and failed and fell back to the old path. + size_t num_invalid_peer_migration = 0; + // Number of detected peer migrations which triggered reverse path validation + // which was canceled because the peer migrated again. Such migration is also + // counted as invalid peer migration. + size_t num_peer_migration_while_validating_default_path = 0; }; } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_connection_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_connection_test.cc index 1d55c1a78c4..60eccb818cd 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_connection_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_connection_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_connection.h" +#include "quic/core/quic_connection.h" #include <errno.h> @@ -12,39 +12,42 @@ #include <utility> #include "absl/base/macros.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/loss_detection_interface.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_connection_close_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#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" -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_framer_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_packet_creator_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/simple_data_producer.h" -#include "net/third_party/quiche/src/quic/test_tools/simple_session_notifier.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "quic/core/congestion_control/loss_detection_interface.h" +#include "quic/core/congestion_control/send_algorithm_interface.h" +#include "quic/core/crypto/null_decrypter.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/frames/quic_connection_close_frame.h" +#include "quic/core/frames/quic_path_response_frame.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_path_validator.h" +#include "quic/core/quic_simple_buffer_allocator.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_reference_counted.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" +#include "quic/test_tools/mock_random.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_framer_peer.h" +#include "quic/test_tools/quic_packet_creator_peer.h" +#include "quic/test_tools/quic_path_validator_peer.h" +#include "quic/test_tools/quic_sent_packet_manager_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/simple_data_producer.h" +#include "quic/test_tools/simple_session_notifier.h" using testing::_; using testing::AnyNumber; @@ -102,10 +105,10 @@ QuicLongHeaderType EncryptionlevelToLongHeaderType(EncryptionLevel level) { case ENCRYPTION_ZERO_RTT: return ZERO_RTT_PROTECTED; case ENCRYPTION_FORWARD_SECURE: - DCHECK(false); + QUICHE_DCHECK(false); return INVALID_PACKET_TYPE; default: - DCHECK(false); + QUICHE_DCHECK(false); return INVALID_PACKET_TYPE; } } @@ -292,7 +295,7 @@ class TestConnection : public QuicConnection { QuicStreamOffset offset, StreamSendingState state) { ScopedPacketFlusher flusher(this); - DCHECK(encryption_level >= ENCRYPTION_ZERO_RTT); + QUICHE_DCHECK(encryption_level >= ENCRYPTION_ZERO_RTT); SetEncrypter(encryption_level, std::make_unique<TaggingEncrypter>(0x01)); SetDefaultEncryptionLevel(encryption_level); struct iovec iov; @@ -460,13 +463,18 @@ class TestConnection : public QuicConnection { QuicConnectionPeer::GetDiscardPreviousOneRttKeysAlarm(this)); } + TestAlarmFactory::TestAlarm* GetDiscardZeroRttDecryptionKeysAlarm() { + return reinterpret_cast<TestAlarmFactory::TestAlarm*>( + QuicConnectionPeer::GetDiscardZeroRttDecryptionKeysAlarm(this)); + } + TestAlarmFactory::TestAlarm* GetBlackholeDetectorAlarm() { return reinterpret_cast<TestAlarmFactory::TestAlarm*>( QuicConnectionPeer::GetBlackholeDetectorAlarm(this)); } void PathDegradingTimeout() { - DCHECK(PathDegradingDetectionInProgress()); + QUICHE_DCHECK(PathDegradingDetectionInProgress()); GetBlackholeDetectorAlarm()->Fire(); } @@ -503,8 +511,8 @@ class TestConnection : public QuicConnection { if (QuicConnectionPeer::GetSentPacketManager(this)->pto_enabled()) { // PTO mode is default enabled for T099. And TLP/RTO related tests are // stale. - DCHECK(PROTOCOL_TLS1_3 == version().handshake_protocol || - GetQuicReloadableFlag(quic_default_on_pto)); + QUICHE_DCHECK(PROTOCOL_TLS1_3 == version().handshake_protocol || + GetQuicReloadableFlag(quic_default_on_pto)); return true; } return false; @@ -556,7 +564,7 @@ struct TestParams { // Used by ::testing::PrintToStringParamName(). std::string PrintToString(const TestParams& p) { - return quiche::QuicheStrCat( + return absl::StrCat( ParsedQuicVersionToString(p.version), "_", (p.ack_response == AckResponse::kDefer ? "defer" : "immediate"), "_", (p.no_stop_waiting ? "No" : ""), "StopWaiting"); @@ -572,8 +580,7 @@ std::vector<TestParams> GetTestParams() { {AckResponse::kDefer, AckResponse::kImmediate}) { params.push_back( TestParams(all_supported_versions[i], ack_response, true)); - if (!VersionHasIetfInvariantHeader( - all_supported_versions[i].transport_version)) { + if (!all_supported_versions[i].HasIetfInvariantHeader()) { params.push_back( TestParams(all_supported_versions[i], ack_response, false)); } @@ -657,7 +664,7 @@ class QuicConnectionTest : public QuicTestWithParam<TestParams> { QuicConnectionPeer::GetFramer(&connection_), connection_id_); QuicFramerPeer::SetLastWrittenPacketNumberLength( QuicConnectionPeer::GetFramer(&connection_), packet_number_length_); - if (VersionHasIetfInvariantHeader(version().transport_version)) { + if (version().HasIetfInvariantHeader()) { EXPECT_TRUE(QuicConnectionPeer::GetNoStopWaitingFrames(&connection_)); } else { QuicConnectionPeer::SetNoStopWaitingFrames(&connection_, @@ -692,7 +699,11 @@ class QuicConnectionTest : public QuicTestWithParam<TestParams> { .Times(AnyNumber()); EXPECT_CALL(*send_algorithm_, InSlowStart()).Times(AnyNumber()); EXPECT_CALL(*send_algorithm_, InRecovery()).Times(AnyNumber()); + EXPECT_CALL(*send_algorithm_, GetCongestionControlType()) + .Times(AnyNumber()); EXPECT_CALL(*send_algorithm_, OnApplicationLimited(_)).Times(AnyNumber()); + EXPECT_CALL(*send_algorithm_, GetCongestionControlType()) + .Times(AnyNumber()); EXPECT_CALL(visitor_, WillingAndAbleToWrite()).Times(AnyNumber()); EXPECT_CALL(visitor_, OnPacketDecrypted(_)).Times(AnyNumber()); EXPECT_CALL(visitor_, OnCanWrite()) @@ -792,7 +803,7 @@ class QuicConnectionTest : public QuicTestWithParam<TestParams> { QuicSocketAddress self_address, QuicSocketAddress peer_address, EncryptionLevel level) { - DCHECK(peer_framer_.HasEncrypterOfEncryptionLevel(level)); + QUICHE_DCHECK(peer_framer_.HasEncrypterOfEncryptionLevel(level)); peer_creator_.set_encryption_level(level); QuicPacketCreatorPeer::SetSendVersionInPacket( &peer_creator_, @@ -828,14 +839,14 @@ class QuicConnectionTest : public QuicTestWithParam<TestParams> { size_t length = peer_framer_.BuildDataPacket( header, frames, encrypted_buffer, kMaxOutgoingPacketSize, ENCRYPTION_INITIAL); - DCHECK_GT(length, 0u); + QUICHE_DCHECK_GT(length, 0u); const size_t encrypted_length = peer_framer_.EncryptInPlace( ENCRYPTION_INITIAL, header.packet_number, GetStartOfEncryptedData(peer_framer_.version().transport_version, header), length, kMaxOutgoingPacketSize, encrypted_buffer); - DCHECK_GT(encrypted_length, 0u); + QUICHE_DCHECK_GT(encrypted_length, 0u); connection_.ProcessUdpPacket( kSelfAddress, kPeerAddress, @@ -934,7 +945,8 @@ class QuicConnectionTest : public QuicTestWithParam<TestParams> { size_t encrypted_length = peer_framer_.EncryptPayload( packet.level, QuicPacketNumber(packet.packet_number), *constructed_packet, buffer, kMaxOutgoingPacketSize); - DCHECK_LE(coalesced_size + encrypted_length, kMaxOutgoingPacketSize); + QUICHE_DCHECK_LE(coalesced_size + encrypted_length, + kMaxOutgoingPacketSize); memcpy(coalesced_buffer + coalesced_size, buffer, encrypted_length); coalesced_size += encrypted_length; } @@ -1116,7 +1128,7 @@ class QuicConnectionTest : public QuicTestWithParam<TestParams> { QuicPacketHeader ConstructPacketHeader(uint64_t number, EncryptionLevel level) { QuicPacketHeader header; - if (VersionHasIetfInvariantHeader(peer_framer_.transport_version()) && + if (peer_framer_.version().HasIetfInvariantHeader() && level < ENCRYPTION_FORWARD_SECURE) { // Set long header type accordingly. header.version_flag = true; @@ -1140,7 +1152,7 @@ class QuicConnectionTest : public QuicTestWithParam<TestParams> { header.destination_connection_id = connection_id_; header.destination_connection_id_included = connection_id_included_; } - if (VersionHasIetfInvariantHeader(peer_framer_.transport_version()) && + if (peer_framer_.version().HasIetfInvariantHeader() && peer_framer_.perspective() == Perspective::IS_SERVER) { header.destination_connection_id_included = CONNECTION_ID_ABSENT; if (header.version_flag) { @@ -1176,7 +1188,7 @@ class QuicConnectionTest : public QuicTestWithParam<TestParams> { {0xde, 0xad, 0xbe, 0xef, 0xba, 0xdc, 0x0f, 0xfe}}; return QuicPacketCreatorPeer:: SerializePathChallengeConnectivityProbingPacket(&peer_creator_, - &payload); + payload); } return QuicPacketCreatorPeer::SerializeConnectivityProbingPacket( &peer_creator_); @@ -1190,12 +1202,12 @@ class QuicConnectionTest : public QuicTestWithParam<TestParams> { if (peer_framer_.perspective() == Perspective::IS_SERVER) { header.source_connection_id = connection_id_; header.destination_connection_id_included = CONNECTION_ID_ABSENT; - if (!VersionHasIetfInvariantHeader(peer_framer_.transport_version())) { + if (!peer_framer_.version().HasIetfInvariantHeader()) { header.source_connection_id_included = CONNECTION_ID_PRESENT; } } else { header.destination_connection_id = connection_id_; - if (VersionHasIetfInvariantHeader(peer_framer_.transport_version())) { + if (peer_framer_.version().HasIetfInvariantHeader()) { header.destination_connection_id_included = CONNECTION_ID_ABSENT; } } @@ -1204,7 +1216,7 @@ class QuicConnectionTest : public QuicTestWithParam<TestParams> { QuicErrorCode kQuicErrorCode = QUIC_PEER_GOING_AWAY; QuicConnectionCloseFrame qccf(peer_framer_.transport_version(), - kQuicErrorCode, "", + kQuicErrorCode, NO_IETF_QUIC_ERROR, "", /*transport_close_frame_type=*/0); QuicFrames frames; frames.push_back(QuicFrame(&qccf)); @@ -1389,6 +1401,28 @@ class QuicConnectionTest : public QuicTestWithParam<TestParams> { // Prevent packets from being coalesced. EXPECT_CALL(visitor_, GetHandshakeState()) .WillRepeatedly(Return(HANDSHAKE_CONFIRMED)); + if (version().SupportsAntiAmplificationLimit() && + perspective == Perspective::IS_SERVER) { + QuicConnectionPeer::SetAddressValidated(&connection_); + } + // Clear direct_peer_address. + QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress()); + // Clear effective_peer_address, it is the same as direct_peer_address for + // this test. + QuicConnectionPeer::SetEffectivePeerAddress(&connection_, + QuicSocketAddress()); + EXPECT_FALSE(connection_.effective_peer_address().IsInitialized()); + + if (QuicVersionUsesCryptoFrames(connection_.transport_version())) { + EXPECT_CALL(visitor_, OnCryptoFrame(_)).Times(AnyNumber()); + } else { + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(AnyNumber()); + } + QuicPacketCreatorPeer::SetPacketNumber(&peer_creator_, 2); + ProcessFramePacketWithAddresses(MakeCryptoFrame(), kSelfAddress, + kPeerAddress, ENCRYPTION_FORWARD_SECURE); + EXPECT_EQ(kPeerAddress, connection_.peer_address()); + EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); } void TestClientRetryHandling(bool invalid_retry_tag, @@ -1541,8 +1575,8 @@ TEST_P(QuicConnectionTest, AllowSelfAddressChangeToMappedIpv4AddressAtServer) { kPeerAddress, ENCRYPTION_INITIAL); // Cause self_address change to mapped Ipv4 address. QuicIpAddress host2; - host2.FromString(quiche::QuicheStrCat( - "::ffff:", connection_.self_address().host().ToString())); + host2.FromString( + absl::StrCat("::ffff:", connection_.self_address().host().ToString())); QuicSocketAddress self_address2(host2, connection_.self_address().port()); ProcessFramePacketWithAddresses(MakeCryptoFrame(), self_address2, kPeerAddress, ENCRYPTION_INITIAL); @@ -1556,6 +1590,8 @@ TEST_P(QuicConnectionTest, AllowSelfAddressChangeToMappedIpv4AddressAtServer) { TEST_P(QuicConnectionTest, ClientAddressChangeAndPacketReordered) { set_perspective(Perspective::IS_SERVER); QuicPacketCreatorPeer::SetSendVersionInPacket(creator_, false); + EXPECT_CALL(visitor_, GetHandshakeState()) + .WillRepeatedly(Return(HANDSHAKE_CONFIRMED)); // Clear direct_peer_address. QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress()); @@ -1588,7 +1624,7 @@ TEST_P(QuicConnectionTest, ClientAddressChangeAndPacketReordered) { EXPECT_EQ(kNewPeerAddress, connection_.effective_peer_address()); } -TEST_P(QuicConnectionTest, PeerAddressChangeAtServer) { +TEST_P(QuicConnectionTest, PeerPortChangeAtServer) { set_perspective(Perspective::IS_SERVER); QuicPacketCreatorPeer::SetSendVersionInPacket(creator_, false); EXPECT_EQ(Perspective::IS_SERVER, connection_.perspective()); @@ -1596,6 +1632,9 @@ TEST_P(QuicConnectionTest, PeerAddressChangeAtServer) { // Prevent packets from being coalesced. EXPECT_CALL(visitor_, GetHandshakeState()) .WillRepeatedly(Return(HANDSHAKE_CONFIRMED)); + if (version().SupportsAntiAmplificationLimit()) { + QuicConnectionPeer::SetAddressValidated(&connection_); + } // Clear direct_peer_address. QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress()); @@ -1605,6 +1644,16 @@ TEST_P(QuicConnectionTest, PeerAddressChangeAtServer) { QuicSocketAddress()); EXPECT_FALSE(connection_.effective_peer_address().IsInitialized()); + RttStats* rtt_stats = const_cast<RttStats*>(manager_->GetRttStats()); + QuicTime::Delta default_init_rtt = rtt_stats->initial_rtt(); + rtt_stats->set_initial_rtt(default_init_rtt * 2); + EXPECT_EQ(2 * default_init_rtt, rtt_stats->initial_rtt()); + + QuicSentPacketManagerPeer::SetConsecutiveRtoCount(manager_, 1); + EXPECT_EQ(1u, manager_->GetConsecutiveRtoCount()); + QuicSentPacketManagerPeer::SetConsecutiveTlpCount(manager_, 2); + EXPECT_EQ(2u, manager_->GetConsecutiveTlpCount()); + const QuicSocketAddress kNewPeerAddress = QuicSocketAddress(QuicIpAddress::Loopback6(), /*port=*/23456); EXPECT_CALL(visitor_, OnStreamFrame(_)) @@ -1633,6 +1682,153 @@ TEST_P(QuicConnectionTest, PeerAddressChangeAtServer) { ENCRYPTION_FORWARD_SECURE); EXPECT_EQ(kNewPeerAddress, connection_.peer_address()); EXPECT_EQ(kNewPeerAddress, connection_.effective_peer_address()); + // PORT_CHANGE shouldn't state change in sent packet manager. + EXPECT_EQ(2 * default_init_rtt, rtt_stats->initial_rtt()); + EXPECT_EQ(1u, manager_->GetConsecutiveRtoCount()); + EXPECT_EQ(2u, manager_->GetConsecutiveTlpCount()); + EXPECT_EQ(manager_->GetSendAlgorithm(), send_algorithm_); + if (connection_.validate_client_address()) { + EXPECT_EQ(NO_CHANGE, connection_.active_effective_peer_migration_type()); + EXPECT_EQ(1u, connection_.GetStats().num_validated_peer_migration); + } +} + +TEST_P(QuicConnectionTest, PeerIpAddressChangeAtServer) { + if (!connection_.validate_client_address()) { + return; + } + set_perspective(Perspective::IS_SERVER); + QuicPacketCreatorPeer::SetSendVersionInPacket(creator_, false); + EXPECT_EQ(Perspective::IS_SERVER, connection_.perspective()); + connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); + // Prevent packets from being coalesced. + EXPECT_CALL(visitor_, GetHandshakeState()) + .WillRepeatedly(Return(HANDSHAKE_CONFIRMED)); + QuicConnectionPeer::SetAddressValidated(&connection_); + + // Enable 5 RTO + QuicConfig config; + QuicTagVector connection_options; + connection_options.push_back(k5RTO); + config.SetInitialReceivedConnectionOptions(connection_options); + QuicConfigPeer::SetNegotiated(&config, true); + QuicConfigPeer::SetReceivedOriginalConnectionId(&config, + connection_.connection_id()); + QuicConfigPeer::SetReceivedInitialSourceConnectionId(&config, + QuicConnectionId()); + EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); + connection_.SetFromConfig(config); + + // Clear direct_peer_address. + QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress()); + // Clear effective_peer_address, it is the same as direct_peer_address for + // this test. + QuicConnectionPeer::SetEffectivePeerAddress(&connection_, + QuicSocketAddress()); + EXPECT_FALSE(connection_.effective_peer_address().IsInitialized()); + + const QuicSocketAddress kNewPeerAddress = + QuicSocketAddress(QuicIpAddress::Loopback4(), /*port=*/23456); + EXPECT_CALL(visitor_, OnStreamFrame(_)) + .WillOnce(Invoke( + [=]() { EXPECT_EQ(kPeerAddress, connection_.peer_address()); })) + .WillOnce(Invoke([=]() { + EXPECT_EQ((GetQuicReloadableFlag(quic_start_peer_migration_earlier) || + !GetParam().version.HasIetfQuicFrames() + ? kNewPeerAddress + : kPeerAddress), + connection_.peer_address()); + })); + QuicFrames frames; + frames.push_back(QuicFrame(frame1_)); + ProcessFramesPacketWithAddresses(frames, kSelfAddress, kPeerAddress, + ENCRYPTION_FORWARD_SECURE); + EXPECT_EQ(kPeerAddress, connection_.peer_address()); + EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); + + // Send some data to make connection has packets in flight. + connection_.SendStreamData3(); + EXPECT_EQ(1u, writer_->packets_write_attempts()); + EXPECT_TRUE(connection_.BlackholeDetectionInProgress()); + + // Process another packet with a different peer address on server side will + // start connection migration. + EXPECT_CALL(visitor_, OnConnectionMigration(IPV6_TO_IPV4_CHANGE)).Times(1); + // IETF QUIC send algorithm should be changed to a different object, so no + // OnPacketSent() called on the old send algorithm. + EXPECT_CALL(*send_algorithm_, + OnPacketSent(_, _, _, _, NO_RETRANSMITTABLE_DATA)) + .Times(0); + // Do not propagate OnCanWrite() to session notifier. + EXPECT_CALL(visitor_, OnCanWrite()).Times(AtLeast(1u)); + + QuicFrames frames2; + frames2.push_back(QuicFrame(frame2_)); + ProcessFramesPacketWithAddresses(frames2, kSelfAddress, kNewPeerAddress, + ENCRYPTION_FORWARD_SECURE); + EXPECT_EQ(kNewPeerAddress, connection_.peer_address()); + EXPECT_EQ(kNewPeerAddress, connection_.effective_peer_address()); + EXPECT_EQ(IPV6_TO_IPV4_CHANGE, + connection_.active_effective_peer_migration_type()); + EXPECT_FALSE(connection_.BlackholeDetectionInProgress()); + + EXPECT_EQ(2u, writer_->packets_write_attempts()); + EXPECT_FALSE(writer_->path_challenge_frames().empty()); + QuicPathFrameBuffer payload = + writer_->path_challenge_frames().front().data_buffer; + EXPECT_NE(connection_.sent_packet_manager().GetSendAlgorithm(), + send_algorithm_); + // Switch to use the mock send algorithm. + send_algorithm_ = new StrictMock<MockSendAlgorithm>(); + EXPECT_CALL(*send_algorithm_, CanSend(_)).WillRepeatedly(Return(true)); + EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) + .WillRepeatedly(Return(kDefaultTCPMSS)); + EXPECT_CALL(*send_algorithm_, OnApplicationLimited(_)).Times(AnyNumber()); + EXPECT_CALL(*send_algorithm_, BandwidthEstimate()) + .Times(AnyNumber()) + .WillRepeatedly(Return(QuicBandwidth::Zero())); + EXPECT_CALL(*send_algorithm_, InSlowStart()).Times(AnyNumber()); + EXPECT_CALL(*send_algorithm_, InRecovery()).Times(AnyNumber()); + EXPECT_CALL(*send_algorithm_, PopulateConnectionStats(_)).Times(AnyNumber()); + connection_.SetSendAlgorithm(send_algorithm_); + + // PATH_CHALLENGE is expanded upto the max packet size which may exceeds the + // anti-amplification limit. + EXPECT_EQ(kNewPeerAddress, writer_->last_write_peer_address()); + EXPECT_EQ(kNewPeerAddress, connection_.peer_address()); + EXPECT_EQ(kNewPeerAddress, connection_.effective_peer_address()); + EXPECT_EQ(1u, + connection_.GetStats().num_reverse_path_validtion_upon_migration); + + // Verify server is throttled by anti-amplification limit. + connection_.SendCryptoDataWithString("foo", 0); + EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); + + // Receiving an ACK to the packet sent after changing peer address doesn't + // finish migration validation. + QuicAckFrame ack_frame = InitAckFrame(2); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(_, _, _, _, _)); + ProcessFramePacketWithAddresses(QuicFrame(&ack_frame), kSelfAddress, + kNewPeerAddress, ENCRYPTION_FORWARD_SECURE); + EXPECT_EQ(kNewPeerAddress, connection_.peer_address()); + EXPECT_EQ(kNewPeerAddress, connection_.effective_peer_address()); + EXPECT_EQ(IPV6_TO_IPV4_CHANGE, + connection_.active_effective_peer_migration_type()); + + // Receiving PATH_RESPONSE should lift the anti-amplification limit. + QuicFrames frames3; + frames3.push_back(QuicFrame(new QuicPathResponseFrame(99, payload))); + EXPECT_CALL(visitor_, MaybeSendAddressToken()); + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) + .Times(testing::AtLeast(1u)); + ProcessFramesPacketWithAddresses(frames3, kSelfAddress, kNewPeerAddress, + ENCRYPTION_FORWARD_SECURE); + EXPECT_EQ(NO_CHANGE, connection_.active_effective_peer_migration_type()); + + // Verify the anti-amplification limit is lifted by sending a packet larger + // than the anti-amplification limit. + connection_.SendCryptoDataWithString(std::string(1200, 'a'), 0); + EXPECT_EQ(1u, connection_.GetStats().num_validated_peer_migration); } TEST_P(QuicConnectionTest, EffectivePeerAddressChangeAtServer) { @@ -1642,6 +1838,8 @@ TEST_P(QuicConnectionTest, EffectivePeerAddressChangeAtServer) { if (version().SupportsAntiAmplificationLimit()) { QuicConnectionPeer::SetAddressValidated(&connection_); } + EXPECT_CALL(visitor_, GetHandshakeState()) + .WillRepeatedly(Return(HANDSHAKE_CONFIRMED)); // Clear direct_peer_address. QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress()); @@ -1673,6 +1871,11 @@ TEST_P(QuicConnectionTest, EffectivePeerAddressChangeAtServer) { ENCRYPTION_INITIAL); EXPECT_EQ(kPeerAddress, connection_.peer_address()); EXPECT_EQ(kNewEffectivePeerAddress, connection_.effective_peer_address()); + EXPECT_EQ(kPeerAddress, writer_->last_write_peer_address()); + if (connection_.validate_client_address()) { + EXPECT_EQ(NO_CHANGE, connection_.active_effective_peer_migration_type()); + EXPECT_EQ(1u, connection_.GetStats().num_validated_peer_migration); + } // Process another packet with a different direct peer address and the same // effective peer address on server side will not start connection migration. @@ -1680,15 +1883,19 @@ TEST_P(QuicConnectionTest, EffectivePeerAddressChangeAtServer) { QuicSocketAddress(QuicIpAddress::Loopback6(), /*port=*/23456); connection_.ReturnEffectivePeerAddressForNextPacket(kNewEffectivePeerAddress); EXPECT_CALL(visitor_, OnConnectionMigration(PORT_CHANGE)).Times(0); - // ack_frame is used to complete the migration started by the last packet, we - // need to make sure a new migration does not start after the previous one is - // completed. - QuicAckFrame ack_frame = InitAckFrame(1); - EXPECT_CALL(*send_algorithm_, OnCongestionEvent(_, _, _, _, _)); - ProcessFramePacketWithAddresses(QuicFrame(&ack_frame), kSelfAddress, - kNewPeerAddress, ENCRYPTION_INITIAL); - EXPECT_EQ(kNewPeerAddress, connection_.peer_address()); - EXPECT_EQ(kNewEffectivePeerAddress, connection_.effective_peer_address()); + + if (!connection_.validate_client_address()) { + // ack_frame is used to complete the migration started by the last packet, + // we need to make sure a new migration does not start after the previous + // one is completed. + QuicAckFrame ack_frame = InitAckFrame(1); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(_, _, _, _, _)); + ProcessFramePacketWithAddresses(QuicFrame(&ack_frame), kSelfAddress, + kNewPeerAddress, ENCRYPTION_INITIAL); + EXPECT_EQ(kNewPeerAddress, connection_.peer_address()); + EXPECT_EQ(kNewEffectivePeerAddress, connection_.effective_peer_address()); + EXPECT_EQ(NO_CHANGE, connection_.active_effective_peer_migration_type()); + } // Process another packet with different direct peer address and different // effective peer address on server side will start connection migration. @@ -1703,7 +1910,12 @@ TEST_P(QuicConnectionTest, EffectivePeerAddressChangeAtServer) { kFinalPeerAddress, ENCRYPTION_INITIAL); EXPECT_EQ(kFinalPeerAddress, connection_.peer_address()); EXPECT_EQ(kNewerEffectivePeerAddress, connection_.effective_peer_address()); - EXPECT_EQ(PORT_CHANGE, connection_.active_effective_peer_migration_type()); + if (connection_.validate_client_address()) { + EXPECT_EQ(NO_CHANGE, connection_.active_effective_peer_migration_type()); + EXPECT_EQ(send_algorithm_, + connection_.sent_packet_manager().GetSendAlgorithm()); + EXPECT_EQ(2u, connection_.GetStats().num_validated_peer_migration); + } // While the previous migration is ongoing, process another packet with the // same direct peer address and different effective peer address on server @@ -1713,17 +1925,38 @@ TEST_P(QuicConnectionTest, EffectivePeerAddressChangeAtServer) { connection_.ReturnEffectivePeerAddressForNextPacket( kNewestEffectivePeerAddress); EXPECT_CALL(visitor_, OnConnectionMigration(IPV6_TO_IPV4_CHANGE)).Times(1); - EXPECT_CALL(*send_algorithm_, OnConnectionMigration()).Times(1); + if (!connection_.validate_client_address()) { + EXPECT_CALL(*send_algorithm_, OnConnectionMigration()).Times(1); + } ProcessFramePacketWithAddresses(MakeCryptoFrame(), kSelfAddress, kFinalPeerAddress, ENCRYPTION_INITIAL); EXPECT_EQ(kFinalPeerAddress, connection_.peer_address()); EXPECT_EQ(kNewestEffectivePeerAddress, connection_.effective_peer_address()); EXPECT_EQ(IPV6_TO_IPV4_CHANGE, connection_.active_effective_peer_migration_type()); + if (connection_.validate_client_address()) { + EXPECT_NE(send_algorithm_, + connection_.sent_packet_manager().GetSendAlgorithm()); + EXPECT_EQ(kFinalPeerAddress, writer_->last_write_peer_address()); + EXPECT_FALSE(writer_->path_challenge_frames().empty()); + EXPECT_EQ(0u, connection_.GetStats() + .num_peer_migration_while_validating_default_path); + EXPECT_TRUE(connection_.HasPendingPathValidation()); + } } -TEST_P(QuicConnectionTest, ReceivePathProbeWithNoAddressChangeAtServer) { - PathProbeTestInit(Perspective::IS_SERVER); +TEST_P(QuicConnectionTest, ReversePathValidationFailureAtServer) { + if (!connection_.validate_client_address()) { + return; + } + set_perspective(Perspective::IS_SERVER); + QuicPacketCreatorPeer::SetSendVersionInPacket(creator_, false); + EXPECT_EQ(Perspective::IS_SERVER, connection_.perspective()); + connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); + // Prevent packets from being coalesced. + EXPECT_CALL(visitor_, GetHandshakeState()) + .WillRepeatedly(Return(HANDSHAKE_CONFIRMED)); + QuicConnectionPeer::SetAddressValidated(&connection_); // Clear direct_peer_address. QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress()); @@ -1733,15 +1966,73 @@ TEST_P(QuicConnectionTest, ReceivePathProbeWithNoAddressChangeAtServer) { QuicSocketAddress()); EXPECT_FALSE(connection_.effective_peer_address().IsInitialized()); - if (QuicVersionUsesCryptoFrames(connection_.transport_version())) { - EXPECT_CALL(visitor_, OnCryptoFrame(_)).Times(AnyNumber()); - } else { - EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(AnyNumber()); + const QuicSocketAddress kNewPeerAddress = + QuicSocketAddress(QuicIpAddress::Loopback4(), /*port=*/23456); + EXPECT_CALL(visitor_, OnStreamFrame(_)) + .WillOnce(Invoke( + [=]() { EXPECT_EQ(kPeerAddress, connection_.peer_address()); })) + .WillOnce(Invoke([=]() { + EXPECT_EQ((GetQuicReloadableFlag(quic_start_peer_migration_earlier) || + !GetParam().version.HasIetfQuicFrames() + ? kNewPeerAddress + : kPeerAddress), + connection_.peer_address()); + })); + QuicFrames frames; + frames.push_back(QuicFrame(frame1_)); + ProcessFramesPacketWithAddresses(frames, kSelfAddress, kPeerAddress, + ENCRYPTION_FORWARD_SECURE); + EXPECT_EQ(kPeerAddress, connection_.peer_address()); + EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); + + // Process another packet with a different peer address on server side will + // start connection migration. + EXPECT_CALL(visitor_, OnConnectionMigration(IPV6_TO_IPV4_CHANGE)).Times(1); + // IETF QUIC send algorithm should be changed to a different object, so no + // OnPacketSent() called on the old send algorithm. + EXPECT_CALL(*send_algorithm_, OnConnectionMigration()).Times(0); + + QuicFrames frames2; + frames2.push_back(QuicFrame(frame2_)); + ProcessFramesPacketWithAddresses(frames2, kSelfAddress, kNewPeerAddress, + ENCRYPTION_FORWARD_SECURE); + EXPECT_EQ(kNewPeerAddress, connection_.peer_address()); + EXPECT_EQ(kNewPeerAddress, connection_.effective_peer_address()); + EXPECT_EQ(IPV6_TO_IPV4_CHANGE, + connection_.active_effective_peer_migration_type()); + EXPECT_EQ(1u, writer_->packets_write_attempts()); + EXPECT_FALSE(writer_->path_challenge_frames().empty()); + EXPECT_NE(connection_.sent_packet_manager().GetSendAlgorithm(), + send_algorithm_); + EXPECT_EQ(kNewPeerAddress, writer_->last_write_peer_address()); + EXPECT_EQ(kNewPeerAddress, connection_.peer_address()); + EXPECT_EQ(kNewPeerAddress, connection_.effective_peer_address()); + + for (size_t i = 0; i < QuicPathValidator::kMaxRetryTimes; ++i) { + clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(3 * kInitialRttMs)); + static_cast<TestAlarmFactory::TestAlarm*>( + QuicPathValidatorPeer::retry_timer( + QuicConnectionPeer::path_validator(&connection_))) + ->Fire(); } - ProcessFramePacketWithAddresses(MakeCryptoFrame(), kSelfAddress, kPeerAddress, - ENCRYPTION_INITIAL); + EXPECT_EQ(IPV6_TO_IPV4_CHANGE, + connection_.active_effective_peer_migration_type()); + + // Advance the time so that the reverse path validation times out. + clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(3 * kInitialRttMs)); + static_cast<TestAlarmFactory::TestAlarm*>( + QuicPathValidatorPeer::retry_timer( + QuicConnectionPeer::path_validator(&connection_))) + ->Fire(); + EXPECT_EQ(NO_CHANGE, connection_.active_effective_peer_migration_type()); EXPECT_EQ(kPeerAddress, connection_.peer_address()); EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); + EXPECT_EQ(connection_.sent_packet_manager().GetSendAlgorithm(), + send_algorithm_); +} + +TEST_P(QuicConnectionTest, ReceivePathProbeWithNoAddressChangeAtServer) { + PathProbeTestInit(Perspective::IS_SERVER); EXPECT_CALL(visitor_, OnConnectionMigration(PORT_CHANGE)).Times(0); EXPECT_CALL(visitor_, OnPacketReceived(_, _, false)).Times(0); @@ -1833,6 +2124,50 @@ TEST_P(QuicConnectionTest, DiscardQueuedPacketsAfterConnectionClose) { EXPECT_EQ(0u, connection_.GetStats().packets_discarded); } +class TestQuicPathValidationContext : public QuicPathValidationContext { + public: + TestQuicPathValidationContext(const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address, + + QuicPacketWriter* writer) + : QuicPathValidationContext(self_address, peer_address), + writer_(writer) {} + + QuicPacketWriter* WriterToUse() override { return writer_; } + + private: + QuicPacketWriter* writer_; +}; + +class TestValidationResultDelegate : public QuicPathValidator::ResultDelegate { + public: + TestValidationResultDelegate(const QuicSocketAddress& expected_self_address, + const QuicSocketAddress& expected_peer_address, + bool* success) + : QuicPathValidator::ResultDelegate(), + expected_self_address_(expected_self_address), + expected_peer_address_(expected_peer_address), + success_(success) {} + void OnPathValidationSuccess( + std::unique_ptr<QuicPathValidationContext> context) override { + EXPECT_EQ(expected_self_address_, context->self_address()); + EXPECT_EQ(expected_peer_address_, context->peer_address()); + *success_ = true; + } + + void OnPathValidationFailure( + std::unique_ptr<QuicPathValidationContext> context) override { + EXPECT_EQ(expected_self_address_, context->self_address()); + EXPECT_EQ(expected_peer_address_, context->peer_address()); + *success_ = false; + } + + private: + QuicSocketAddress expected_self_address_; + QuicSocketAddress expected_peer_address_; + bool* success_; +}; + // Receive a path probe request at the server side, i.e., // in non-IETF version: receive a padded PING packet with a peer addess change; // in IETF version: receive a packet contains PATH CHALLENGE with peer address @@ -1840,43 +2175,34 @@ TEST_P(QuicConnectionTest, DiscardQueuedPacketsAfterConnectionClose) { TEST_P(QuicConnectionTest, ReceivePathProbingAtServer) { PathProbeTestInit(Perspective::IS_SERVER); - // Clear direct_peer_address. - QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress()); - // Clear effective_peer_address, it is the same as direct_peer_address for - // this test. - QuicConnectionPeer::SetEffectivePeerAddress(&connection_, - QuicSocketAddress()); - EXPECT_FALSE(connection_.effective_peer_address().IsInitialized()); - - if (QuicVersionUsesCryptoFrames(connection_.transport_version())) { - EXPECT_CALL(visitor_, OnCryptoFrame(_)).Times(AnyNumber()); - } else { - EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(AnyNumber()); - } - ProcessFramePacketWithAddresses(MakeCryptoFrame(), kSelfAddress, kPeerAddress, - ENCRYPTION_INITIAL); - EXPECT_EQ(kPeerAddress, connection_.peer_address()); - EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); - EXPECT_CALL(visitor_, OnConnectionMigration(PORT_CHANGE)).Times(0); + QuicPathFrameBuffer payload; if (!GetParam().version.HasIetfQuicFrames()) { EXPECT_CALL(visitor_, OnPacketReceived(_, _, /*is_connectivity_probe=*/true)) .Times(1); } else { EXPECT_CALL(visitor_, OnPacketReceived(_, _, _)).Times(0); + if (connection_.validate_client_address()) { + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) + .Times(AtLeast(1u)) + .WillOnce(Invoke([&]() { + EXPECT_EQ(1u, writer_->path_challenge_frames().size()); + EXPECT_EQ(1u, writer_->path_response_frames().size()); + payload = writer_->path_challenge_frames().front().data_buffer; + })); + } } - // Process a padded PING packet from a new peer address on server side + // Process a probing packet from a new peer address on server side // is effectively receiving a connectivity probing. - const QuicSocketAddress kNewPeerAddress = - QuicSocketAddress(QuicIpAddress::Loopback6(), /*port=*/23456); + const QuicSocketAddress kNewPeerAddress(QuicIpAddress::Loopback4(), + /*port=*/23456); std::unique_ptr<SerializedPacket> probing_packet = ConstructProbingPacket(); std::unique_ptr<QuicReceivedPacket> received(ConstructReceivedPacket( QuicEncryptedPacket(probing_packet->encrypted_buffer, probing_packet->encrypted_length), clock_.Now())); - uint64_t num_probing_received = connection_.GetStats().num_connectivity_probing_received; ProcessReceivedPacket(kSelfAddress, kNewPeerAddress, *received); @@ -1885,6 +2211,70 @@ TEST_P(QuicConnectionTest, ReceivePathProbingAtServer) { connection_.GetStats().num_connectivity_probing_received); EXPECT_EQ(kPeerAddress, connection_.peer_address()); EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); + if (GetParam().version.HasIetfQuicFrames() && + connection_.use_path_validator() && + GetQuicReloadableFlag(quic_count_bytes_on_alternative_path_seperately)) { + QuicByteCount bytes_sent = + QuicConnectionPeer::BytesSentOnAlternativePath(&connection_); + EXPECT_LT(0u, bytes_sent); + EXPECT_EQ(received->length(), + QuicConnectionPeer::BytesReceivedOnAlternativePath(&connection_)); + + // Receiving one more probing packet should update the bytes count. + probing_packet = ConstructProbingPacket(); + received.reset(ConstructReceivedPacket( + QuicEncryptedPacket(probing_packet->encrypted_buffer, + probing_packet->encrypted_length), + clock_.Now())); + ProcessReceivedPacket(kSelfAddress, kNewPeerAddress, *received); + + EXPECT_EQ(num_probing_received + 2, + connection_.GetStats().num_connectivity_probing_received); + EXPECT_EQ(2 * bytes_sent, + QuicConnectionPeer::BytesSentOnAlternativePath(&connection_)); + EXPECT_EQ(2 * received->length(), + QuicConnectionPeer::BytesReceivedOnAlternativePath(&connection_)); + + bool success = false; + if (!connection_.validate_client_address()) { + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) + .Times(AtLeast(1u)) + .WillOnce(Invoke([&]() { + EXPECT_EQ(1u, writer_->path_challenge_frames().size()); + payload = writer_->path_challenge_frames().front().data_buffer; + })); + + connection_.ValidatePath( + std::make_unique<TestQuicPathValidationContext>( + connection_.self_address(), kNewPeerAddress, writer_.get()), + std::make_unique<TestValidationResultDelegate>( + connection_.self_address(), kNewPeerAddress, &success)); + } + EXPECT_EQ((connection_.validate_client_address() ? 2 : 3) * bytes_sent, + QuicConnectionPeer::BytesSentOnAlternativePath(&connection_)); + QuicFrames frames; + frames.push_back(QuicFrame(new QuicPathResponseFrame(99, payload))); + ProcessFramesPacketWithAddresses(frames, connection_.self_address(), + kNewPeerAddress, + ENCRYPTION_FORWARD_SECURE); + EXPECT_LT(2 * received->length(), + QuicConnectionPeer::BytesReceivedOnAlternativePath(&connection_)); + EXPECT_TRUE(QuicConnectionPeer::IsAlternativePathValidated(&connection_)); + + // Receiving another probing packet from a newer address with a different + // port shouldn't trigger another reverse path validation. + QuicSocketAddress kNewerPeerAddress(QuicIpAddress::Loopback4(), + /*port=*/34567); + probing_packet = ConstructProbingPacket(); + received.reset(ConstructReceivedPacket( + QuicEncryptedPacket(probing_packet->encrypted_buffer, + probing_packet->encrypted_length), + clock_.Now())); + ProcessReceivedPacket(kSelfAddress, kNewerPeerAddress, *received); + EXPECT_FALSE(connection_.HasPendingPathValidation()); + EXPECT_EQ(connection_.validate_client_address(), + QuicConnectionPeer::IsAlternativePathValidated(&connection_)); + } // Process another packet with the old peer address on server side will not // start peer migration. @@ -1900,6 +2290,9 @@ TEST_P(QuicConnectionTest, ReceivePaddedPingWithPortChangeAtServer) { set_perspective(Perspective::IS_SERVER); QuicPacketCreatorPeer::SetSendVersionInPacket(creator_, false); EXPECT_EQ(Perspective::IS_SERVER, connection_.perspective()); + if (version().SupportsAntiAmplificationLimit()) { + QuicConnectionPeer::SetAddressValidated(&connection_); + } // Clear direct_peer_address. QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress()); @@ -1922,6 +2315,8 @@ TEST_P(QuicConnectionTest, ReceivePaddedPingWithPortChangeAtServer) { if (GetParam().version.HasIetfQuicFrames()) { // In IETF version, a padded PING packet with port change is not taken as // connectivity probe. + EXPECT_CALL(visitor_, GetHandshakeState()) + .WillRepeatedly(Return(HANDSHAKE_CONFIRMED)); EXPECT_CALL(visitor_, OnConnectionMigration(PORT_CHANGE)).Times(1); EXPECT_CALL(visitor_, OnPacketReceived(_, _, _)).Times(0); } else { @@ -1964,12 +2359,11 @@ TEST_P(QuicConnectionTest, ReceivePaddedPingWithPortChangeAtServer) { EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); } - // Process another packet with the old peer address on server side. if (GetParam().version.HasIetfQuicFrames()) { EXPECT_CALL(visitor_, OnConnectionMigration(PORT_CHANGE)).Times(1); - } else { - EXPECT_CALL(visitor_, OnConnectionMigration(PORT_CHANGE)).Times(0); } + // Process another packet with the old peer address on server side. gQUIC + // shouldn't regard this as a peer migration. ProcessFramePacketWithAddresses(MakeCryptoFrame(), kSelfAddress, kPeerAddress, ENCRYPTION_INITIAL); EXPECT_EQ(kPeerAddress, connection_.peer_address()); @@ -1979,25 +2373,6 @@ TEST_P(QuicConnectionTest, ReceivePaddedPingWithPortChangeAtServer) { TEST_P(QuicConnectionTest, ReceiveReorderedPathProbingAtServer) { PathProbeTestInit(Perspective::IS_SERVER); - // Clear direct_peer_address. - QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress()); - // Clear effective_peer_address, it is the same as direct_peer_address for - // this test. - QuicConnectionPeer::SetEffectivePeerAddress(&connection_, - QuicSocketAddress()); - EXPECT_FALSE(connection_.effective_peer_address().IsInitialized()); - - if (QuicVersionUsesCryptoFrames(connection_.transport_version())) { - EXPECT_CALL(visitor_, OnCryptoFrame(_)).Times(AnyNumber()); - } else { - EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(AnyNumber()); - } - QuicPacketCreatorPeer::SetPacketNumber(&peer_creator_, 5); - ProcessFramePacketWithAddresses(MakeCryptoFrame(), kSelfAddress, kPeerAddress, - ENCRYPTION_INITIAL); - EXPECT_EQ(kPeerAddress, connection_.peer_address()); - EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); - // Decrease packet number to simulate out-of-order packets. QuicPacketCreatorPeer::SetPacketNumber(&peer_creator_, 4); @@ -2035,24 +2410,6 @@ TEST_P(QuicConnectionTest, ReceiveReorderedPathProbingAtServer) { TEST_P(QuicConnectionTest, MigrateAfterProbingAtServer) { PathProbeTestInit(Perspective::IS_SERVER); - // Clear direct_peer_address. - QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress()); - // Clear effective_peer_address, it is the same as direct_peer_address for - // this test. - QuicConnectionPeer::SetEffectivePeerAddress(&connection_, - QuicSocketAddress()); - EXPECT_FALSE(connection_.effective_peer_address().IsInitialized()); - - if (QuicVersionUsesCryptoFrames(connection_.transport_version())) { - EXPECT_CALL(visitor_, OnCryptoFrame(_)).Times(AnyNumber()); - } else { - EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(AnyNumber()); - } - ProcessFramePacketWithAddresses(MakeCryptoFrame(), kSelfAddress, kPeerAddress, - ENCRYPTION_INITIAL); - EXPECT_EQ(kPeerAddress, connection_.peer_address()); - EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); - EXPECT_CALL(visitor_, OnConnectionMigration(PORT_CHANGE)).Times(0); if (!GetParam().version.HasIetfQuicFrames()) { EXPECT_CALL(visitor_, @@ -2090,24 +2447,6 @@ TEST_P(QuicConnectionTest, ReceiveConnectivityProbingPacketAtClient) { EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); PathProbeTestInit(Perspective::IS_CLIENT); - // Clear direct_peer_address. - QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress()); - // Clear effective_peer_address, it is the same as direct_peer_address for - // this test. - QuicConnectionPeer::SetEffectivePeerAddress(&connection_, - QuicSocketAddress()); - EXPECT_FALSE(connection_.effective_peer_address().IsInitialized()); - - if (QuicVersionUsesCryptoFrames(connection_.transport_version())) { - EXPECT_CALL(visitor_, OnCryptoFrame(_)).Times(AnyNumber()); - } else { - EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(AnyNumber()); - } - ProcessFramePacketWithAddresses(MakeCryptoFrame(), kSelfAddress, kPeerAddress, - ENCRYPTION_INITIAL); - EXPECT_EQ(kPeerAddress, connection_.peer_address()); - EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); - // Client takes all padded PING packet as speculative connectivity // probing packet, and reports to visitor. EXPECT_CALL(visitor_, OnConnectionMigration(PORT_CHANGE)).Times(0); @@ -2143,24 +2482,6 @@ TEST_P(QuicConnectionTest, ReceiveConnectivityProbingResponseAtClient) { EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); PathProbeTestInit(Perspective::IS_CLIENT); - // Clear direct_peer_address. - QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress()); - // Clear effective_peer_address, it is the same as direct_peer_address for - // this test. - QuicConnectionPeer::SetEffectivePeerAddress(&connection_, - QuicSocketAddress()); - EXPECT_FALSE(connection_.effective_peer_address().IsInitialized()); - - if (QuicVersionUsesCryptoFrames(connection_.transport_version())) { - EXPECT_CALL(visitor_, OnCryptoFrame(_)).Times(AnyNumber()); - } else { - EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(AnyNumber()); - } - ProcessFramePacketWithAddresses(MakeCryptoFrame(), kSelfAddress, kPeerAddress, - ENCRYPTION_INITIAL); - EXPECT_EQ(kPeerAddress, connection_.peer_address()); - EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); - // Process a padded PING packet with a different self address on client side // is effectively receiving a connectivity probing. EXPECT_CALL(visitor_, OnConnectionMigration(PORT_CHANGE)).Times(0); @@ -2544,8 +2865,7 @@ TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) { // switched to ENCRYPTION_FORWARD_SECURE in SendStreamDataToPeer. EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, - VersionHasIetfInvariantHeader( - GetParam().version.transport_version) + GetParam().version.HasIetfInvariantHeader() ? packet_size : packet_size - kQuicVersionSize, _)) @@ -2763,7 +3083,7 @@ TEST_P(QuicConnectionTest, AckNeedsRetransmittableFramesAfterPto) { } TEST_P(QuicConnectionTest, LeastUnackedLower) { - if (VersionHasIetfInvariantHeader(GetParam().version.transport_version)) { + if (GetParam().version.HasIetfInvariantHeader()) { return; } EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); @@ -2814,14 +3134,25 @@ TEST_P(QuicConnectionTest, TooManySentPackets) { SendStreamDataToPeer(1, "foo", 3 * i, NO_FIN, nullptr); } - // Ack packet 1, which leaves more than the limit outstanding. - EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _, _)); EXPECT_CALL(visitor_, OnConnectionClosed(_, ConnectionCloseSource::FROM_SELF)); - // Nack the first packet and ack the rest, leaving a huge gap. - QuicAckFrame frame1 = ConstructAckFrame(num_packets, 1); - ProcessAckPacket(&frame1); + ProcessFramePacket(QuicFrame(QuicPingFrame())); + + if (!GetQuicReloadableFlag( + quic_close_connection_with_too_many_outstanding_packets)) { + // When the flag is false, the ping packet processed above shouldn't cause + // the connection to close. But the ack packet below will. + EXPECT_TRUE(connection_.connected()); + + // Ack packet 1, which leaves more than the limit outstanding. + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _, _)); + + // Nack the first packet and ack the rest, leaving a huge gap. + QuicAckFrame frame1 = ConstructAckFrame(num_packets, 1); + ProcessAckPacket(&frame1); + } + TestConnectionCloseQuicErrorCode(QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS); } @@ -3582,8 +3913,7 @@ TEST_P(QuicConnectionTest, RetransmitNackedLargestObserved) { // switched to ENCRYPTION_FORWARD_SECURE in SendStreamDataToPeer. EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, - VersionHasIetfInvariantHeader( - GetParam().version.transport_version) + GetParam().version.HasIetfInvariantHeader() ? packet_size : packet_size - kQuicVersionSize, _)); @@ -3975,7 +4305,7 @@ TEST_P(QuicConnectionTest, TailLossProbeDelayForNonStreamDataInTLPR) { options.push_back(kTLPR); config.SetConnectionOptionsToSend(options); QuicConfigPeer::SetNegotiated(&config, true); - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_.connection_id()); QuicConfigPeer::SetReceivedInitialSourceConnectionId( @@ -4047,11 +4377,6 @@ TEST_P(QuicConnectionTest, TailLossProbeDelayForNonStreamDataInTLPR) { connection_.GetPingAlarm()->deadline() - clock_.ApproximateNow()); // Simulate firing of the retransmittable on wire and send a PING. - if (!GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - EXPECT_CALL(visitor_, SendPing()).WillOnce(Invoke([this]() { - SendPing(); - })); - } clock_.AdvanceTime(retransmittable_on_wire_timeout); connection_.GetPingAlarm()->Fire(); @@ -4065,21 +4390,14 @@ TEST_P(QuicConnectionTest, TailLossProbeDelayForNonStreamDataInTLPR) { QuicTime::Delta::FromMilliseconds(kMinRetransmissionTimeMs); srtt = manager_->GetRttStats()->SmoothedOrInitialRtt(); - if (GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - // Arm RTO mode since there is only PING in flight. - expected_delay = manager_->GetPtoDelay(); - } else { - // First TLP without unacked stream data will no longer use TLPR. - expected_delay = std::max(2 * srtt, 1.5 * srtt + 0.5 * min_rto_timeout); - } + // Arm RTO mode since there is only PING in flight. + expected_delay = manager_->GetPtoDelay(); EXPECT_EQ(expected_delay, connection_.GetRetransmissionAlarm()->deadline() - clock_.Now()); // Verify the path degrading delay = TLP delay + 1st RTO + 2nd RTO. // Add 1st RTO. - if (GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - expected_delay = std::max(2 * srtt, 1.5 * srtt + 0.5 * min_rto_timeout); - } + expected_delay = std::max(2 * srtt, 1.5 * srtt + 0.5 * min_rto_timeout); retransmission_delay = std::max(manager_->GetRttStats()->smoothed_rtt() + 4 * manager_->GetRttStats()->mean_deviation(), @@ -4106,12 +4424,8 @@ TEST_P(QuicConnectionTest, TailLossProbeDelayForNonStreamDataInTLPR) { // Verify the retransmission delay. // First TLP without unacked stream data will no longer use TLPR. - if (GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - // Arm RTO mode since there is only PING in flight. - expected_delay = manager_->GetPtoDelay(); - } else { - expected_delay = std::max(2 * srtt, 1.5 * srtt + 0.5 * min_rto_timeout); - } + // Arm RTO mode since there is only PING in flight. + expected_delay = manager_->GetPtoDelay(); expected_delay = expected_delay - QuicTime::Delta::FromMilliseconds(5); EXPECT_EQ(expected_delay, connection_.GetRetransmissionAlarm()->deadline() - clock_.Now()); @@ -4637,11 +4951,6 @@ TEST_P(QuicConnectionTest, PingAfterSend) { writer_->Reset(); clock_.AdvanceTime(QuicTime::Delta::FromSeconds(15)); - if (!GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - EXPECT_CALL(visitor_, SendPing()).WillOnce(Invoke([this]() { - SendPing(); - })); - } connection_.GetPingAlarm()->Fire(); size_t padding_frame_count = writer_->padding_frames().size(); EXPECT_EQ(padding_frame_count + 1u, writer_->frame_count()); @@ -4695,11 +5004,6 @@ TEST_P(QuicConnectionTest, ReducedPingTimeout) { writer_->Reset(); clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10)); - if (!GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - EXPECT_CALL(visitor_, SendPing()).WillOnce(Invoke([this]() { - connection_.SendControlFrame(QuicFrame(QuicPingFrame(1))); - })); - } connection_.GetPingAlarm()->Fire(); size_t padding_frame_count = writer_->padding_frames().size(); EXPECT_EQ(padding_frame_count + 1u, writer_->frame_count()); @@ -5482,7 +5786,7 @@ TEST_P(QuicConnectionTest, TimeoutAfterSendAfterHandshake) { config.ProcessPeerHello(msg, CLIENT, &error_details); EXPECT_THAT(error, IsQuicNoError()); - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_.connection_id()); QuicConfigPeer::SetReceivedInitialSourceConnectionId( @@ -5619,7 +5923,7 @@ TEST_P(QuicConnectionTest, TimeoutAfterSendSilentCloseWithOpenStreams) { config.ProcessPeerHello(msg, CLIENT, &error_details); EXPECT_THAT(error, IsQuicNoError()); - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_.connection_id()); QuicConfigPeer::SetReceivedInitialSourceConnectionId( @@ -5786,7 +6090,7 @@ TEST_P(QuicConnectionTest, TimeoutAfter5ClientRTOs) { EXPECT_CALL(visitor_, GetHandshakeState()) .WillRepeatedly(Return(HANDSHAKE_COMPLETE)); } - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_.connection_id()); QuicConfigPeer::SetReceivedInitialSourceConnectionId( @@ -5889,7 +6193,7 @@ TEST_P(QuicConnectionTest, SendingThreePackets) { TEST_P(QuicConnectionTest, LoopThroughSendingPacketsWithTruncation) { set_perspective(Perspective::IS_SERVER); - if (!VersionHasIetfInvariantHeader(GetParam().version.transport_version)) { + if (!GetParam().version.HasIetfInvariantHeader()) { // For IETF QUIC, encryption level will be switched to FORWARD_SECURE in // SendStreamDataWithString. QuicPacketCreatorPeer::SetSendVersionInPacket(creator_, false); @@ -5915,7 +6219,7 @@ TEST_P(QuicConnectionTest, LoopThroughSendingPacketsWithTruncation) { EXPECT_EQ(payload.size(), connection_.SendStreamDataWithString(3, payload, 1350, NO_FIN) .bytes_consumed); - if (VersionHasIetfInvariantHeader(connection_.transport_version())) { + if (connection_.version().HasIetfInvariantHeader()) { // Short header packets sent from server omit connection ID already, and // stream offset size increases from 0 to 2. EXPECT_EQ(non_truncated_packet_size, writer_->last_packet_size() - 2); @@ -6505,10 +6809,12 @@ TEST_P(QuicConnectionTest, WriterBlockedAfterServerSendsConnectivityProbe) { .Times(1); if (connection_.send_path_response() && VersionHasIetfQuicFrames(GetParam().version.transport_version)) { - QuicPathFrameBuffer payload; + QuicPathFrameBuffer payload{ + {0xde, 0xad, 0xbe, 0xef, 0xba, 0xdc, 0x0f, 0xfe}}; QuicConnection::ScopedPacketFlusher flusher(&connection_); - connection_.SendPathChallenge(&payload, connection_.self_address(), - connection_.peer_address(), writer_.get()); + connection_.SendPathChallenge( + payload, connection_.self_address(), connection_.peer_address(), + connection_.effective_peer_address(), writer_.get()); } else { connection_.SendConnectivityProbingPacket(writer_.get(), connection_.peer_address()); @@ -6545,7 +6851,7 @@ TEST_P(QuicConnectionTest, WriterErrorWhenServerSendsConnectivityProbe) { } TEST_P(QuicConnectionTest, PublicReset) { - if (VersionHasIetfInvariantHeader(GetParam().version.transport_version)) { + if (GetParam().version.HasIetfInvariantHeader()) { return; } QuicPublicResetPacket header; @@ -6564,7 +6870,7 @@ TEST_P(QuicConnectionTest, PublicReset) { } TEST_P(QuicConnectionTest, IetfStatelessReset) { - if (!VersionHasIetfInvariantHeader(GetParam().version.transport_version)) { + if (!GetParam().version.HasIetfInvariantHeader()) { return; } const QuicUint128 kTestStatelessResetToken = 1010101; @@ -6578,7 +6884,9 @@ TEST_P(QuicConnectionTest, IetfStatelessReset) { kTestStatelessResetToken)); std::unique_ptr<QuicReceivedPacket> received( ConstructReceivedPacket(*packet, QuicTime::Zero())); - EXPECT_CALL(visitor_, ValidateStatelessReset(_, _)).WillOnce(Return(true)); + if (!connection_.use_path_validator()) { + EXPECT_CALL(visitor_, ValidateStatelessReset(_, _)).WillOnce(Return(true)); + } EXPECT_CALL(visitor_, OnConnectionClosed(_, ConnectionCloseSource::FROM_PEER)) .WillOnce(Invoke(this, &QuicConnectionTest::SaveConnectionCloseFrame)); connection_.ProcessUdpPacket(kSelfAddress, kPeerAddress, *received); @@ -6632,7 +6940,7 @@ TEST_P(QuicConnectionTest, ZeroBytePacket) { } TEST_P(QuicConnectionTest, MissingPacketsBeforeLeastUnacked) { - if (VersionHasIetfInvariantHeader(GetParam().version.transport_version)) { + if (GetParam().version.HasIetfInvariantHeader()) { return; } // Set the packet number of the ack packet to be least unacked (4). @@ -6655,7 +6963,7 @@ TEST_P(QuicConnectionTest, ClientHandlesVersionNegotiation) { std::unique_ptr<QuicEncryptedPacket> encrypted( QuicFramer::BuildVersionNegotiationPacket( connection_id_, EmptyQuicConnectionId(), - VersionHasIetfInvariantHeader(connection_.transport_version()), + connection_.version().HasIetfInvariantHeader(), connection_.version().HasLengthPrefixedConnectionIds(), versions)); std::unique_ptr<QuicReceivedPacket> received( ConstructReceivedPacket(*encrypted, QuicTime::Zero())); @@ -6678,7 +6986,7 @@ TEST_P(QuicConnectionTest, BadVersionNegotiation) { std::unique_ptr<QuicEncryptedPacket> encrypted( QuicFramer::BuildVersionNegotiationPacket( connection_id_, EmptyQuicConnectionId(), - VersionHasIetfInvariantHeader(connection_.transport_version()), + connection_.version().HasIetfInvariantHeader(), connection_.version().HasLengthPrefixedConnectionIds(), AllSupportedVersions())); std::unique_ptr<QuicReceivedPacket> received( @@ -6735,9 +7043,7 @@ TEST_P(QuicConnectionTest, CheckSendStats) { // For IETF QUIC, version is not included as the encryption level switches to // FORWARD_SECURE in SendStreamDataWithString. size_t save_on_version = - VersionHasIetfInvariantHeader(GetParam().version.transport_version) - ? 0 - : kQuicVersionSize; + GetParam().version.HasIetfInvariantHeader() ? 0 : kQuicVersionSize; EXPECT_EQ(3 * first_packet_size + 2 * second_packet_size - save_on_version, stats.bytes_sent); EXPECT_EQ(5u, stats.packets_sent); @@ -6754,12 +7060,12 @@ TEST_P(QuicConnectionTest, ProcessFramesIfPacketClosedConnection) { if (peer_framer_.perspective() == Perspective::IS_SERVER) { header.source_connection_id = connection_id_; header.destination_connection_id_included = CONNECTION_ID_ABSENT; - if (!VersionHasIetfInvariantHeader(peer_framer_.transport_version())) { + if (!peer_framer_.version().HasIetfInvariantHeader()) { header.source_connection_id_included = CONNECTION_ID_PRESENT; } } else { header.destination_connection_id = connection_id_; - if (VersionHasIetfInvariantHeader(peer_framer_.transport_version())) { + if (peer_framer_.version().HasIetfInvariantHeader()) { header.destination_connection_id_included = CONNECTION_ID_ABSENT; } } @@ -6771,7 +7077,7 @@ TEST_P(QuicConnectionTest, ProcessFramesIfPacketClosedConnection) { // close. If doing IETF QUIC then set fields appropriately for CC/T or CC/A, // depending on the mapping. QuicConnectionCloseFrame qccf(peer_framer_.transport_version(), - kQuicErrorCode, "", + kQuicErrorCode, NO_IETF_QUIC_ERROR, "", /*transport_close_frame_type=*/0); QuicFrames frames; frames.push_back(QuicFrame(frame1_)); @@ -6856,20 +7162,10 @@ TEST_P(QuicConnectionTest, OnPacketSentDebugVisitor) { MockQuicConnectionDebugVisitor debug_visitor; connection_.set_debug_visitor(&debug_visitor); - if (connection_.sent_packet_manager() - .give_sent_packet_to_debug_visitor_after_sent()) { - EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _, _, _, _, _, _)).Times(1); - } else { - EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _)).Times(1); - } + EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _, _, _, _, _, _)).Times(1); connection_.SendStreamDataWithString(1, "foo", 0, NO_FIN); - if (connection_.sent_packet_manager() - .give_sent_packet_to_debug_visitor_after_sent()) { - EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _, _, _, _, _, _)).Times(1); - } else { - EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _)).Times(1); - } + EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _, _, _, _, _, _)).Times(1); connection_.SendConnectivityProbingPacket(writer_.get(), connection_.peer_address()); } @@ -6877,7 +7173,7 @@ TEST_P(QuicConnectionTest, OnPacketSentDebugVisitor) { TEST_P(QuicConnectionTest, OnPacketHeaderDebugVisitor) { QuicPacketHeader header; header.packet_number = QuicPacketNumber(1); - if (VersionHasIetfInvariantHeader(GetParam().version.transport_version)) { + if (GetParam().version.HasIetfInvariantHeader()) { header.form = IETF_QUIC_LONG_HEADER_PACKET; } @@ -6996,12 +7292,7 @@ TEST_P(QuicConnectionTest, SendPingImmediately) { CongestionBlockWrites(); connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); - if (connection_.sent_packet_manager() - .give_sent_packet_to_debug_visitor_after_sent()) { - EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _, _, _, _, _, _)).Times(1); - } else { - EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _)).Times(1); - } + EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _, _, _, _, _, _)).Times(1); EXPECT_CALL(debug_visitor, OnPingSent()).Times(1); connection_.SendControlFrame(QuicFrame(QuicPingFrame(1))); EXPECT_FALSE(connection_.HasQueuedData()); @@ -7013,12 +7304,7 @@ TEST_P(QuicConnectionTest, SendBlockedImmediately) { connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); - if (connection_.sent_packet_manager() - .give_sent_packet_to_debug_visitor_after_sent()) { - EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _, _, _, _, _, _)).Times(1); - } else { - EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _)).Times(1); - } + EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _, _, _, _, _, _)).Times(1); EXPECT_EQ(0u, connection_.GetStats().blocked_frames_sent); connection_.SendControlFrame(QuicFrame(new QuicBlockedFrame(1, 3))); EXPECT_EQ(1u, connection_.GetStats().blocked_frames_sent); @@ -7034,12 +7320,7 @@ TEST_P(QuicConnectionTest, FailedToSendBlockedFrames) { QuicBlockedFrame blocked(1, 3); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); - if (connection_.sent_packet_manager() - .give_sent_packet_to_debug_visitor_after_sent()) { - EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _, _, _, _, _, _)).Times(0); - } else { - EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _)).Times(0); - } + EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _, _, _, _, _, _)).Times(0); EXPECT_EQ(0u, connection_.GetStats().blocked_frames_sent); connection_.SendControlFrame(QuicFrame(&blocked)); EXPECT_EQ(0u, connection_.GetStats().blocked_frames_sent); @@ -7216,11 +7497,6 @@ TEST_P(QuicConnectionTest, RetransmittableOnWireSetsPingAlarm) { // Simulate firing the ping alarm and sending a PING. clock_.AdvanceTime(retransmittable_on_wire_timeout); - if (!GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - EXPECT_CALL(visitor_, SendPing()).WillOnce(Invoke([this]() { - connection_.SendControlFrame(QuicFrame(QuicPingFrame(1))); - })); - } connection_.GetPingAlarm()->Fire(); // Now there's a retransmittable packet (PING) on the wire, so the path @@ -7232,6 +7508,45 @@ TEST_P(QuicConnectionTest, RetransmittableOnWireSetsPingAlarm) { clock_.ApproximateNow()); } +TEST_P(QuicConnectionTest, ServerRetransmittableOnWire) { + set_perspective(Perspective::IS_SERVER); + QuicPacketCreatorPeer::SetSendVersionInPacket(creator_, false); + SetQuicReloadableFlag(quic_enable_server_on_wire_ping, true); + + EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); + QuicConfig config; + QuicTagVector connection_options; + connection_options.push_back(kSRWP); + config.SetInitialReceivedConnectionOptions(connection_options); + connection_.SetFromConfig(config); + + EXPECT_CALL(visitor_, ShouldKeepConnectionAlive()) + .WillRepeatedly(Return(true)); + + ProcessPacket(1); + + ASSERT_TRUE(connection_.GetPingAlarm()->IsSet()); + QuicTime::Delta ping_delay = QuicTime::Delta::FromMilliseconds(200); + EXPECT_EQ(ping_delay, + connection_.GetPingAlarm()->deadline() - clock_.ApproximateNow()); + + clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(10)); + connection_.SendStreamDataWithString(2, "foo", 0, NO_FIN); + // Verify PING alarm gets cancelled. + EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); + + // Now receive an ACK of the packet. + clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(100)); + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _, _)); + QuicAckFrame frame = + InitAckFrame({{QuicPacketNumber(1), QuicPacketNumber(2)}}); + ProcessAckPacket(2, &frame); + // Verify PING alarm gets scheduled. + ASSERT_TRUE(connection_.GetPingAlarm()->IsSet()); + EXPECT_EQ(ping_delay, + connection_.GetPingAlarm()->deadline() - clock_.ApproximateNow()); +} + // This test verifies that the connection marks path as degrading and does not // spin timer to detect path degrading when a new packet is sent on the // degraded path. @@ -7770,45 +8085,26 @@ TEST_P(QuicConnectionTest, SendProbingRetransmissions) { } // Expect them retransmitted in cyclic order (foo, bar, test, foo, bar...). QuicPacketCount sent_count = 0; - if (connection_.sent_packet_manager() - .give_sent_packet_to_debug_visitor_after_sent()) { - EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _, _, _, _, _, _)) - .WillRepeatedly( - Invoke([this, &sent_count](QuicPacketNumber, QuicPacketLength, bool, - TransmissionType, EncryptionLevel, - const QuicFrames&, const QuicFrames&, - QuicTime) { - ASSERT_EQ(1u, writer_->stream_frames().size()); - if (connection_.version().CanSendCoalescedPackets()) { - // There is a delay of sending coalesced packet, so (6, 0, 3, 6, - // 0...). - EXPECT_EQ(3 * ((sent_count + 2) % 3), - writer_->stream_frames()[0]->offset); - } else { - // Identify the frames by stream offset (0, 3, 6, 0, 3...). - EXPECT_EQ(3 * (sent_count % 3), - writer_->stream_frames()[0]->offset); - } - sent_count++; - })); - } else { - EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _)) - .WillRepeatedly(Invoke([this, &sent_count](const SerializedPacket&, - TransmissionType, QuicTime) { - ASSERT_EQ(1u, writer_->stream_frames().size()); - if (connection_.version().CanSendCoalescedPackets()) { - // There is a delay of sending coalesced packet, so (6, 0, 3, 6, - // 0...). - EXPECT_EQ(3 * ((sent_count + 2) % 3), - writer_->stream_frames()[0]->offset); - } else { - // Identify the frames by stream offset (0, 3, 6, 0, 3...). - EXPECT_EQ(3 * (sent_count % 3), - writer_->stream_frames()[0]->offset); - } - sent_count++; - })); - } + + EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _, _, _, _, _, _)) + .WillRepeatedly(Invoke( + [this, &sent_count](QuicPacketNumber, QuicPacketLength, bool, + TransmissionType, EncryptionLevel, + const QuicFrames&, const QuicFrames&, QuicTime) { + ASSERT_EQ(1u, writer_->stream_frames().size()); + if (connection_.version().CanSendCoalescedPackets()) { + // There is a delay of sending coalesced packet, so (6, 0, 3, 6, + // 0...). + EXPECT_EQ(3 * ((sent_count + 2) % 3), + writer_->stream_frames()[0]->offset); + } else { + // Identify the frames by stream offset (0, 3, 6, 0, 3...). + EXPECT_EQ(3 * (sent_count % 3), + writer_->stream_frames()[0]->offset); + } + sent_count++; + })); + EXPECT_CALL(*send_algorithm_, ShouldSendProbingPacket()) .WillRepeatedly(Return(true)); EXPECT_CALL(visitor_, SendProbingData()).WillRepeatedly([this] { @@ -7832,12 +8128,7 @@ TEST_P(QuicConnectionTest, MockQuicConnectionDebugVisitor debug_visitor; connection_.set_debug_visitor(&debug_visitor); - if (connection_.sent_packet_manager() - .give_sent_packet_to_debug_visitor_after_sent()) { - EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _, _, _, _, _, _)).Times(0); - } else { - EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _)).Times(0); - } + EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _, _, _, _, _, _)).Times(0); EXPECT_CALL(*send_algorithm_, ShouldSendProbingPacket()) .WillRepeatedly(Return(true)); EXPECT_CALL(visitor_, SendProbingData()).WillRepeatedly([this] { @@ -7927,11 +8218,6 @@ TEST_P(QuicConnectionTest, PingAfterLastRetransmittablePacketAcked) { EXPECT_EQ(prev_deadline, connection_.GetPingAlarm()->deadline()); // Simulate the alarm firing and check that a PING is sent. - if (!GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - EXPECT_CALL(visitor_, SendPing()).WillOnce(Invoke([this]() { - connection_.SendControlFrame(QuicFrame(QuicPingFrame(1))); - })); - } connection_.GetPingAlarm()->Fire(); size_t padding_frame_count = writer_->padding_frames().size(); if (GetParam().no_stop_waiting) { @@ -8002,11 +8288,6 @@ TEST_P(QuicConnectionTest, NoPingIfRetransmittablePacketSent) { // Simulate the alarm firing and check that a PING is sent. writer_->Reset(); - if (!GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - EXPECT_CALL(visitor_, SendPing()).WillOnce(Invoke([this]() { - connection_.SendControlFrame(QuicFrame(QuicPingFrame(1))); - })); - } connection_.GetPingAlarm()->Fire(); size_t padding_frame_count = writer_->padding_frames().size(); if (GetParam().no_stop_waiting) { @@ -8066,11 +8347,6 @@ TEST_P(QuicConnectionTest, BackOffRetransmittableOnWireTimeout) { connection_.GetPingAlarm()->deadline() - clock_.ApproximateNow()); // Simulate the alarm firing and check that a PING is sent. writer_->Reset(); - if (!GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - EXPECT_CALL(visitor_, SendPing()).WillOnce(Invoke([this]() { - SendPing(); - })); - } clock_.AdvanceTime(initial_retransmittable_on_wire_timeout); connection_.GetPingAlarm()->Fire(); } @@ -8095,11 +8371,6 @@ TEST_P(QuicConnectionTest, BackOffRetransmittableOnWireTimeout) { // Simulate the alarm firing and check that a PING is sent. writer_->Reset(); - if (!GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - EXPECT_CALL(visitor_, SendPing()).WillOnce(Invoke([this]() { - SendPing(); - })); - } clock_.AdvanceTime(retransmittable_on_wire_timeout); connection_.GetPingAlarm()->Fire(); } @@ -8165,11 +8436,6 @@ TEST_P(QuicConnectionTest, ResetBackOffRetransmitableOnWireTimeout) { // Simulate the alarm firing and check that a PING is sent. writer_->Reset(); - if (!GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - EXPECT_CALL(visitor_, SendPing()).WillOnce(Invoke([this]() { - SendPing(); - })); - } clock_.AdvanceTime(initial_retransmittable_on_wire_timeout); connection_.GetPingAlarm()->Fire(); @@ -8205,11 +8471,6 @@ TEST_P(QuicConnectionTest, ResetBackOffRetransmitableOnWireTimeout) { connection_.GetPingAlarm()->deadline() - clock_.ApproximateNow()); // Simulate the alarm firing and check that a PING is sent. writer_->Reset(); - if (!GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - EXPECT_CALL(visitor_, SendPing()).WillOnce(Invoke([this]() { - SendPing(); - })); - } clock_.AdvanceTime(initial_retransmittable_on_wire_timeout); connection_.GetPingAlarm()->Fire(); // Advance 5ms to receive next packet. @@ -8227,11 +8488,6 @@ TEST_P(QuicConnectionTest, ResetBackOffRetransmitableOnWireTimeout) { connection_.GetPingAlarm()->deadline() - clock_.ApproximateNow()); writer_->Reset(); - if (!GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - EXPECT_CALL(visitor_, SendPing()).WillOnce(Invoke([this]() { - SendPing(); - })); - } clock_.AdvanceTime(2 * initial_retransmittable_on_wire_timeout); connection_.GetPingAlarm()->Fire(); @@ -8300,11 +8556,6 @@ TEST_P(QuicConnectionTest, RetransmittableOnWirePingLimit) { connection_.GetPingAlarm()->deadline() - clock_.ApproximateNow()); // Simulate the alarm firing and check that a PING is sent. writer_->Reset(); - if (!GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - EXPECT_CALL(visitor_, SendPing()).WillOnce(Invoke([this]() { - SendPing(); - })); - } clock_.AdvanceTime(initial_retransmittable_on_wire_timeout); connection_.GetPingAlarm()->Fire(); } @@ -8539,7 +8790,7 @@ TEST_P(QuicConnectionTest, ServerResponseToPathChallenge) { sizeof(challenge_data))); } -TEST_P(QuicConnectionTest, ClientResponseToPathChallenge) { +TEST_P(QuicConnectionTest, ClientResponseToPathChallengeOnDefaulSocket) { if (!VersionHasIetfQuicFrames(connection_.version().transport_version) || !connection_.send_path_response()) { return; @@ -8580,39 +8831,61 @@ TEST_P(QuicConnectionTest, ClientResponseToPathChallenge) { sizeof(challenge_data))); } -TEST_P(QuicConnectionTest, - RestartPathDegradingDetectionAfterMigrationWithProbe) { - // TODO(b/150095484): add test coverage for IETF to verify that client takes - // PATH RESPONSE with peer address change as correct validation on the new - // path. - if (GetParam().version.HasIetfQuicFrames()) { +TEST_P(QuicConnectionTest, ClientResponseToPathChallengeOnAlternativeSocket) { + if (!VersionHasIetfQuicFrames(connection_.version().transport_version) || + !connection_.use_path_validator()) { return; } - EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); PathProbeTestInit(Perspective::IS_CLIENT); + QuicPacketCreatorPeer::SetSendVersionInPacket(creator_, false); - // Clear direct_peer_address and effective_peer_address. - QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress()); - QuicConnectionPeer::SetEffectivePeerAddress(&connection_, - QuicSocketAddress()); - EXPECT_FALSE(connection_.effective_peer_address().IsInitialized()); + QuicSocketAddress kNewSelfAddress(QuicIpAddress::Loopback6(), /*port=*/23456); + TestPacketWriter new_writer(version(), &clock_, Perspective::IS_CLIENT); + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) + .Times(AtLeast(1u)) + .WillOnce(Invoke([&]() { + EXPECT_EQ(1u, new_writer.packets_write_attempts()); + EXPECT_EQ(1u, new_writer.path_challenge_frames().size()); + EXPECT_EQ(1u, new_writer.padding_frames().size()); + EXPECT_EQ(kNewSelfAddress.host(), + new_writer.last_write_source_address()); + })); + bool success = false; + connection_.ValidatePath( + std::make_unique<TestQuicPathValidationContext>( + kNewSelfAddress, connection_.peer_address(), &new_writer), + std::make_unique<TestValidationResultDelegate>( + kNewSelfAddress, connection_.peer_address(), &success)); + + // Receiving a PATH_CHALLENGE on the alternative path. Response to this + // PATH_CHALLENGE should be sent via the alternative writer. + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) + .Times(AtLeast(1u)) + .WillOnce(Invoke([&]() { + EXPECT_EQ(2u, new_writer.packets_write_attempts()); + EXPECT_EQ(1u, new_writer.path_response_frames().size()); + EXPECT_EQ(1u, new_writer.padding_frames().size()); + EXPECT_EQ(kNewSelfAddress.host(), + new_writer.last_write_source_address()); + })); + std::unique_ptr<SerializedPacket> probing_packet = ConstructProbingPacket(); + std::unique_ptr<QuicReceivedPacket> received(ConstructReceivedPacket( + QuicEncryptedPacket(probing_packet->encrypted_buffer, + probing_packet->encrypted_length), + clock_.Now())); + ProcessReceivedPacket(kNewSelfAddress, kPeerAddress, *received); - EXPECT_TRUE(connection_.connected()); - EXPECT_CALL(visitor_, ShouldKeepConnectionAlive()) - .WillRepeatedly(Return(true)); - EXPECT_FALSE(connection_.PathDegradingDetectionInProgress()); - EXPECT_FALSE(connection_.IsPathDegrading()); - EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); + QuicSocketAddress kNewerSelfAddress(QuicIpAddress::Loopback6(), + /*port=*/34567); + // Receiving a PATH_CHALLENGE on an unknown socket should be ignored. + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0u); + ProcessReceivedPacket(kNewerSelfAddress, kPeerAddress, *received); +} - if (QuicVersionUsesCryptoFrames(connection_.transport_version())) { - EXPECT_CALL(visitor_, OnCryptoFrame(_)).Times(AnyNumber()); - } else { - EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(AnyNumber()); - } - ProcessFramePacketWithAddresses(MakeCryptoFrame(), kSelfAddress, kPeerAddress, - ENCRYPTION_INITIAL); - EXPECT_EQ(kPeerAddress, connection_.peer_address()); - EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); +TEST_P(QuicConnectionTest, + RestartPathDegradingDetectionAfterMigrationWithProbe) { + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); + PathProbeTestInit(Perspective::IS_CLIENT); // Send data and verify the path degrading detection is set. const char data[] = "data"; @@ -8633,24 +8906,21 @@ TEST_P(QuicConnectionTest, EXPECT_TRUE(connection_.IsPathDegrading()); EXPECT_FALSE(connection_.PathDegradingDetectionInProgress()); - // Simulate path degrading handling by sending a probe on an alternet path. - clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); - TestPacketWriter probing_writer(version(), &clock_, Perspective::IS_CLIENT); - connection_.SendConnectivityProbingPacket(&probing_writer, - connection_.peer_address()); - // Verify that path degrading detection is not reset. - EXPECT_FALSE(connection_.PathDegradingDetectionInProgress()); + if (!GetParam().version.HasIetfQuicFrames()) { + // Simulate path degrading handling by sending a probe on an alternet path. + clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); + TestPacketWriter probing_writer(version(), &clock_, Perspective::IS_CLIENT); + connection_.SendConnectivityProbingPacket(&probing_writer, + connection_.peer_address()); + // Verify that path degrading detection is not reset. + EXPECT_FALSE(connection_.PathDegradingDetectionInProgress()); - // Simulate successful path degrading handling by receiving probe response. - clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(20)); + // Simulate successful path degrading handling by receiving probe response. + clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(20)); - if (!GetParam().version.HasIetfQuicFrames()) { EXPECT_CALL(visitor_, OnPacketReceived(_, _, /*is_connectivity_probe=*/true)) .Times(1); - } else { - EXPECT_CALL(visitor_, OnPacketReceived(_, _, _)).Times(0); - } const QuicSocketAddress kNewSelfAddress = QuicSocketAddress(QuicIpAddress::Loopback6(), /*port=*/23456); @@ -8668,14 +8938,46 @@ TEST_P(QuicConnectionTest, EXPECT_EQ(kPeerAddress, connection_.peer_address()); EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); EXPECT_TRUE(connection_.IsPathDegrading()); + } // Verify new path degrading detection is activated. EXPECT_CALL(visitor_, OnForwardProgressMadeAfterPathDegrading()).Times(1); - connection_.OnSuccessfulMigrationAfterProbing(); + connection_.OnSuccessfulMigration(/*is_port_change*/ true); EXPECT_FALSE(connection_.IsPathDegrading()); EXPECT_TRUE(connection_.PathDegradingDetectionInProgress()); } +TEST_P(QuicConnectionTest, ClientsResetCwndAfterConnectionMigration) { + if (!GetParam().version.HasIetfQuicFrames()) { + return; + } + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); + PathProbeTestInit(Perspective::IS_CLIENT); + EXPECT_EQ(kSelfAddress, connection_.self_address()); + + RttStats* rtt_stats = const_cast<RttStats*>(manager_->GetRttStats()); + QuicTime::Delta default_init_rtt = rtt_stats->initial_rtt(); + rtt_stats->set_initial_rtt(default_init_rtt * 2); + EXPECT_EQ(2 * default_init_rtt, rtt_stats->initial_rtt()); + + QuicSentPacketManagerPeer::SetConsecutiveRtoCount(manager_, 1); + EXPECT_EQ(1u, manager_->GetConsecutiveRtoCount()); + QuicSentPacketManagerPeer::SetConsecutiveTlpCount(manager_, 2); + EXPECT_EQ(2u, manager_->GetConsecutiveTlpCount()); + const SendAlgorithmInterface* send_algorithm = manager_->GetSendAlgorithm(); + + // Migrate to a new address with different IP. + const QuicSocketAddress kNewSelfAddress = + QuicSocketAddress(QuicIpAddress::Loopback4(), /*port=*/23456); + TestPacketWriter new_writer(version(), &clock_, Perspective::IS_CLIENT); + connection_.MigratePath(kNewSelfAddress, connection_.peer_address(), + &new_writer, false); + EXPECT_EQ(default_init_rtt, manager_->GetRttStats()->initial_rtt()); + EXPECT_EQ(0u, manager_->GetConsecutiveRtoCount()); + EXPECT_EQ(0u, manager_->GetConsecutiveTlpCount()); + EXPECT_NE(send_algorithm, manager_->GetSendAlgorithm()); +} + // Regression test for b/110259444 TEST_P(QuicConnectionTest, DoNotScheduleSpuriousAckAlarm) { EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); @@ -9050,7 +9352,7 @@ TEST_P(QuicConnectionTest, CheckConnectedBeforeFlush) { const QuicErrorCode kErrorCode = QUIC_INTERNAL_ERROR; std::unique_ptr<QuicConnectionCloseFrame> connection_close_frame( new QuicConnectionCloseFrame(connection_.transport_version(), kErrorCode, - "", + NO_IETF_QUIC_ERROR, "", /*transport_close_frame_type=*/0)); // Received 2 packets. @@ -9262,11 +9564,6 @@ TEST_P(QuicConnectionTest, RtoForcesSendingPing) { // RTO fires, verify a PING packet gets sent because there is no data to send. EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, QuicPacketNumber(3), _, _)); - if (!GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - EXPECT_CALL(visitor_, SendPing()).WillOnce(Invoke([this]() { - SendPing(); - })); - } clock_.AdvanceTime(retransmission_time - clock_.Now()); connection_.GetRetransmissionAlarm()->Fire(); EXPECT_EQ(1u, connection_.GetStats().tlp_count); @@ -9308,7 +9605,7 @@ TEST_P(QuicConnectionTest, CloseConnectionAfter6ClientPTOs) { connection_options.push_back(k6PTO); config.SetConnectionOptionsToSend(connection_options); QuicConfigPeer::SetNegotiated(&config, true); - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_.connection_id()); QuicConfigPeer::SetReceivedInitialSourceConnectionId( @@ -9360,7 +9657,7 @@ TEST_P(QuicConnectionTest, CloseConnectionAfter7ClientPTOs) { connection_options.push_back(k7PTO); config.SetConnectionOptionsToSend(connection_options); QuicConfigPeer::SetNegotiated(&config, true); - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_.connection_id()); QuicConfigPeer::SetReceivedInitialSourceConnectionId( @@ -9410,7 +9707,7 @@ TEST_P(QuicConnectionTest, CloseConnectionAfter8ClientPTOs) { connection_options.push_back(k2PTO); connection_options.push_back(k8PTO); QuicConfigPeer::SetNegotiated(&config, true); - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_.connection_id()); QuicConfigPeer::SetReceivedInitialSourceConnectionId( @@ -9486,11 +9783,6 @@ TEST_P(QuicConnectionTest, DeprecateHandshakeMode) { ? QuicPacketNumber(2) : QuicPacketNumber(3), _, _)); - if (!GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - EXPECT_CALL(visitor_, SendPing()).WillOnce(Invoke([this]() { - SendPing(); - })); - } connection_.GetRetransmissionAlarm()->Fire(); EXPECT_EQ(1u, connection_.GetStats().pto_count); EXPECT_EQ(1u, connection_.GetStats().crypto_retransmit_count); @@ -9561,7 +9853,7 @@ TEST_P(QuicConnectionTest, 3AntiAmplificationLimit) { QuicTagVector connection_options; connection_options.push_back(k3AFF); config.SetInitialReceivedConnectionOptions(connection_options); - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_.connection_id()); QuicConfigPeer::SetReceivedInitialSourceConnectionId(&config, @@ -9626,7 +9918,7 @@ TEST_P(QuicConnectionTest, 10AntiAmplificationLimit) { QuicTagVector connection_options; connection_options.push_back(k10AF); config.SetInitialReceivedConnectionOptions(connection_options); - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_.connection_id()); QuicConfigPeer::SetReceivedInitialSourceConnectionId(&config, @@ -9787,11 +10079,6 @@ TEST_P(QuicConnectionTest, RtoPacketAsTwo) { // Fires TLP, verify a PING gets sent because packet 3 is marked // RTO_RETRANSMITTED. EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, QuicPacketNumber(70), _, _)); - if (!GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - EXPECT_CALL(visitor_, SendPing()).WillOnce(Invoke([this]() { - SendPing(); - })); - } connection_.GetRetransmissionAlarm()->Fire(); } @@ -9826,12 +10113,7 @@ TEST_P(QuicConnectionTest, SendCoalescedPackets) { } MockQuicConnectionDebugVisitor debug_visitor; connection_.set_debug_visitor(&debug_visitor); - if (connection_.sent_packet_manager() - .give_sent_packet_to_debug_visitor_after_sent()) { - EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _, _, _, _, _, _)).Times(3); - } else { - EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _)).Times(3); - } + EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _, _, _, _, _, _)).Times(3); EXPECT_CALL(debug_visitor, OnCoalescedPacketSent(_, _)).Times(1); EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(1); { @@ -9873,12 +10155,7 @@ TEST_P(QuicConnectionTest, LegacyVersionEncapsulation) { MockQuicConnectionDebugVisitor debug_visitor; connection_.set_debug_visitor(&debug_visitor); - if (connection_.sent_packet_manager() - .give_sent_packet_to_debug_visitor_after_sent()) { - EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _, _, _, _, _, _)).Times(1); - } else { - EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _)).Times(1); - } + EXPECT_CALL(debug_visitor, OnPacketSent(_, _, _, _, _, _, _, _)).Times(1); // Our TestPacketWriter normally parses the sent packet using the version // from the connection, so here we need to tell it to use the encapsulation @@ -9917,7 +10194,7 @@ TEST_P(QuicConnectionTest, LegacyVersionEncapsulation) { } TEST_P(QuicConnectionTest, ClientReceivedHandshakeDone) { - if (!connection_.version().HasHandshakeDone()) { + if (!connection_.version().UsesTls()) { return; } EXPECT_CALL(visitor_, OnHandshakeDoneReceived()); @@ -9928,7 +10205,7 @@ TEST_P(QuicConnectionTest, ClientReceivedHandshakeDone) { } TEST_P(QuicConnectionTest, ServerReceivedHandshakeDone) { - if (!connection_.version().HasHandshakeDone()) { + if (!connection_.version().UsesTls()) { return; } set_perspective(Perspective::IS_SERVER); @@ -9976,9 +10253,6 @@ TEST_P(QuicConnectionTest, MultiplePacketNumberSpacePto) { ? QuicPacketNumber(3) : QuicPacketNumber(4), _, _)); - if (!GetQuicReloadableFlag(quic_fix_missing_initial_keys2)) { - EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(1); - } connection_.GetRetransmissionAlarm()->Fire(); // Verify 1-RTT packet gets coalesced with handshake retransmission. EXPECT_EQ(0x01010101u, writer_->final_bytes_of_last_packet()); @@ -10000,9 +10274,6 @@ TEST_P(QuicConnectionTest, MultiplePacketNumberSpacePto) { OnPacketSent(_, _, handshake_retransmission + 1, _, _)); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, handshake_retransmission, _, _)); - if (!GetQuicReloadableFlag(quic_fix_missing_initial_keys2)) { - EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(1); - } connection_.GetRetransmissionAlarm()->Fire(); // Verify 1-RTT packet gets coalesced with handshake retransmission. EXPECT_EQ(0x01010101u, writer_->final_bytes_of_last_packet()); @@ -10039,15 +10310,15 @@ void QuicConnectionTest::TestClientRetryHandling( ASSERT_FALSE(missing_original_id_in_config && wrong_original_id_in_config); ASSERT_FALSE(missing_retry_id_in_config && wrong_retry_id_in_config); } - if (!version().HasRetryIntegrityTag()) { + if (!version().UsesTls()) { return; } // These values come from draft-ietf-quic-tls Appendix A.4. - char retry_packet27[] = { - 0xff, 0xff, 0x00, 0x00, 0x1b, 0x00, 0x08, 0xf0, 0x67, 0xa5, 0x50, 0x2a, - 0x42, 0x62, 0xb5, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0xa5, 0x23, 0xcb, 0x5b, - 0xa5, 0x24, 0x69, 0x5f, 0x65, 0x69, 0xf2, 0x93, 0xa1, 0x35, 0x9d, 0x8e}; + char retry_packet_rfcv1[] = { + 0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0xf0, 0x67, 0xa5, 0x50, 0x2a, + 0x42, 0x62, 0xb5, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x04, 0xa2, 0x65, 0xba, + 0x2e, 0xff, 0x4d, 0x82, 0x90, 0x58, 0xfb, 0x3f, 0x0f, 0x24, 0x96, 0xba}; char retry_packet29[] = { 0xff, 0xff, 0x00, 0x00, 0x1d, 0x00, 0x08, 0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, 0xb5, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0xd1, 0x69, 0x26, 0xd8, @@ -10055,12 +10326,12 @@ void QuicConnectionTest::TestClientRetryHandling( char* retry_packet; size_t retry_packet_length; - if (version() == ParsedQuicVersion::Draft29()) { + if (version() == ParsedQuicVersion::RFCv1()) { + retry_packet = retry_packet_rfcv1; + retry_packet_length = ABSL_ARRAYSIZE(retry_packet_rfcv1); + } else if (version() == ParsedQuicVersion::Draft29()) { retry_packet = retry_packet29; retry_packet_length = ABSL_ARRAYSIZE(retry_packet29); - } else if (version() == ParsedQuicVersion::Draft27()) { - retry_packet = retry_packet27; - retry_packet_length = ABSL_ARRAYSIZE(retry_packet27); } else { // TODO(dschinazi) generate retry packets for all versions once we have // server-side support for generating these programmatically. @@ -10103,6 +10374,9 @@ void QuicConnectionTest::TestClientRetryHandling( // Make sure the connection uses the connection ID from the test vectors, QuicConnectionPeer::SetServerConnectionId(&connection_, original_connection_id); + // Make sure our fake framer has the new post-retry INITIAL keys so that any + // retransmission triggered by retry can be decrypted. + writer_->framer()->framer()->SetInitialObfuscators(new_connection_id); // Process the RETRY packet. connection_.ProcessUdpPacket( @@ -10125,13 +10399,11 @@ void QuicConnectionTest::TestClientRetryHandling( EXPECT_EQ(QuicPacketCreatorPeer::GetRetryToken( QuicConnectionPeer::GetPacketCreator(&connection_)), retry_token); - // Make sure our fake framer has the new post-retry INITIAL keys. - writer_->framer()->framer()->SetInitialObfuscators(new_connection_id); // Test validating the original_connection_id from the config. QuicConfig received_config; QuicConfigPeer::SetNegotiated(&received_config, true); - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedInitialSourceConnectionId( &received_config, connection_.connection_id()); if (!missing_retry_id_in_config) { @@ -10198,7 +10470,7 @@ TEST_P(QuicConnectionTest, ClientParsesRetryWrongOriginalId) { } TEST_P(QuicConnectionTest, ClientParsesRetryMissingRetryId) { - if (!connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (!connection_.version().UsesTls()) { // Versions that do not authenticate connection IDs never send the // retry_source_connection_id transport parameter. return; @@ -10211,7 +10483,7 @@ TEST_P(QuicConnectionTest, ClientParsesRetryMissingRetryId) { } TEST_P(QuicConnectionTest, ClientParsesRetryWrongRetryId) { - if (!connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (!connection_.version().UsesTls()) { // Versions that do not authenticate connection IDs never send the // retry_source_connection_id transport parameter. return; @@ -10223,12 +10495,54 @@ TEST_P(QuicConnectionTest, ClientParsesRetryWrongRetryId) { /*wrong_retry_id_in_config=*/true); } +TEST_P(QuicConnectionTest, ClientRetransmitsInitialPacketsOnRetry) { + if (!connection_.version().HasIetfQuicFrames()) { + // TestClientRetryHandling() currently only supports IETF draft versions. + return; + } + connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); + + connection_.SendCryptoStreamData(); + + EXPECT_EQ(1u, writer_->packets_write_attempts()); + TestClientRetryHandling(/*invalid_retry_tag=*/false, + /*missing_original_id_in_config=*/false, + /*wrong_original_id_in_config=*/false, + /*missing_retry_id_in_config=*/false, + /*wrong_retry_id_in_config=*/false); + + // Verify that initial data is retransmitted immediately after receiving + // RETRY. + if (GetParam().ack_response == AckResponse::kImmediate) { + EXPECT_EQ(2u, writer_->packets_write_attempts()); + EXPECT_EQ(1u, writer_->framer()->crypto_frames().size()); + } +} + +TEST_P(QuicConnectionTest, NoInitialPacketsRetransmissionOnInvalidRetry) { + if (!connection_.version().HasIetfQuicFrames()) { + return; + } + connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); + + connection_.SendCryptoStreamData(); + + EXPECT_EQ(1u, writer_->packets_write_attempts()); + TestClientRetryHandling(/*invalid_retry_tag=*/true, + /*missing_original_id_in_config=*/false, + /*wrong_original_id_in_config=*/false, + /*missing_retry_id_in_config=*/false, + /*wrong_retry_id_in_config=*/false); + + EXPECT_EQ(1u, writer_->packets_write_attempts()); +} + TEST_P(QuicConnectionTest, ClientReceivesOriginalConnectionIdWithoutRetry) { if (!connection_.version().UsesTls()) { // QUIC+TLS is required to transmit connection ID transport parameters. return; } - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { // Versions that authenticate connection IDs always send the // original_destination_connection_id transport parameter. return; @@ -10248,7 +10562,7 @@ TEST_P(QuicConnectionTest, ClientReceivesOriginalConnectionIdWithoutRetry) { } TEST_P(QuicConnectionTest, ClientReceivesRetrySourceConnectionIdWithoutRetry) { - if (!connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (!connection_.version().UsesTls()) { // Versions that do not authenticate connection IDs never send the // retry_source_connection_id transport parameter. return; @@ -10384,11 +10698,6 @@ TEST_P(QuicConnectionTest, SendPingWhenSkipPacketNumberForPto) { // PTO fires, verify a PING packet gets sent because there is no data to // send. EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, QuicPacketNumber(3), _, _)); - if (!GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - EXPECT_CALL(visitor_, SendPing()).WillOnce(Invoke([this]() { - SendPing(); - })); - } connection_.GetRetransmissionAlarm()->Fire(); EXPECT_EQ(1u, connection_.GetStats().pto_count); EXPECT_EQ(0u, connection_.GetStats().crypto_retransmit_count); @@ -10682,7 +10991,7 @@ TEST_P(QuicConnectionTest, MadeForwardProgressOnDiscardingKeys) { EXPECT_CALL(visitor_, GetHandshakeState()) .WillRepeatedly(Return(HANDSHAKE_COMPLETE)); } - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_.connection_id()); QuicConfigPeer::SetReceivedInitialSourceConnectionId( @@ -10742,11 +11051,7 @@ TEST_P(QuicConnectionTest, ProcessUndecryptablePacketsBasedOnEncryptionLevel) { // Verify all ENCRYPTION_HANDSHAKE packets get processed. EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(6); connection_.GetProcessUndecryptablePacketsAlarm()->Fire(); - if (GetQuicReloadableFlag(quic_fix_undecryptable_packets2)) { - EXPECT_EQ(1u, QuicConnectionPeer::NumUndecryptablePackets(&connection_)); - } else { - EXPECT_EQ(4u, QuicConnectionPeer::NumUndecryptablePackets(&connection_)); - } + EXPECT_EQ(1u, QuicConnectionPeer::NumUndecryptablePackets(&connection_)); SetDecrypter(ENCRYPTION_FORWARD_SECURE, std::make_unique<StrictTaggingDecrypter>(0x02)); @@ -10785,11 +11090,7 @@ TEST_P(QuicConnectionTest, ServerBundlesInitialDataWithInitialAck) { connection_.SetEncrypter(ENCRYPTION_HANDSHAKE, std::make_unique<TaggingEncrypter>(0x02)); connection_.SetDefaultEncryptionLevel(ENCRYPTION_HANDSHAKE); - if (GetQuicReloadableFlag(quic_fix_missing_initial_keys2)) { - EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(1); - } else { - EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(2); - } + EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(1); connection_.SendCryptoDataWithString("foo", 0, ENCRYPTION_HANDSHAKE); // Verify PTO time does not change. EXPECT_EQ(expected_pto_time, @@ -10828,11 +11129,7 @@ TEST_P(QuicConnectionTest, ClientBundlesHandshakeDataWithHandshakeAck) { // Receives packet 1000 in handshake data. ProcessCryptoPacketAtLevel(1000, ENCRYPTION_HANDSHAKE); EXPECT_TRUE(connection_.HasPendingAcks()); - if (GetQuicReloadableFlag(quic_fix_missing_initial_keys2)) { - EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(1); - } else { - EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(2); - } + EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(1); connection_.SendCryptoDataWithString("foo", 0, ENCRYPTION_HANDSHAKE); // Receives packet 1001 in handshake data. @@ -10895,11 +11192,7 @@ TEST_P(QuicConnectionTest, ServerRetransmitsHandshakeDataEarly) { connection_.SetEncrypter(ENCRYPTION_HANDSHAKE, std::make_unique<TaggingEncrypter>(0x02)); connection_.SetDefaultEncryptionLevel(ENCRYPTION_HANDSHAKE); - if (GetQuicReloadableFlag(quic_fix_missing_initial_keys2)) { - EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(1); - } else { - EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(3); - } + EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(1); // Send HANDSHAKE 2 and 3. connection_.SendCryptoDataWithString("foo", 0, ENCRYPTION_HANDSHAKE); connection_.SendCryptoDataWithString("bar", 3, ENCRYPTION_HANDSHAKE); @@ -10965,11 +11258,7 @@ TEST_P(QuicConnectionTest, InflatedRttSample) { connection_.SetEncrypter(ENCRYPTION_HANDSHAKE, std::make_unique<TaggingEncrypter>(0x02)); connection_.SetDefaultEncryptionLevel(ENCRYPTION_HANDSHAKE); - if (GetQuicReloadableFlag(quic_fix_missing_initial_keys2)) { - EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(1); - } else { - EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(2); - } + EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(1); std::string handshake_crypto_data(1024, 'a'); connection_.SendCryptoDataWithString(handshake_crypto_data, 0, ENCRYPTION_HANDSHAKE); @@ -11041,11 +11330,7 @@ TEST_P(QuicConnectionTest, CoalscingPacketCausesInfiniteLoop) { std::make_unique<TaggingEncrypter>(0x02)); connection_.SetDefaultEncryptionLevel(ENCRYPTION_HANDSHAKE); // Verify HANDSHAKE packet is coalesced with INITIAL retransmission. - if (GetQuicReloadableFlag(quic_fix_missing_initial_keys2)) { - EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(1); - } else { - EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(2); - } + EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(1); std::string handshake_crypto_data(1024, 'a'); connection_.SendCryptoDataWithString(handshake_crypto_data, 0, ENCRYPTION_HANDSHAKE); @@ -11076,7 +11361,7 @@ TEST_P(QuicConnectionTest, TestingLiveness) { config.ProcessPeerHello(msg, CLIENT, &error_details); EXPECT_THAT(error, IsQuicNoError()); - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_.connection_id()); QuicConfigPeer::SetReceivedInitialSourceConnectionId( @@ -11108,7 +11393,7 @@ TEST_P(QuicConnectionTest, SilentIdleTimeout) { QuicConfig config; QuicConfigPeer::SetNegotiated(&config, true); - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_.connection_id()); QuicConfigPeer::SetReceivedInitialSourceConnectionId(&config, @@ -11176,11 +11461,7 @@ TEST_P(QuicConnectionTest, DonotSendPing) { EXPECT_CALL(visitor_, ShouldKeepConnectionAlive()) .WillRepeatedly(Return(false)); // Verify PING does not get sent. - if (GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); - } else { - EXPECT_CALL(visitor_, SendPing()).Times(0); - } + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); connection_.GetPingAlarm()->Fire(); } @@ -11261,7 +11542,7 @@ TEST_P(QuicConnectionTest, ShorterIdleTimeoutOnSentPackets) { EXPECT_CALL(visitor_, GetHandshakeState()) .WillRepeatedly(Return(HANDSHAKE_COMPLETE)); } - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_.connection_id()); QuicConfigPeer::SetReceivedInitialSourceConnectionId( @@ -11296,10 +11577,7 @@ TEST_P(QuicConnectionTest, ShorterIdleTimeoutOnSentPackets) { // Regression test for b/166255274 TEST_P(QuicConnectionTest, ReserializeInitialPacketInCoalescerAfterDiscardingInitialKey) { - if (!connection_.version().CanSendCoalescedPackets() || - !GetQuicReloadableFlag(quic_fix_missing_initial_keys2)) { - // Cannot set quic_fix_missing_initial_keys in the test since connection_ is - // created since the setup. + if (!connection_.version().CanSendCoalescedPackets()) { return; } use_tagging_decrypter(); @@ -11333,44 +11611,145 @@ TEST_P(QuicConnectionTest, EXPECT_TRUE(connection_.connected()); } -TEST_P(QuicConnectionTest, SendPathChallenge) { +TEST_P(QuicConnectionTest, PathValidationOnNewSocketSuccess) { if (!VersionHasIetfQuicFrames(connection_.version().transport_version) || - !connection_.send_path_response()) { + !connection_.use_path_validator()) { return; } PathProbeTestInit(Perspective::IS_CLIENT); - const QuicSocketAddress kNewSourceAddress(QuicIpAddress::Any6(), 12345); - EXPECT_NE(kNewSourceAddress, connection_.self_address()); + const QuicSocketAddress kNewSelfAddress(QuicIpAddress::Any4(), 12345); + EXPECT_NE(kNewSelfAddress, connection_.self_address()); TestPacketWriter new_writer(version(), &clock_, Perspective::IS_CLIENT); - QuicPathFrameBuffer payload; EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) + .Times(AtLeast(1u)) .WillOnce(Invoke([&]() { EXPECT_EQ(1u, new_writer.packets_write_attempts()); EXPECT_EQ(1u, new_writer.path_challenge_frames().size()); - EXPECT_EQ( - 0, memcmp(payload.data(), - &(new_writer.path_challenge_frames().front().data_buffer), - sizeof(payload))); EXPECT_EQ(1u, new_writer.padding_frames().size()); - EXPECT_EQ(kNewSourceAddress.host(), + EXPECT_EQ(kNewSelfAddress.host(), new_writer.last_write_source_address()); })); - connection_.SendPathChallenge(&payload, kNewSourceAddress, - connection_.peer_address(), &new_writer); + bool success = false; + connection_.ValidatePath( + std::make_unique<TestQuicPathValidationContext>( + kNewSelfAddress, connection_.peer_address(), &new_writer), + std::make_unique<TestValidationResultDelegate>( + kNewSelfAddress, connection_.peer_address(), &success)); EXPECT_EQ(0u, writer_->packets_write_attempts()); + + QuicFrames frames; + frames.push_back(QuicFrame(new QuicPathResponseFrame( + 99, new_writer.path_challenge_frames().front().data_buffer))); + ProcessFramesPacketWithAddresses(frames, kNewSelfAddress, kPeerAddress, + ENCRYPTION_FORWARD_SECURE); + EXPECT_TRUE(success); } +TEST_P(QuicConnectionTest, NewPathValidationCancelsPreviousOne) { + if (!VersionHasIetfQuicFrames(connection_.version().transport_version) || + !connection_.use_path_validator()) { + return; + } + PathProbeTestInit(Perspective::IS_CLIENT); + const QuicSocketAddress kNewSelfAddress(QuicIpAddress::Any4(), 12345); + EXPECT_NE(kNewSelfAddress, connection_.self_address()); + TestPacketWriter new_writer(version(), &clock_, Perspective::IS_CLIENT); + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) + .Times(AtLeast(1u)) + .WillOnce(Invoke([&]() { + EXPECT_EQ(1u, new_writer.packets_write_attempts()); + EXPECT_EQ(1u, new_writer.path_challenge_frames().size()); + EXPECT_EQ(1u, new_writer.padding_frames().size()); + EXPECT_EQ(kNewSelfAddress.host(), + new_writer.last_write_source_address()); + })); + bool success = true; + connection_.ValidatePath( + std::make_unique<TestQuicPathValidationContext>( + kNewSelfAddress, connection_.peer_address(), &new_writer), + std::make_unique<TestValidationResultDelegate>( + kNewSelfAddress, connection_.peer_address(), &success)); + EXPECT_EQ(0u, writer_->packets_write_attempts()); + + // Start another path validation request. + const QuicSocketAddress kNewSelfAddress2(QuicIpAddress::Any4(), 12346); + EXPECT_NE(kNewSelfAddress2, connection_.self_address()); + TestPacketWriter new_writer2(version(), &clock_, Perspective::IS_CLIENT); + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) + .Times(AtLeast(1u)) + .WillOnce(Invoke([&]() { + EXPECT_EQ(1u, new_writer2.packets_write_attempts()); + EXPECT_EQ(1u, new_writer2.path_challenge_frames().size()); + EXPECT_EQ(1u, new_writer2.padding_frames().size()); + EXPECT_EQ(kNewSelfAddress2.host(), + new_writer2.last_write_source_address()); + })); + bool success2 = false; + connection_.ValidatePath( + std::make_unique<TestQuicPathValidationContext>( + kNewSelfAddress2, connection_.peer_address(), &new_writer2), + std::make_unique<TestValidationResultDelegate>( + kNewSelfAddress2, connection_.peer_address(), &success2)); + EXPECT_FALSE(success); + EXPECT_TRUE(connection_.HasPendingPathValidation()); +} + +TEST_P(QuicConnectionTest, PathValidationReceivesStatelessReset) { + if (!VersionHasIetfQuicFrames(connection_.version().transport_version) || + !connection_.use_path_validator()) { + return; + } + PathProbeTestInit(Perspective::IS_CLIENT); + const QuicUint128 kTestStatelessResetToken = 1010101; + QuicConfig config; + QuicConfigPeer::SetReceivedStatelessResetToken(&config, + kTestStatelessResetToken); + EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); + connection_.SetFromConfig(config); + const QuicSocketAddress kNewSelfAddress(QuicIpAddress::Any4(), 12345); + EXPECT_NE(kNewSelfAddress, connection_.self_address()); + TestPacketWriter new_writer(version(), &clock_, Perspective::IS_CLIENT); + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) + .Times(AtLeast(1u)) + .WillOnce(Invoke([&]() { + EXPECT_EQ(1u, new_writer.packets_write_attempts()); + EXPECT_EQ(1u, new_writer.path_challenge_frames().size()); + EXPECT_EQ(1u, new_writer.padding_frames().size()); + EXPECT_EQ(kNewSelfAddress.host(), + new_writer.last_write_source_address()); + })); + bool success = true; + connection_.ValidatePath( + std::make_unique<TestQuicPathValidationContext>( + kNewSelfAddress, connection_.peer_address(), &new_writer), + std::make_unique<TestValidationResultDelegate>( + kNewSelfAddress, connection_.peer_address(), &success)); + EXPECT_EQ(0u, writer_->packets_write_attempts()); + EXPECT_TRUE(connection_.HasPendingPathValidation()); + + 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); + connection_.ProcessUdpPacket(kNewSelfAddress, kPeerAddress, *received); + EXPECT_FALSE(connection_.HasPendingPathValidation()); + EXPECT_FALSE(success); +} + +// Tests that PATH_CHALLENGE is dropped if it is sent via a blocked alternative +// writer. TEST_P(QuicConnectionTest, SendPathChallengeUsingBlockedNewSocket) { if (!VersionHasIetfQuicFrames(connection_.version().transport_version) || - !connection_.send_path_response()) { + !connection_.use_path_validator()) { return; } PathProbeTestInit(Perspective::IS_CLIENT); - const QuicSocketAddress kNewSourceAddress(QuicIpAddress::Any6(), 12345); - EXPECT_NE(kNewSourceAddress, connection_.self_address()); + const QuicSocketAddress kNewSelfAddress(QuicIpAddress::Any4(), 12345); + EXPECT_NE(kNewSelfAddress, connection_.self_address()); TestPacketWriter new_writer(version(), &clock_, Perspective::IS_CLIENT); new_writer.BlockOnNextWrite(); - QuicPathFrameBuffer payload; EXPECT_CALL(visitor_, OnWriteBlocked()).Times(0); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) .WillOnce(Invoke([&]() { @@ -11378,16 +11757,16 @@ TEST_P(QuicConnectionTest, SendPathChallengeUsingBlockedNewSocket) { // treated as sent. EXPECT_EQ(1u, new_writer.packets_write_attempts()); EXPECT_EQ(1u, new_writer.path_challenge_frames().size()); - EXPECT_EQ( - 0, memcmp(payload.data(), - &(new_writer.path_challenge_frames().front().data_buffer), - sizeof(payload))); EXPECT_EQ(1u, new_writer.padding_frames().size()); - EXPECT_EQ(kNewSourceAddress.host(), + EXPECT_EQ(kNewSelfAddress.host(), new_writer.last_write_source_address()); })); - connection_.SendPathChallenge(&payload, kNewSourceAddress, - connection_.peer_address(), &new_writer); + bool success = false; + connection_.ValidatePath( + std::make_unique<TestQuicPathValidationContext>( + kNewSelfAddress, connection_.peer_address(), &new_writer), + std::make_unique<TestValidationResultDelegate>( + kNewSelfAddress, connection_.peer_address(), &success)); EXPECT_EQ(0u, writer_->packets_write_attempts()); new_writer.SetWritable(); @@ -11397,78 +11776,108 @@ TEST_P(QuicConnectionTest, SendPathChallengeUsingBlockedNewSocket) { EXPECT_EQ(1u, new_writer.packets_write_attempts()); } -TEST_P(QuicConnectionTest, SendPathChallengeWithDefaultSocketBlocked) { +// Tests that PATH_CHALLENGE is dropped if it is sent via the default writer +// and the writer is blocked. +TEST_P(QuicConnectionTest, SendPathChallengeUsingBlockedDefaultSocket) { if (!VersionHasIetfQuicFrames(connection_.version().transport_version) || - !connection_.send_path_response()) { + !connection_.use_path_validator()) { return; } PathProbeTestInit(Perspective::IS_SERVER); - if (version().SupportsAntiAmplificationLimit()) { - QuicConnectionPeer::SetAddressValidated(&connection_); - } - const QuicSocketAddress kNewPeerAddress(QuicIpAddress::Any6(), 12345); + const QuicSocketAddress kNewPeerAddress(QuicIpAddress::Any4(), 12345); writer_->BlockOnNextWrite(); - QuicPathFrameBuffer payload; // 1st time is after writer returns WRITE_STATUS_BLOCKED. 2nd time is in - // ShouldGeneratePacket(); - EXPECT_CALL(visitor_, OnWriteBlocked()).Times(2u); - // This packet isn't sent actually, instead it is buffered in the connection. + // ShouldGeneratePacket(). + EXPECT_CALL(visitor_, OnWriteBlocked()).Times(AtLeast(2)); + QuicPathFrameBuffer path_challenge_payload{0, 1, 2, 3, 4, 5, 6, 7}; EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) + .Times(AtLeast(1u)) .WillOnce(Invoke([&]() { + // This packet isn't sent actually, instead it is buffered in the + // connection. + EXPECT_EQ(1u, writer_->packets_write_attempts()); + if (connection_.validate_client_address()) { + EXPECT_EQ(1u, writer_->path_response_frames().size()); + EXPECT_EQ(0, + memcmp(&path_challenge_payload, + &writer_->path_response_frames().front().data_buffer, + sizeof(path_challenge_payload))); + } EXPECT_EQ(1u, writer_->path_challenge_frames().size()); - EXPECT_EQ( - 0, memcmp(payload.data(), - &(writer_->path_challenge_frames().front().data_buffer), - sizeof(payload))); EXPECT_EQ(1u, writer_->padding_frames().size()); EXPECT_EQ(kNewPeerAddress, writer_->last_write_peer_address()); + })) + .WillRepeatedly(Invoke([&]() { + // Only one PATH_CHALLENGE should be sent out. + EXPECT_EQ(0u, writer_->path_challenge_frames().size()); })); - connection_.SendPathChallenge(&payload, connection_.self_address(), - kNewPeerAddress, writer_.get()); + bool success = false; + if (connection_.validate_client_address()) { + // Receiving a PATH_CHALLENGE from the new peer address should trigger + // address validation. + QuicFrames frames; + frames.push_back( + QuicFrame(new QuicPathChallengeFrame(0, path_challenge_payload))); + ProcessFramesPacketWithAddresses(frames, kSelfAddress, kNewPeerAddress, + ENCRYPTION_FORWARD_SECURE); + } else { + // Manually start to validate the new peer address. + connection_.ValidatePath( + std::make_unique<TestQuicPathValidationContext>( + connection_.self_address(), kNewPeerAddress, writer_.get()), + std::make_unique<TestValidationResultDelegate>( + connection_.self_address(), kNewPeerAddress, &success)); + } EXPECT_EQ(1u, writer_->packets_write_attempts()); - memset(payload.data(), 0, sizeof(payload)); // Try again with the new socket blocked from the beginning. The 2nd // PATH_CHALLENGE shouldn't be serialized, but be dropped. - connection_.SendPathChallenge(&payload, connection_.self_address(), - kNewPeerAddress, writer_.get()); + clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(3 * kInitialRttMs)); + static_cast<test::MockRandom*>(helper_->GetRandomGenerator())->ChangeValue(); + static_cast<TestAlarmFactory::TestAlarm*>( + QuicPathValidatorPeer::retry_timer( + QuicConnectionPeer::path_validator(&connection_))) + ->Fire(); + // No more write attempt should be made. EXPECT_EQ(1u, writer_->packets_write_attempts()); writer_->SetWritable(); // OnCanWrite() should actually write out the 1st PATH_CHALLENGE packet - // buffered earlier, thus incrementing the write counter. + // buffered earlier, thus incrementing the write counter. It may also send + // ACKs to previously received packets. connection_.OnCanWrite(); - EXPECT_EQ(2u, writer_->packets_write_attempts()); + EXPECT_LE(2u, writer_->packets_write_attempts()); } // Tests that write error on the alternate socket should be ignored. TEST_P(QuicConnectionTest, SendPathChallengeFailOnNewSocket) { if (!VersionHasIetfQuicFrames(connection_.version().transport_version) || - !connection_.send_path_response()) { + !connection_.use_path_validator()) { return; } PathProbeTestInit(Perspective::IS_CLIENT); - const QuicSocketAddress kNewSourceAddress(QuicIpAddress::Any6(), 12345); - EXPECT_NE(kNewSourceAddress, connection_.self_address()); + const QuicSocketAddress kNewSelfAddress(QuicIpAddress::Any4(), 12345); + EXPECT_NE(kNewSelfAddress, connection_.self_address()); TestPacketWriter new_writer(version(), &clock_, Perspective::IS_CLIENT); new_writer.SetShouldWriteFail(); - QuicPathFrameBuffer payload; EXPECT_CALL(visitor_, OnConnectionClosed(_, ConnectionCloseSource::FROM_SELF)) .Times(0); + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0u); - connection_.SendPathChallenge(&payload, kNewSourceAddress, - connection_.peer_address(), &new_writer); - // Regardless of the write error, the PATH_CHALLENGE should still be - // treated as sent. + bool success = false; + connection_.ValidatePath( + std::make_unique<TestQuicPathValidationContext>( + kNewSelfAddress, connection_.peer_address(), &new_writer), + std::make_unique<TestValidationResultDelegate>( + kNewSelfAddress, connection_.peer_address(), &success)); EXPECT_EQ(1u, new_writer.packets_write_attempts()); EXPECT_EQ(1u, new_writer.path_challenge_frames().size()); - EXPECT_EQ(0, memcmp(payload.data(), - &(new_writer.path_challenge_frames().front().data_buffer), - sizeof(payload))); EXPECT_EQ(1u, new_writer.padding_frames().size()); - EXPECT_EQ(kNewSourceAddress.host(), new_writer.last_write_source_address()); + EXPECT_EQ(kNewSelfAddress.host(), new_writer.last_write_source_address()); + EXPECT_EQ(0u, writer_->packets_write_attempts()); + // Regardless of the write error, the connection should still be connected. EXPECT_TRUE(connection_.connected()); } @@ -11476,12 +11885,12 @@ TEST_P(QuicConnectionTest, SendPathChallengeFailOnNewSocket) { // should close the connection. TEST_P(QuicConnectionTest, SendPathChallengeFailOnDefaultPath) { if (!VersionHasIetfQuicFrames(connection_.version().transport_version) || - !connection_.send_path_response()) { + !connection_.use_path_validator()) { return; } PathProbeTestInit(Perspective::IS_CLIENT); + writer_->SetShouldWriteFail(); - QuicPathFrameBuffer payload; EXPECT_CALL(visitor_, OnConnectionClosed(_, ConnectionCloseSource::FROM_SELF)) .WillOnce( Invoke([](QuicConnectionCloseFrame frame, ConnectionCloseSource) { @@ -11491,18 +11900,84 @@ TEST_P(QuicConnectionTest, SendPathChallengeFailOnDefaultPath) { { // Add a flusher to force flush, otherwise the frames will remain in the // packet creator. + bool success = false; QuicConnection::ScopedPacketFlusher flusher(&connection_); - connection_.SendPathChallenge(&payload, connection_.self_address(), - connection_.peer_address(), writer_.get()); + connection_.ValidatePath( + std::make_unique<TestQuicPathValidationContext>( + connection_.self_address(), connection_.peer_address(), + writer_.get()), + std::make_unique<TestValidationResultDelegate>( + connection_.self_address(), connection_.peer_address(), &success)); } EXPECT_EQ(1u, writer_->packets_write_attempts()); EXPECT_EQ(1u, writer_->path_challenge_frames().size()); - EXPECT_EQ(0, memcmp(payload.data(), - &(writer_->path_challenge_frames().front().data_buffer), - sizeof(payload))); EXPECT_EQ(1u, writer_->padding_frames().size()); EXPECT_EQ(connection_.peer_address(), writer_->last_write_peer_address()); EXPECT_FALSE(connection_.connected()); + // Closing connection should abandon ongoing path validation. + EXPECT_FALSE(connection_.HasPendingPathValidation()); +} + +TEST_P(QuicConnectionTest, SendPathChallengeFailOnAlternativePeerAddress) { + if (!VersionHasIetfQuicFrames(connection_.version().transport_version) || + !connection_.use_path_validator()) { + return; + } + PathProbeTestInit(Perspective::IS_CLIENT); + + writer_->SetShouldWriteFail(); + const QuicSocketAddress kNewPeerAddress(QuicIpAddress::Any4(), 12345); + EXPECT_CALL(visitor_, OnConnectionClosed(_, ConnectionCloseSource::FROM_SELF)) + .WillOnce( + Invoke([](QuicConnectionCloseFrame frame, ConnectionCloseSource) { + EXPECT_EQ(QUIC_PACKET_WRITE_ERROR, frame.quic_error_code); + })); + // Sending PATH_CHALLENGE to trigger a flush write which will fail and close + // the connection. + bool success = false; + connection_.ValidatePath( + std::make_unique<TestQuicPathValidationContext>( + connection_.self_address(), kNewPeerAddress, writer_.get()), + std::make_unique<TestValidationResultDelegate>( + connection_.self_address(), kNewPeerAddress, &success)); + + EXPECT_EQ(1u, writer_->packets_write_attempts()); + EXPECT_FALSE(connection_.HasPendingPathValidation()); + EXPECT_EQ(1u, writer_->path_challenge_frames().size()); + EXPECT_EQ(1u, writer_->padding_frames().size()); + EXPECT_EQ(kNewPeerAddress, writer_->last_write_peer_address()); + EXPECT_FALSE(connection_.connected()); +} + +TEST_P(QuicConnectionTest, + SendPathChallengeFailPacketTooBigOnAlternativePeerAddress) { + if (!VersionHasIetfQuicFrames(connection_.version().transport_version) || + !connection_.use_path_validator()) { + return; + } + PathProbeTestInit(Perspective::IS_CLIENT); + + writer_->SetShouldWriteFail(); + writer_->SetWriteError(EMSGSIZE); + const QuicSocketAddress kNewPeerAddress(QuicIpAddress::Any4(), 12345); + EXPECT_CALL(visitor_, OnConnectionClosed(_, ConnectionCloseSource::FROM_SELF)) + .Times(0u); + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0u); + // Sending PATH_CHALLENGE to trigger a flush write which will fail with + // MSG_TOO_BIG. + bool success = false; + connection_.ValidatePath( + std::make_unique<TestQuicPathValidationContext>( + connection_.self_address(), kNewPeerAddress, writer_.get()), + std::make_unique<TestValidationResultDelegate>( + connection_.self_address(), kNewPeerAddress, &success)); + EXPECT_TRUE(connection_.HasPendingPathValidation()); + // Connection shouldn't be closed. + EXPECT_TRUE(connection_.connected()); + EXPECT_EQ(1u, writer_->packets_write_attempts()); + EXPECT_EQ(1u, writer_->path_challenge_frames().size()); + EXPECT_EQ(1u, writer_->padding_frames().size()); + EXPECT_EQ(kNewPeerAddress, writer_->last_write_peer_address()); } // Check that if there are two PATH_CHALLENGE frames in the packet, the latter @@ -11513,24 +11988,6 @@ TEST_P(QuicConnectionTest, ReceiveMultiplePathChallenge) { } PathProbeTestInit(Perspective::IS_SERVER); - // Clear direct_peer_address. - QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress()); - // Clear effective_peer_address, it is the same as direct_peer_address for - // this test. - QuicConnectionPeer::SetEffectivePeerAddress(&connection_, - QuicSocketAddress()); - EXPECT_FALSE(connection_.effective_peer_address().IsInitialized()); - - if (QuicVersionUsesCryptoFrames(connection_.transport_version())) { - EXPECT_CALL(visitor_, OnCryptoFrame(_)).Times(AnyNumber()); - } else { - EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(AnyNumber()); - } - ProcessFramePacketWithAddresses(MakeCryptoFrame(), kSelfAddress, kPeerAddress, - ENCRYPTION_FORWARD_SECURE); - EXPECT_EQ(kPeerAddress, connection_.peer_address()); - EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); - QuicPathFrameBuffer path_frame_buffer1{0, 1, 2, 3, 4, 5, 6, 7}; QuicPathFrameBuffer path_frame_buffer2{8, 9, 10, 11, 12, 13, 14, 15}; QuicFrames frames; @@ -11583,36 +12040,20 @@ TEST_P(QuicConnectionTest, ReceiveStreamFrameBeforePathChallenge) { } PathProbeTestInit(Perspective::IS_SERVER); - // Clear direct_peer_address. - QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress()); - // Clear effective_peer_address, it is the same as direct_peer_address for - // this test. - QuicConnectionPeer::SetEffectivePeerAddress(&connection_, - QuicSocketAddress()); - EXPECT_FALSE(connection_.effective_peer_address().IsInitialized()); - - if (QuicVersionUsesCryptoFrames(connection_.transport_version())) { - EXPECT_CALL(visitor_, OnCryptoFrame(_)).Times(AnyNumber()); - } else { - EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(AnyNumber()); - } - ProcessFramePacketWithAddresses(MakeCryptoFrame(), kSelfAddress, kPeerAddress, - ENCRYPTION_INITIAL); - EXPECT_EQ(kPeerAddress, connection_.peer_address()); - EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); - QuicFrames frames; frames.push_back(QuicFrame(frame1_)); QuicPathFrameBuffer path_frame_buffer{0, 1, 2, 3, 4, 5, 6, 7}; frames.push_back(QuicFrame(new QuicPathChallengeFrame(0, path_frame_buffer))); - const QuicSocketAddress kNewPeerAddress(QuicIpAddress::Loopback6(), + const QuicSocketAddress kNewPeerAddress(QuicIpAddress::Loopback4(), /*port=*/23456); - EXPECT_CALL(visitor_, OnConnectionMigration(PORT_CHANGE)); + EXPECT_CALL(visitor_, OnConnectionMigration(IPV6_TO_IPV4_CHANGE)); + EXPECT_CALL(*send_algorithm_, OnConnectionMigration()) + .Times(connection_.validate_client_address() ? 0u : 1u); EXPECT_CALL(visitor_, OnStreamFrame(_)) .WillOnce(Invoke([=](const QuicStreamFrame& frame) { // Send some data on the stream. The STREAM_FRAME should be built into - // one packet together with the latter PATH_RESPONSE. + // one packet together with the latter PATH_RESPONSE and PATH_CHALLENGE. std::string data{"response body"}; struct iovec iov; MakeIOVector(data, &iov); @@ -11621,7 +12062,8 @@ TEST_P(QuicConnectionTest, ReceiveStreamFrameBeforePathChallenge) { return notifier_.WriteOrBufferData(frame.stream_id, data.length(), NO_FIN); })); - EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) + .Times(connection_.validate_client_address() ? 0u : 1u); ProcessFramesPacketWithAddresses(frames, kSelfAddress, kNewPeerAddress, ENCRYPTION_FORWARD_SECURE); @@ -11629,13 +12071,20 @@ TEST_P(QuicConnectionTest, ReceiveStreamFrameBeforePathChallenge) { // PATH_RESPONSE_FRAME. EXPECT_EQ(1u, writer_->stream_frames().size()); EXPECT_EQ(1u, writer_->path_response_frames().size()); + EXPECT_EQ(connection_.validate_client_address() ? 1u : 0u, + writer_->path_challenge_frames().size()); // The final check is to ensure that the random data in the response // matches the random data from the challenge. EXPECT_EQ(0, memcmp(path_frame_buffer.data(), &(writer_->path_response_frames().front().data_buffer), sizeof(path_frame_buffer))); + EXPECT_EQ(connection_.validate_client_address() ? 1u : 0u, + writer_->path_challenge_frames().size()); EXPECT_EQ(1u, writer_->padding_frames().size()); EXPECT_EQ(kNewPeerAddress, writer_->last_write_peer_address()); + if (connection_.validate_client_address()) { + EXPECT_TRUE(connection_.HasPendingPathValidation()); + } } TEST_P(QuicConnectionTest, ReceiveStreamFrameFollowingPathChallenge) { @@ -11645,33 +12094,17 @@ TEST_P(QuicConnectionTest, ReceiveStreamFrameFollowingPathChallenge) { } PathProbeTestInit(Perspective::IS_SERVER); - // Clear direct_peer_address. - QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress()); - // Clear effective_peer_address, it is the same as direct_peer_address for - // this test. - QuicConnectionPeer::SetEffectivePeerAddress(&connection_, - QuicSocketAddress()); - EXPECT_FALSE(connection_.effective_peer_address().IsInitialized()); - - if (QuicVersionUsesCryptoFrames(connection_.transport_version())) { - EXPECT_CALL(visitor_, OnCryptoFrame(_)).Times(AnyNumber()); - } else { - EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(AnyNumber()); - } - ProcessFramePacketWithAddresses(MakeCryptoFrame(), kSelfAddress, kPeerAddress, - ENCRYPTION_INITIAL); - EXPECT_EQ(kPeerAddress, connection_.peer_address()); - EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); - QuicFrames frames; QuicPathFrameBuffer path_frame_buffer{0, 1, 2, 3, 4, 5, 6, 7}; frames.push_back(QuicFrame(new QuicPathChallengeFrame(0, path_frame_buffer))); // PATH_RESPONSE should be flushed out before the rest packet is parsed. frames.push_back(QuicFrame(frame1_)); - const QuicSocketAddress kNewPeerAddress(QuicIpAddress::Loopback6(), + const QuicSocketAddress kNewPeerAddress(QuicIpAddress::Loopback4(), /*port=*/23456); + QuicByteCount received_packet_size; EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) - .WillOnce(Invoke([=]() { + .Times(AtLeast(1u)) + .WillOnce(Invoke([=, &received_packet_size]() { // Verify that this packet contains a PATH_RESPONSE_FRAME. EXPECT_EQ(0u, writer_->stream_frames().size()); EXPECT_EQ(1u, writer_->path_response_frames().size()); @@ -11681,19 +12114,20 @@ TEST_P(QuicConnectionTest, ReceiveStreamFrameFollowingPathChallenge) { memcmp(path_frame_buffer.data(), &(writer_->path_response_frames().front().data_buffer), sizeof(path_frame_buffer))); + EXPECT_EQ(connection_.validate_client_address() ? 1u : 0u, + writer_->path_challenge_frames().size()); EXPECT_EQ(1u, writer_->padding_frames().size()); EXPECT_EQ(kNewPeerAddress, writer_->last_write_peer_address()); - })) - .WillOnce(Invoke([=]() { - // Verify that this packet contains a STREAM_FRAME. - EXPECT_EQ(1u, writer_->stream_frames().size()); - EXPECT_EQ(kNewPeerAddress, writer_->last_write_peer_address()); + received_packet_size = + QuicConnectionPeer::BytesReceivedOnAlternativePath(&connection_); })); - EXPECT_CALL(visitor_, OnConnectionMigration(PORT_CHANGE)); + EXPECT_CALL(visitor_, OnConnectionMigration(IPV6_TO_IPV4_CHANGE)); + EXPECT_CALL(*send_algorithm_, OnConnectionMigration()) + .Times(connection_.validate_client_address() ? 0u : 1u); EXPECT_CALL(visitor_, OnStreamFrame(_)) .WillOnce(Invoke([=](const QuicStreamFrame& frame) { - // Send some data on the stream. The STREAM_FRAME should be built into - // one packet together with the latter PATH_RESPONSE. + // Send some data on the stream. The STREAM_FRAME should be built into a + // new packet but throttled by anti-amplifciation limit. std::string data{"response body"}; struct iovec iov; MakeIOVector(data, &iov); @@ -11705,6 +12139,15 @@ TEST_P(QuicConnectionTest, ReceiveStreamFrameFollowingPathChallenge) { ProcessFramesPacketWithAddresses(frames, kSelfAddress, kNewPeerAddress, ENCRYPTION_FORWARD_SECURE); + if (!connection_.validate_client_address()) { + return; + } + EXPECT_TRUE(connection_.HasPendingPathValidation()); + EXPECT_EQ(0u, + QuicConnectionPeer::BytesReceivedOnAlternativePath(&connection_)); + EXPECT_EQ( + received_packet_size, + QuicConnectionPeer::BytesReceivedBeforeAddressValidation(&connection_)); } // Tests that a PATH_CHALLENGE is received in between other frames in an out of @@ -11716,25 +12159,6 @@ TEST_P(QuicConnectionTest, PathChallengeWithDataInOutOfOrderPacket) { } PathProbeTestInit(Perspective::IS_SERVER); - // Clear direct_peer_address. - QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress()); - // Clear effective_peer_address, it is the same as direct_peer_address for - // this test. - QuicConnectionPeer::SetEffectivePeerAddress(&connection_, - QuicSocketAddress()); - EXPECT_FALSE(connection_.effective_peer_address().IsInitialized()); - - if (QuicVersionUsesCryptoFrames(connection_.transport_version())) { - EXPECT_CALL(visitor_, OnCryptoFrame(_)).Times(AnyNumber()); - } else { - EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(AnyNumber()); - } - QuicPacketCreatorPeer::SetPacketNumber(&peer_creator_, 2); - ProcessFramePacketWithAddresses(MakeCryptoFrame(), kSelfAddress, kPeerAddress, - ENCRYPTION_FORWARD_SECURE); - EXPECT_EQ(kPeerAddress, connection_.peer_address()); - EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); - QuicFrames frames; frames.push_back(QuicFrame(frame1_)); QuicPathFrameBuffer path_frame_buffer{0, 1, 2, 3, 4, 5, 6, 7}; @@ -11802,25 +12226,6 @@ TEST_P(QuicConnectionTest, FailToWritePathResponse) { } PathProbeTestInit(Perspective::IS_SERVER); - // Clear direct_peer_address. - QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress()); - // Clear effective_peer_address, it is the same as direct_peer_address for - // this test. - QuicConnectionPeer::SetEffectivePeerAddress(&connection_, - QuicSocketAddress()); - EXPECT_FALSE(connection_.effective_peer_address().IsInitialized()); - - if (QuicVersionUsesCryptoFrames(connection_.transport_version())) { - EXPECT_CALL(visitor_, OnCryptoFrame(_)).Times(AnyNumber()); - } else { - EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(AnyNumber()); - } - QuicPacketCreatorPeer::SetPacketNumber(&peer_creator_, 2); - ProcessFramePacketWithAddresses(MakeCryptoFrame(), kSelfAddress, kPeerAddress, - ENCRYPTION_INITIAL); - EXPECT_EQ(kPeerAddress, connection_.peer_address()); - EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); - QuicFrames frames; QuicPathFrameBuffer path_frame_buffer{0, 1, 2, 3, 4, 5, 6, 7}; frames.push_back(QuicFrame(new QuicPathChallengeFrame(0, path_frame_buffer))); @@ -11837,8 +12242,7 @@ TEST_P(QuicConnectionTest, FailToWritePathResponse) { ENCRYPTION_FORWARD_SECURE); EXPECT_EQ( - 1u, - QuicConnectionPeer::pending_path_challenge_payloads(&connection_).size()); + 1u, QuicConnectionPeer::NumPendingPathChallengesToResponse(&connection_)); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AtLeast(1)); writer_->SetWritable(); @@ -11853,8 +12257,8 @@ TEST_P(QuicConnectionTest, FailToWritePathResponse) { // PATH_RESPONSE should be sent in another packet to a different peer // address. EXPECT_EQ(kNewPeerAddress, writer_->last_write_peer_address()); - EXPECT_TRUE(QuicConnectionPeer::pending_path_challenge_payloads(&connection_) - .empty()); + EXPECT_EQ( + 0u, QuicConnectionPeer::NumPendingPathChallengesToResponse(&connection_)); } // Regression test for b/168101557. @@ -11905,58 +12309,20 @@ TEST_P(QuicConnectionTest, HandshakeDataDoesNotGetPtoed) { connection_.GetSendAlarm()->Set(clock_.ApproximateNow()); // Fire ACK alarm. - if (!GetQuicReloadableFlag(quic_fix_missing_initial_keys2)) { - EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(1); - } connection_.GetAckAlarm()->Fire(); - if (GetQuicReloadableFlag(quic_fix_pto_pending_timer_count)) { - // Verify 1-RTT packet is coalesced with handshake packet. - EXPECT_EQ(0x03030303u, writer_->final_bytes_of_last_packet()); - } else { - // Verify handshake crypto frame is not bundled. - EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet()); - EXPECT_FALSE(writer_->ack_frames().empty()); - EXPECT_TRUE(writer_->crypto_frames().empty()); - } + // Verify 1-RTT packet is coalesced with handshake packet. + EXPECT_EQ(0x03030303u, writer_->final_bytes_of_last_packet()); connection_.GetSendAlarm()->Fire(); ASSERT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); - if (GetQuicReloadableFlag(quic_fix_pto_pending_timer_count)) { - if (!GetQuicReloadableFlag(quic_fix_missing_initial_keys2)) { - EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(1); - } - } else if (GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - if (!GetQuicReloadableFlag(quic_fix_missing_initial_keys2)) { - EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(1); - } - } else { - EXPECT_CALL(visitor_, OnHandshakePacketSent()).Times(0); - EXPECT_CALL(visitor_, SendPing()).WillOnce(Invoke([this]() { - SendPing(); - })); - } connection_.GetRetransmissionAlarm()->Fire(); - if (GetQuicReloadableFlag(quic_fix_pto_pending_timer_count)) { - // Verify a handshake packet gets PTOed and 1-RTT packet gets coalesced. - EXPECT_EQ(0x03030303u, writer_->final_bytes_of_last_packet()); - } else { - if (GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - // Verify PING is sent in the right encryption level. - EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet()); - } else { - // Verify an 1-RTT PING gets sent because there is nothing to PTO, bummer, - // since this 1-RTT PING cannot be processed by peer and there is a - // deadlock. - EXPECT_EQ(0x03030303u, writer_->final_bytes_of_last_packet()); - } - EXPECT_FALSE(writer_->ping_frames().empty()); - } + // Verify a handshake packet gets PTOed and 1-RTT packet gets coalesced. + EXPECT_EQ(0x03030303u, writer_->final_bytes_of_last_packet()); } // Regression test for b/168294218. TEST_P(QuicConnectionTest, CoalescerHandlesInitialKeyDiscard) { - if (!connection_.version().CanSendCoalescedPackets() || - !GetQuicReloadableFlag(quic_fix_missing_initial_keys2)) { + if (!connection_.version().CanSendCoalescedPackets()) { return; } SetQuicReloadableFlag(quic_discard_initial_packet_with_key_dropped, true); @@ -11987,8 +12353,7 @@ TEST_P(QuicConnectionTest, CoalescerHandlesInitialKeyDiscard) { // Regresstion test for b/168294218 TEST_P(QuicConnectionTest, ZeroRttRejectionAndMissingInitialKeys) { - if (!connection_.SupportsMultiplePacketNumberSpaces() || - !GetQuicReloadableFlag(quic_fix_missing_initial_keys2)) { + if (!connection_.SupportsMultiplePacketNumberSpaces()) { return; } // Not defer send in response to packet. @@ -12037,11 +12402,6 @@ TEST_P(QuicConnectionTest, ZeroRttRejectionAndMissingInitialKeys) { EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); // Fire retransmission alarm. - if (!GetQuicReloadableFlag(quic_let_connection_handle_pings)) { - EXPECT_CALL(visitor_, SendPing()).WillOnce(Invoke([this]() { - SendPing(); - })); - } connection_.GetRetransmissionAlarm()->Fire(); QuicFrames frames1; @@ -12115,7 +12475,7 @@ TEST_P(QuicConnectionTest, InitiateKeyUpdate) { IsQuicNoError()); config.SetKeyUpdateSupportedLocally(); QuicConfigPeer::SetNegotiated(&config, true); - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_.connection_id()); QuicConfigPeer::SetReceivedInitialSourceConnectionId( @@ -12264,7 +12624,6 @@ TEST_P(QuicConnectionTest, InitiateKeyUpdateApproachingConfidentialityLimit) { return; } - QuicConnectionPeer::SetEnableAeadLimits(&connection_, true); SetQuicFlag(FLAGS_quic_key_update_confidentiality_limit, 3U); std::string error_details; @@ -12277,7 +12636,7 @@ TEST_P(QuicConnectionTest, InitiateKeyUpdateApproachingConfidentialityLimit) { IsQuicNoError()); config.SetKeyUpdateSupportedLocally(); QuicConfigPeer::SetNegotiated(&config, true); - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_.connection_id()); QuicConfigPeer::SetReceivedInitialSourceConnectionId( @@ -12360,7 +12719,6 @@ TEST_P(QuicConnectionTest, return; } - QuicConnectionPeer::SetEnableAeadLimits(&connection_, true); // Set key update confidentiality limit to 1 packet. SetQuicFlag(FLAGS_quic_key_update_confidentiality_limit, 1U); // Use confidentiality limit for connection close of 3 packets. @@ -12376,7 +12734,7 @@ TEST_P(QuicConnectionTest, IsQuicNoError()); config.SetKeyUpdateSupportedLocally(); QuicConfigPeer::SetNegotiated(&config, true); - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_.connection_id()); QuicConfigPeer::SetReceivedInitialSourceConnectionId( @@ -12416,7 +12774,6 @@ TEST_P(QuicConnectionTest, return; } - QuicConnectionPeer::SetEnableAeadLimits(&connection_, true); // Set key update confidentiality limit to 1 packet. SetQuicFlag(FLAGS_quic_key_update_confidentiality_limit, 1U); // Use confidentiality limit for connection close of 3 packets. @@ -12433,7 +12790,7 @@ TEST_P(QuicConnectionTest, // Key update is supported locally. config.SetKeyUpdateSupportedLocally(); QuicConfigPeer::SetNegotiated(&config, true); - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_.connection_id()); QuicConfigPeer::SetReceivedInitialSourceConnectionId( @@ -12483,7 +12840,6 @@ TEST_P(QuicConnectionTest, return; } - QuicConnectionPeer::SetEnableAeadLimits(&connection_, true); // Set key update confidentiality limit to 1 packet. SetQuicFlag(FLAGS_quic_key_update_confidentiality_limit, 1U); // Use confidentiality limit for connection close of 3 packets. @@ -12499,7 +12855,7 @@ TEST_P(QuicConnectionTest, params, /* is_resumption = */ false, &error_details), IsQuicNoError()); QuicConfigPeer::SetNegotiated(&config, true); - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_.connection_id()); QuicConfigPeer::SetReceivedInitialSourceConnectionId( @@ -12548,8 +12904,6 @@ TEST_P(QuicConnectionTest, CloseConnectionOnIntegrityLimitDuringHandshake) { return; } - QuicConnectionPeer::SetEnableAeadLimits(&connection_, true); - constexpr uint8_t correct_tag = 0x01; constexpr uint8_t wrong_tag = 0xFE; constexpr QuicPacketCount kIntegrityLimit = 3; @@ -12581,8 +12935,6 @@ TEST_P(QuicConnectionTest, CloseConnectionOnIntegrityLimitAfterHandshake) { return; } - QuicConnectionPeer::SetEnableAeadLimits(&connection_, true); - constexpr uint8_t correct_tag = 0x01; constexpr uint8_t wrong_tag = 0xFE; constexpr QuicPacketCount kIntegrityLimit = 3; @@ -12619,8 +12971,6 @@ TEST_P(QuicConnectionTest, return; } - QuicConnectionPeer::SetEnableAeadLimits(&connection_, true); - constexpr uint8_t correct_tag = 0x01; constexpr uint8_t wrong_tag = 0xFE; constexpr QuicPacketCount kIntegrityLimit = 4; @@ -12672,8 +13022,6 @@ TEST_P(QuicConnectionTest, IntegrityLimitDoesNotApplyWithoutDecryptionKey) { return; } - QuicConnectionPeer::SetEnableAeadLimits(&connection_, true); - constexpr uint8_t correct_tag = 0x01; constexpr uint8_t wrong_tag = 0xFE; constexpr QuicPacketCount kIntegrityLimit = 3; @@ -12705,7 +13053,6 @@ TEST_P(QuicConnectionTest, CloseConnectionOnIntegrityLimitAcrossKeyPhases) { constexpr QuicPacketCount kIntegrityLimit = 4; - QuicConnectionPeer::SetEnableAeadLimits(&connection_, true); TransportParameters params; params.key_update_not_yet_supported = false; QuicConfig config; @@ -12715,7 +13062,7 @@ TEST_P(QuicConnectionTest, CloseConnectionOnIntegrityLimitAcrossKeyPhases) { IsQuicNoError()); config.SetKeyUpdateSupportedLocally(); QuicConfigPeer::SetNegotiated(&config, true); - if (connection_.version().AuthenticatesHandshakeConnectionIds()) { + if (connection_.version().UsesTls()) { QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_.connection_id()); QuicConfigPeer::SetReceivedInitialSourceConnectionId( @@ -12944,6 +13291,631 @@ TEST_P(QuicConnectionTest, ServerHelloGetsReordered) { connection_.GetRetransmissionAlarm()->deadline()); } +TEST_P(QuicConnectionTest, MigratePath) { + EXPECT_CALL(visitor_, OnPathDegrading()); + connection_.OnPathDegradingDetected(); + const QuicSocketAddress kNewSelfAddress(QuicIpAddress::Any4(), 12345); + EXPECT_NE(kNewSelfAddress, connection_.self_address()); + TestPacketWriter new_writer(version(), &clock_, Perspective::IS_CLIENT); + EXPECT_CALL(visitor_, OnForwardProgressMadeAfterPathDegrading()); + connection_.MigratePath(kNewSelfAddress, connection_.peer_address(), + &new_writer, /*owns_writer=*/false); + EXPECT_EQ(kNewSelfAddress, connection_.self_address()); + EXPECT_EQ(&new_writer, QuicConnectionPeer::GetWriter(&connection_)); + EXPECT_FALSE(connection_.IsPathDegrading()); +} + +TEST_P(QuicConnectionTest, MigrateToNewPathDuringProbing) { + if (!VersionHasIetfQuicFrames(connection_.version().transport_version) || + !connection_.use_path_validator()) { + return; + } + PathProbeTestInit(Perspective::IS_CLIENT); + const QuicSocketAddress kNewSelfAddress(QuicIpAddress::Any4(), 12345); + EXPECT_NE(kNewSelfAddress, connection_.self_address()); + TestPacketWriter new_writer(version(), &clock_, Perspective::IS_CLIENT); + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); + bool success = false; + connection_.ValidatePath( + std::make_unique<TestQuicPathValidationContext>( + kNewSelfAddress, connection_.peer_address(), &new_writer), + std::make_unique<TestValidationResultDelegate>( + kNewSelfAddress, connection_.peer_address(), &success)); + EXPECT_TRUE(connection_.HasPendingPathValidation()); + EXPECT_TRUE(QuicConnectionPeer::IsAlternativePath( + &connection_, kNewSelfAddress, connection_.peer_address())); + + connection_.MigratePath(kNewSelfAddress, connection_.peer_address(), + &new_writer, /*owns_writer=*/false); + EXPECT_EQ(kNewSelfAddress, connection_.self_address()); + EXPECT_TRUE(connection_.HasPendingPathValidation()); + EXPECT_FALSE(QuicConnectionPeer::IsAlternativePath( + &connection_, kNewSelfAddress, connection_.peer_address())); +} + +TEST_P(QuicConnectionTest, SingleAckInPacket) { + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); + EXPECT_CALL(visitor_, OnConnectionClosed(_, _)); + connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); + connection_.RemoveEncrypter(ENCRYPTION_INITIAL); + connection_.NeuterUnencryptedPackets(); + connection_.OnHandshakeComplete(); + + EXPECT_CALL(visitor_, OnStreamFrame(_)).WillOnce(Invoke([=]() { + connection_.SendStreamData3(); + connection_.CloseConnection( + QUIC_INTERNAL_ERROR, "error", + ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); + })); + QuicFrames frames; + frames.push_back(QuicFrame(frame1_)); + ProcessFramesPacketWithAddresses(frames, kSelfAddress, kPeerAddress, + ENCRYPTION_FORWARD_SECURE); + ASSERT_FALSE(writer_->ack_frames().empty()); + if (GetQuicReloadableFlag(quic_single_ack_in_packet2)) { + EXPECT_EQ(1u, writer_->ack_frames().size()); + } else { + EXPECT_EQ(2u, writer_->ack_frames().size()); + } +} + +TEST_P(QuicConnectionTest, + ServerReceivedZeroRttPacketAfterOneRttPacketWithRetainedKey) { + if (!connection_.version().UsesTls()) { + return; + } + + set_perspective(Perspective::IS_SERVER); + SetDecrypter(ENCRYPTION_ZERO_RTT, + std::make_unique<NullDecrypter>(Perspective::IS_SERVER)); + + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1); + ProcessDataPacketAtLevel(1, !kHasStopWaiting, ENCRYPTION_ZERO_RTT); + + // Finish handshake. + connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); + notifier_.NeuterUnencryptedData(); + connection_.NeuterUnencryptedPackets(); + connection_.OnHandshakeComplete(); + EXPECT_CALL(visitor_, GetHandshakeState()) + .WillRepeatedly(Return(HANDSHAKE_COMPLETE)); + + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1); + ProcessDataPacketAtLevel(4, !kHasStopWaiting, ENCRYPTION_FORWARD_SECURE); + EXPECT_TRUE(connection_.GetDiscardZeroRttDecryptionKeysAlarm()->IsSet()); + + // 0-RTT packet received out of order should be decoded since the decrypter + // is temporarily retained. + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1); + ProcessDataPacketAtLevel(2, !kHasStopWaiting, ENCRYPTION_ZERO_RTT); + EXPECT_EQ( + 0u, + connection_.GetStats() + .num_tls_server_zero_rtt_packets_received_after_discarding_decrypter); + + // Simulate the timeout for discarding 0-RTT keys passing. + connection_.GetDiscardZeroRttDecryptionKeysAlarm()->Fire(); + + // Another 0-RTT packet received now should not be decoded. + EXPECT_FALSE(connection_.GetDiscardZeroRttDecryptionKeysAlarm()->IsSet()); + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(0); + ProcessDataPacketAtLevel(3, !kHasStopWaiting, ENCRYPTION_ZERO_RTT); + EXPECT_EQ( + 1u, + connection_.GetStats() + .num_tls_server_zero_rtt_packets_received_after_discarding_decrypter); + + // The |discard_zero_rtt_decryption_keys_alarm_| should only be set on the + // first 1-RTT packet received. + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1); + ProcessDataPacketAtLevel(5, !kHasStopWaiting, ENCRYPTION_FORWARD_SECURE); + EXPECT_FALSE(connection_.GetDiscardZeroRttDecryptionKeysAlarm()->IsSet()); +} + +TEST_P(QuicConnectionTest, NewTokenFrameInstigateAcks) { + if (!version().HasIetfQuicFrames()) { + return; + } + SetQuicReloadableFlag(quic_enable_token_based_address_validation, true); + EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); + + QuicNewTokenFrame* new_token = new QuicNewTokenFrame(); + EXPECT_CALL(visitor_, OnNewTokenReceived(_)); + ProcessFramePacket(QuicFrame(new_token)); + + // Ensure that this has caused the ACK alarm to be set. + EXPECT_TRUE(connection_.HasPendingAcks()); +} + +TEST_P(QuicConnectionTest, ServerClosesConnectionOnNewTokenFrame) { + if (!version().HasIetfQuicFrames()) { + return; + } + SetQuicReloadableFlag(quic_enable_token_based_address_validation, true); + set_perspective(Perspective::IS_SERVER); + QuicNewTokenFrame* new_token = new QuicNewTokenFrame(); + EXPECT_CALL(visitor_, OnNewTokenReceived(_)).Times(0); + EXPECT_CALL(visitor_, OnConnectionClosed(_, _)); + EXPECT_CALL(visitor_, BeforeConnectionCloseSent()); + ProcessFramePacket(QuicFrame(new_token)); + EXPECT_FALSE(connection_.connected()); +} + +TEST_P(QuicConnectionTest, OverrideRetryTokenWithRetryPacket) { + if (!version().HasIetfQuicFrames()) { + return; + } + std::string address_token = "TestAddressToken"; + connection_.SetSourceAddressTokenToSend(address_token); + EXPECT_EQ(QuicPacketCreatorPeer::GetRetryToken( + QuicConnectionPeer::GetPacketCreator(&connection_)), + address_token); + // Passes valid retry and verify token gets overridden. + TestClientRetryHandling(/*invalid_retry_tag=*/false, + /*missing_original_id_in_config=*/false, + /*wrong_original_id_in_config=*/false, + /*missing_retry_id_in_config=*/false, + /*wrong_retry_id_in_config=*/false); +} + +TEST_P(QuicConnectionTest, DonotOverrideRetryTokenWithAddressToken) { + if (!version().HasIetfQuicFrames()) { + return; + } + // Passes valid retry and verify token gets overridden. + TestClientRetryHandling(/*invalid_retry_tag=*/false, + /*missing_original_id_in_config=*/false, + /*wrong_original_id_in_config=*/false, + /*missing_retry_id_in_config=*/false, + /*wrong_retry_id_in_config=*/false); + std::string retry_token = QuicPacketCreatorPeer::GetRetryToken( + QuicConnectionPeer::GetPacketCreator(&connection_)); + + std::string address_token = "TestAddressToken"; + connection_.SetSourceAddressTokenToSend(address_token); + EXPECT_EQ(QuicPacketCreatorPeer::GetRetryToken( + QuicConnectionPeer::GetPacketCreator(&connection_)), + retry_token); +} + +TEST_P(QuicConnectionTest, + ServerReceivedZeroRttWithHigherPacketNumberThanOneRttAndFlagDisabled) { + SetQuicReloadableFlag( + quic_close_connection_on_0rtt_packet_number_higher_than_1rtt, false); + if (!connection_.version().UsesTls()) { + return; + } + + // The code that checks for this error piggybacks on some book-keeping state + // kept for key update, so enable key update for the test. + std::string error_details; + TransportParameters params; + params.key_update_not_yet_supported = false; + QuicConfig config; + EXPECT_THAT(config.ProcessTransportParameters( + params, /* is_resumption = */ false, &error_details), + IsQuicNoError()); + config.SetKeyUpdateSupportedLocally(); + QuicConfigPeer::SetNegotiated(&config, true); + QuicConfigPeer::SetReceivedOriginalConnectionId(&config, + connection_.connection_id()); + QuicConfigPeer::SetReceivedInitialSourceConnectionId( + &config, connection_.connection_id()); + EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); + connection_.SetFromConfig(config); + + set_perspective(Perspective::IS_SERVER); + SetDecrypter(ENCRYPTION_ZERO_RTT, + std::make_unique<NullDecrypter>(Perspective::IS_SERVER)); + + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1); + ProcessDataPacketAtLevel(1, !kHasStopWaiting, ENCRYPTION_ZERO_RTT); + + // Finish handshake. + connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); + notifier_.NeuterUnencryptedData(); + connection_.NeuterUnencryptedPackets(); + connection_.OnHandshakeComplete(); + EXPECT_CALL(visitor_, GetHandshakeState()) + .WillRepeatedly(Return(HANDSHAKE_COMPLETE)); + + // Decrypt a 1-RTT packet. + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1); + ProcessDataPacketAtLevel(2, !kHasStopWaiting, ENCRYPTION_FORWARD_SECURE); + EXPECT_TRUE(connection_.GetDiscardZeroRttDecryptionKeysAlarm()->IsSet()); + + // 0-RTT packet with higher packet number than a 1-RTT packet is invalid, but + // accepted as the + // quic_close_connection_on_0rtt_packet_number_higher_than_1rtt + // flag is disabled. + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1); + ProcessDataPacketAtLevel(3, !kHasStopWaiting, ENCRYPTION_ZERO_RTT); + EXPECT_TRUE(connection_.connected()); +} + +TEST_P(QuicConnectionTest, + ServerReceivedZeroRttWithHigherPacketNumberThanOneRtt) { + SetQuicReloadableFlag( + quic_close_connection_on_0rtt_packet_number_higher_than_1rtt, true); + if (!connection_.version().UsesTls()) { + return; + } + + // The code that checks for this error piggybacks on some book-keeping state + // kept for key update, so enable key update for the test. + std::string error_details; + TransportParameters params; + params.key_update_not_yet_supported = false; + QuicConfig config; + EXPECT_THAT(config.ProcessTransportParameters( + params, /* is_resumption = */ false, &error_details), + IsQuicNoError()); + config.SetKeyUpdateSupportedLocally(); + QuicConfigPeer::SetNegotiated(&config, true); + QuicConfigPeer::SetReceivedOriginalConnectionId(&config, + connection_.connection_id()); + QuicConfigPeer::SetReceivedInitialSourceConnectionId( + &config, connection_.connection_id()); + EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); + connection_.SetFromConfig(config); + + set_perspective(Perspective::IS_SERVER); + SetDecrypter(ENCRYPTION_ZERO_RTT, + std::make_unique<NullDecrypter>(Perspective::IS_SERVER)); + + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1); + ProcessDataPacketAtLevel(1, !kHasStopWaiting, ENCRYPTION_ZERO_RTT); + + // Finish handshake. + connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); + notifier_.NeuterUnencryptedData(); + connection_.NeuterUnencryptedPackets(); + connection_.OnHandshakeComplete(); + EXPECT_CALL(visitor_, GetHandshakeState()) + .WillRepeatedly(Return(HANDSHAKE_COMPLETE)); + + // Decrypt a 1-RTT packet. + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1); + ProcessDataPacketAtLevel(2, !kHasStopWaiting, ENCRYPTION_FORWARD_SECURE); + EXPECT_TRUE(connection_.GetDiscardZeroRttDecryptionKeysAlarm()->IsSet()); + + // 0-RTT packet with higher packet number than a 1-RTT packet is invalid and + // should cause the connection to be closed. + EXPECT_CALL(visitor_, BeforeConnectionCloseSent()); + EXPECT_CALL(visitor_, OnConnectionClosed(_, _)); + ProcessDataPacketAtLevel(3, !kHasStopWaiting, ENCRYPTION_ZERO_RTT); + EXPECT_FALSE(connection_.connected()); + TestConnectionCloseQuicErrorCode( + QUIC_INVALID_0RTT_PACKET_NUMBER_OUT_OF_ORDER); +} + +// Regression test for b/177312785 +TEST_P(QuicConnectionTest, PeerMigrateBeforeHandshakeConfirm) { + if (!VersionHasIetfQuicFrames(version().transport_version) || + !GetQuicReloadableFlag(quic_start_peer_migration_earlier)) { + return; + } + set_perspective(Perspective::IS_SERVER); + QuicPacketCreatorPeer::SetSendVersionInPacket(creator_, false); + EXPECT_EQ(Perspective::IS_SERVER, connection_.perspective()); + EXPECT_CALL(visitor_, GetHandshakeState()) + .WillRepeatedly(Return(HANDSHAKE_START)); + + // Clear direct_peer_address. + QuicConnectionPeer::SetDirectPeerAddress(&connection_, QuicSocketAddress()); + // Clear effective_peer_address, it is the same as direct_peer_address for + // this test. + QuicConnectionPeer::SetEffectivePeerAddress(&connection_, + QuicSocketAddress()); + EXPECT_FALSE(connection_.effective_peer_address().IsInitialized()); + + const QuicSocketAddress kNewPeerAddress = + QuicSocketAddress(QuicIpAddress::Loopback6(), /*port=*/23456); + EXPECT_CALL(visitor_, OnCryptoFrame(_)).Times(AnyNumber()); + ProcessFramePacketWithAddresses(MakeCryptoFrame(), kSelfAddress, kPeerAddress, + ENCRYPTION_INITIAL); + EXPECT_EQ(kPeerAddress, connection_.peer_address()); + EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); + + // Process another packet with a different peer address on server side will + // close connection. + QuicAckFrame frame = InitAckFrame(1); + EXPECT_CALL(visitor_, BeforeConnectionCloseSent()); + EXPECT_CALL(visitor_, + OnConnectionClosed(_, ConnectionCloseSource::FROM_SELF)); + EXPECT_CALL(visitor_, OnConnectionMigration(PORT_CHANGE)).Times(0u); + if (!GetQuicReloadableFlag(quic_update_packet_content_returns_connected)) { + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(_, _, _, _, _)); + EXPECT_QUIC_BUG( + ProcessFramePacketWithAddresses(QuicFrame(&frame), kSelfAddress, + kNewPeerAddress, ENCRYPTION_INITIAL), + ""); + } else { + EXPECT_CALL(*send_algorithm_, OnCongestionEvent(_, _, _, _, _)).Times(0); + ProcessFramePacketWithAddresses(QuicFrame(&frame), kSelfAddress, + kNewPeerAddress, ENCRYPTION_INITIAL); + } + EXPECT_FALSE(connection_.connected()); +} + +// Regresstion test for b/175685916 +TEST_P(QuicConnectionTest, TryToFlushAckWithAckQueued) { + if (!version().HasIetfQuicFrames()) { + return; + } + SetQuicReloadableFlag(quic_can_send_ack_frequency, true); + SetQuicReloadableFlag(quic_single_ack_in_packet2, true); + set_perspective(Perspective::IS_SERVER); + + QuicConfig config; + QuicConfigPeer::SetReceivedMinAckDelayMs(&config, /*min_ack_delay_ms=*/1); + EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); + connection_.SetFromConfig(config); + connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); + connection_.OnHandshakeComplete(); + QuicPacketCreatorPeer::SetPacketNumber(creator_, 200); + + EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1); + ProcessDataPacketAtLevel(1, !kHasStopWaiting, ENCRYPTION_FORWARD_SECURE); + // Sending ACK_FREQUENCY bundles ACK. QuicConnectionPeer::SendPing + // will try to bundle ACK but there is no pending ACK. + EXPECT_CALL(visitor_, SendAckFrequency(_)) + .WillOnce(Invoke(¬ifier_, + &SimpleSessionNotifier::WriteOrBufferAckFrequency)); + QuicConnectionPeer::SendPing(&connection_); +} + +TEST_P(QuicConnectionTest, PathChallengeBeforePeerIpAddressChangeAtServer) { + if (!connection_.validate_client_address()) { + return; + } + set_perspective(Perspective::IS_SERVER); + PathProbeTestInit(Perspective::IS_SERVER); + + const QuicSocketAddress kNewPeerAddress = + QuicSocketAddress(QuicIpAddress::Loopback4(), /*port=*/23456); + QuicPathFrameBuffer path_challenge_payload{0, 1, 2, 3, 4, 5, 6, 7}; + QuicFrames frames1; + frames1.push_back( + QuicFrame(new QuicPathChallengeFrame(0, path_challenge_payload))); + QuicPathFrameBuffer payload; + EXPECT_CALL(*send_algorithm_, + OnPacketSent(_, _, _, _, NO_RETRANSMITTABLE_DATA)) + .Times(AtLeast(1)) + .WillOnce(Invoke([&]() { + EXPECT_EQ(kNewPeerAddress, writer_->last_write_peer_address()); + EXPECT_EQ(kPeerAddress, connection_.peer_address()); + EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); + EXPECT_FALSE(writer_->path_response_frames().empty()); + EXPECT_FALSE(writer_->path_challenge_frames().empty()); + payload = writer_->path_challenge_frames().front().data_buffer; + })); + ProcessFramesPacketWithAddresses(frames1, kSelfAddress, kNewPeerAddress, + ENCRYPTION_FORWARD_SECURE); + EXPECT_EQ(kPeerAddress, connection_.peer_address()); + EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); + EXPECT_TRUE(connection_.HasPendingPathValidation()); + + // Process another packet with a different peer address on server side will + // start connection migration. + EXPECT_CALL(visitor_, OnConnectionMigration(IPV6_TO_IPV4_CHANGE)).Times(1); + EXPECT_CALL(visitor_, OnStreamFrame(_)).WillOnce(Invoke([=]() { + EXPECT_EQ(kNewPeerAddress, connection_.peer_address()); + })); + // IETF QUIC send algorithm should be changed to a different object, so no + // OnPacketSent() called on the old send algorithm. + EXPECT_CALL(*send_algorithm_, + OnPacketSent(_, _, _, _, NO_RETRANSMITTABLE_DATA)) + .Times(0); + QuicFrames frames2; + frames2.push_back(QuicFrame(frame2_)); + ProcessFramesPacketWithAddresses(frames2, kSelfAddress, kNewPeerAddress, + ENCRYPTION_FORWARD_SECURE); + EXPECT_EQ(kNewPeerAddress, connection_.peer_address()); + EXPECT_EQ(kNewPeerAddress, connection_.effective_peer_address()); + EXPECT_EQ(IPV6_TO_IPV4_CHANGE, + connection_.active_effective_peer_migration_type()); + EXPECT_TRUE(writer_->path_challenge_frames().empty()); + EXPECT_NE(connection_.sent_packet_manager().GetSendAlgorithm(), + send_algorithm_); + // Switch to use the mock send algorithm. + send_algorithm_ = new StrictMock<MockSendAlgorithm>(); + EXPECT_CALL(*send_algorithm_, CanSend(_)).WillRepeatedly(Return(true)); + EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) + .WillRepeatedly(Return(kDefaultTCPMSS)); + EXPECT_CALL(*send_algorithm_, OnApplicationLimited(_)).Times(AnyNumber()); + EXPECT_CALL(*send_algorithm_, BandwidthEstimate()) + .Times(AnyNumber()) + .WillRepeatedly(Return(QuicBandwidth::Zero())); + EXPECT_CALL(*send_algorithm_, InSlowStart()).Times(AnyNumber()); + EXPECT_CALL(*send_algorithm_, InRecovery()).Times(AnyNumber()); + EXPECT_CALL(*send_algorithm_, PopulateConnectionStats(_)).Times(AnyNumber()); + connection_.SetSendAlgorithm(send_algorithm_); + + EXPECT_EQ(kNewPeerAddress, connection_.peer_address()); + EXPECT_EQ(kNewPeerAddress, connection_.effective_peer_address()); + EXPECT_EQ(IPV6_TO_IPV4_CHANGE, + connection_.active_effective_peer_migration_type()); + EXPECT_EQ(1u, connection_.GetStats() + .num_peer_migration_to_proactively_validated_address); + + // The PATH_CHALLENGE and PATH_RESPONSE is expanded upto the max packet size + // which may exceeds the anti-amplification limit. Verify server is throttled + // by anti-amplification limit. + connection_.SendCryptoDataWithString("foo", 0); + EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); + + // Receiving PATH_RESPONSE should lift the anti-amplification limit. + QuicFrames frames3; + frames3.push_back(QuicFrame(new QuicPathResponseFrame(99, payload))); + EXPECT_CALL(visitor_, MaybeSendAddressToken()); + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) + .Times(testing::AtLeast(1u)); + ProcessFramesPacketWithAddresses(frames3, kSelfAddress, kNewPeerAddress, + ENCRYPTION_FORWARD_SECURE); + EXPECT_EQ(NO_CHANGE, connection_.active_effective_peer_migration_type()); + + // Verify the anti-amplification limit is lifted by sending a packet larger + // than the anti-amplification limit. + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); + connection_.SendCryptoDataWithString(std::string(1200, 'a'), 0); + EXPECT_EQ(1u, connection_.GetStats().num_validated_peer_migration); +} + +TEST_P(QuicConnectionTest, + PathValidationSucceedsBeforePeerIpAddressChangeAtServer) { + if (!connection_.validate_client_address()) { + return; + } + set_perspective(Perspective::IS_SERVER); + PathProbeTestInit(Perspective::IS_SERVER); + + // Receive probing packet with new peer address. + const QuicSocketAddress kNewPeerAddress(QuicIpAddress::Loopback4(), + /*port=*/23456); + QuicPathFrameBuffer payload; + EXPECT_CALL(*send_algorithm_, + OnPacketSent(_, _, _, _, NO_RETRANSMITTABLE_DATA)) + .WillOnce(Invoke([&]() { + EXPECT_EQ(kNewPeerAddress, writer_->last_write_peer_address()); + EXPECT_EQ(kPeerAddress, connection_.peer_address()); + EXPECT_EQ(kPeerAddress, connection_.effective_peer_address()); + EXPECT_FALSE(writer_->path_response_frames().empty()); + EXPECT_FALSE(writer_->path_challenge_frames().empty()); + payload = writer_->path_challenge_frames().front().data_buffer; + })) + .WillRepeatedly(Invoke([&]() { + // Only start reverse path validation once. + EXPECT_TRUE(writer_->path_challenge_frames().empty()); + })); + QuicPathFrameBuffer path_challenge_payload{0, 1, 2, 3, 4, 5, 6, 7}; + QuicFrames frames1; + frames1.push_back( + QuicFrame(new QuicPathChallengeFrame(0, path_challenge_payload))); + ProcessFramesPacketWithAddresses(frames1, kSelfAddress, kNewPeerAddress, + ENCRYPTION_FORWARD_SECURE); + EXPECT_TRUE(connection_.HasPendingPathValidation()); + + // Receive PATH_RESPONSE should mark the new peer address validated. + QuicFrames frames3; + frames3.push_back(QuicFrame(new QuicPathResponseFrame(99, payload))); + ProcessFramesPacketWithAddresses(frames3, kSelfAddress, kNewPeerAddress, + ENCRYPTION_FORWARD_SECURE); + + // Process another packet with a newer peer address with the same port will + // start connection migration. + EXPECT_CALL(visitor_, OnConnectionMigration(IPV6_TO_IPV4_CHANGE)).Times(1); + // IETF QUIC send algorithm should be changed to a different object, so no + // OnPacketSent() called on the old send algorithm. + EXPECT_CALL(*send_algorithm_, + OnPacketSent(_, _, _, _, NO_RETRANSMITTABLE_DATA)) + .Times(0); + const QuicSocketAddress kNewerPeerAddress(QuicIpAddress::Loopback4(), + /*port=*/34567); + EXPECT_CALL(visitor_, OnStreamFrame(_)).WillOnce(Invoke([=]() { + EXPECT_EQ(kNewerPeerAddress, connection_.peer_address()); + })); + EXPECT_CALL(visitor_, MaybeSendAddressToken()); + QuicFrames frames2; + frames2.push_back(QuicFrame(frame2_)); + ProcessFramesPacketWithAddresses(frames2, kSelfAddress, kNewerPeerAddress, + ENCRYPTION_FORWARD_SECURE); + EXPECT_EQ(kNewerPeerAddress, connection_.peer_address()); + EXPECT_EQ(kNewerPeerAddress, connection_.effective_peer_address()); + // Since the newer address has the same IP as the previously validated probing + // address. The peer migration becomes validated immediately. + EXPECT_EQ(NO_CHANGE, connection_.active_effective_peer_migration_type()); + EXPECT_EQ(kNewerPeerAddress, writer_->last_write_peer_address()); + EXPECT_EQ(1u, connection_.GetStats() + .num_peer_migration_to_proactively_validated_address); + EXPECT_FALSE(connection_.HasPendingPathValidation()); + EXPECT_NE(connection_.sent_packet_manager().GetSendAlgorithm(), + send_algorithm_); + + // Switch to use the mock send algorithm. + send_algorithm_ = new StrictMock<MockSendAlgorithm>(); + EXPECT_CALL(*send_algorithm_, CanSend(_)).WillRepeatedly(Return(true)); + EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) + .WillRepeatedly(Return(kDefaultTCPMSS)); + EXPECT_CALL(*send_algorithm_, OnApplicationLimited(_)).Times(AnyNumber()); + EXPECT_CALL(*send_algorithm_, BandwidthEstimate()) + .Times(AnyNumber()) + .WillRepeatedly(Return(QuicBandwidth::Zero())); + EXPECT_CALL(*send_algorithm_, InSlowStart()).Times(AnyNumber()); + EXPECT_CALL(*send_algorithm_, InRecovery()).Times(AnyNumber()); + EXPECT_CALL(*send_algorithm_, PopulateConnectionStats(_)).Times(AnyNumber()); + connection_.SetSendAlgorithm(send_algorithm_); + + // Verify the server is not throttled by the anti-amplification limit by + // sending a packet larger than the anti-amplification limit. + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); + connection_.SendCryptoDataWithString(std::string(1200, 'a'), 0); + EXPECT_EQ(1u, connection_.GetStats().num_validated_peer_migration); +} + +TEST_P(QuicConnectionTest, + ProbedOnAnotherPathAfterPeerIpAddressChangeAtServer) { + if (!connection_.validate_client_address()) { + return; + } + PathProbeTestInit(Perspective::IS_SERVER); + + const QuicSocketAddress kNewPeerAddress(QuicIpAddress::Loopback4(), + /*port=*/23456); + + // Process a packet with a new peer address will start connection migration. + EXPECT_CALL(visitor_, OnConnectionMigration(IPV6_TO_IPV4_CHANGE)).Times(1); + // IETF QUIC send algorithm should be changed to a different object, so no + // OnPacketSent() called on the old send algorithm. + EXPECT_CALL(*send_algorithm_, + OnPacketSent(_, _, _, _, NO_RETRANSMITTABLE_DATA)) + .Times(0); + EXPECT_CALL(visitor_, OnStreamFrame(_)).WillOnce(Invoke([=]() { + EXPECT_EQ(kNewPeerAddress, connection_.peer_address()); + })); + QuicFrames frames2; + frames2.push_back(QuicFrame(frame2_)); + ProcessFramesPacketWithAddresses(frames2, kSelfAddress, kNewPeerAddress, + ENCRYPTION_FORWARD_SECURE); + EXPECT_TRUE(QuicConnectionPeer::IsAlternativePathValidated(&connection_)); + EXPECT_TRUE(connection_.HasPendingPathValidation()); + + // Switch to use the mock send algorithm. + send_algorithm_ = new StrictMock<MockSendAlgorithm>(); + EXPECT_CALL(*send_algorithm_, CanSend(_)).WillRepeatedly(Return(true)); + EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) + .WillRepeatedly(Return(kDefaultTCPMSS)); + EXPECT_CALL(*send_algorithm_, OnApplicationLimited(_)).Times(AnyNumber()); + EXPECT_CALL(*send_algorithm_, BandwidthEstimate()) + .Times(AnyNumber()) + .WillRepeatedly(Return(QuicBandwidth::Zero())); + EXPECT_CALL(*send_algorithm_, InSlowStart()).Times(AnyNumber()); + EXPECT_CALL(*send_algorithm_, InRecovery()).Times(AnyNumber()); + EXPECT_CALL(*send_algorithm_, PopulateConnectionStats(_)).Times(AnyNumber()); + connection_.SetSendAlgorithm(send_algorithm_); + + // Receive probing packet with a newer peer address shouldn't override the + // on-going path validation. + const QuicSocketAddress kNewerPeerAddress(QuicIpAddress::Loopback4(), + /*port=*/34567); + EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) + .WillOnce(Invoke([&]() { + EXPECT_EQ(kNewerPeerAddress, writer_->last_write_peer_address()); + EXPECT_FALSE(writer_->path_response_frames().empty()); + EXPECT_TRUE(writer_->path_challenge_frames().empty()); + })); + QuicPathFrameBuffer path_challenge_payload{0, 1, 2, 3, 4, 5, 6, 7}; + QuicFrames frames1; + frames1.push_back( + QuicFrame(new QuicPathChallengeFrame(0, path_challenge_payload))); + ProcessFramesPacketWithAddresses(frames1, kSelfAddress, kNewerPeerAddress, + ENCRYPTION_FORWARD_SECURE); + EXPECT_EQ(kNewPeerAddress, connection_.effective_peer_address()); + EXPECT_EQ(kNewPeerAddress, connection_.peer_address()); + EXPECT_TRUE(QuicConnectionPeer::IsAlternativePathValidated(&connection_)); + EXPECT_TRUE(connection_.HasPendingPathValidation()); +} + } // namespace } // namespace test } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_constants.cc b/chromium/net/third_party/quiche/src/quic/core/quic_constants.cc index 8e46f886080..36ede3cef2c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_constants.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_constants.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_constants.h" +#include "quic/core/quic_constants.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_constants.h b/chromium/net/third_party/quiche/src/quic/core/quic_constants.h index 4cd6ba59901..2de827f6227 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_constants.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_constants.h @@ -10,8 +10,8 @@ #include <cstdint> #include <limits> -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" // Definitions of constant values used throughout the QUIC code. @@ -209,6 +209,10 @@ const size_t kDiversificationNonceSize = 32; // This will likely have to be tuned. const QuicPacketCount kMaxPacketGap = 5000; +// The max number of sequence number intervals that +// QuicPeerIssuedConnetionIdManager can maintain. +const size_t kMaxNumConnectionIdSequenceNumberIntervals = 20; + // The maximum number of random padding bytes to add. const QuicByteCount kMaxNumRandomPaddingBytes = 256; @@ -275,6 +279,9 @@ const float kAckDecimationDelay = 0.25; // The default alarm granularity assumed by QUIC code. const QuicTime::Delta kAlarmGranularity = QuicTime::Delta::FromMilliseconds(1); +// Maximum number of unretired connection IDs a connection can have. +const size_t kMaxNumConnectonIdsInUse = 10u; + // Packet number of first sending packet of a connection. Please note, this // cannot be used as first received packet because peer can choose its starting // packet number. diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_control_frame_manager.cc b/chromium/net/third_party/quiche/src/quic/core/quic_control_frame_manager.cc index fddf0878586..64e5f5d38eb 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_control_frame_manager.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_control_frame_manager.cc @@ -2,19 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_control_frame_manager.h" +#include "quic/core/quic_control_frame_manager.h" #include <string> -#include "net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_cat.h" +#include "quic/core/frames/quic_ack_frequency_frame.h" +#include "quic/core/frames/quic_frame.h" +#include "quic/core/frames/quic_new_connection_id_frame.h" +#include "quic/core/frames/quic_retire_connection_id_frame.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_map_util.h" namespace quic { @@ -45,10 +48,9 @@ void QuicControlFrameManager::WriteOrBufferQuicFrame(QuicFrame frame) { if (control_frames_.size() > kMaxNumControlFrames) { delegate_->OnControlFrameManagerError( QUIC_TOO_MANY_BUFFERED_CONTROL_FRAMES, - quiche::QuicheStrCat( - "More than ", kMaxNumControlFrames, - "buffered control frames, least_unacked: ", least_unacked_, - ", least_unsent_: ", least_unsent_)); + absl::StrCat("More than ", kMaxNumControlFrames, + "buffered control frames, least_unacked: ", least_unacked_, + ", least_unsent_: ", least_unsent_)); return; } if (had_buffered_frames) { @@ -132,26 +134,28 @@ void QuicControlFrameManager::WriteOrBufferAckFrequency( ack_frequency_frame.max_ack_delay))); } -void QuicControlFrameManager::WritePing() { - QUIC_DVLOG(1) << "Writing PING_FRAME"; - if (HasBufferedFrames()) { - // Do not send ping if there is buffered frames. - QUIC_LOG(WARNING) - << "Try to send PING when there is buffered control frames."; - return; - } - control_frames_.emplace_back( - QuicFrame(QuicPingFrame(++last_control_frame_id_))); - if (control_frames_.size() > kMaxNumControlFrames) { - delegate_->OnControlFrameManagerError( - QUIC_TOO_MANY_BUFFERED_CONTROL_FRAMES, - quiche::QuicheStrCat( - "More than ", kMaxNumControlFrames, - "buffered control frames, least_unacked: ", least_unacked_, - ", least_unsent_: ", least_unsent_)); - return; - } - WriteBufferedFrames(); +void QuicControlFrameManager::WriteOrBufferNewConnectionId( + const QuicConnectionId& connection_id, + uint64_t sequence_number, + uint64_t retire_prior_to, + QuicUint128 stateless_reset_token) { + QUIC_DVLOG(1) << "Writing NEW_CONNECTION_ID frame"; + WriteOrBufferQuicFrame(QuicFrame(new QuicNewConnectionIdFrame( + ++last_control_frame_id_, connection_id, sequence_number, + stateless_reset_token, retire_prior_to))); +} + +void QuicControlFrameManager::WriteOrBufferRetireConnectionId( + uint64_t sequence_number) { + QUIC_DVLOG(1) << "Writing RETIRE_CONNECTION_ID frame"; + WriteOrBufferQuicFrame(QuicFrame(new QuicRetireConnectionIdFrame( + ++last_control_frame_id_, sequence_number))); +} + +void QuicControlFrameManager::WriteOrBufferNewToken(absl::string_view token) { + QUIC_DVLOG(1) << "Writing NEW_TOKEN frame"; + WriteOrBufferQuicFrame( + QuicFrame(new QuicNewTokenFrame(++last_control_frame_id_, token))); } void QuicControlFrameManager::OnControlFrameSent(const QuicFrame& frame) { @@ -266,8 +270,8 @@ void QuicControlFrameManager::OnCanWrite() { bool QuicControlFrameManager::RetransmitControlFrame(const QuicFrame& frame, TransmissionType type) { - DCHECK(type == PTO_RETRANSMISSION || type == RTO_RETRANSMISSION || - type == TLP_RETRANSMISSION || type == PROBING_RETRANSMISSION); + QUICHE_DCHECK(type == PTO_RETRANSMISSION || type == RTO_RETRANSMISSION || + type == TLP_RETRANSMISSION || type == PROBING_RETRANSMISSION); QuicControlFrameId id = GetControlFrameId(frame); if (id == kInvalidControlFrameId) { // Frame does not have a valid control frame ID, ignore it. Returns true diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_control_frame_manager.h b/chromium/net/third_party/quiche/src/quic/core/quic_control_frame_manager.h index 493e7f02416..e4a55260afe 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_control_frame_manager.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_control_frame_manager.h @@ -5,11 +5,12 @@ #ifndef QUICHE_QUIC_CORE_QUIC_CONTROL_FRAME_MANAGER_H_ #define QUICHE_QUIC_CORE_QUIC_CONTROL_FRAME_MANAGER_H_ +#include <cstdint> #include <string> -#include "net/third_party/quiche/src/quic/core/frames/quic_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_circular_deque.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "quic/core/frames/quic_frame.h" +#include "quic/core/quic_circular_deque.h" +#include "quic/core/quic_connection_id.h" namespace quic { @@ -89,8 +90,20 @@ class QUIC_EXPORT_PRIVATE QuicControlFrameManager { void WriteOrBufferAckFrequency( const QuicAckFrequencyFrame& ack_frequency_frame); - // Sends a PING_FRAME. Do not send PING if there is buffered frames. - void WritePing(); + // Tries to send a NEW_CONNECTION_ID frame. The frame is buffered if it cannot + // be sent immediately. + void WriteOrBufferNewConnectionId(const QuicConnectionId& connection_id, + uint64_t sequence_number, + uint64_t retire_prior_to, + QuicUint128 stateless_reset_token); + + // Tries to send a RETIRE_CONNNECTION_ID frame. The frame is buffered if it + // cannot be sent immediately. + void WriteOrBufferRetireConnectionId(uint64_t sequence_number); + + // Tries to send a NEW_TOKEN frame. Buffers the frame if it cannot be sent + // immediately. + void WriteOrBufferNewToken(absl::string_view token); // Called when |frame| gets acked. Returns true if |frame| gets acked for the // first time, return false otherwise. diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_control_frame_manager_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_control_frame_manager_test.cc index 68658bb32c3..5aed6e0c17f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_control_frame_manager_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_control_frame_manager_test.cc @@ -2,17 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_control_frame_manager.h" +#include "quic/core/quic_control_frame_manager.h" #include <utility> -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/frames/quic_ack_frequency_frame.h" +#include "quic/core/frames/quic_retire_connection_id_frame.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" using testing::_; using testing::InSequence; @@ -72,7 +73,6 @@ class QuicControlFrameManagerTest : public QuicTest { manager_->WriteOrBufferBlocked(kTestStreamId); manager_->WriteOrBufferStopSending(kTestStopSendingCode, kTestStreamId); number_of_frames_ = 5u; - ping_frame_id_ = 6u; EXPECT_EQ(number_of_frames_, QuicControlFrameManagerPeer::QueueSize(manager_.get())); EXPECT_TRUE(manager_->IsControlFrameOutstanding(QuicFrame(&rst_stream_))); @@ -81,8 +81,6 @@ class QuicControlFrameManagerTest : public QuicTest { manager_->IsControlFrameOutstanding(QuicFrame(&window_update_))); EXPECT_TRUE(manager_->IsControlFrameOutstanding(QuicFrame(&blocked_))); EXPECT_TRUE(manager_->IsControlFrameOutstanding(QuicFrame(&stop_sending_))); - EXPECT_FALSE(manager_->IsControlFrameOutstanding( - QuicFrame(QuicPingFrame(ping_frame_id_)))); EXPECT_FALSE(manager_->HasPendingRetransmission()); EXPECT_TRUE(manager_->WillingToWrite()); @@ -101,7 +99,6 @@ class QuicControlFrameManagerTest : public QuicTest { std::unique_ptr<QuicControlFrameManager> manager_; QuicFrame frame_; size_t number_of_frames_; - int ping_frame_id_; }; TEST_F(QuicControlFrameManagerTest, OnControlFrameAcked) { @@ -119,8 +116,6 @@ TEST_F(QuicControlFrameManagerTest, OnControlFrameAcked) { EXPECT_TRUE(manager_->IsControlFrameOutstanding(QuicFrame(&blocked_))); EXPECT_TRUE(manager_->IsControlFrameOutstanding(QuicFrame(&stop_sending_))); - EXPECT_FALSE(manager_->IsControlFrameOutstanding( - QuicFrame(QuicPingFrame(ping_frame_id_)))); EXPECT_TRUE(manager_->OnControlFrameAcked(QuicFrame(&window_update_))); EXPECT_FALSE(manager_->IsControlFrameOutstanding(QuicFrame(&window_update_))); EXPECT_EQ(number_of_frames_, @@ -146,7 +141,6 @@ TEST_F(QuicControlFrameManagerTest, OnControlFrameAcked) { EXPECT_CALL(*session_, WriteControlFrame(_, _)) .WillRepeatedly(Invoke(&ClearControlFrameWithTransmissionType)); manager_->OnCanWrite(); - manager_->WritePing(); EXPECT_FALSE(manager_->WillingToWrite()); } @@ -179,10 +173,9 @@ TEST_F(QuicControlFrameManagerTest, OnControlFrameLost) { // Send control frames 4, 5, and 6. EXPECT_CALL(*session_, WriteControlFrame(_, _)) - .Times(number_of_frames_ - 2u) + .Times(number_of_frames_ - 3u) .WillRepeatedly(Invoke(&ClearControlFrameWithTransmissionType)); manager_->OnCanWrite(); - manager_->WritePing(); EXPECT_FALSE(manager_->WillingToWrite()); } @@ -214,28 +207,6 @@ TEST_F(QuicControlFrameManagerTest, RetransmitControlFrame) { PTO_RETRANSMISSION)); } -TEST_F(QuicControlFrameManagerTest, DonotSendPingWithBufferedFrames) { - Initialize(); - InSequence s; - EXPECT_CALL(*session_, WriteControlFrame(_, _)) - .WillOnce(Invoke(&ClearControlFrameWithTransmissionType)); - EXPECT_CALL(*session_, WriteControlFrame(_, _)).WillOnce(Return(false)); - // Send control frame 1. - manager_->OnCanWrite(); - EXPECT_FALSE(manager_->HasPendingRetransmission()); - EXPECT_TRUE(manager_->WillingToWrite()); - - // Send PING when there is buffered frames. - manager_->WritePing(); - // Verify only the buffered frames are sent. - EXPECT_CALL(*session_, WriteControlFrame(_, _)) - .Times(number_of_frames_ - 1) - .WillRepeatedly(Invoke(&ClearControlFrameWithTransmissionType)); - manager_->OnCanWrite(); - EXPECT_FALSE(manager_->HasPendingRetransmission()); - EXPECT_FALSE(manager_->WillingToWrite()); -} - TEST_F(QuicControlFrameManagerTest, SendAndAckAckFrequencyFrame) { Initialize(); InSequence s; @@ -262,6 +233,39 @@ TEST_F(QuicControlFrameManagerTest, SendAndAckAckFrequencyFrame) { manager_->OnControlFrameAcked(QuicFrame(&expected_ack_frequency))); } +TEST_F(QuicControlFrameManagerTest, NewAndRetireConnectionIdFrames) { + Initialize(); + InSequence s; + + // Send other frames 1-5. + EXPECT_CALL(*session_, WriteControlFrame(_, _)) + .Times(5) + .WillRepeatedly(Invoke(&ClearControlFrameWithTransmissionType)); + manager_->OnCanWrite(); + + EXPECT_CALL(*session_, WriteControlFrame(_, _)).WillOnce(Return(false)); + EXPECT_CALL(*session_, WriteControlFrame(_, _)) + .Times(2) + .WillRepeatedly(Invoke(&ClearControlFrameWithTransmissionType)); + // Send NewConnectionIdFrame as frame 6. + manager_->WriteOrBufferNewConnectionId( + TestConnectionId(3), /*sequence_number=*/2, /*retire_prior_to=*/1, + /*stateless_reset_token=*/MakeQuicUint128(1, 1)); + // Send RetireConnectionIdFrame as frame 7. + manager_->WriteOrBufferRetireConnectionId(/*sequence_number=*/0); + manager_->OnCanWrite(); + + // Ack both frames. + QuicNewConnectionIdFrame new_connection_id_frame; + new_connection_id_frame.control_frame_id = 6; + QuicRetireConnectionIdFrame retire_connection_id_frame; + retire_connection_id_frame.control_frame_id = 7; + EXPECT_TRUE( + manager_->OnControlFrameAcked(QuicFrame(&new_connection_id_frame))); + EXPECT_TRUE( + manager_->OnControlFrameAcked(QuicFrame(&retire_connection_id_frame))); +} + TEST_F(QuicControlFrameManagerTest, DonotRetransmitOldWindowUpdates) { Initialize(); // Send two more window updates of the same stream. diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_handshaker.cc b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_handshaker.cc index 74f0724e368..29a4367d599 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_handshaker.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_handshaker.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_crypto_client_handshaker.h" +#include "quic/core/quic_crypto_client_handshaker.h" #include <memory> #include <string> -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_client_stats.h" -#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/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_cat.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/crypto_utils.h" +#include "quic/core/quic_session.h" +#include "quic/platform/api/quic_client_stats.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -167,7 +167,12 @@ HandshakeState QuicCryptoClientHandshaker::GetHandshakeState() const { } void QuicCryptoClientHandshaker::OnHandshakeDoneReceived() { - DCHECK(false); + QUICHE_DCHECK(false); +} + +void QuicCryptoClientHandshaker::OnNewTokenReceived( + absl::string_view /*token*/) { + QUICHE_DCHECK(false); } size_t QuicCryptoClientHandshaker::BufferSizeLimitForLevel( @@ -182,14 +187,14 @@ bool QuicCryptoClientHandshaker::KeyUpdateSupportedLocally() const { std::unique_ptr<QuicDecrypter> QuicCryptoClientHandshaker::AdvanceKeysAndCreateCurrentOneRttDecrypter() { // Key update is only defined in QUIC+TLS. - DCHECK(false); + QUICHE_DCHECK(false); return nullptr; } std::unique_ptr<QuicEncrypter> QuicCryptoClientHandshaker::CreateCurrentOneRttEncrypter() { // Key update is only defined in QUIC+TLS. - DCHECK(false); + QUICHE_DCHECK(false); return nullptr; } @@ -201,7 +206,7 @@ void QuicCryptoClientHandshaker::OnConnectionClosed( void QuicCryptoClientHandshaker::HandleServerConfigUpdateMessage( const CryptoHandshakeMessage& server_config_update) { - DCHECK(server_config_update.tag() == kSCUP); + QUICHE_DCHECK(server_config_update.tag() == kSCUP); std::string error_details; QuicCryptoClientConfig::CachedState* cached = crypto_config_->LookupOrCreate(server_id_); @@ -216,7 +221,7 @@ void QuicCryptoClientHandshaker::HandleServerConfigUpdateMessage( return; } - DCHECK(one_rtt_keys_available()); + QUICHE_DCHECK(one_rtt_keys_available()); if (proof_verify_callback_) { proof_verify_callback_->Cancel(); } @@ -231,7 +236,7 @@ void QuicCryptoClientHandshaker::DoHandshakeLoop( QuicAsyncStatus rv = QUIC_SUCCESS; do { - CHECK_NE(STATE_NONE, next_state_); + QUICHE_CHECK_NE(STATE_NONE, next_state_); const State state = next_state_; next_state_ = STATE_IDLE; rv = QUIC_SUCCESS; @@ -279,7 +284,7 @@ void QuicCryptoClientHandshaker::DoInitialize( // This allows us to respond to CA trust changes or certificate // expiration because it may have been a while since we last verified // the proof. - DCHECK(crypto_config_->proof_verifier()); + QUICHE_DCHECK(crypto_config_->proof_verifier()); // Track proof verification time when cached server config is used. proof_verify_start_time_ = session()->connection()->clock()->Now(); chlo_hash_ = cached->chlo_hash(); @@ -298,16 +303,15 @@ void QuicCryptoClientHandshaker::DoSendCHLO( if (num_client_hellos_ >= QuicCryptoClientStream::kMaxClientHellos) { stream_->OnUnrecoverableError( QUIC_CRYPTO_TOO_MANY_REJECTS, - quiche::QuicheStrCat("More than ", - QuicCryptoClientStream::kMaxClientHellos, - " rejects")); + absl::StrCat("More than ", QuicCryptoClientStream::kMaxClientHellos, + " rejects")); return; } num_client_hellos_++; CryptoHandshakeMessage out; - DCHECK(session() != nullptr); - DCHECK(session()->config() != nullptr); + QUICHE_DCHECK(session() != nullptr); + QUICHE_DCHECK(session()->config() != nullptr); // Send all the options, regardless of whether we're sending an // inchoate or subsequent hello. session()->config()->ToHandshakeMessage(&out, session()->transport_version()); @@ -459,7 +463,7 @@ void QuicCryptoClientHandshaker::DoReceiveREJ( QuicAsyncStatus QuicCryptoClientHandshaker::DoVerifyProof( QuicCryptoClientConfig::CachedState* cached) { ProofVerifier* verifier = crypto_config_->proof_verifier(); - DCHECK(verifier); + QUICHE_DCHECK(verifier); next_state_ = STATE_VERIFY_PROOF_COMPLETE; generation_counter_ = cached->generation_counter(); @@ -553,8 +557,8 @@ void QuicCryptoClientHandshaker::DoReceiveSHLO( if (in->tag() != kSHLO) { stream_->OnUnrecoverableError( QUIC_INVALID_CRYPTO_MESSAGE_TYPE, - quiche::QuicheStrCat("Expected SHLO or REJ. Received: ", - QuicTagToString(in->tag()))); + absl::StrCat("Expected SHLO or REJ. Received: ", + QuicTagToString(in->tag()))); return; } @@ -610,7 +614,7 @@ void QuicCryptoClientHandshaker::DoInitializeServerConfigUpdate( bool update_ignored = false; if (!cached->IsEmpty() && !cached->signature().empty()) { // Note that we verify the proof even if the cached proof is valid. - DCHECK(crypto_config_->proof_verifier()); + QUICHE_DCHECK(crypto_config_->proof_verifier()); next_state_ = STATE_VERIFY_PROOF; } else { update_ignored = true; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_handshaker.h b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_handshaker.h index 49fa405c469..e92606669de 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_handshaker.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_handshaker.h @@ -7,12 +7,12 @@ #include <string> -#include "net/third_party/quiche/src/quic/core/crypto/proof_verifier.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_client_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_logging.h" +#include "quic/core/crypto/proof_verifier.h" +#include "quic/core/crypto/quic_crypto_client_config.h" +#include "quic/core/quic_crypto_client_stream.h" +#include "quic/core/quic_server_id.h" +#include "quic/platform/api/quic_export.h" +#include "common/platform/api/quiche_logging.h" namespace quic { @@ -60,6 +60,7 @@ class QUIC_EXPORT_PRIVATE QuicCryptoClientHandshaker void OnConnectionClosed(QuicErrorCode /*error*/, ConnectionCloseSource /*source*/) override; void OnHandshakeDoneReceived() override; + void OnNewTokenReceived(absl::string_view token) override; void SetServerApplicationStateForResumption( std::unique_ptr<ApplicationState> /*application_state*/) override { QUICHE_NOTREACHED(); diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_handshaker_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_handshaker_test.cc index 2d6db7f28f7..660663a9acd 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_handshaker_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_handshaker_test.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_crypto_client_handshaker.h" +#include "quic/core/quic_crypto_client_handshaker.h" #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/proto/crypto_server_config_proto.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/proto/crypto_server_config_proto.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_stream.cc b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_stream.cc index 94a894836b4..3160f583185 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_stream.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_stream.cc @@ -2,23 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_crypto_client_stream.h" +#include "quic/core/quic_crypto_client_stream.h" #include <memory> #include <string> #include <utility> -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_client_handshaker.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/tls_client_handshaker.h" -#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 "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/crypto_utils.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/crypto/quic_crypto_client_config.h" +#include "quic/core/quic_crypto_client_handshaker.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_utils.h" +#include "quic/core/tls_client_handshaker.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -35,7 +35,8 @@ QuicCryptoClientStream::QuicCryptoClientStream( ProofHandler* proof_handler, bool has_application_state) : QuicCryptoClientStreamBase(session) { - DCHECK_EQ(Perspective::IS_CLIENT, session->connection()->perspective()); + QUICHE_DCHECK_EQ(Perspective::IS_CLIENT, + session->connection()->perspective()); switch (session->connection()->version().handshake_protocol) { case PROTOCOL_QUIC_CRYPTO: handshaker_ = std::make_unique<QuicCryptoClientHandshaker>( @@ -144,6 +145,21 @@ void QuicCryptoClientStream::OnHandshakeDoneReceived() { handshaker_->OnHandshakeDoneReceived(); } +void QuicCryptoClientStream::OnNewTokenReceived(absl::string_view token) { + handshaker_->OnNewTokenReceived(token); +} + +std::string QuicCryptoClientStream::GetAddressToken() const { + QUICHE_DCHECK(false); + return ""; +} + +bool QuicCryptoClientStream::ValidateAddressToken( + absl::string_view /*token*/) const { + QUICHE_DCHECK(false); + return false; +} + void QuicCryptoClientStream::SetServerApplicationStateForResumption( std::unique_ptr<ApplicationState> application_state) { handshaker_->SetServerApplicationStateForResumption( diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_stream.h b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_stream.h index 123bdfeaffb..b3d3c2b2bc3 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_stream.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_stream.h @@ -9,15 +9,15 @@ #include <memory> #include <string> -#include "net/third_party/quiche/src/quic/core/crypto/proof_verifier.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_handshaker.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/proof_verifier.h" +#include "quic/core/crypto/quic_crypto_client_config.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_crypto_handshaker.h" +#include "quic/core/quic_crypto_stream.h" +#include "quic/core/quic_server_id.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -179,6 +179,9 @@ class QUIC_EXPORT_PRIVATE QuicCryptoClientStream // Called when handshake done has been received. virtual void OnHandshakeDoneReceived() = 0; + // Called when new token has been received. + virtual void OnNewTokenReceived(absl::string_view token) = 0; + // Called when application state is received. virtual void SetServerApplicationStateForResumption( std::unique_ptr<ApplicationState> application_state) = 0; @@ -236,6 +239,9 @@ class QUIC_EXPORT_PRIVATE QuicCryptoClientStream void OnConnectionClosed(QuicErrorCode error, ConnectionCloseSource source) override; void OnHandshakeDoneReceived() override; + void OnNewTokenReceived(absl::string_view token) override; + std::string GetAddressToken() const override; + bool ValidateAddressToken(absl::string_view token) const override; HandshakeState GetHandshakeState() const override; void SetServerApplicationStateForResumption( std::unique_ptr<ApplicationState> application_state) override; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_stream_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_stream_test.cc index 86fa3b8b341..ac0a4fc6a9d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_stream_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_client_stream_test.cc @@ -2,28 +2,28 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_crypto_client_stream.h" +#include "quic/core/quic_crypto_client_stream.h" #include <memory> #include <string> #include <utility> #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/simple_quic_framer.h" -#include "net/third_party/quiche/src/quic/test_tools/simple_session_cache.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/core/crypto/aes_128_gcm_12_encrypter.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_server_id.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/quic_stream_peer.h" +#include "quic/test_tools/quic_stream_sequencer_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/simple_quic_framer.h" +#include "quic/test_tools/simple_session_cache.h" +#include "common/test_tools/quiche_test_utils.h" using testing::_; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_handshaker.cc b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_handshaker.cc index 8adf83b7e86..25bf9dcdf15 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_handshaker.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_handshaker.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_crypto_handshaker.h" +#include "quic/core/quic_crypto_handshaker.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" +#include "quic/core/quic_session.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_handshaker.h b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_handshaker.h index b971580a4a3..b5077d9566d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_handshaker.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_handshaker.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_CORE_QUIC_CRYPTO_HANDSHAKER_H_ #define QUICHE_QUIC_CORE_QUIC_CRYPTO_HANDSHAKER_H_ -#include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_crypto_stream.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream.cc b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream.cc index 2bad8ecfdcd..fc9be1764a2 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream.h" +#include "quic/core/quic_crypto_server_stream.h" #include <memory> #include <string> @@ -10,8 +10,8 @@ #include "absl/base/macros.h" #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/sha.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { @@ -126,8 +126,8 @@ void QuicCryptoServerStream::OnHandshakeMessage( CryptoUtils::HashHandshakeMessage(message, Perspective::IS_SERVER); std::unique_ptr<ValidateCallback> cb(new ValidateCallback(this)); - DCHECK(validate_client_hello_cb_ == nullptr); - DCHECK(process_client_hello_cb_ == nullptr); + QUICHE_DCHECK(validate_client_hello_cb_ == nullptr); + QUICHE_DCHECK(process_client_hello_cb_ == nullptr); validate_client_hello_cb_ = cb.get(); crypto_config_->ValidateClientHello( message, GetClientAddress(), session()->connection()->self_address(), @@ -140,8 +140,8 @@ void QuicCryptoServerStream::FinishProcessingHandshakeMessage( result, std::unique_ptr<ProofSource::Details> details) { // Clear the callback that got us here. - DCHECK(validate_client_hello_cb_ != nullptr); - DCHECK(process_client_hello_cb_ == nullptr); + QUICHE_DCHECK(validate_client_hello_cb_ != nullptr); + QUICHE_DCHECK(process_client_hello_cb_ == nullptr); validate_client_hello_cb_ = nullptr; std::unique_ptr<ProcessClientHelloCallback> cb( @@ -159,8 +159,8 @@ void QuicCryptoServerStream:: std::unique_ptr<DiversificationNonce> diversification_nonce, std::unique_ptr<ProofSource::Details> proof_source_details) { // Clear the callback that got us here. - DCHECK(process_client_hello_cb_ != nullptr); - DCHECK(validate_client_hello_cb_ == nullptr); + QUICHE_DCHECK(process_client_hello_cb_ != nullptr); + QUICHE_DCHECK(validate_client_hello_cb_ == nullptr); process_client_hello_cb_ = nullptr; proof_source_details_ = std::move(proof_source_details); @@ -276,7 +276,7 @@ void QuicCryptoServerStream::FinishSendServerConfigUpdate( bool ok, const CryptoHandshakeMessage& message) { // Clear the callback that got us here. - DCHECK(send_server_config_update_cb_ != nullptr); + QUICHE_DCHECK(send_server_config_update_cb_ != nullptr); send_server_config_update_cb_ = nullptr; if (!ok) { @@ -337,7 +337,22 @@ void QuicCryptoServerStream::OnPacketDecrypted(EncryptionLevel level) { } void QuicCryptoServerStream::OnHandshakeDoneReceived() { - DCHECK(false); + QUICHE_DCHECK(false); +} + +void QuicCryptoServerStream::OnNewTokenReceived(absl::string_view /*token*/) { + QUICHE_DCHECK(false); +} + +std::string QuicCryptoServerStream::GetAddressToken() const { + QUICHE_DCHECK(false); + return ""; +} + +bool QuicCryptoServerStream::ValidateAddressToken( + absl::string_view /*token*/) const { + QUICHE_DCHECK(false); + return false; } bool QuicCryptoServerStream::ShouldSendExpectCTHeader() const { @@ -413,14 +428,14 @@ bool QuicCryptoServerStream::KeyUpdateSupportedLocally() const { std::unique_ptr<QuicDecrypter> QuicCryptoServerStream::AdvanceKeysAndCreateCurrentOneRttDecrypter() { // Key update is only defined in QUIC+TLS. - DCHECK(false); + QUICHE_DCHECK(false); return nullptr; } std::unique_ptr<QuicEncrypter> QuicCryptoServerStream::CreateCurrentOneRttEncrypter() { // Key update is only defined in QUIC+TLS. - DCHECK(false); + QUICHE_DCHECK(false); return nullptr; } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream.h b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream.h index c99a13689d8..911ca7e789f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream.h @@ -7,12 +7,12 @@ #include <string> -#include "net/third_party/quiche/src/quic/core/proto/cached_network_parameters_proto.h" -#include "net/third_party/quiche/src/quic/core/proto/source_address_token_proto.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_handshaker.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/proto/cached_network_parameters_proto.h" +#include "quic/core/proto/source_address_token_proto.h" +#include "quic/core/quic_crypto_handshaker.h" +#include "quic/core/quic_crypto_server_stream_base.h" +#include "quic/core/quic_session.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -47,6 +47,9 @@ class QUIC_EXPORT_PRIVATE QuicCryptoServerStream void OnConnectionClosed(QuicErrorCode /*error*/, ConnectionCloseSource /*source*/) override {} void OnHandshakeDoneReceived() override; + void OnNewTokenReceived(absl::string_view token) override; + std::string GetAddressToken() const override; + bool ValidateAddressToken(absl::string_view token) const override; bool ShouldSendExpectCTHeader() const override; const ProofSource::Details* ProofSourceDetails() const override; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.cc b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.cc index 8ea63ba0876..b80d06dc1e5 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.cc @@ -2,25 +2,25 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.h" +#include "quic/core/quic_crypto_server_stream_base.h" #include <memory> #include <string> #include <utility> -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/proto/cached_network_parameters_proto.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/tls_server_handshaker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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 "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/crypto_utils.h" +#include "quic/core/crypto/quic_crypto_server_config.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/proto/cached_network_parameters_proto.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_crypto_server_stream.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_session.h" +#include "quic/core/tls_server_handshaker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -38,7 +38,7 @@ std::unique_ptr<QuicCryptoServerStreamBase> CreateCryptoServerStream( crypto_config, compressed_certs_cache, session, helper)); case PROTOCOL_TLS1_3: return std::unique_ptr<TlsServerHandshaker>( - new TlsServerHandshaker(session, *crypto_config)); + new TlsServerHandshaker(session, crypto_config)); case PROTOCOL_UNSUPPORTED: break; } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.h b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.h index bea998d398b..3ff9c37fa1e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.h @@ -9,14 +9,14 @@ #include <memory> #include <string> -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_handshaker.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/quic_compressed_certs_cache.h" +#include "quic/core/crypto/quic_crypto_server_config.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_crypto_handshaker.h" +#include "quic/core/quic_crypto_stream.h" +#include "quic/core/quic_session.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream_test.cc index 2831dc03b64..88fdda9d6c2 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_server_stream_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.h" +#include "quic/core/quic_crypto_server_stream_base.h" #include <map> #include <memory> @@ -10,29 +10,29 @@ #include <vector> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_framer.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_client_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#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_socket_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/failing_proof_source.h" -#include "net/third_party/quiche/src/quic/test_tools/fake_proof_source.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_crypto_server_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/crypto/aes_128_gcm_12_encrypter.h" +#include "quic/core/crypto/crypto_framer.h" +#include "quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/crypto_utils.h" +#include "quic/core/crypto/quic_crypto_server_config.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/quic_crypto_client_stream.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/failing_proof_source.h" +#include "quic/test_tools/fake_proof_source.h" +#include "quic/test_tools/quic_crypto_server_config_peer.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { class QuicConnection; @@ -90,7 +90,7 @@ class QuicCryptoServerStreamTest : public QuicTest { helpers_.back().get(), alarm_factories_.back().get(), &server_crypto_config_, &server_compressed_certs_cache_, &server_connection_, &server_session); - CHECK(server_session); + QUICHE_CHECK(server_session); server_session_.reset(server_session); EXPECT_CALL(*server_session_->helper(), CanAcceptClientHello(_, _, _, _, _)) .Times(testing::AnyNumber()); @@ -124,13 +124,13 @@ class QuicCryptoServerStreamTest : public QuicTest { server_id_, QuicTime::Delta::FromSeconds(100000), supported_versions_, helpers_.back().get(), alarm_factories_.back().get(), &client_crypto_config_, &client_connection_, &client_session); - CHECK(client_session); + QUICHE_CHECK(client_session); client_session_.reset(client_session); } int CompleteCryptoHandshake() { - CHECK(server_connection_); - CHECK(server_session_ != nullptr); + QUICHE_CHECK(server_connection_); + QUICHE_CHECK(server_session_ != nullptr); return crypto_test_utils::HandshakeWithFakeClient( helpers_.back().get(), alarm_factories_.back().get(), @@ -141,8 +141,8 @@ class QuicCryptoServerStreamTest : public QuicTest { // Performs a single round of handshake message-exchange between the // client and server. void AdvanceHandshakeWithFakeClient() { - CHECK(server_connection_); - CHECK(client_session_ != nullptr); + QUICHE_CHECK(server_connection_); + QUICHE_CHECK(client_session_ != nullptr); EXPECT_CALL(*client_session_, OnProofValid(_)).Times(testing::AnyNumber()); EXPECT_CALL(*client_session_, OnProofVerifyDetailsAvailable(_)) diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_stream.cc b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_stream.cc index 5cdae35e3ea..1b2f6db928f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_stream.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_stream.cc @@ -2,21 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h" +#include "quic/core/quic_crypto_stream.h" #include <string> #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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 "quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/crypto_utils.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -49,7 +49,8 @@ QuicCryptoStream::~QuicCryptoStream() {} QuicByteCount QuicCryptoStream::CryptoMessageFramingOverhead( QuicTransportVersion version, QuicConnectionId connection_id) { - DCHECK(QuicUtils::IsConnectionIdValidForVersion(connection_id, version)); + QUICHE_DCHECK( + QuicUtils::IsConnectionIdValidForVersion(connection_id, version)); QuicVariableLengthIntegerLength retry_token_length_length = VARIABLE_LENGTH_INTEGER_LENGTH_1; QuicVariableLengthIntegerLength length_length = @@ -312,7 +313,7 @@ bool QuicCryptoStream::RetransmitStreamData(QuicStreamOffset offset, QuicByteCount data_length, bool /*fin*/, TransmissionType type) { - DCHECK(type == HANDSHAKE_RETRANSMISSION || type == PTO_RETRANSMISSION); + QUICHE_DCHECK(type == HANDSHAKE_RETRANSMISSION || type == PTO_RETRANSMISSION); QuicIntervalSet<QuicStreamOffset> retransmission(offset, offset + data_length); // Determine the encryption level to send data. This only needs to be once as @@ -345,7 +346,7 @@ QuicConsumedData QuicCryptoStream::RetransmitStreamDataAtLevel( QuicByteCount retransmission_length, EncryptionLevel encryption_level, TransmissionType type) { - DCHECK(type == HANDSHAKE_RETRANSMISSION || type == PTO_RETRANSMISSION); + QUICHE_DCHECK(type == HANDSHAKE_RETRANSMISSION || type == PTO_RETRANSMISSION); const auto consumed = stream_delegate()->WritevData( id(), retransmission_length, retransmission_offset, NO_FIN, type, encryption_level); @@ -446,7 +447,8 @@ bool QuicCryptoStream::HasBufferedCryptoFrames() const { << "Versions less than 47 don't use CRYPTO frames"; for (EncryptionLevel level : AllEncryptionLevels()) { const QuicStreamSendBuffer& send_buffer = substreams_[level].send_buffer; - DCHECK_GE(send_buffer.stream_offset(), send_buffer.stream_bytes_written()); + QUICHE_DCHECK_GE(send_buffer.stream_offset(), + send_buffer.stream_bytes_written()); if (send_buffer.stream_offset() > send_buffer.stream_bytes_written()) { return true; } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_stream.h b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_stream.h index ea15ded0a33..2a86a723d3c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_stream.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_stream.h @@ -11,13 +11,13 @@ #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_framer.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/crypto_framer.h" +#include "quic/core/crypto/crypto_utils.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_stream.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -104,6 +104,15 @@ class QUIC_EXPORT_PRIVATE QuicCryptoStream : public QuicStream { // Called when a handshake done frame has been received. virtual void OnHandshakeDoneReceived() = 0; + // Called when a new token frame has been received. + virtual void OnNewTokenReceived(absl::string_view token) = 0; + + // Called to get an address token. + virtual std::string GetAddressToken() const = 0; + + // Called to validate |token|. + virtual bool ValidateAddressToken(absl::string_view token) const = 0; + // Returns current handshake state. virtual HandshakeState GetHandshakeState() const = 0; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_stream_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_stream_test.cc index c67a5dcd797..545fdd8180f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_crypto_stream_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_crypto_stream_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h" +#include "quic/core/quic_crypto_stream.h" #include <cstdint> #include <memory> @@ -10,15 +10,15 @@ #include <utility> #include <vector> -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.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/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/quic_stream_peer.h" +#include "quic/test_tools/quic_test_utils.h" using testing::_; using testing::InSequence; @@ -63,6 +63,11 @@ class MockQuicCryptoStream : public QuicCryptoStream, void OnOneRttPacketAcknowledged() override {} void OnHandshakePacketSent() override {} void OnHandshakeDoneReceived() override {} + void OnNewTokenReceived(absl::string_view /*token*/) override {} + std::string GetAddressToken() const override { return ""; } + bool ValidateAddressToken(absl::string_view /*token*/) const override { + return true; + } HandshakeState GetHandshakeState() const override { return HANDSHAKE_START; } void SetServerApplicationStateForResumption( std::unique_ptr<ApplicationState> /*application_state*/) override {} @@ -576,20 +581,22 @@ TEST_F(QuicCryptoStreamTest, HasUnackedCryptoDataWithCryptoFrames) { // Regression test for bugfix of GetPacketHeaderSize. TEST_F(QuicCryptoStreamTest, CryptoMessageFramingOverhead) { - for (auto version : AllSupportedTransportVersions()) { + for (const ParsedQuicVersion& version : + AllSupportedVersionsWithQuicCrypto()) { SCOPED_TRACE(version); QuicByteCount expected_overhead = 48; - if (VersionHasIetfInvariantHeader(version)) { + if (version.HasIetfInvariantHeader()) { expected_overhead += 4; } - if (QuicVersionHasLongHeaderLengths(version)) { + if (version.HasLongHeaderLengths()) { expected_overhead += 3; } - if (VersionHasLengthPrefixedConnectionIds(version)) { + if (version.HasLengthPrefixedConnectionIds()) { expected_overhead += 1; } - EXPECT_EQ(expected_overhead, QuicCryptoStream::CryptoMessageFramingOverhead( - version, TestConnectionId())); + EXPECT_EQ(expected_overhead, + QuicCryptoStream::CryptoMessageFramingOverhead( + version.transport_version, TestConnectionId())); } } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_data_reader.cc b/chromium/net/third_party/quiche/src/quic/core/quic_data_reader.cc index be533b13677..7b605d36661 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_data_reader.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_data_reader.cc @@ -2,15 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_data_reader.h" +#include "quic/core/quic_data_reader.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flags.h" +#include "common/quiche_endian.h" namespace quic { @@ -45,16 +44,16 @@ bool QuicDataReader::ReadUFloat16(uint64_t* result) { // After the fast pass, the exponent is at least one (offset by one). // Un-offset the exponent. --exponent; - DCHECK_GE(exponent, 1); - DCHECK_LE(exponent, kUFloat16MaxExponent); + QUICHE_DCHECK_GE(exponent, 1); + QUICHE_DCHECK_LE(exponent, kUFloat16MaxExponent); // Here we need to clear the exponent and set the hidden bit. We have already // decremented the exponent, so when we subtract it, it leaves behind the // hidden bit. *result -= exponent << kUFloat16MantissaBits; *result <<= exponent; - DCHECK_GE(*result, - static_cast<uint64_t>(1 << kUFloat16MantissaEffectiveBits)); - DCHECK_LE(*result, kUFloat16MaxValue); + QUICHE_DCHECK_GE(*result, + static_cast<uint64_t>(1 << kUFloat16MantissaEffectiveBits)); + QUICHE_DCHECK_LE(*result, kUFloat16MaxValue); return true; } @@ -72,7 +71,7 @@ bool QuicDataReader::ReadConnectionId(QuicConnectionId* connection_id, connection_id->set_length(length); const bool ok = ReadBytes(connection_id->mutable_data(), connection_id->length()); - DCHECK(ok); + QUICHE_DCHECK(ok); return ok; } @@ -86,7 +85,7 @@ bool QuicDataReader::ReadLengthPrefixedConnectionId( } QuicVariableLengthIntegerLength QuicDataReader::PeekVarInt62Length() { - DCHECK_EQ(endianness(), quiche::NETWORK_BYTE_ORDER); + QUICHE_DCHECK_EQ(endianness(), quiche::NETWORK_BYTE_ORDER); const unsigned char* next = reinterpret_cast<const unsigned char*>(data() + pos()); if (BytesRemaining() == 0) { @@ -113,7 +112,7 @@ QuicVariableLengthIntegerLength QuicDataReader::PeekVarInt62Length() { // Low-level optimization is useful here because this function will be // called frequently, leading to outsize benefits. bool QuicDataReader::ReadVarInt62(uint64_t* result) { - DCHECK_EQ(endianness(), quiche::NETWORK_BYTE_ORDER); + QUICHE_DCHECK_EQ(endianness(), quiche::NETWORK_BYTE_ORDER); size_t remaining = BytesRemaining(); const unsigned char* next = diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_data_reader.h b/chromium/net/third_party/quiche/src/quic/core/quic_data_reader.h index 00b1dba34c6..cca22410684 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_data_reader.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_data_reader.h @@ -9,10 +9,10 @@ #include <cstdint> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/quiche_data_reader.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" +#include "common/quiche_data_reader.h" +#include "common/quiche_endian.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_data_writer.cc b/chromium/net/third_party/quiche/src/quic/core/quic_data_writer.cc index 91645b8d04a..4ed9b4584c1 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_data_writer.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_data_writer.cc @@ -2,18 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" +#include "quic/core/quic_data_writer.h" #include <algorithm> #include <limits> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/quic_constants.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flags.h" +#include "common/quiche_endian.h" namespace quic { @@ -52,10 +51,10 @@ bool QuicDataWriter::WriteUFloat16(uint64_t value) { } } - DCHECK_GE(exponent, 1); - DCHECK_LE(exponent, kUFloat16MaxExponent); - DCHECK_GE(value, UINT64_C(1) << kUFloat16MantissaBits); - DCHECK_LT(value, UINT64_C(1) << kUFloat16MantissaEffectiveBits); + QUICHE_DCHECK_GE(exponent, 1); + QUICHE_DCHECK_LE(exponent, kUFloat16MaxExponent); + QUICHE_DCHECK_GE(value, UINT64_C(1) << kUFloat16MantissaBits); + QUICHE_DCHECK_LT(value, UINT64_C(1) << kUFloat16MantissaEffectiveBits); // Hidden bit (position 11) is set. We should remove it and increment the // exponent. Equivalently, we just add it to the exponent. @@ -92,6 +91,17 @@ bool QuicDataWriter::WriteRandomBytes(QuicRandom* random, size_t length) { return true; } +bool QuicDataWriter::WriteInsecureRandomBytes(QuicRandom* random, + size_t length) { + char* dest = BeginWrite(length); + if (!dest) { + return false; + } + + random->InsecureRandBytes(dest, length); + IncreaseLength(length); + return true; +} // Converts a uint64_t into an IETF/Quic formatted Variable Length // Integer. IETF Variable Length Integers have 62 significant bits, so @@ -111,7 +121,7 @@ bool QuicDataWriter::WriteRandomBytes(QuicRandom* random, size_t length) { // Low-level optimization is useful here because this function will be // called frequently, leading to outsize benefits. bool QuicDataWriter::WriteVarInt62(uint64_t value) { - DCHECK_EQ(endianness(), quiche::NETWORK_BYTE_ORDER); + QUICHE_DCHECK_EQ(endianness(), quiche::NETWORK_BYTE_ORDER); size_t remaining_bytes = remaining(); char* next = buffer() + length(); @@ -182,7 +192,7 @@ bool QuicDataWriter::WriteVarInt62(uint64_t value) { bool QuicDataWriter::WriteVarInt62( uint64_t value, QuicVariableLengthIntegerLength write_length) { - DCHECK_EQ(endianness(), quiche::NETWORK_BYTE_ORDER); + QUICHE_DCHECK_EQ(endianness(), quiche::NETWORK_BYTE_ORDER); size_t remaining_bytes = remaining(); if (remaining_bytes < write_length) { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_data_writer.h b/chromium/net/third_party/quiche/src/quic/core/quic_data_writer.h index e0a27c60766..2a23ce26eff 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_data_writer.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_data_writer.h @@ -9,10 +9,10 @@ #include <cstdint> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/quiche_data_writer.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" +#include "common/quiche_data_writer.h" +#include "common/quiche_endian.h" namespace quic { @@ -89,6 +89,10 @@ class QUIC_EXPORT_PRIVATE QuicDataWriter : public quiche::QuicheDataWriter { // Write |length| random bytes generated by |random|. bool WriteRandomBytes(QuicRandom* random, size_t length); + + // Write |length| random bytes generated by |random|. This MUST NOT be used + // for any application that requires cryptographically-secure randomness. + bool WriteInsecureRandomBytes(QuicRandom* random, size_t length); }; } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_data_writer_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_data_writer_test.cc index ef83ac82a63..cbe0351fbfc 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_data_writer_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_data_writer_test.cc @@ -2,24 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" +#include "quic/core/quic_data_writer.h" #include <cstdint> #include <cstring> #include "absl/base/macros.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_data_reader.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_data_reader.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/quiche_endian.h" +#include "common/test_tools/quiche_test_utils.h" namespace quic { namespace test { @@ -37,7 +37,7 @@ struct TestParams { // Used by ::testing::PrintToStringParamName(). std::string PrintToString(const TestParams& p) { - return quiche::QuicheStrCat( + return absl::StrCat( (p.endianness == quiche::NETWORK_BYTE_ORDER ? "Network" : "Host"), "ByteOrder"); } @@ -1131,6 +1131,21 @@ TEST_P(QuicDataWriterTest, WriteRandomBytes) { 20); } +TEST_P(QuicDataWriterTest, WriteInsecureRandomBytes) { + char buffer[20]; + char expected[20]; + for (size_t i = 0; i < 20; ++i) { + expected[i] = 'r'; + } + MockRandom random; + QuicDataWriter writer(20, buffer, GetParam().endianness); + EXPECT_FALSE(writer.WriteInsecureRandomBytes(&random, 30)); + + EXPECT_TRUE(writer.WriteInsecureRandomBytes(&random, 20)); + quiche::test::CompareCharArraysWithHexError("random", buffer, 20, expected, + 20); +} + TEST_P(QuicDataWriterTest, PeekVarInt62Length) { // In range [0, 63], variable length should be 1 byte. char buffer[20]; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_datagram_queue.cc b/chromium/net/third_party/quiche/src/quic/core/quic_datagram_queue.cc index e10a91904c1..d4513e48f69 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_datagram_queue.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_datagram_queue.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_datagram_queue.h" +#include "quic/core/quic_datagram_queue.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_mem_slice_span.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_mem_slice_span.h" namespace quic { @@ -17,7 +17,13 @@ constexpr float kExpiryInMinRtts = 1.25; constexpr float kMinPacingWindows = 4; QuicDatagramQueue::QuicDatagramQueue(QuicSession* session) - : session_(session), clock_(session->connection()->clock()) {} + : QuicDatagramQueue(session, nullptr) {} + +QuicDatagramQueue::QuicDatagramQueue(QuicSession* session, + std::unique_ptr<Observer> observer) + : session_(session), + clock_(session->connection()->clock()), + observer_(std::move(observer)) {} MessageStatus QuicDatagramQueue::SendOrQueueDatagram(QuicMemSlice datagram) { // If the queue is non-empty, always queue the daragram. This ensures that @@ -27,6 +33,9 @@ MessageStatus QuicDatagramQueue::SendOrQueueDatagram(QuicMemSlice datagram) { QuicMemSliceSpan span(&datagram); MessageResult result = session_->SendMessage(span); if (result.status != MESSAGE_STATUS_BLOCKED) { + if (observer_) { + observer_->OnDatagramProcessed(result.status); + } return result.status; } } @@ -46,6 +55,9 @@ absl::optional<MessageStatus> QuicDatagramQueue::TrySendingNextDatagram() { MessageResult result = session_->SendMessage(span); if (result.status != MESSAGE_STATUS_BLOCKED) { queue_.pop_front(); + if (observer_) { + observer_->OnDatagramProcessed(result.status); + } } return result.status; } @@ -80,6 +92,9 @@ void QuicDatagramQueue::RemoveExpiredDatagrams() { QuicTime now = clock_->ApproximateNow(); while (!queue_.empty() && queue_.front().expiry <= now) { queue_.pop_front(); + if (observer_) { + observer_->OnDatagramProcessed(absl::nullopt); + } } } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_datagram_queue.h b/chromium/net/third_party/quiche/src/quic/core/quic_datagram_queue.h index 09524027533..286aeae6bf8 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_datagram_queue.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_datagram_queue.h @@ -5,11 +5,13 @@ #ifndef QUICHE_QUIC_CORE_QUIC_DATAGRAM_QUEUE_H_ #define QUICHE_QUIC_CORE_QUIC_DATAGRAM_QUEUE_H_ +#include <memory> + #include "absl/types/optional.h" -#include "net/third_party/quiche/src/quic/core/quic_circular_deque.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_mem_slice.h" +#include "quic/core/quic_circular_deque.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_mem_slice.h" namespace quic { @@ -20,9 +22,26 @@ class QuicSession; // amount of time, and deleted after that time passes. class QUIC_EXPORT_PRIVATE QuicDatagramQueue { public: + // An interface used to monitor events on the associated `QuicDatagramQueue`. + class QUIC_EXPORT_PRIVATE Observer { + public: + virtual ~Observer() = default; + + // Called when a datagram in the associated queue is sent or discarded. + // Identity information for the datagram is not given, because the sending + // and discarding order is always first-in-first-out. + // This function is called synchronously in `QuicDatagramQueue` methods. + // `status` is nullopt when the datagram is dropped due to being in the + // queue for too long. + virtual void OnDatagramProcessed(absl::optional<MessageStatus> status) = 0; + }; + // |session| is not owned and must outlive this object. explicit QuicDatagramQueue(QuicSession* session); + // |session| is not owned and must outlive this object. + QuicDatagramQueue(QuicSession* session, std::unique_ptr<Observer> observer); + // Adds the datagram to the end of the queue. May send it immediately; if // not, MESSAGE_STATUS_BLOCKED is returned. MessageStatus SendOrQueueDatagram(QuicMemSlice datagram); @@ -62,6 +81,7 @@ class QUIC_EXPORT_PRIVATE QuicDatagramQueue { QuicTime::Delta max_time_in_queue_ = QuicTime::Delta::Zero(); QuicCircularDeque<Datagram> queue_; + std::unique_ptr<Observer> observer_; }; } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_datagram_queue_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_datagram_queue_test.cc index 0e6e3dec39a..f47bbb883cb 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_datagram_queue_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_datagram_queue_test.cc @@ -2,17 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_datagram_queue.h" +#include "quic/core/quic_datagram_queue.h" + +#include <vector> #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/quic_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_mem_slice.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/quic_buffer_allocator.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_mem_slice.h" +#include "quic/platform/api/quic_reference_counted.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { @@ -30,20 +33,43 @@ class EstablishedCryptoStream : public MockQuicCryptoStream { bool encryption_established() const override { return true; } }; -class QuicDatagramQueueTest : public QuicTest { +class QuicDatagramQueueObserver final : public QuicDatagramQueue::Observer { public: - QuicDatagramQueueTest() + class Context : public QuicReferenceCounted { + public: + std::vector<absl::optional<MessageStatus>> statuses; + }; + + QuicDatagramQueueObserver() : context_(new Context()) {} + QuicDatagramQueueObserver(const QuicDatagramQueueObserver&) = delete; + QuicDatagramQueueObserver& operator=(const QuicDatagramQueueObserver&) = + delete; + + void OnDatagramProcessed(absl::optional<MessageStatus> status) override { + context_->statuses.push_back(std::move(status)); + } + + const QuicReferenceCountedPointer<Context>& context() { return context_; } + + private: + QuicReferenceCountedPointer<Context> context_; +}; + +class QuicDatagramQueueTestBase : public QuicTest { + protected: + QuicDatagramQueueTestBase() : connection_(new MockQuicConnection(&helper_, &alarm_factory_, Perspective::IS_CLIENT)), - session_(connection_), - queue_(&session_) { + session_(connection_) { session_.SetCryptoStream(new EstablishedCryptoStream(&session_)); connection_->SetEncrypter( ENCRYPTION_FORWARD_SECURE, std::make_unique<NullEncrypter>(connection_->perspective())); } + ~QuicDatagramQueueTestBase() = default; + QuicMemSlice CreateMemSlice(absl::string_view data) { QuicUniqueBufferPtr buffer = MakeUniqueBuffer(helper_.GetStreamSendBufferAllocator(), data.size()); @@ -51,11 +77,17 @@ class QuicDatagramQueueTest : public QuicTest { return QuicMemSlice(std::move(buffer), data.size()); } - protected: MockQuicConnectionHelper helper_; MockAlarmFactory alarm_factory_; MockQuicConnection* connection_; // Owned by |session_|. MockQuicSession session_; +}; + +class QuicDatagramQueueTest : public QuicDatagramQueueTestBase { + public: + QuicDatagramQueueTest() : queue_(&session_) {} + + protected: QuicDatagramQueue queue_; }; @@ -167,6 +199,99 @@ TEST_F(QuicDatagramQueueTest, ExpireAll) { EXPECT_EQ(0u, queue_.SendDatagrams()); } +class QuicDatagramQueueWithObserverTest : public QuicDatagramQueueTestBase { + public: + QuicDatagramQueueWithObserverTest() + : observer_(std::make_unique<QuicDatagramQueueObserver>()), + context_(observer_->context()), + queue_(&session_, std::move(observer_)) {} + + protected: + // This is moved out immediately. + std::unique_ptr<QuicDatagramQueueObserver> observer_; + + QuicReferenceCountedPointer<QuicDatagramQueueObserver::Context> context_; + QuicDatagramQueue queue_; +}; + +TEST_F(QuicDatagramQueueWithObserverTest, ObserveSuccessImmediately) { + EXPECT_TRUE(context_->statuses.empty()); + + EXPECT_CALL(*connection_, SendMessage(_, _, _)) + .WillOnce(Return(MESSAGE_STATUS_SUCCESS)); + + EXPECT_EQ(MESSAGE_STATUS_SUCCESS, + queue_.SendOrQueueDatagram(CreateMemSlice("a"))); + + EXPECT_THAT(context_->statuses, ElementsAre(MESSAGE_STATUS_SUCCESS)); +} + +TEST_F(QuicDatagramQueueWithObserverTest, ObserveFailureImmediately) { + EXPECT_TRUE(context_->statuses.empty()); + + EXPECT_CALL(*connection_, SendMessage(_, _, _)) + .WillOnce(Return(MESSAGE_STATUS_TOO_LARGE)); + + EXPECT_EQ(MESSAGE_STATUS_TOO_LARGE, + queue_.SendOrQueueDatagram(CreateMemSlice("a"))); + + EXPECT_THAT(context_->statuses, ElementsAre(MESSAGE_STATUS_TOO_LARGE)); +} + +TEST_F(QuicDatagramQueueWithObserverTest, BlockingShouldNotBeObserved) { + EXPECT_TRUE(context_->statuses.empty()); + + EXPECT_CALL(*connection_, SendMessage(_, _, _)) + .WillRepeatedly(Return(MESSAGE_STATUS_BLOCKED)); + + EXPECT_EQ(MESSAGE_STATUS_BLOCKED, + queue_.SendOrQueueDatagram(CreateMemSlice("a"))); + EXPECT_EQ(0u, queue_.SendDatagrams()); + + EXPECT_TRUE(context_->statuses.empty()); +} + +TEST_F(QuicDatagramQueueWithObserverTest, ObserveSuccessAfterBuffering) { + EXPECT_TRUE(context_->statuses.empty()); + + EXPECT_CALL(*connection_, SendMessage(_, _, _)) + .WillOnce(Return(MESSAGE_STATUS_BLOCKED)); + + EXPECT_EQ(MESSAGE_STATUS_BLOCKED, + queue_.SendOrQueueDatagram(CreateMemSlice("a"))); + + EXPECT_TRUE(context_->statuses.empty()); + + EXPECT_CALL(*connection_, SendMessage(_, _, _)) + .WillOnce(Return(MESSAGE_STATUS_SUCCESS)); + + EXPECT_EQ(1u, queue_.SendDatagrams()); + EXPECT_THAT(context_->statuses, ElementsAre(MESSAGE_STATUS_SUCCESS)); +} + +TEST_F(QuicDatagramQueueWithObserverTest, ObserveExpiry) { + constexpr QuicTime::Delta expiry = QuicTime::Delta::FromMilliseconds(100); + queue_.SetMaxTimeInQueue(expiry); + + EXPECT_TRUE(context_->statuses.empty()); + + EXPECT_CALL(*connection_, SendMessage(_, _, _)) + .WillOnce(Return(MESSAGE_STATUS_BLOCKED)); + + EXPECT_EQ(MESSAGE_STATUS_BLOCKED, + queue_.SendOrQueueDatagram(CreateMemSlice("a"))); + + EXPECT_TRUE(context_->statuses.empty()); + + EXPECT_CALL(*connection_, SendMessage(_, _, _)).Times(0); + helper_.AdvanceTime(100 * expiry); + + EXPECT_TRUE(context_->statuses.empty()); + + EXPECT_EQ(0u, queue_.SendDatagrams()); + EXPECT_THAT(context_->statuses, ElementsAre(absl::nullopt)); +} + } // namespace } // namespace test } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_default_packet_writer.cc b/chromium/net/third_party/quiche/src/quic/core/quic_default_packet_writer.cc index b34bed49fcf..e71169a6b57 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_default_packet_writer.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_default_packet_writer.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_default_packet_writer.h" +#include "quic/core/quic_default_packet_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_udp_socket.h" +#include "quic/core/quic_udp_socket.h" namespace quic { @@ -19,8 +19,8 @@ WriteResult QuicDefaultPacketWriter::WritePacket( const QuicIpAddress& self_address, const QuicSocketAddress& peer_address, PerPacketOptions* options) { - DCHECK(!write_blocked_); - DCHECK(nullptr == options) + QUICHE_DCHECK(!write_blocked_); + QUICHE_DCHECK(nullptr == options) << "QuicDefaultPacketWriter does not accept any options."; QuicUdpPacketInfo packet_info; packet_info.SetPeerAddress(peer_address); diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_default_packet_writer.h b/chromium/net/third_party/quiche/src/quic/core/quic_default_packet_writer.h index 5388cae2314..df30f248f40 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_default_packet_writer.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_default_packet_writer.h @@ -7,9 +7,9 @@ #include <cstddef> -#include "net/third_party/quiche/src/quic/core/quic_packet_writer.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/quic_packet_writer.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_dispatcher.cc b/chromium/net/third_party/quiche/src/quic/core/quic_dispatcher.cc index d048e60af29..d0d44b6a1ab 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_dispatcher.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_dispatcher.cc @@ -2,28 +2,32 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_dispatcher.h" +#include "quic/core/quic_dispatcher.h" +#include <memory> #include <string> #include <utility> +#include "absl/container/flat_hash_set.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/chlo_extractor.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_time_wait_list_manager.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/core/tls_chlo_extractor.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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_ptr_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_stack_trace.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/chlo_extractor.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_time_wait_list_manager.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/core/tls_chlo_extractor.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/platform/api/quic_stack_trace.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { @@ -78,12 +82,12 @@ class PacketCollector : public QuicPacketCreator::DelegateInterface, bool ShouldGeneratePacket(HasRetransmittableData /*retransmittable*/, IsHandshake /*handshake*/) override { - DCHECK(false); + QUICHE_DCHECK(false); return true; } const QuicFrames MaybeBundleAckOpportunistically() override { - DCHECK(false); + QUICHE_DCHECK(false); return {}; } @@ -151,21 +155,25 @@ class StatelessConnectionTerminator { // |error_code| and |error_details| and add the connection to time wait. void CloseConnection(QuicErrorCode error_code, const std::string& error_details, - bool ietf_quic) { + bool ietf_quic, + std::vector<QuicConnectionId> active_connection_ids) { SerializeConnectionClosePacket(error_code, error_details); time_wait_list_manager_->AddConnectionIdToTimeWait( server_connection_id_, QuicTimeWaitListManager::SEND_TERMINATION_PACKETS, - TimeWaitConnectionInfo(ietf_quic, collector_.packets())); + TimeWaitConnectionInfo(ietf_quic, collector_.packets(), + std::move(active_connection_ids), + /*srtt=*/QuicTime::Delta::Zero())); } private: void SerializeConnectionClosePacket(QuicErrorCode error_code, const std::string& error_details) { - QuicConnectionCloseFrame* frame = new QuicConnectionCloseFrame( - framer_.transport_version(), error_code, error_details, - /*transport_close_frame_type=*/0); + QuicConnectionCloseFrame* frame = + new QuicConnectionCloseFrame(framer_.transport_version(), error_code, + NO_IETF_QUIC_ERROR, error_details, + /*transport_close_frame_type=*/0); if (!creator_.AddFrame(QuicFrame(frame), NOT_RETRANSMISSION)) { QUIC_BUG << "Unable to add frame to an empty packet"; @@ -173,7 +181,7 @@ class StatelessConnectionTerminator { return; } creator_.FlushCurrentPacket(); - DCHECK_EQ(1u, collector_.packets()->size()); + QUICHE_DCHECK_EQ(1u, collector_.packets()->size()); } QuicConnectionId server_connection_id_; @@ -316,6 +324,9 @@ QuicDispatcher::QuicDispatcher( expected_server_connection_id_length_( expected_server_connection_id_length), should_update_expected_server_connection_id_length_(false) { + if (use_reference_counted_session_map_) { + QUIC_RESTART_FLAG_COUNT(quic_use_reference_counted_sesssion_map); + } QUIC_BUG_IF(GetSupportedVersions().empty()) << "Trying to create dispatcher without any supported versions"; QUIC_DLOG(INFO) << "Created QuicDispatcher with versions: " @@ -323,12 +334,20 @@ QuicDispatcher::QuicDispatcher( } QuicDispatcher::~QuicDispatcher() { - session_map_.clear(); - closed_session_list_.clear(); + if (use_reference_counted_session_map_) { + reference_counted_session_map_.clear(); + closed_ref_counted_session_list_.clear(); + if (support_multiple_cid_per_connection_) { + num_sessions_in_session_map_ = 0; + } + } else { + session_map_.clear(); + closed_session_list_.clear(); + } } void QuicDispatcher::InitializeWithWriter(QuicPacketWriter* writer) { - DCHECK(writer_ == nullptr); + QUICHE_DCHECK(writer_ == nullptr); writer_.reset(writer); time_wait_list_manager_.reset(CreateQuicTimeWaitListManager()); } @@ -405,24 +424,27 @@ QuicConnectionId QuicDispatcher::MaybeReplaceServerConnectionId( if (server_connection_id_length == expected_server_connection_id_length_) { return server_connection_id; } - DCHECK(version.AllowsVariableLengthConnectionIds()); + QUICHE_DCHECK(version.AllowsVariableLengthConnectionIds()); QuicConnectionId new_connection_id; if (server_connection_id_length < expected_server_connection_id_length_) { new_connection_id = ReplaceShortServerConnectionId( version, server_connection_id, expected_server_connection_id_length_); // Verify that ReplaceShortServerConnectionId is deterministic. - DCHECK_EQ(new_connection_id, ReplaceShortServerConnectionId( - version, server_connection_id, - expected_server_connection_id_length_)); + QUICHE_DCHECK_EQ( + new_connection_id, + ReplaceShortServerConnectionId(version, server_connection_id, + expected_server_connection_id_length_)); } else { new_connection_id = ReplaceLongServerConnectionId( version, server_connection_id, expected_server_connection_id_length_); // Verify that ReplaceLongServerConnectionId is deterministic. - DCHECK_EQ(new_connection_id, ReplaceLongServerConnectionId( - version, server_connection_id, - expected_server_connection_id_length_)); + QUICHE_DCHECK_EQ( + new_connection_id, + ReplaceLongServerConnectionId(version, server_connection_id, + expected_server_connection_id_length_)); } - DCHECK_EQ(expected_server_connection_id_length_, new_connection_id.length()); + QUICHE_DCHECK_EQ(expected_server_connection_id_length_, + new_connection_id.length()); QUIC_DLOG(INFO) << "Replacing incoming connection ID " << server_connection_id << " with " << new_connection_id; @@ -433,8 +455,8 @@ QuicConnectionId QuicDispatcher::ReplaceShortServerConnectionId( const ParsedQuicVersion& /*version*/, const QuicConnectionId& server_connection_id, uint8_t expected_server_connection_id_length) const { - DCHECK_LT(server_connection_id.length(), - expected_server_connection_id_length); + QUICHE_DCHECK_LT(server_connection_id.length(), + expected_server_connection_id_length); return QuicUtils::CreateReplacementConnectionId( server_connection_id, expected_server_connection_id_length); } @@ -443,8 +465,8 @@ QuicConnectionId QuicDispatcher::ReplaceLongServerConnectionId( const ParsedQuicVersion& /*version*/, const QuicConnectionId& server_connection_id, uint8_t expected_server_connection_id_length) const { - DCHECK_GT(server_connection_id.length(), - expected_server_connection_id_length); + QUICHE_DCHECK_GT(server_connection_id.length(), + expected_server_connection_id_length); return QuicUtils::CreateReplacementConnectionId( server_connection_id, expected_server_connection_id_length); } @@ -464,21 +486,15 @@ bool QuicDispatcher::MaybeDispatchPacket( // connection ID that is at least 64 bits long. After that initial // connection ID, the dispatcher picks a new one of its expected length. // Therefore we should never receive a connection ID that is smaller - // than 64 bits and smaller than what we expect. - bool should_check_short_connection_ids = true; - if (GetQuicReloadableFlag( - quic_send_version_negotiation_for_short_connection_ids)) { - QUIC_RELOADABLE_FLAG_COUNT( - quic_send_version_negotiation_for_short_connection_ids); - should_check_short_connection_ids = - packet_info.version_flag && packet_info.version.IsKnown(); - } - if (should_check_short_connection_ids && + // than 64 bits and smaller than what we expect. Unless the version is + // unknown, in which case we allow short connection IDs for version + // negotiation because that version could allow those. + if (packet_info.version_flag && packet_info.version.IsKnown() && server_connection_id.length() < kQuicMinimumInitialConnectionIdLength && server_connection_id.length() < expected_server_connection_id_length_ && !allow_short_initial_server_connection_ids_) { - DCHECK(packet_info.version_flag); - DCHECK(packet_info.version.AllowsVariableLengthConnectionIds()); + QUICHE_DCHECK(packet_info.version_flag); + QUICHE_DCHECK(packet_info.version.AllowsVariableLengthConnectionIds()); QUIC_DLOG(INFO) << "Packet with short destination connection ID " << server_connection_id << " expected " << static_cast<int>(expected_server_connection_id_length_); @@ -489,29 +505,60 @@ bool QuicDispatcher::MaybeDispatchPacket( // Packets with connection IDs for active connections are processed // immediately. - auto it = session_map_.find(server_connection_id); - if (it != session_map_.end()) { - DCHECK(!buffered_packets_.HasBufferedPackets(server_connection_id)); - if (packet_info.version_flag && - packet_info.version != it->second->version() && - packet_info.version == LegacyVersionForEncapsulation()) { - // This packet is using the Legacy Version Encapsulation version but the - // corresponding session isn't, attempt extraction of inner packet. - ChloAlpnExtractor alpn_extractor; - if (ChloExtractor::Extract(packet_info.packet, packet_info.version, - config_->create_session_tag_indicators(), - &alpn_extractor, - server_connection_id.length())) { - if (MaybeHandleLegacyVersionEncapsulation(this, &alpn_extractor, - packet_info)) { - return true; + if (use_reference_counted_session_map_) { + auto it = reference_counted_session_map_.find(server_connection_id); + if (it != reference_counted_session_map_.end()) { + QUICHE_DCHECK( + !buffered_packets_.HasBufferedPackets(server_connection_id)); + if (packet_info.version_flag && + packet_info.version != it->second->version() && + packet_info.version == LegacyVersionForEncapsulation()) { + // This packet is using the Legacy Version Encapsulation version but the + // corresponding session isn't, attempt extraction of inner packet. + ChloAlpnExtractor alpn_extractor; + if (ChloExtractor::Extract(packet_info.packet, packet_info.version, + config_->create_session_tag_indicators(), + &alpn_extractor, + server_connection_id.length())) { + if (MaybeHandleLegacyVersionEncapsulation(this, &alpn_extractor, + packet_info)) { + return true; + } } } + it->second->ProcessUdpPacket(packet_info.self_address, + packet_info.peer_address, + packet_info.packet); + return true; } - it->second->ProcessUdpPacket(packet_info.self_address, - packet_info.peer_address, packet_info.packet); - return true; - } else if (packet_info.version.IsKnown()) { + } else { + auto it = session_map_.find(server_connection_id); + if (it != session_map_.end()) { + QUICHE_DCHECK( + !buffered_packets_.HasBufferedPackets(server_connection_id)); + if (packet_info.version_flag && + packet_info.version != it->second->version() && + packet_info.version == LegacyVersionForEncapsulation()) { + // This packet is using the Legacy Version Encapsulation version but the + // corresponding session isn't, attempt extraction of inner packet. + ChloAlpnExtractor alpn_extractor; + if (ChloExtractor::Extract(packet_info.packet, packet_info.version, + config_->create_session_tag_indicators(), + &alpn_extractor, + server_connection_id.length())) { + if (MaybeHandleLegacyVersionEncapsulation(this, &alpn_extractor, + packet_info)) { + return true; + } + } + } + it->second->ProcessUdpPacket(packet_info.self_address, + packet_info.peer_address, + packet_info.packet); + return true; + } + } + if (packet_info.version.IsKnown()) { // We did not find the connection ID, check if we've replaced it. // This is only performed for supported versions because packets with // unsupported versions can flow through this function in order to send @@ -521,14 +568,28 @@ bool QuicDispatcher::MaybeDispatchPacket( QuicConnectionId replaced_connection_id = MaybeReplaceServerConnectionId( server_connection_id, packet_info.version); if (replaced_connection_id != server_connection_id) { - // Search for the replacement. - auto it2 = session_map_.find(replaced_connection_id); - if (it2 != session_map_.end()) { - DCHECK(!buffered_packets_.HasBufferedPackets(replaced_connection_id)); - it2->second->ProcessUdpPacket(packet_info.self_address, - packet_info.peer_address, - packet_info.packet); - return true; + if (use_reference_counted_session_map_) { + // Search for the replacement. + auto it2 = reference_counted_session_map_.find(replaced_connection_id); + if (it2 != reference_counted_session_map_.end()) { + QUICHE_DCHECK( + !buffered_packets_.HasBufferedPackets(replaced_connection_id)); + it2->second->ProcessUdpPacket(packet_info.self_address, + packet_info.peer_address, + packet_info.packet); + return true; + } + } else { + // Search for the replacement. + auto it2 = session_map_.find(replaced_connection_id); + if (it2 != session_map_.end()) { + QUICHE_DCHECK( + !buffered_packets_.HasBufferedPackets(replaced_connection_id)); + it2->second->ProcessUdpPacket(packet_info.self_address, + packet_info.peer_address, + packet_info.packet); + return true; + } } } } @@ -694,7 +755,7 @@ void QuicDispatcher::ProcessHeader(ReceivedPacketInfo* packet_info) { QUIC_HANDSHAKE_FAILED, "Reject connection", quic::QuicTimeWaitListManager::SEND_STATELESS_RESET); - DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait( + QUICHE_DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait( server_connection_id)); time_wait_list_manager_->ProcessPacket( packet_info->self_address, packet_info->peer_address, @@ -738,7 +799,7 @@ QuicDispatcher::QuicPacketFate QuicDispatcher::ValidityChecks( return kFateProcess; } -void QuicDispatcher::CleanUpSession(SessionMap::iterator it, +void QuicDispatcher::CleanUpSession(QuicConnectionId server_connection_id, QuicConnection* connection, ConnectionCloseSource /*source*/) { write_blocked_list_.erase(connection); @@ -749,39 +810,53 @@ void QuicDispatcher::CleanUpSession(SessionMap::iterator it, action = QuicTimeWaitListManager::SEND_CONNECTION_CLOSE_PACKETS; } else { if (!connection->IsHandshakeComplete()) { - if (!VersionHasIetfInvariantHeader(connection->transport_version())) { + if (!connection->version().HasIetfInvariantHeader()) { QUIC_CODE_COUNT(gquic_add_to_time_wait_list_with_handshake_failed); } else { QUIC_CODE_COUNT(quic_v44_add_to_time_wait_list_with_handshake_failed); } - action = QuicTimeWaitListManager::SEND_TERMINATION_PACKETS; - // This serializes a connection close termination packet with error code - // QUIC_HANDSHAKE_FAILED and adds the connection to the time wait list. - StatelesslyTerminateConnection( - connection->connection_id(), - VersionHasIetfInvariantHeader(connection->transport_version()) - ? IETF_QUIC_LONG_HEADER_PACKET - : GOOGLE_QUIC_PACKET, - /*version_flag=*/true, - connection->version().HasLengthPrefixedConnectionIds(), - connection->version(), QUIC_HANDSHAKE_FAILED, - "Connection is closed by server before handshake confirmed", - // Although it is our intention to send termination packets, the - // |action| argument is not used by this call to - // StatelesslyTerminateConnection(). - action); - session_map_.erase(it); + if (support_multiple_cid_per_connection_) { + QUIC_RESTART_FLAG_COUNT_N( + quic_dispatcher_support_multiple_cid_per_connection_v2, 1, 2); + // This serializes a connection close termination packet with error code + // QUIC_HANDSHAKE_FAILED and adds the connection to the time wait list. + StatelessConnectionTerminator terminator( + server_connection_id, connection->version(), helper_.get(), + time_wait_list_manager_.get()); + terminator.CloseConnection( + QUIC_HANDSHAKE_FAILED, + "Connection is closed by server before handshake confirmed", + connection->version().HasIetfInvariantHeader(), + connection->GetActiveServerConnectionIds()); + } else { + action = QuicTimeWaitListManager::SEND_TERMINATION_PACKETS; + // This serializes a connection close termination packet with error code + // QUIC_HANDSHAKE_FAILED and adds the connection to the time wait list. + StatelesslyTerminateConnection( + connection->connection_id(), + connection->version().HasIetfInvariantHeader() + ? IETF_QUIC_LONG_HEADER_PACKET + : GOOGLE_QUIC_PACKET, + /*version_flag=*/true, + connection->version().HasLengthPrefixedConnectionIds(), + connection->version(), QUIC_HANDSHAKE_FAILED, + "Connection is closed by server before handshake confirmed", + // Although it is our intention to send termination packets, the + // |action| argument is not used by this call to + // StatelesslyTerminateConnection(). + action); + } return; } QUIC_CODE_COUNT(quic_v44_add_to_time_wait_list_with_stateless_reset); } time_wait_list_manager_->AddConnectionIdToTimeWait( - it->first, action, + server_connection_id, action, TimeWaitConnectionInfo( - VersionHasIetfInvariantHeader(connection->transport_version()), + connection->version().HasIetfInvariantHeader(), connection->termination_packets(), + connection->GetActiveServerConnectionIds(), connection->sent_packet_manager().GetRttStats()->smoothed_rtt())); - session_map_.erase(it); } void QuicDispatcher::StartAcceptingNewConnections() { @@ -795,21 +870,70 @@ void QuicDispatcher::StopAcceptingNewConnections() { buffered_packets_.DiscardAllPackets(); } +void QuicDispatcher::PerformActionOnActiveSessions( + std::function<void(QuicSession*)> operation) const { + if (use_reference_counted_session_map_) { + absl::flat_hash_set<QuicSession*> visited_session; + visited_session.reserve(reference_counted_session_map_.size()); + for (auto const& kv : reference_counted_session_map_) { + QuicSession* session = kv.second.get(); + if (visited_session.insert(session).second) { + operation(session); + } + } + } else { + for (auto const& kv : session_map_) { + operation(kv.second.get()); + } + } +} + +// Get a snapshot of all sessions. +std::vector<std::shared_ptr<QuicSession>> QuicDispatcher::GetSessionsSnapshot() + const { + QUICHE_DCHECK(use_reference_counted_session_map_); + std::vector<std::shared_ptr<QuicSession>> snapshot; + snapshot.reserve(reference_counted_session_map_.size()); + absl::flat_hash_set<QuicSession*> visited_session; + visited_session.reserve(reference_counted_session_map_.size()); + for (auto const& kv : reference_counted_session_map_) { + QuicSession* session = kv.second.get(); + if (visited_session.insert(session).second) { + snapshot.push_back(kv.second); + } + } + return snapshot; +} + std::unique_ptr<QuicPerPacketContext> QuicDispatcher::GetPerPacketContext() const { return nullptr; } void QuicDispatcher::DeleteSessions() { - if (!write_blocked_list_.empty()) { - for (const std::unique_ptr<QuicSession>& session : closed_session_list_) { - if (write_blocked_list_.erase(session->connection()) != 0) { - QUIC_BUG << "QuicConnection was in WriteBlockedList before destruction " - << session->connection()->connection_id(); + if (use_reference_counted_session_map_) { + if (!write_blocked_list_.empty()) { + for (const auto& session : closed_ref_counted_session_list_) { + if (write_blocked_list_.erase(session->connection()) != 0) { + QUIC_BUG + << "QuicConnection was in WriteBlockedList before destruction " + << session->connection()->connection_id(); + } + } + } + closed_ref_counted_session_list_.clear(); + } else { + if (!write_blocked_list_.empty()) { + for (const std::unique_ptr<QuicSession>& session : closed_session_list_) { + if (write_blocked_list_.erase(session->connection()) != 0) { + QUIC_BUG + << "QuicConnection was in WriteBlockedList before destruction " + << session->connection()->connection_id(); + } } } + closed_session_list_.clear(); } - closed_session_list_.clear(); } void QuicDispatcher::OnCanWrite() { @@ -820,7 +944,7 @@ void QuicDispatcher::OnCanWrite() { const size_t num_blocked_writers_before = write_blocked_list_.size(); WriteBlockedList temp_list; temp_list.swap(write_blocked_list_); - DCHECK(write_blocked_list_.empty()); + QUICHE_DCHECK(write_blocked_list_.empty()); // Give each blocked writer a chance to write what they indended to write. // If they are blocked again, they will call |OnWriteBlocked| to add @@ -845,14 +969,28 @@ bool QuicDispatcher::HasPendingWrites() const { } void QuicDispatcher::Shutdown() { - while (!session_map_.empty()) { - QuicSession* session = session_map_.begin()->second.get(); - session->connection()->CloseConnection( - QUIC_PEER_GOING_AWAY, "Server shutdown imminent", - ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); - // Validate that the session removes itself from the session map on close. - DCHECK(session_map_.empty() || - session_map_.begin()->second.get() != session); + if (use_reference_counted_session_map_) { + while (!reference_counted_session_map_.empty()) { + QuicSession* session = + reference_counted_session_map_.begin()->second.get(); + session->connection()->CloseConnection( + QUIC_PEER_GOING_AWAY, "Server shutdown imminent", + ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); + // Validate that the session removes itself from the session map on close. + QUICHE_DCHECK(reference_counted_session_map_.empty() || + reference_counted_session_map_.begin()->second.get() != + session); + } + } else { + while (!session_map_.empty()) { + QuicSession* session = session_map_.begin()->second.get(); + session->connection()->CloseConnection( + QUIC_PEER_GOING_AWAY, "Server shutdown imminent", + ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); + // Validate that the session removes itself from the session map on close. + QUICHE_DCHECK(session_map_.empty() || + session_map_.begin()->second.get() != session); + } } DeleteSessions(); } @@ -861,38 +999,78 @@ void QuicDispatcher::OnConnectionClosed(QuicConnectionId server_connection_id, QuicErrorCode error, const std::string& error_details, ConnectionCloseSource source) { - auto it = session_map_.find(server_connection_id); - if (it == session_map_.end()) { - QUIC_BUG << "ConnectionId " << server_connection_id - << " does not exist in the session map. Error: " - << QuicErrorCodeToString(error); - QUIC_BUG << QuicStackTrace(); - return; - } + if (use_reference_counted_session_map_) { + auto it = reference_counted_session_map_.find(server_connection_id); + if (it == reference_counted_session_map_.end()) { + QUIC_BUG << "ConnectionId " << server_connection_id + << " does not exist in the session map. Error: " + << QuicErrorCodeToString(error); + QUIC_BUG << QuicStackTrace(); + return; + } - QUIC_DLOG_IF(INFO, error != QUIC_NO_ERROR) - << "Closing connection (" << server_connection_id - << ") due to error: " << QuicErrorCodeToString(error) - << ", with details: " << error_details; + QUIC_DLOG_IF(INFO, error != QUIC_NO_ERROR) + << "Closing connection (" << server_connection_id + << ") due to error: " << QuicErrorCodeToString(error) + << ", with details: " << error_details; + + QuicConnection* connection = it->second->connection(); + if (ShouldDestroySessionAsynchronously()) { + // Set up alarm to fire immediately to bring destruction of this session + // out of current call stack. + if (closed_ref_counted_session_list_.empty()) { + delete_sessions_alarm_->Update(helper()->GetClock()->ApproximateNow(), + QuicTime::Delta::Zero()); + } + closed_ref_counted_session_list_.push_back(std::move(it->second)); + } + CleanUpSession(it->first, connection, source); + if (support_multiple_cid_per_connection_) { + QUIC_RESTART_FLAG_COUNT_N( + quic_dispatcher_support_multiple_cid_per_connection_v2, 1, 2); + for (const QuicConnectionId& cid : + connection->GetActiveServerConnectionIds()) { + reference_counted_session_map_.erase(cid); + } + --num_sessions_in_session_map_; + } else { + reference_counted_session_map_.erase(it); + } + } else { + auto it = session_map_.find(server_connection_id); + if (it == session_map_.end()) { + QUIC_BUG << "ConnectionId " << server_connection_id + << " does not exist in the session map. Error: " + << QuicErrorCodeToString(error); + QUIC_BUG << QuicStackTrace(); + return; + } - QuicConnection* connection = it->second->connection(); - if (ShouldDestroySessionAsynchronously()) { - // Set up alarm to fire immediately to bring destruction of this session - // out of current call stack. - if (closed_session_list_.empty()) { - delete_sessions_alarm_->Update(helper()->GetClock()->ApproximateNow(), - QuicTime::Delta::Zero()); + QUIC_DLOG_IF(INFO, error != QUIC_NO_ERROR) + << "Closing connection (" << server_connection_id + << ") due to error: " << QuicErrorCodeToString(error) + << ", with details: " << error_details; + + QuicConnection* connection = it->second->connection(); + if (ShouldDestroySessionAsynchronously()) { + // Set up alarm to fire immediately to bring destruction of this session + // out of current call stack. + if (closed_session_list_.empty()) { + delete_sessions_alarm_->Update(helper()->GetClock()->ApproximateNow(), + QuicTime::Delta::Zero()); + } + closed_session_list_.push_back(std::move(it->second)); } - closed_session_list_.push_back(std::move(it->second)); + CleanUpSession(it->first, connection, source); + session_map_.erase(it); } - CleanUpSession(it, connection, source); } void QuicDispatcher::OnWriteBlocked( QuicBlockedWriterInterface* blocked_writer) { if (!blocked_writer->IsWriterBlocked()) { // It is a programming error if this ever happens. When we are sure it is - // not happening, replace it with a DCHECK. + // not happening, replace it with a QUICHE_DCHECK. QUIC_BUG << "Tried to add writer into blocked list when it shouldn't be added"; // Return without adding the connection to the blocked list, to avoid @@ -908,6 +1086,29 @@ void QuicDispatcher::OnRstStreamReceived(const QuicRstStreamFrame& /*frame*/) {} void QuicDispatcher::OnStopSendingReceived( const QuicStopSendingFrame& /*frame*/) {} +void QuicDispatcher::OnNewConnectionIdSent( + const QuicConnectionId& server_connection_id, + const QuicConnectionId& new_connection_id) { + QUICHE_DCHECK(support_multiple_cid_per_connection_); + auto it = reference_counted_session_map_.find(server_connection_id); + if (it == reference_counted_session_map_.end()) { + QUIC_BUG << "Couldn't locate the session that issues the connection ID in " + "reference_counted_session_map_. server_connection_id:" + << server_connection_id + << " new_connection_id: " << new_connection_id; + return; + } + auto insertion_result = reference_counted_session_map_.insert( + std::make_pair(new_connection_id, it->second)); + QUICHE_DCHECK(insertion_result.second); +} + +void QuicDispatcher::OnConnectionIdRetired( + const QuicConnectionId& server_connection_id) { + QUICHE_DCHECK(support_multiple_cid_per_connection_); + reference_counted_session_map_.erase(server_connection_id); +} + void QuicDispatcher::OnConnectionAddedToTimeWaitList( QuicConnectionId server_connection_id) { QUIC_DLOG(INFO) << "Connection " << server_connection_id @@ -930,7 +1131,8 @@ void QuicDispatcher::StatelesslyTerminateConnection( << ", error_details:" << error_details; time_wait_list_manager_->AddConnectionIdToTimeWait( server_connection_id, action, - TimeWaitConnectionInfo(format != GOOGLE_QUIC_PACKET, nullptr)); + TimeWaitConnectionInfo(format != GOOGLE_QUIC_PACKET, nullptr, + {server_connection_id})); return; } @@ -946,8 +1148,9 @@ void QuicDispatcher::StatelesslyTerminateConnection( helper_.get(), time_wait_list_manager_.get()); // This also adds the connection to time wait list. - terminator.CloseConnection(error_code, error_details, - format != GOOGLE_QUIC_PACKET); + terminator.CloseConnection( + error_code, error_details, format != GOOGLE_QUIC_PACKET, + /*active_connection_ids=*/{server_connection_id}); return; } @@ -966,7 +1169,7 @@ void QuicDispatcher::StatelesslyTerminateConnection( time_wait_list_manager()->AddConnectionIdToTimeWait( server_connection_id, QuicTimeWaitListManager::SEND_TERMINATION_PACKETS, TimeWaitConnectionInfo(/*ietf_quic=*/format != GOOGLE_QUIC_PACKET, - &termination_packets)); + &termination_packets, {server_connection_id})); } bool QuicDispatcher::ShouldCreateSessionForUnknownVersion( @@ -1015,12 +1218,28 @@ void QuicDispatcher::ProcessBufferedChlos(size_t max_connections_to_create) { } QUIC_DLOG(INFO) << "Created new session for " << server_connection_id; - auto insertion_result = session_map_.insert( - std::make_pair(server_connection_id, std::move(session))); - QUIC_BUG_IF(!insertion_result.second) - << "Tried to add a session to session_map with existing connection id: " - << server_connection_id; - DeliverPacketsToSession(packets, insertion_result.first->second.get()); + if (use_reference_counted_session_map_) { + auto insertion_result = reference_counted_session_map_.insert( + std::make_pair(server_connection_id, + std::shared_ptr<QuicSession>(std::move(session)))); + if (!insertion_result.second) { + QUIC_BUG + << "Tried to add a session to session_map with existing connection " + "id: " + << server_connection_id; + } else if (support_multiple_cid_per_connection_) { + ++num_sessions_in_session_map_; + } + DeliverPacketsToSession(packets, insertion_result.first->second.get()); + } else { + auto insertion_result = session_map_.insert( + std::make_pair(server_connection_id, std::move(session))); + QUIC_BUG_IF(!insertion_result.second) + << "Tried to add a session to session_map with existing connection " + "id: " + << server_connection_id; + DeliverPacketsToSession(packets, insertion_result.first->second.get()); + } } } @@ -1116,12 +1335,28 @@ void QuicDispatcher::ProcessChlo(const std::vector<std::string>& alpns, QUIC_DLOG(INFO) << "Created new session for " << packet_info->destination_connection_id; - auto insertion_result = session_map_.insert(std::make_pair( - packet_info->destination_connection_id, std::move(session))); - QUIC_BUG_IF(!insertion_result.second) - << "Tried to add a session to session_map with existing connection id: " - << packet_info->destination_connection_id; - QuicSession* session_ptr = insertion_result.first->second.get(); + QuicSession* session_ptr; + if (use_reference_counted_session_map_) { + auto insertion_result = + reference_counted_session_map_.insert(std::make_pair( + packet_info->destination_connection_id, + std::shared_ptr<QuicSession>(std::move(session.release())))); + if (!insertion_result.second) { + QUIC_BUG << "Tried to add a session to session_map with existing " + "connection id: " + << packet_info->destination_connection_id; + } else if (support_multiple_cid_per_connection_) { + ++num_sessions_in_session_map_; + } + session_ptr = insertion_result.first->second.get(); + } else { + auto insertion_result = session_map_.insert(std::make_pair( + packet_info->destination_connection_id, std::move(session))); + QUIC_BUG_IF(!insertion_result.second) + << "Tried to add a session to session_map with existing connection id: " + << packet_info->destination_connection_id; + session_ptr = insertion_result.first->second.get(); + } std::list<BufferedPacket> packets = buffered_packets_.DeliverPackets(packet_info->destination_connection_id) .buffered_packets; @@ -1148,11 +1383,6 @@ bool QuicDispatcher::OnFailedToDispatchPacket( return false; } -const QuicTransportVersionVector& -QuicDispatcher::GetSupportedTransportVersions() { - return version_manager_->GetSupportedTransportVersions(); -} - const ParsedQuicVersionVector& QuicDispatcher::GetSupportedVersions() { return version_manager_->GetSupportedVersions(); } @@ -1183,7 +1413,7 @@ bool QuicDispatcher::IsSupportedVersion(const ParsedQuicVersion version) { void QuicDispatcher::MaybeResetPacketsWithNoVersion( const ReceivedPacketInfo& packet_info) { - DCHECK(!packet_info.version_flag); + QUICHE_DCHECK(!packet_info.version_flag); const size_t MinValidPacketLength = kPacketHeaderTypeSize + expected_server_connection_id_length_ + PACKET_1BYTE_PACKET_NUMBER + /*payload size=*/1 + /*tag size=*/12; @@ -1201,4 +1431,13 @@ void QuicDispatcher::MaybeResetPacketsWithNoVersion( packet_info.form != GOOGLE_QUIC_PACKET, GetPerPacketContext()); } +size_t QuicDispatcher::NumSessions() const { + if (support_multiple_cid_per_connection_) { + return num_sessions_in_session_map_; + } + return use_reference_counted_session_map_ + ? reference_counted_session_map_.size() + : session_map_.size(); +} + } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_dispatcher.h b/chromium/net/third_party/quiche/src/quic/core/quic_dispatcher.h index 92c73208412..4245a5df7fd 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_dispatcher.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_dispatcher.h @@ -8,24 +8,28 @@ #ifndef QUICHE_QUIC_CORE_QUIC_DISPATCHER_H_ #define QUICHE_QUIC_CORE_QUIC_DISPATCHER_H_ +#include <cstddef> #include <memory> #include <string> #include <vector> +#include "absl/container/flat_hash_map.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/quic_blocked_writer_interface.h" -#include "net/third_party/quiche/src/quic/core/quic_buffered_packet_store.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_process_packet_interface.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_time_wait_list_manager.h" -#include "net/third_party/quiche/src/quic/core/quic_version_manager.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/crypto/quic_compressed_certs_cache.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/quic_blocked_writer_interface.h" +#include "quic/core/quic_buffered_packet_store.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_crypto_server_stream_base.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_process_packet_interface.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_time_wait_list_manager.h" +#include "quic/core/quic_version_manager.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_reference_counted.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { namespace test { @@ -97,23 +101,43 @@ class QUIC_NO_EXPORT QuicDispatcher // Collects reset error code received on streams. void OnStopSendingReceived(const QuicStopSendingFrame& frame) override; + // QuicSession::Visitor interface implementation (via inheritance of + // QuicTimeWaitListManager::Visitor): + // Add the newly issued connection ID to the session map. + void OnNewConnectionIdSent( + const QuicConnectionId& server_connection_id, + const QuicConnectionId& new_connection_id) override; + + // QuicSession::Visitor interface implementation (via inheritance of + // QuicTimeWaitListManager::Visitor): + // Remove the retired connection ID from the session map. + void OnConnectionIdRetired( + const QuicConnectionId& server_connection_id) override; + // QuicTimeWaitListManager::Visitor interface implementation // Called whenever the time wait list manager adds a new connection to the // time-wait list. void OnConnectionAddedToTimeWaitList( QuicConnectionId server_connection_id) override; - using SessionMap = QuicHashMap<QuicConnectionId, - std::unique_ptr<QuicSession>, - QuicConnectionIdHash>; + using SessionMap = absl::flat_hash_map<QuicConnectionId, + std::unique_ptr<QuicSession>, + QuicConnectionIdHash>; + + using ReferenceCountedSessionMap = + absl::flat_hash_map<QuicConnectionId, + std::shared_ptr<QuicSession>, + QuicConnectionIdHash>; + + size_t NumSessions() const; const SessionMap& session_map() const { return session_map_; } // Deletes all sessions on the closed session list and clears the list. virtual void DeleteSessions(); - using ConnectionIdMap = - QuicHashMap<QuicConnectionId, QuicConnectionId, QuicConnectionIdHash>; + using ConnectionIdMap = absl:: + flat_hash_map<QuicConnectionId, QuicConnectionId, QuicConnectionIdHash>; // QuicBufferedPacketStore::VisitorInterface implementation. void OnExpiredPackets(QuicConnectionId server_connection_id, @@ -133,8 +157,23 @@ class QUIC_NO_EXPORT QuicDispatcher // duck process or because explicitly configured. void StopAcceptingNewConnections(); + // Apply an operation for each session. + void PerformActionOnActiveSessions( + std::function<void(QuicSession*)> operation) const; + + // Get a snapshot of all sessions. + std::vector<std::shared_ptr<QuicSession>> GetSessionsSnapshot() const; + bool accept_new_connections() const { return accept_new_connections_; } + bool use_reference_counted_session_map() const { + return use_reference_counted_session_map_; + } + + bool support_multiple_cid_per_connection() const { + return support_multiple_cid_per_connection_; + } + protected: virtual std::unique_ptr<QuicSession> CreateQuicSession( QuicConnectionId server_connection_id, @@ -213,8 +252,6 @@ class QUIC_NO_EXPORT QuicDispatcher return time_wait_list_manager_.get(); } - const QuicTransportVersionVector& GetSupportedTransportVersions(); - const ParsedQuicVersionVector& GetSupportedVersions(); const ParsedQuicVersionVector& GetSupportedVersionsWithQuicCrypto(); @@ -263,11 +300,12 @@ class QUIC_NO_EXPORT QuicDispatcher QuicBufferedPacketStore::EnqueuePacketResult result, QuicConnectionId server_connection_id); - // Removes the session from the session map and write blocked list, and adds - // the ConnectionId to the time-wait list. - virtual void CleanUpSession(SessionMap::iterator it, - QuicConnection* connection, - ConnectionCloseSource source); + // Removes the session from the write blocked list, and adds the ConnectionId + // to the time-wait list. The caller needs to manually remove the session + // from the map after that. + void CleanUpSession(QuicConnectionId server_connection_id, + QuicConnection* connection, + ConnectionCloseSource source); // Called to terminate a connection statelessly. Depending on |format|, either // 1) send connection close with |error_code| and |error_details| and add @@ -352,12 +390,14 @@ class QUIC_NO_EXPORT QuicDispatcher WriteBlockedList write_blocked_list_; SessionMap session_map_; + ReferenceCountedSessionMap reference_counted_session_map_; // Entity that manages connection_ids in time wait state. std::unique_ptr<QuicTimeWaitListManager> time_wait_list_manager_; // The list of closed but not-yet-deleted sessions. std::vector<std::unique_ptr<QuicSession>> closed_session_list_; + std::vector<std::shared_ptr<QuicSession>> closed_ref_counted_session_list_; // The helper used for all connections. std::unique_ptr<QuicConnectionHelperInterface> helper_; @@ -385,6 +425,9 @@ class QUIC_NO_EXPORT QuicDispatcher // TODO(fayang): consider removing last_error_. QuicErrorCode last_error_; + // Number of unique session in session map. + size_t num_sessions_in_session_map_ = 0; + // A backward counter of how many new sessions can be create within current // event loop. When reaches 0, it means can't create sessions for now. int16_t new_sessions_allowed_per_event_loop_; @@ -409,6 +452,14 @@ class QUIC_NO_EXPORT QuicDispatcher // If true, change expected_server_connection_id_length_ to be the received // destination connection ID length of all IETF long headers. bool should_update_expected_server_connection_id_length_; + + const bool use_reference_counted_session_map_ = + GetQuicRestartFlag(quic_use_reference_counted_sesssion_map); + const bool support_multiple_cid_per_connection_ = + use_reference_counted_session_map_ && + GetQuicRestartFlag(quic_time_wait_list_support_multiple_cid_v2) && + GetQuicRestartFlag( + quic_dispatcher_support_multiple_cid_per_connection_v2); }; } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_dispatcher_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_dispatcher_test.cc index 9f692a8029a..3f2f8cc2bb3 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_dispatcher_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_dispatcher_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_dispatcher.h" +#include "quic/core/quic_dispatcher.h" #include <memory> #include <ostream> @@ -10,35 +10,38 @@ #include <utility> #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/core/chlo_extractor.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.h" -#include "net/third_party/quiche/src/quic/core/quic_time_wait_list_manager.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#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_test.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/fake_proof_source.h" -#include "net/third_party/quiche/src/quic/test_tools/first_flight.h" -#include "net/third_party/quiche/src/quic/test_tools/mock_quic_time_wait_list_manager.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_buffered_packet_store_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_crypto_server_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_dispatcher_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_time_wait_list_manager_peer.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_crypto_server_stream_helper.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "absl/strings/str_cat.h" +#include "quic/core/chlo_extractor.h" +#include "quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/quic_crypto_server_config.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/frames/quic_new_connection_id_frame.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_crypto_stream.h" +#include "quic/core/quic_packet_writer_wrapper.h" +#include "quic/core/quic_time_wait_list_manager.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/fake_proof_source.h" +#include "quic/test_tools/first_flight.h" +#include "quic/test_tools/mock_quic_time_wait_list_manager.h" +#include "quic/test_tools/quic_buffered_packet_store_peer.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_crypto_server_config_peer.h" +#include "quic/test_tools/quic_dispatcher_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/quic_time_wait_list_manager_peer.h" +#include "quic/tools/quic_simple_crypto_server_stream_helper.h" +#include "common/test_tools/quiche_test_utils.h" using testing::_; using testing::ByMove; @@ -183,7 +186,26 @@ class MockServerConnection : public MockQuicConnection { helper, alarm_factory, Perspective::IS_SERVER), - dispatcher_(dispatcher) {} + dispatcher_(dispatcher), + active_connection_ids_({connection_id}) {} + + void AddNewConnectionId(QuicConnectionId id) { + dispatcher_->OnNewConnectionIdSent(active_connection_ids_.back(), id); + QuicConnectionPeer::SetServerConnectionId(this, id); + active_connection_ids_.push_back(id); + } + + void RetireConnectionId(QuicConnectionId id) { + auto it = std::find(active_connection_ids_.begin(), + active_connection_ids_.end(), id); + QUICHE_DCHECK(it != active_connection_ids_.end()); + dispatcher_->OnConnectionIdRetired(id); + active_connection_ids_.erase(it); + } + + std::vector<QuicConnectionId> GetActiveServerConnectionIds() const override { + return active_connection_ids_; + } void UnregisterOnConnectionClosed() { QUIC_LOG(ERROR) << "Unregistering " << connection_id(); @@ -194,6 +216,7 @@ class MockServerConnection : public MockQuicConnection { private: QuicDispatcher* dispatcher_; + std::vector<QuicConnectionId> active_connection_ids_; }; class QuicDispatcherTestBase : public QuicTestWithParam<ParsedQuicVersion> { @@ -557,7 +580,7 @@ void QuicDispatcherTestBase::TestTlsMultiPacketClientHello( ProcessReceivedPacket(std::move(packets[0]), client_address, version_, server_connection_id); - EXPECT_EQ(dispatcher_->session_map().size(), 0u) + EXPECT_EQ(dispatcher_->NumSessions(), 0u) << "No session should be created before the rest of the CHLO arrives."; // Processing the second packet should create the new session. @@ -574,7 +597,7 @@ void QuicDispatcherTestBase::TestTlsMultiPacketClientHello( ProcessReceivedPacket(std::move(packets[1]), client_address, version_, server_connection_id); - EXPECT_EQ(dispatcher_->session_map().size(), 1u); + EXPECT_EQ(dispatcher_->NumSessions(), 1u); } TEST_P(QuicDispatcherTestAllVersions, TlsMultiPacketClientHello) { @@ -641,7 +664,7 @@ TEST_P(QuicDispatcherTestAllVersions, LegacyVersionEncapsulation) { ProcessReceivedPacket(packets[0]->Clone(), client_address, version_, server_connection_id); - EXPECT_EQ(dispatcher_->session_map().size(), 1u); + EXPECT_EQ(dispatcher_->NumSessions(), 1u); // Processing the same packet a second time should also be routed by the // dispatcher to the right connection (we expect ProcessUdpPacket to be @@ -777,9 +800,9 @@ TEST_P(QuicDispatcherTestOneVersion, NoVersionNegotiationWithSmallPacket) { std::string chlo = SerializeCHLO() + std::string(1200, 'a'); // Truncate to 1100 bytes of payload which results in a packet just // under 1200 bytes after framing, packet, and encryption overhead. - DCHECK_LE(1200u, chlo.length()); + QUICHE_DCHECK_LE(1200u, chlo.length()); std::string truncated_chlo = chlo.substr(0, 1100); - DCHECK_EQ(1100u, truncated_chlo.length()); + QUICHE_DCHECK_EQ(1100u, truncated_chlo.length()); ProcessPacket(client_address, TestConnectionId(1), true, QuicVersionReservedForNegotiation(), truncated_chlo, false, CONNECTION_ID_PRESENT, PACKET_4BYTE_PACKET_NUMBER, 1); @@ -801,9 +824,9 @@ TEST_P(QuicDispatcherTestOneVersion, std::string chlo = SerializeCHLO() + std::string(1200, 'a'); // Truncate to 1100 bytes of payload which results in a packet just // under 1200 bytes after framing, packet, and encryption overhead. - DCHECK_LE(1200u, chlo.length()); + QUICHE_DCHECK_LE(1200u, chlo.length()); std::string truncated_chlo = chlo.substr(0, 1100); - DCHECK_EQ(1100u, truncated_chlo.length()); + QUICHE_DCHECK_EQ(1100u, truncated_chlo.length()); ProcessPacket(client_address, TestConnectionId(1), true, QuicVersionReservedForNegotiation(), truncated_chlo, true, CONNECTION_ID_PRESENT, PACKET_4BYTE_PACKET_NUMBER, 1); @@ -1078,8 +1101,6 @@ void QuicDispatcherTestBase:: TestVersionNegotiationForUnknownVersionInvalidShortInitialConnectionId( const QuicConnectionId& server_connection_id, const QuicConnectionId& client_connection_id) { - SetQuicReloadableFlag(quic_send_version_negotiation_for_short_connection_ids, - true); CreateTimeWaitListManager(); QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); @@ -1149,6 +1170,23 @@ TEST_P(QuicDispatcherTestOneVersion, } TEST_P(QuicDispatcherTestOneVersion, + RejectDeprecatedVersionDraft27WithVersionNegotiation) { + QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); + CreateTimeWaitListManager(); + char packet[kMinPacketSizeForVersionNegotiation] = { + 0xC0, 0xFF, 0x00, 0x00, 27, /*destination connection ID length*/ 0x08}; + QuicReceivedPacket received_packet(packet, ABSL_ARRAYSIZE(packet), + QuicTime::Zero()); + EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _)).Times(0); + EXPECT_CALL( + *time_wait_list_manager_, + SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, + /*use_length_prefix=*/true, _, _, _, _)) + .Times(1); + dispatcher_->ProcessPacket(server_address_, client_address, received_packet); +} + +TEST_P(QuicDispatcherTestOneVersion, RejectDeprecatedVersionDraft25WithVersionNegotiation) { QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); CreateTimeWaitListManager(); @@ -1166,6 +1204,23 @@ TEST_P(QuicDispatcherTestOneVersion, } TEST_P(QuicDispatcherTestOneVersion, + RejectDeprecatedVersionT050WithVersionNegotiation) { + QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); + CreateTimeWaitListManager(); + char packet[kMinPacketSizeForVersionNegotiation] = { + 0xC0, 'T', '0', '5', '0', /*destination connection ID length*/ 0x08}; + QuicReceivedPacket received_packet(packet, ABSL_ARRAYSIZE(packet), + QuicTime::Zero()); + EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _)).Times(0); + EXPECT_CALL( + *time_wait_list_manager_, + SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, + /*use_length_prefix=*/true, _, _, _, _)) + .Times(1); + dispatcher_->ProcessPacket(server_address_, client_address, received_packet); +} + +TEST_P(QuicDispatcherTestOneVersion, RejectDeprecatedVersionQ049WithVersionNegotiation) { QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); CreateTimeWaitListManager(); @@ -1251,7 +1306,7 @@ TEST_P(QuicDispatcherTestOneVersion, received_packet44); } -static_assert(quic::SupportedVersions().size() == 7u, +static_assert(quic::SupportedVersions().size() == 6u, "Please add new RejectDeprecatedVersion tests above this assert " "when deprecating versions"); @@ -1911,6 +1966,190 @@ TEST_P(QuicDispatcherWriteBlockedListTest, MarkSession1Deleted(); } +class QuicDispatcherSupportMultipleConnectionIdPerConnectionTest + : public QuicDispatcherTestBase { + public: + QuicDispatcherSupportMultipleConnectionIdPerConnectionTest() + : QuicDispatcherTestBase(crypto_test_utils::ProofSourceForTesting()) { + SetQuicRestartFlag(quic_use_reference_counted_sesssion_map, true); + SetQuicRestartFlag(quic_time_wait_list_support_multiple_cid_v2, true); + SetQuicRestartFlag(quic_dispatcher_support_multiple_cid_per_connection_v2, + true); + dispatcher_ = std::make_unique<NiceMock<TestDispatcher>>( + &config_, &crypto_config_, &version_manager_, + mock_helper_.GetRandomGenerator()); + } + void AddConnection1() { + QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); + EXPECT_CALL(*dispatcher_, + CreateQuicSession(_, _, client_address, Eq(ExpectedAlpn()), _)) + .WillOnce(Return(ByMove(CreateSession( + dispatcher_.get(), config_, TestConnectionId(1), client_address, + &helper_, &alarm_factory_, &crypto_config_, + QuicDispatcherPeer::GetCache(dispatcher_.get()), &session1_)))); + EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), + ProcessUdpPacket(_, _, _)) + .WillOnce(WithArg<2>(Invoke([this](const QuicEncryptedPacket& packet) { + ValidatePacket(TestConnectionId(1), packet); + }))); + EXPECT_CALL(*dispatcher_, + ShouldCreateOrBufferPacketForConnection( + ReceivedPacketInfoConnectionIdEquals(TestConnectionId(1)))); + ProcessFirstFlight(client_address, TestConnectionId(1)); + } + + void AddConnection2() { + QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 2); + EXPECT_CALL(*dispatcher_, + CreateQuicSession(_, _, client_address, Eq(ExpectedAlpn()), _)) + .WillOnce(Return(ByMove(CreateSession( + dispatcher_.get(), config_, TestConnectionId(2), client_address, + &helper_, &alarm_factory_, &crypto_config_, + QuicDispatcherPeer::GetCache(dispatcher_.get()), &session2_)))); + EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session2_->connection()), + ProcessUdpPacket(_, _, _)) + .WillOnce(WithArg<2>(Invoke([this](const QuicEncryptedPacket& packet) { + ValidatePacket(TestConnectionId(2), packet); + }))); + EXPECT_CALL(*dispatcher_, + ShouldCreateOrBufferPacketForConnection( + ReceivedPacketInfoConnectionIdEquals(TestConnectionId(2)))); + ProcessFirstFlight(client_address, TestConnectionId(2)); + } + + protected: + MockQuicConnectionHelper helper_; + MockAlarmFactory alarm_factory_; +}; + +INSTANTIATE_TEST_SUITE_P( + QuicDispatcherSupportMultipleConnectionIdPerConnectionTests, + QuicDispatcherSupportMultipleConnectionIdPerConnectionTest, + ::testing::Values(CurrentSupportedVersions().front()), + ::testing::PrintToStringParamName()); + +TEST_P(QuicDispatcherSupportMultipleConnectionIdPerConnectionTest, + OnNewConnectionIdSent) { + AddConnection1(); + ASSERT_EQ(dispatcher_->NumSessions(), 1u); + ASSERT_THAT(session1_, testing::NotNull()); + MockServerConnection* mock_server_connection1 = + reinterpret_cast<MockServerConnection*>(connection1()); + + { + mock_server_connection1->AddNewConnectionId(TestConnectionId(3)); + EXPECT_EQ(dispatcher_->NumSessions(), 1u); + auto* session = + QuicDispatcherPeer::FindSession(dispatcher_.get(), TestConnectionId(3)); + ASSERT_EQ(session, session1_); + } + + { + mock_server_connection1->AddNewConnectionId(TestConnectionId(4)); + EXPECT_EQ(dispatcher_->NumSessions(), 1u); + auto* session = + QuicDispatcherPeer::FindSession(dispatcher_.get(), TestConnectionId(4)); + ASSERT_EQ(session, session1_); + } + + EXPECT_CALL(*connection1(), CloseConnection(QUIC_PEER_GOING_AWAY, _, _)); + // Would timed out unless all sessions have been removed from the session map. + dispatcher_->Shutdown(); +} + +TEST_P(QuicDispatcherSupportMultipleConnectionIdPerConnectionTest, + RetireConnectionIdFromSingleConnection) { + AddConnection1(); + ASSERT_EQ(dispatcher_->NumSessions(), 1u); + ASSERT_THAT(session1_, testing::NotNull()); + MockServerConnection* mock_server_connection1 = + reinterpret_cast<MockServerConnection*>(connection1()); + + // Adds 1 new connection id every turn and retires 2 connection ids every + // other turn. + for (int i = 2; i < 10; ++i) { + mock_server_connection1->AddNewConnectionId(TestConnectionId(i)); + ASSERT_EQ( + QuicDispatcherPeer::FindSession(dispatcher_.get(), TestConnectionId(i)), + session1_); + ASSERT_EQ(QuicDispatcherPeer::FindSession(dispatcher_.get(), + TestConnectionId(i - 1)), + session1_); + EXPECT_EQ(dispatcher_->NumSessions(), 1u); + if (i % 2 == 1) { + mock_server_connection1->RetireConnectionId(TestConnectionId(i - 2)); + mock_server_connection1->RetireConnectionId(TestConnectionId(i - 1)); + } + } + + EXPECT_CALL(*connection1(), CloseConnection(QUIC_PEER_GOING_AWAY, _, _)); + // Would timed out unless all sessions have been removed from the session map. + dispatcher_->Shutdown(); +} + +TEST_P(QuicDispatcherSupportMultipleConnectionIdPerConnectionTest, + RetireConnectionIdFromMultipleConnections) { + AddConnection1(); + AddConnection2(); + ASSERT_EQ(dispatcher_->NumSessions(), 2u); + MockServerConnection* mock_server_connection1 = + reinterpret_cast<MockServerConnection*>(connection1()); + MockServerConnection* mock_server_connection2 = + reinterpret_cast<MockServerConnection*>(connection2()); + + for (int i = 2; i < 10; ++i) { + mock_server_connection1->AddNewConnectionId(TestConnectionId(2 * i - 1)); + mock_server_connection2->AddNewConnectionId(TestConnectionId(2 * i)); + ASSERT_EQ(QuicDispatcherPeer::FindSession(dispatcher_.get(), + TestConnectionId(2 * i - 1)), + session1_); + ASSERT_EQ(QuicDispatcherPeer::FindSession(dispatcher_.get(), + TestConnectionId(2 * i)), + session2_); + EXPECT_EQ(dispatcher_->NumSessions(), 2u); + mock_server_connection1->RetireConnectionId(TestConnectionId(2 * i - 3)); + mock_server_connection2->RetireConnectionId(TestConnectionId(2 * i - 2)); + } + + mock_server_connection1->AddNewConnectionId(TestConnectionId(19)); + mock_server_connection2->AddNewConnectionId(TestConnectionId(20)); + EXPECT_CALL(*connection1(), CloseConnection(QUIC_PEER_GOING_AWAY, _, _)); + EXPECT_CALL(*connection2(), CloseConnection(QUIC_PEER_GOING_AWAY, _, _)); + // Would timed out unless all sessions have been removed from the session map. + dispatcher_->Shutdown(); +} + +TEST_P(QuicDispatcherSupportMultipleConnectionIdPerConnectionTest, + TimeWaitListPoplulateCorrectly) { + QuicTimeWaitListManager* time_wait_list_manager = + QuicDispatcherPeer::GetTimeWaitListManager(dispatcher_.get()); + AddConnection1(); + MockServerConnection* mock_server_connection1 = + reinterpret_cast<MockServerConnection*>(connection1()); + + mock_server_connection1->AddNewConnectionId(TestConnectionId(2)); + mock_server_connection1->AddNewConnectionId(TestConnectionId(3)); + mock_server_connection1->AddNewConnectionId(TestConnectionId(4)); + mock_server_connection1->RetireConnectionId(TestConnectionId(1)); + mock_server_connection1->RetireConnectionId(TestConnectionId(2)); + + EXPECT_CALL(*connection1(), CloseConnection(QUIC_PEER_GOING_AWAY, _, _)); + connection1()->CloseConnection( + QUIC_PEER_GOING_AWAY, "Close for testing", + ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); + + EXPECT_FALSE( + time_wait_list_manager->IsConnectionIdInTimeWait(TestConnectionId(1))); + EXPECT_FALSE( + time_wait_list_manager->IsConnectionIdInTimeWait(TestConnectionId(2))); + EXPECT_TRUE( + time_wait_list_manager->IsConnectionIdInTimeWait(TestConnectionId(3))); + EXPECT_TRUE( + time_wait_list_manager->IsConnectionIdInTimeWait(TestConnectionId(4))); + + dispatcher_->Shutdown(); +} + class BufferedPacketStoreTest : public QuicDispatcherTestBase { public: BufferedPacketStoreTest() @@ -1977,7 +2216,7 @@ TEST_P(BufferedPacketStoreTest, ProcessNonChloPacketBeforeChlo) { ReceivedPacketInfoConnectionIdEquals(conn_id))); // Process non-CHLO packet. ProcessUndecryptableEarlyPacket(conn_id); - EXPECT_EQ(0u, dispatcher_->session_map().size()) + EXPECT_EQ(0u, dispatcher_->NumSessions()) << "No session should be created before CHLO arrives."; // When CHLO arrives, a new session should be created, and all packets @@ -2010,7 +2249,7 @@ TEST_P(BufferedPacketStoreTest, ProcessNonChloPacketsUptoLimitAndProcessChlo) { for (size_t i = 1; i <= kDefaultMaxUndecryptablePackets + 1; ++i) { ProcessUndecryptableEarlyPacket(conn_id); } - EXPECT_EQ(0u, dispatcher_->session_map().size()) + EXPECT_EQ(0u, dispatcher_->NumSessions()) << "No session should be created before CHLO arrives."; // Pop out the last packet as it is also be dropped by the store. @@ -2152,9 +2391,8 @@ TEST_P(BufferedPacketStoreTest, ReceiveCHLOAfterExpiration) { QuicBufferedPacketStorePeer::set_clock(store, mock_helper_.GetClock()); QuicConnectionId conn_id = TestConnectionId(1); - ProcessPacket(client_addr_, conn_id, true, - quiche::QuicheStrCat("data packet ", 2), CONNECTION_ID_PRESENT, - PACKET_4BYTE_PACKET_NUMBER, + ProcessPacket(client_addr_, conn_id, true, absl::StrCat("data packet ", 2), + CONNECTION_ID_PRESENT, PACKET_4BYTE_PACKET_NUMBER, /*packet_number=*/2); mock_helper_.AdvanceTime( diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.cc b/chromium/net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.cc index 75b375ff0ed..2a088687ef1 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.h" +#include "quic/core/quic_epoll_alarm_factory.h" #include <type_traits> -#include "net/third_party/quiche/src/quic/core/quic_arena_scoped_ptr.h" +#include "quic/core/quic_arena_scoped_ptr.h" namespace quic { namespace { @@ -21,18 +21,18 @@ class QuicEpollAlarm : public QuicAlarm { protected: void SetImpl() override { - DCHECK(deadline().IsInitialized()); + QUICHE_DCHECK(deadline().IsInitialized()); epoll_server_->RegisterAlarm( (deadline() - QuicTime::Zero()).ToMicroseconds(), &epoll_alarm_impl_); } void CancelImpl() override { - DCHECK(!deadline().IsInitialized()); + QUICHE_DCHECK(!deadline().IsInitialized()); epoll_alarm_impl_.UnregisterIfRegistered(); } void UpdateImpl() override { - DCHECK(deadline().IsInitialized()); + QUICHE_DCHECK(deadline().IsInitialized()); int64_t epoll_deadline = (deadline() - QuicTime::Zero()).ToMicroseconds(); if (epoll_alarm_impl_.registered()) { epoll_alarm_impl_.ReregisterAlarm(epoll_deadline); diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.h b/chromium/net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.h index 5c04e3d4cd5..6fb1e02ed4e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.h @@ -5,10 +5,10 @@ #ifndef QUICHE_QUIC_CORE_QUIC_EPOLL_ALARM_FACTORY_H_ #define QUICHE_QUIC_CORE_QUIC_EPOLL_ALARM_FACTORY_H_ -#include "net/third_party/quiche/src/quic/core/quic_alarm.h" -#include "net/third_party/quiche/src/quic/core/quic_alarm_factory.h" -#include "net/third_party/quiche/src/quic/core/quic_one_block_arena.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_epoll.h" +#include "quic/core/quic_alarm.h" +#include "quic/core/quic_alarm_factory.h" +#include "quic/core/quic_one_block_arena.h" +#include "quic/platform/api/quic_epoll.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory_test.cc index 88b27bc0c8c..e2268dbb502 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory_test.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.h" +#include "quic/core/quic_epoll_alarm_factory.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_epoll_test_tools.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_epoll_test_tools.h" +#include "quic/platform/api/quic_test.h" #include "net/quic/platform/impl/quic_epoll_clock.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.cc b/chromium/net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.cc index 3bfe7e68636..8f532562aee 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h" +#include "quic/core/quic_epoll_connection_helper.h" #include <errno.h> #include <sys/socket.h> -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" +#include "quic/core/crypto/quic_random.h" namespace quic { @@ -32,7 +32,7 @@ QuicBufferAllocator* QuicEpollConnectionHelper::GetStreamSendBufferAllocator() { if (allocator_type_ == QuicAllocator::BUFFER_POOL) { return &stream_buffer_allocator_; } else { - DCHECK(allocator_type_ == QuicAllocator::SIMPLE); + QUICHE_DCHECK(allocator_type_ == QuicAllocator::SIMPLE); return &simple_buffer_allocator_; } } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h b/chromium/net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h index ce68cfbb756..0db6ed2cd0a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h @@ -11,14 +11,14 @@ #include <sys/types.h> #include <set> -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_default_packet_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_epoll.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_stream_buffer_allocator.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_default_packet_writer.h" +#include "quic/core/quic_packet_writer.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_simple_buffer_allocator.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_epoll.h" +#include "quic/platform/api/quic_stream_buffer_allocator.h" #include "net/quic/platform/impl/quic_epoll_clock.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_epoll_connection_helper_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_epoll_connection_helper_test.cc index ea639480ec1..b50ce6d4d52 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_epoll_connection_helper_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_epoll_connection_helper_test.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h" +#include "quic/core/quic_epoll_connection_helper.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_epoll_test_tools.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/platform/api/quic_epoll_test_tools.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_error_codes.cc b/chromium/net/third_party/quiche/src/quic/core/quic_error_codes.cc index 9abde9f52b1..dd8be33e747 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_error_codes.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_error_codes.cc @@ -5,10 +5,10 @@ #include <cstdint> #include <cstring> +#include "absl/strings/str_cat.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "quic/core/quic_error_codes.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -108,6 +108,7 @@ const char* QuicErrorCodeToString(QuicErrorCode error) { RETURN_STRING_LITERAL(QUIC_TOO_MANY_OPEN_STREAMS); RETURN_STRING_LITERAL(QUIC_PUBLIC_RESET); RETURN_STRING_LITERAL(QUIC_INVALID_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); RETURN_STRING_LITERAL(QUIC_DECOMPRESSION_FAILURE); @@ -166,10 +167,13 @@ const char* QuicErrorCodeToString(QuicErrorCode error) { RETURN_STRING_LITERAL(QUIC_STREAMS_BLOCKED_DATA); RETURN_STRING_LITERAL(QUIC_INVALID_NEW_CONNECTION_ID_DATA); RETURN_STRING_LITERAL(QUIC_INVALID_RETIRE_CONNECTION_ID_DATA); + RETURN_STRING_LITERAL(QUIC_CONNECTION_ID_LIMIT_ERROR); + RETURN_STRING_LITERAL(QUIC_TOO_MANY_CONNECTION_ID_WAITING_TO_RETIRE); RETURN_STRING_LITERAL(QUIC_INVALID_STOP_SENDING_FRAME_DATA); RETURN_STRING_LITERAL(QUIC_INVALID_PATH_CHALLENGE_DATA); RETURN_STRING_LITERAL(QUIC_INVALID_PATH_RESPONSE_DATA); RETURN_STRING_LITERAL(QUIC_CONNECTION_MIGRATION_HANDSHAKE_UNCONFIRMED); + RETURN_STRING_LITERAL(QUIC_PEER_PORT_CHANGE_HANDSHAKE_UNCONFIRMED); RETURN_STRING_LITERAL(QUIC_INVALID_MESSAGE_DATA); RETURN_STRING_LITERAL(IETF_QUIC_PROTOCOL_VIOLATION); RETURN_STRING_LITERAL(QUIC_INVALID_NEW_TOKEN); @@ -256,6 +260,15 @@ const char* QuicErrorCodeToString(QuicErrorCode error) { RETURN_STRING_LITERAL(QUIC_KEY_UPDATE_ERROR); RETURN_STRING_LITERAL(QUIC_AEAD_LIMIT_REACHED); RETURN_STRING_LITERAL(QUIC_MAX_AGE_TIMEOUT); + RETURN_STRING_LITERAL(QUIC_INVALID_PRIORITY_UPDATE); + RETURN_STRING_LITERAL(QUIC_TLS_BAD_CERTIFICATE); + RETURN_STRING_LITERAL(QUIC_TLS_UNSUPPORTED_CERTIFICATE); + RETURN_STRING_LITERAL(QUIC_TLS_CERTIFICATE_REVOKED); + RETURN_STRING_LITERAL(QUIC_TLS_CERTIFICATE_EXPIRED); + RETURN_STRING_LITERAL(QUIC_TLS_CERTIFICATE_UNKNOWN); + RETURN_STRING_LITERAL(QUIC_TLS_INTERNAL_ERROR); + RETURN_STRING_LITERAL(QUIC_TLS_UNRECOGNIZED_NAME); + RETURN_STRING_LITERAL(QUIC_TLS_CERTIFICATE_REQUIRED); RETURN_STRING_LITERAL(QUIC_LAST_ERROR); // Intentionally have no default case, so we'll break the build @@ -269,15 +282,15 @@ const char* QuicErrorCodeToString(QuicErrorCode error) { std::string QuicIetfTransportErrorCodeString(QuicIetfTransportErrorCodes c) { if (static_cast<uint64_t>(c) >= 0xff00u) { - return quiche::QuicheStrCat("Private(", static_cast<uint64_t>(c), ")"); + return absl::StrCat("Private(", static_cast<uint64_t>(c), ")"); } if (c >= CRYPTO_ERROR_FIRST && c <= CRYPTO_ERROR_LAST) { const int tls_error = static_cast<int>(c - CRYPTO_ERROR_FIRST); const char* tls_error_description = SSL_alert_desc_string_long(tls_error); if (strcmp("unknown", tls_error_description) != 0) { - return quiche::QuicheStrCat("CRYPTO_ERROR(", tls_error_description, ")"); + return absl::StrCat("CRYPTO_ERROR(", tls_error_description, ")"); } - return quiche::QuicheStrCat("CRYPTO_ERROR(unknown(", tls_error, "))"); + return absl::StrCat("CRYPTO_ERROR(unknown(", tls_error, "))"); } switch (c) { @@ -300,11 +313,11 @@ std::string QuicIetfTransportErrorCodeString(QuicIetfTransportErrorCodes c) { // change behavior and are only here to make the compiler happy. case CRYPTO_ERROR_FIRST: case CRYPTO_ERROR_LAST: - DCHECK(false) << "Unexpected error " << static_cast<uint64_t>(c); + QUICHE_DCHECK(false) << "Unexpected error " << static_cast<uint64_t>(c); break; } - return quiche::QuicheStrCat("Unknown(", static_cast<uint64_t>(c), ")"); + return absl::StrCat("Unknown(", static_cast<uint64_t>(c), ")"); } std::ostream& operator<<(std::ostream& os, @@ -384,6 +397,8 @@ QuicErrorCodeToIetfMapping QuicErrorCodeToTransportErrorCode( return {true, static_cast<uint64_t>(INTERNAL_ERROR)}; case QUIC_INVALID_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: return {true, static_cast<uint64_t>(INTERNAL_ERROR)}; case QUIC_INVALID_NEGOTIATED_VALUE: @@ -504,6 +519,8 @@ QuicErrorCodeToIetfMapping QuicErrorCodeToTransportErrorCode( return {true, static_cast<uint64_t>(INTERNAL_ERROR)}; case QUIC_CONNECTION_MIGRATION_HANDSHAKE_UNCONFIRMED: return {true, static_cast<uint64_t>(INTERNAL_ERROR)}; + case QUIC_PEER_PORT_CHANGE_HANDSHAKE_UNCONFIRMED: + return {true, static_cast<uint64_t>(INTERNAL_ERROR)}; case QUIC_TOO_MANY_STREAM_DATA_INTERVALS: return {true, static_cast<uint64_t>(PROTOCOL_VIOLATION)}; case QUIC_STREAM_SEQUENCER_INVALID_STATE: @@ -716,6 +733,37 @@ QuicErrorCodeToIetfMapping QuicErrorCodeToTransportErrorCode( return {true, static_cast<uint64_t>(AEAD_LIMIT_REACHED)}; case QUIC_MAX_AGE_TIMEOUT: return {false, static_cast<uint64_t>(QuicHttp3ErrorCode::INTERNAL_ERROR)}; + case QUIC_INVALID_PRIORITY_UPDATE: + return {false, static_cast<uint64_t>( + QuicHttp3ErrorCode::GENERAL_PROTOCOL_ERROR)}; + case QUIC_TLS_BAD_CERTIFICATE: + return {true, static_cast<uint64_t>(CRYPTO_ERROR_FIRST + + SSL_AD_BAD_CERTIFICATE)}; + case QUIC_TLS_UNSUPPORTED_CERTIFICATE: + return {true, static_cast<uint64_t>(CRYPTO_ERROR_FIRST + + SSL_AD_UNSUPPORTED_CERTIFICATE)}; + case QUIC_TLS_CERTIFICATE_REVOKED: + return {true, static_cast<uint64_t>(CRYPTO_ERROR_FIRST + + SSL_AD_CERTIFICATE_REVOKED)}; + case QUIC_TLS_CERTIFICATE_EXPIRED: + return {true, static_cast<uint64_t>(CRYPTO_ERROR_FIRST + + SSL_AD_CERTIFICATE_EXPIRED)}; + case QUIC_TLS_CERTIFICATE_UNKNOWN: + return {true, static_cast<uint64_t>(CRYPTO_ERROR_FIRST + + SSL_AD_CERTIFICATE_UNKNOWN)}; + case QUIC_TLS_INTERNAL_ERROR: + return {true, static_cast<uint64_t>(CRYPTO_ERROR_FIRST + + SSL_AD_INTERNAL_ERROR)}; + case QUIC_TLS_UNRECOGNIZED_NAME: + return {true, static_cast<uint64_t>(CRYPTO_ERROR_FIRST + + SSL_AD_UNRECOGNIZED_NAME)}; + case QUIC_TLS_CERTIFICATE_REQUIRED: + return {true, static_cast<uint64_t>(CRYPTO_ERROR_FIRST + + SSL_AD_CERTIFICATE_REQUIRED)}; + case QUIC_CONNECTION_ID_LIMIT_ERROR: + return {true, static_cast<uint64_t>(CONNECTION_ID_LIMIT_ERROR)}; + case QUIC_TOO_MANY_CONNECTION_ID_WAITING_TO_RETIRE: + return {true, static_cast<uint64_t>(INTERNAL_ERROR)}; case QUIC_LAST_ERROR: return {false, static_cast<uint64_t>(QUIC_LAST_ERROR)}; } @@ -723,6 +771,29 @@ QuicErrorCodeToIetfMapping QuicErrorCodeToTransportErrorCode( return {true, static_cast<uint64_t>(INTERNAL_ERROR)}; } +QuicErrorCode TlsAlertToQuicErrorCode(uint8_t desc) { + switch (desc) { + case SSL_AD_BAD_CERTIFICATE: + return QUIC_TLS_BAD_CERTIFICATE; + case SSL_AD_UNSUPPORTED_CERTIFICATE: + return QUIC_TLS_UNSUPPORTED_CERTIFICATE; + case SSL_AD_CERTIFICATE_REVOKED: + return QUIC_TLS_CERTIFICATE_REVOKED; + case SSL_AD_CERTIFICATE_EXPIRED: + return QUIC_TLS_CERTIFICATE_EXPIRED; + case SSL_AD_CERTIFICATE_UNKNOWN: + return QUIC_TLS_CERTIFICATE_UNKNOWN; + case SSL_AD_INTERNAL_ERROR: + return QUIC_TLS_INTERNAL_ERROR; + case SSL_AD_UNRECOGNIZED_NAME: + return QUIC_TLS_UNRECOGNIZED_NAME; + case SSL_AD_CERTIFICATE_REQUIRED: + return QUIC_TLS_CERTIFICATE_REQUIRED; + default: + return QUIC_HANDSHAKE_FAILED; + } +} + // Convert a QuicRstStreamErrorCode to an application error code to be used in // an IETF QUIC RESET_STREAM frame uint64_t RstStreamErrorCodeToIetfResetStreamErrorCode( diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_error_codes.h b/chromium/net/third_party/quiche/src/quic/core/quic_error_codes.h index a1cd7a6eac9..3a8069675f1 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_error_codes.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_error_codes.h @@ -9,7 +9,7 @@ #include <limits> #include <string> -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -321,6 +321,7 @@ enum QuicErrorCode { QUIC_CONNECTION_MIGRATION_INTERNAL_ERROR = 100, // Network changed, but handshake is not confirmed yet. QUIC_CONNECTION_MIGRATION_HANDSHAKE_UNCONFIRMED = 111, + QUIC_PEER_PORT_CHANGE_HANDSHAKE_UNCONFIRMED = 194, // Stream frames arrived too discontiguously so that stream sequencer buffer // maintains too many intervals. @@ -347,6 +348,10 @@ enum QuicErrorCode { QUIC_INVALID_STREAM_BLOCKED_DATA = 106, // NEW CONNECTION ID frame data is malformed. QUIC_INVALID_NEW_CONNECTION_ID_DATA = 107, + // More connection IDs than allowed are issued. + QUIC_CONNECTION_ID_LIMIT_ERROR = 203, + // The peer retires connection IDs too quickly. + QUIC_TOO_MANY_CONNECTION_ID_WAITING_TO_RETIRE = 204, // Received a MAX STREAM DATA frame with errors. QUIC_INVALID_STOP_SENDING_FRAME_DATA = 108, // Error deframing PATH CHALLENGE or PATH RESPONSE frames. @@ -393,7 +398,6 @@ enum QuicErrorCode { QUIC_QPACK_DECOMPRESSION_FAILED = 126, // Obsolete generic QPACK encoder and decoder stream error codes. - // (Obsoleted by gfe2_reloadable_flag_quic_granular_qpack_error_codes.) QUIC_QPACK_ENCODER_STREAM_ERROR = 127, QUIC_QPACK_DECODER_STREAM_ERROR = 128, @@ -563,8 +567,27 @@ enum QuicErrorCode { // timeout. QUIC_MAX_AGE_TIMEOUT = 191, + // Decrypted a 0-RTT packet with a higher packet number than a 1-RTT packet. + QUIC_INVALID_0RTT_PACKET_NUMBER_OUT_OF_ORDER = 192, + + // Received PRIORITY_UPDATE frame with invalid payload. + QUIC_INVALID_PRIORITY_UPDATE = 193, + + // Maps to specific errors from the CRYPTO_ERROR range from + // https://quicwg.org/base-drafts/draft-ietf-quic-transport.html#name-transport-error-codes + // This attempts to choose a subset of the most interesting errors rather + // than mapping every possible CRYPTO_ERROR code. + QUIC_TLS_BAD_CERTIFICATE = 195, + QUIC_TLS_UNSUPPORTED_CERTIFICATE = 196, + QUIC_TLS_CERTIFICATE_REVOKED = 197, + QUIC_TLS_CERTIFICATE_EXPIRED = 198, + QUIC_TLS_CERTIFICATE_UNKNOWN = 199, + QUIC_TLS_INTERNAL_ERROR = 200, + QUIC_TLS_UNRECOGNIZED_NAME = 201, + QUIC_TLS_CERTIFICATE_REQUIRED = 202, + // No error. Used as bound while iterating. - QUIC_LAST_ERROR = 192, + QUIC_LAST_ERROR = 205, }; // 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 @@ -573,6 +596,9 @@ static_assert(static_cast<uint64_t>(QUIC_LAST_ERROR) <= static_cast<uint64_t>(std::numeric_limits<uint32_t>::max()), "QuicErrorCode exceeds four octets"); +// Convert TLS alert code to QuicErrorCode. +QUIC_EXPORT_PRIVATE QuicErrorCode TlsAlertToQuicErrorCode(uint8_t desc); + // Returns the name of the QuicRstStreamErrorCode as a char* QUIC_EXPORT_PRIVATE const char* QuicRstStreamErrorCodeToString( QuicRstStreamErrorCode error); diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_error_codes_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_error_codes_test.cc index ee4cacdbdf4..f72c150da14 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_error_codes_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_error_codes_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" +#include "quic/core/quic_error_codes.h" #include <cstdint> #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { @@ -78,7 +78,17 @@ TEST_F(QuicErrorCodesTest, QuicErrorCodeToTransportErrorCode) { if (ietf_error_code.is_transport_close) { QuicIetfTransportErrorCodes transport_error_code = static_cast<QuicIetfTransportErrorCodes>(ietf_error_code.error_code); - bool is_valid_transport_error_code = transport_error_code <= 0x0f; + bool is_transport_crypto_error_code = + transport_error_code >= 0x100 && transport_error_code <= 0x1ff; + if (is_transport_crypto_error_code) { + // Ensure that every QuicErrorCode that maps to a CRYPTO_ERROR code has + // a corresponding reverse mapping in TlsAlertToQuicErrorCode: + EXPECT_EQ( + internal_error_code, + TlsAlertToQuicErrorCode(transport_error_code - CRYPTO_ERROR_FIRST)); + } + bool is_valid_transport_error_code = + transport_error_code <= 0x0f || is_transport_crypto_error_code; EXPECT_TRUE(is_valid_transport_error_code) << internal_error_code_string; } else { // Non-transport errors are application errors, either HTTP/3 or QPACK. diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_flags_list.h b/chromium/net/third_party/quiche/src/quic/core/quic_flags_list.h index 72cd4bb38df..a3bc2251327 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_flags_list.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_flags_list.h @@ -1,92 +1,82 @@ -// Copyright (c) 2020 The Chromium Authors. All rights reserved. +// Copyright (c) 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This file is autogenerated by the QUICHE Copybara export script. -QUIC_FLAG(FLAGS_quic_reloadable_flag_http2_use_fast_huffman_encoder, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_abort_qpack_on_stream_close, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_abort_qpack_on_stream_reset, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_accept_empty_stream_frame_with_no_fin, true) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_ack_delay_alarm_granularity, false) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_add_stream_info_to_idle_close_detail, true) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_allocate_stream_sequencer_buffer_blocks_on_demand, false) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_allow_client_enabled_bbr_v2, false) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_bbr2_avoid_too_low_probe_bw_cwnd, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_bbr2_fewer_startup_round_trips, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_bbr2_no_exit_startup_on_loss_with_bw_growth, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_bbr2_startup_loss_exit_use_max_delivered, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_bbr2_support_max_bootstrap_cwnd, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_bbr2_use_post_inflight_to_detect_queuing, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_bbr2_use_tcp_inflight_hi_headroom, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_bbr2_bw_startup, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_bbr2_fewer_startup_round_trips, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_bbr2_reset_max_bytes_delivered, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_bbr2_use_bytes_delivered, true) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_can_send_ack_frequency, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_check_keys_before_writing, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_clean_up_spdy_session_destructor, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_close_connection_in_on_can_write_with_blocked_writer, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_connection_set_initial_self_address, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_close_connection_on_0rtt_packet_number_higher_than_1rtt, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_close_connection_with_too_many_outstanding_packets, true) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_conservative_bursts, false) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_conservative_cwnd_and_pacing_gains, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_copy_bbr_cwnd_to_bbr2, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_deallocate_message_right_after_sent, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_count_bytes_on_alternative_path_seperately, false) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_default_enable_5rto_blackhole_detection2, true) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_default_on_pto, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_default_to_2_rttvar, true) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_default_to_bbr, false) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_default_to_bbr_v2, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_delay_initial_ack, false) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_delay_initial_ack, true) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_disable_server_blackhole_detection, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_disable_version_draft_27, true) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_disable_version_draft_29, false) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_disable_version_q043, false) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_disable_version_q046, false) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_disable_version_q050, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_disable_version_t050, true) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_disable_version_t051, false) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_discard_initial_packet_with_key_dropped, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_do_not_clip_received_error_code, false) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_donot_reset_ideal_next_packet_send_time, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_enable_aead_limits, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_dont_defer_sending, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_enable_alps_client, false) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_enable_alps_server, false) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_enable_mtu_discovery_at_server, false) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_enable_server_on_wire_ping, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_enable_token_based_address_validation, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_enable_version_rfcv1, false) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_encrypted_control_frames, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_extract_x509_subject_using_certificate_view, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_fix_address_validation, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_fix_arm_pto_for_application_data, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_fix_http3_goaway_stream_id, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_fix_missing_initial_keys2, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_fix_out_of_order_sending2, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_fix_pto_pending_timer_count, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_fix_undecryptable_packets2, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_encrypted_goaway, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_fix_on_stream_reset, false) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_fix_willing_and_able_to_write2, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_give_sent_packet_to_debug_visitor_after_sent, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_goaway_with_max_stream_id, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_granular_qpack_error_codes, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_key_update_supported, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_let_connection_handle_pings, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_max_age_send_goaway, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_new_priority_update_frame, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_process_undecryptable_packets_after_async_decrypt_callback, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_record_received_min_ack_delay, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_reject_spdy_frames, true) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_reject_spdy_settings, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_goaway_with_max_stream_id, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_parse_accept_ch_frame, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_pass_path_response_to_validator, false) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_require_handshake_confirmation, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_round_up_tiny_bandwidth, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_send_goaway_with_connection_close, false) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_send_goaway_with_connection_close, true) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_send_path_response, false) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_send_timestamps, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_send_version_negotiation_for_short_connection_ids, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_split_up_send_rst_2, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_start_peer_migration_earlier, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_stop_sending_uses_ietf_error_code, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_send_tls_crypto_error_code, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_server_reverse_validate_new_path, false) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_single_ack_in_packet2, false) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_start_peer_migration_earlier, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_stateless_reset, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_stateless_reset_faster_random, false) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_testonly_default_false, false) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_testonly_default_true, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_tls_use_normalized_sni_for_cert_selectioon, false) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_tls_use_per_handshaker_proof_source, true) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_unified_iw_options, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_use_circular_deque_for_unacked_packets, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_use_encryption_level_context, false) -QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_use_fast_huffman_encoder, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_unify_stop_sending, false) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_update_packet_content_returns_connected, true) +QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_use_encryption_level_context, true) QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_use_write_or_buffer_data_at_level, false) QUIC_FLAG(FLAGS_quic_reloadable_flag_send_quic_fallback_server_config_on_leto_error, false) QUIC_FLAG(FLAGS_quic_restart_flag_dont_fetch_quic_private_keys_from_leto, false) +QUIC_FLAG(FLAGS_quic_restart_flag_http2_parse_priority_update_frame, true) +QUIC_FLAG(FLAGS_quic_restart_flag_quic_dispatcher_support_multiple_cid_per_connection_v2, true) QUIC_FLAG(FLAGS_quic_restart_flag_quic_enable_zero_rtt_for_tls_v2, true) QUIC_FLAG(FLAGS_quic_restart_flag_quic_offload_pacing_to_usps2, false) QUIC_FLAG(FLAGS_quic_restart_flag_quic_session_tickets_always_enabled, true) QUIC_FLAG(FLAGS_quic_restart_flag_quic_support_release_time_for_gso, false) QUIC_FLAG(FLAGS_quic_restart_flag_quic_testonly_default_false, false) QUIC_FLAG(FLAGS_quic_restart_flag_quic_testonly_default_true, true) +QUIC_FLAG(FLAGS_quic_restart_flag_quic_time_wait_list_support_multiple_cid_v2, true) +QUIC_FLAG(FLAGS_quic_restart_flag_quic_tls_prefer_server_cipher_and_curve_list, true) +QUIC_FLAG(FLAGS_quic_restart_flag_quic_use_reference_counted_sesssion_map, true) diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_flow_controller.cc b/chromium/net/third_party/quiche/src/quic/core/quic_flow_controller.cc index 625cf46777b..01fb72ce008 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_flow_controller.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_flow_controller.cc @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_flow_controller.h" +#include "quic/core/quic_flow_controller.h" #include <cstdint> -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_cat.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -25,7 +25,7 @@ std::string QuicFlowController::LogLabel() { if (is_connection_flow_controller_) { return "connection"; } - return quiche::QuicheStrCat("stream ", id_); + return absl::StrCat("stream ", id_); } QuicFlowController::QuicFlowController( @@ -53,8 +53,8 @@ QuicFlowController::QuicFlowController( session_flow_controller_(session_flow_controller), last_blocked_send_window_offset_(0), prev_window_update_time_(QuicTime::Zero()) { - DCHECK_LE(receive_window_size_, receive_window_size_limit_); - DCHECK_EQ( + QUICHE_DCHECK_LE(receive_window_size_, receive_window_size_limit_); + QUICHE_DCHECK_EQ( is_connection_flow_controller_, QuicUtils::GetInvalidStreamId(session_->transport_version()) == id_); @@ -99,8 +99,8 @@ void QuicFlowController::AddBytesSent(QuicByteCount bytes_sent) { // This is an error on our side, close the connection as soon as possible. connection_->CloseConnection( QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA, - quiche::QuicheStrCat(send_window_offset_ - (bytes_sent_ + bytes_sent), - "bytes over send window offset"), + absl::StrCat(send_window_offset_ - (bytes_sent_ + bytes_sent), + "bytes over send window offset"), ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); return; } @@ -198,7 +198,7 @@ void QuicFlowController::MaybeSendWindowUpdate() { // Send WindowUpdate to increase receive window if // (receive window offset - consumed bytes) < (max window / 2). // This is behaviour copied from SPDY. - DCHECK_LE(bytes_consumed_, receive_window_offset_); + QUICHE_DCHECK_LE(bytes_consumed_, receive_window_offset_); QuicStreamOffset available_window = receive_window_offset_ - bytes_consumed_; QuicByteCount threshold = WindowUpdateThreshold(); @@ -294,7 +294,7 @@ uint64_t QuicFlowController::SendWindowSize() const { } void QuicFlowController::UpdateReceiveWindowSize(QuicStreamOffset size) { - DCHECK_LE(size, receive_window_size_limit_); + QUICHE_DCHECK_LE(size, receive_window_size_limit_); QUIC_DVLOG(1) << ENDPOINT << "UpdateReceiveWindowSize for " << LogLabel() << ": " << size; if (receive_window_size_ != receive_window_offset_) { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_flow_controller.h b/chromium/net/third_party/quiche/src/quic/core/quic_flow_controller.h index 1a45821f69e..3998081736d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_flow_controller.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_flow_controller.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_CORE_QUIC_FLOW_CONTROLLER_H_ #define QUICHE_QUIC_CORE_QUIC_FLOW_CONTROLLER_H_ -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -77,6 +77,8 @@ class QUIC_EXPORT_PRIVATE QuicFlowController // Returns the current available send window. QuicByteCount SendWindowSize() const; + QuicByteCount receive_window_size() const { return receive_window_size_; } + // Returns whether a BLOCKED frame should be sent. bool ShouldSendBlocked(); @@ -100,7 +102,7 @@ class QUIC_EXPORT_PRIVATE QuicFlowController } void set_receive_window_size_limit(QuicByteCount receive_window_size_limit) { - DCHECK_GE(receive_window_size_limit, receive_window_size_limit_); + QUICHE_DCHECK_GE(receive_window_size_limit, receive_window_size_limit_); receive_window_size_limit_ = receive_window_size_limit; } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_flow_controller_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_flow_controller_test.cc index 5a275700502..4c2ce45860d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_flow_controller_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_flow_controller_test.cc @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_flow_controller.h" +#include "quic/core/quic_flow_controller.h" #include <memory> #include <utility> -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_flow_controller_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_cat.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_flow_controller_peer.h" +#include "quic/test_tools/quic_sent_packet_manager_peer.h" +#include "quic/test_tools/quic_test_utils.h" using testing::_; using testing::Invoke; @@ -95,9 +95,9 @@ TEST_F(QuicFlowControllerTest, SendingBytes) { // Try to send more bytes, violating flow control. EXPECT_CALL(*connection_, CloseConnection(QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA, _, _)); - EXPECT_QUIC_BUG(flow_controller_->AddBytesSent(send_window_ * 10), - quiche::QuicheStrCat("Trying to send an extra ", - send_window_ * 10, " bytes")); + EXPECT_QUIC_BUG( + flow_controller_->AddBytesSent(send_window_ * 10), + absl::StrCat("Trying to send an extra ", send_window_ * 10, " bytes")); EXPECT_TRUE(flow_controller_->IsBlocked()); EXPECT_EQ(0u, flow_controller_->SendWindowSize()); } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_framer.cc b/chromium/net/third_party/quiche/src/quic/core/quic_framer.cc index 90f4370b063..fdccef9c72f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_framer.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_framer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_framer.h" +#include "quic/core/quic_framer.h" #include <cstddef> #include <cstdint> @@ -16,40 +16,40 @@ #include "absl/base/optimization.h" #include "absl/strings/escaping.h" #include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_framer.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_data_reader.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_socket_address_coder.h" -#include "net/third_party/quiche/src/quic/core/quic_stream_frame_data_producer.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_client_stats.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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_map_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_stack_trace.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/crypto_framer.h" +#include "quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/crypto_handshake_message.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/crypto_utils.h" +#include "quic/core/crypto/null_decrypter.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/frames/quic_ack_frequency_frame.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_data_reader.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_socket_address_coder.h" +#include "quic/core/quic_stream_frame_data_producer.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_client_stats.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_map_util.h" +#include "quic/platform/api/quic_stack_trace.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { @@ -194,7 +194,7 @@ uint8_t PacketNumberLengthToOnWireValue( } QuicPacketNumberLength GetShortHeaderPacketNumberLength(uint8_t type) { - DCHECK(!(type & FLAGS_LONG_HEADER)); + QUICHE_DCHECK(!(type & FLAGS_LONG_HEADER)); return static_cast<QuicPacketNumberLength>((type & 0x03) + 1); } @@ -217,7 +217,7 @@ uint8_t LongHeaderTypeToOnWireValue(QuicLongHeaderType type) { } bool GetLongHeaderType(uint8_t type, QuicLongHeaderType* long_header_type) { - DCHECK((type & FLAGS_LONG_HEADER)); + QUICHE_DCHECK((type & FLAGS_LONG_HEADER)); switch ((type & 0x30) >> 4) { case 0: *long_header_type = INITIAL; @@ -390,9 +390,8 @@ std::string GenerateErrorString(std::string initial_error_string, // the error value in the string. return initial_error_string; } - return quiche::QuicheStrCat( - std::to_string(static_cast<unsigned>(quic_error_code)), ":", - initial_error_string); + return absl::StrCat(std::to_string(static_cast<unsigned>(quic_error_code)), + ":", initial_error_string); } } // namespace @@ -430,9 +429,9 @@ QuicFramer::QuicFramer(const ParsedQuicVersionVector& supported_versions, peer_ack_delay_exponent_(kDefaultAckDelayExponent), local_ack_delay_exponent_(kDefaultAckDelayExponent), current_received_frame_type_(0) { - DCHECK(!supported_versions.empty()); + QUICHE_DCHECK(!supported_versions.empty()); version_ = supported_versions_[0]; - DCHECK(version_.IsKnown()) + QUICHE_DCHECK(version_.IsKnown()) << ParsedQuicVersionVectorToString(supported_versions_); } @@ -705,12 +704,12 @@ size_t QuicFramer::GetRetransmittableControlFrameSize( case MESSAGE_FRAME: case CRYPTO_FRAME: case NUM_FRAME_TYPES: - DCHECK(false); + QUICHE_DCHECK(false); return 0; } // Not reachable, but some Chrome compilers can't figure that out. *sigh* - DCHECK(false); + QUICHE_DCHECK(false); return 0; } @@ -887,8 +886,7 @@ size_t QuicFramer::BuildDataPacket(const QuicPacketHeader& header, char* buffer, size_t packet_length, EncryptionLevel level) { - QUIC_BUG_IF(header.version_flag && - VersionHasIetfInvariantHeader(transport_version()) && + QUIC_BUG_IF(header.version_flag && version().HasIetfInvariantHeader() && header.long_packet_type == RETRY && !frames.empty()) << "IETF RETRY packets cannot contain frames " << header; QuicDataWriter writer(packet_length, buffer); @@ -1289,10 +1287,22 @@ std::unique_ptr<QuicEncryptedPacket> QuicFramer::BuildIetfStatelessResetPacket( if (!writer.WriteUInt8(type)) { return nullptr; } - // Append random bytes. - if (!writer.WriteRandomBytes(QuicRandom::GetInstance(), - kMinRandomBytesLengthInStatelessReset)) { - return nullptr; + + // Append random bytes. This randomness only exists to prevent middleboxes + // from comparing the entire packet to a known value. Therefore it has no + // cryptographic use, and does not need a secure cryptographic pseudo-random + // number generator. It's therefore safe to use WriteInsecureRandomBytes here. + if (GetQuicReloadableFlag(quic_stateless_reset_faster_random)) { + QUIC_RELOADABLE_FLAG_COUNT(quic_stateless_reset_faster_random); + if (!writer.WriteInsecureRandomBytes( + QuicRandom::GetInstance(), kMinRandomBytesLengthInStatelessReset)) { + return nullptr; + } + } else { + if (!writer.WriteRandomBytes(QuicRandom::GetInstance(), + kMinRandomBytesLengthInStatelessReset)) { + return nullptr; + } } // Append stateless reset token. @@ -1312,7 +1322,7 @@ std::unique_ptr<QuicEncryptedPacket> QuicFramer::BuildVersionNegotiationPacket( const ParsedQuicVersionVector& versions) { QUIC_CODE_COUNT(quic_build_version_negotiation); if (use_length_prefix) { - DCHECK(ietf_quic); + QUICHE_DCHECK(ietf_quic); QUIC_CODE_COUNT(quic_build_version_negotiation_ietf); } else if (ietf_quic) { QUIC_CODE_COUNT(quic_build_version_negotiation_old_ietf); @@ -1348,11 +1358,11 @@ std::unique_ptr<QuicEncryptedPacket> QuicFramer::BuildVersionNegotiationPacket( } // The GQUIC encoding does not support encoding client connection IDs. - DCHECK(client_connection_id.IsEmpty()); + QUICHE_DCHECK(client_connection_id.IsEmpty()); // The GQUIC encoding does not support length-prefixed connection IDs. - DCHECK(!use_length_prefix); + QUICHE_DCHECK(!use_length_prefix); - DCHECK(!wire_versions.empty()); + QUICHE_DCHECK(!wire_versions.empty()); size_t len = kPublicFlagsSize + server_connection_id.length() + wire_versions.size() * kQuicVersionSize; std::unique_ptr<char[]> buffer(new char[len]); @@ -1391,7 +1401,7 @@ QuicFramer::BuildIetfVersionNegotiationPacket( << server_connection_id << " client_connection_id " << client_connection_id << " versions " << ParsedQuicVersionVectorToString(versions); - DCHECK(!versions.empty()); + QUICHE_DCHECK(!versions.empty()); size_t len = kPacketHeaderTypeSize + kConnectionIdLengthSize + client_connection_id.length() + server_connection_id.length() + (versions.size() + 1) * kQuicVersionSize; @@ -1439,8 +1449,7 @@ bool QuicFramer::ProcessPacketInternal(const QuicEncryptedPacket& packet) { bool packet_has_ietf_packet_header = false; if (infer_packet_header_type_from_version_) { - packet_has_ietf_packet_header = - VersionHasIetfInvariantHeader(version_.transport_version); + packet_has_ietf_packet_header = version_.HasIetfInvariantHeader(); } else if (!reader.IsDoneReading()) { uint8_t type = reader.PeekByte(); packet_has_ietf_packet_header = QuicUtils::IsIetfPacketHeader(type); @@ -1453,10 +1462,10 @@ bool QuicFramer::ProcessPacketInternal(const QuicEncryptedPacket& packet) { QuicPacketHeader header; if (!ProcessPublicHeader(&reader, packet_has_ietf_packet_header, &header)) { - DCHECK_NE("", detailed_error_); + QUICHE_DCHECK_NE("", detailed_error_); QUIC_DVLOG(1) << ENDPOINT << "Unable to process public header. Error: " << detailed_error_; - DCHECK_NE("", detailed_error_); + QUICHE_DCHECK_NE("", detailed_error_); RecordDroppedPacketReason(DroppedPacketReason::INVALID_PUBLIC_HEADER); return RaiseError(QUIC_INVALID_PACKET_HEADER); } @@ -1529,7 +1538,7 @@ bool QuicFramer::ProcessPacketInternal(const QuicEncryptedPacket& packet) { bool QuicFramer::ProcessVersionNegotiationPacket( QuicDataReader* reader, const QuicPacketHeader& header) { - DCHECK_EQ(Perspective::IS_CLIENT, perspective_); + QUICHE_DCHECK_EQ(Perspective::IS_CLIENT, perspective_); QuicVersionNegotiationPacket packet( GetServerConnectionIdAsRecipient(header, perspective_)); @@ -1557,10 +1566,14 @@ bool QuicFramer::ProcessVersionNegotiationPacket( bool QuicFramer::ProcessRetryPacket(QuicDataReader* reader, const QuicPacketHeader& header) { - DCHECK_EQ(Perspective::IS_CLIENT, perspective_); + QUICHE_DCHECK_EQ(Perspective::IS_CLIENT, perspective_); + if (drop_incoming_retry_packets_) { + QUIC_DLOG(INFO) << "Ignoring received RETRY packet"; + return true; + } - if (version_.HasRetryIntegrityTag()) { - DCHECK(version_.HasLengthPrefixedConnectionIds()) << version_; + if (version_.UsesTls()) { + QUICHE_DCHECK(version_.HasLengthPrefixedConnectionIds()) << version_; const size_t bytes_remaining = reader->BytesRemaining(); if (bytes_remaining <= kRetryIntegrityTagLength) { set_detailed_error("Retry packet too short to parse integrity tag."); @@ -1568,7 +1581,7 @@ bool QuicFramer::ProcessRetryPacket(QuicDataReader* reader, } const size_t retry_token_length = bytes_remaining - kRetryIntegrityTagLength; - DCHECK_GT(retry_token_length, 0u); + QUICHE_DCHECK_GT(retry_token_length, 0u); absl::string_view retry_token; if (!reader->ReadStringPiece(&retry_token, retry_token_length)) { set_detailed_error("Failed to read retry token."); @@ -1576,7 +1589,7 @@ bool QuicFramer::ProcessRetryPacket(QuicDataReader* reader, } absl::string_view retry_without_tag = reader->PreviouslyReadPayload(); absl::string_view integrity_tag = reader->ReadRemainingPayload(); - DCHECK_EQ(integrity_tag.length(), kRetryIntegrityTagLength); + QUICHE_DCHECK_EQ(integrity_tag.length(), kRetryIntegrityTagLength); visitor_->OnRetryPacket(EmptyQuicConnectionId(), header.source_connection_id, retry_token, integrity_tag, retry_without_tag); @@ -1633,7 +1646,7 @@ void QuicFramer::MaybeProcessCoalescedPacket( } absl::string_view remaining_data = encrypted_reader.PeekRemainingPayload(); - DCHECK_EQ(remaining_data.length(), remaining_bytes_length); + QUICHE_DCHECK_EQ(remaining_data.length(), remaining_bytes_length); const char* coalesced_data = remaining_data.data() + header.remaining_packet_length; @@ -1707,8 +1720,8 @@ bool QuicFramer::ProcessIetfDataPacket(QuicDataReader* encrypted_reader, const QuicEncryptedPacket& packet, char* decrypted_buffer, size_t buffer_length) { - DCHECK_NE(GOOGLE_QUIC_PACKET, header->form); - DCHECK(!header->has_possible_stateless_reset_token); + QUICHE_DCHECK_NE(GOOGLE_QUIC_PACKET, header->form); + QUICHE_DCHECK(!header->has_possible_stateless_reset_token); header->length_length = VARIABLE_LENGTH_INTEGER_LENGTH_0; header->remaining_packet_length = 0; if (header->form == IETF_QUIC_SHORT_HEADER_PACKET && @@ -1734,10 +1747,10 @@ bool QuicFramer::ProcessIetfDataPacket(QuicDataReader* encrypted_reader, QuicPacketNumber base_packet_number; if (header->form == IETF_QUIC_SHORT_HEADER_PACKET || header->long_packet_type != VERSION_NEGOTIATION) { - DCHECK(header->form == IETF_QUIC_SHORT_HEADER_PACKET || - header->long_packet_type == INITIAL || - header->long_packet_type == HANDSHAKE || - header->long_packet_type == ZERO_RTT_PROTECTED); + QUICHE_DCHECK(header->form == IETF_QUIC_SHORT_HEADER_PACKET || + header->long_packet_type == INITIAL || + header->long_packet_type == HANDSHAKE || + header->long_packet_type == ZERO_RTT_PROTECTED); // Process packet number. if (supports_multiple_packet_number_spaces_) { PacketNumberSpace pn_space = GetPacketNumberSpace(*header); @@ -1780,7 +1793,7 @@ bool QuicFramer::ProcessIetfDataPacket(QuicDataReader* encrypted_reader, QuicEncryptedPacket(encrypted_reader->FullPayload()), decryption_level, has_decryption_key); RecordDroppedPacketReason(DroppedPacketReason::DECRYPTION_FAILURE); - set_detailed_error(quiche::QuicheStrCat( + set_detailed_error(absl::StrCat( "Unable to decrypt ", EncryptionLevelToString(decryption_level), " header protection", has_decryption_key ? "" : " (missing key)", ".")); @@ -1832,8 +1845,9 @@ bool QuicFramer::ProcessIetfDataPacket(QuicDataReader* encrypted_reader, size_t decrypted_length = 0; EncryptionLevel decrypted_level; - if (!DecryptPayload(encrypted, associated_data, *header, decrypted_buffer, - buffer_length, &decrypted_length, &decrypted_level)) { + if (!DecryptPayload(packet.length(), encrypted, associated_data, *header, + decrypted_buffer, buffer_length, &decrypted_length, + &decrypted_level)) { if (IsIetfStatelessResetPacket(*header)) { // This is a stateless reset packet. QuicIetfStatelessResetPacket packet( @@ -1847,7 +1861,7 @@ bool QuicFramer::ProcessIetfDataPacket(QuicDataReader* encrypted_reader, visitor_->OnUndecryptablePacket( QuicEncryptedPacket(encrypted_reader->FullPayload()), decryption_level, has_decryption_key); - set_detailed_error(quiche::QuicheStrCat( + set_detailed_error(absl::StrCat( "Unable to decrypt ", EncryptionLevelToString(decryption_level), " payload with reconstructed packet number ", header->packet_number.ToString(), " (largest decrypted was ", @@ -1887,8 +1901,9 @@ bool QuicFramer::ProcessIetfDataPacket(QuicDataReader* encrypted_reader, current_received_frame_type_ = 0; if (!ProcessIetfFrameData(&reader, *header)) { current_received_frame_type_ = 0; - DCHECK_NE(QUIC_NO_ERROR, error_); // ProcessIetfFrameData sets the error. - DCHECK_NE("", detailed_error_); + QUICHE_DCHECK_NE(QUIC_NO_ERROR, + error_); // ProcessIetfFrameData sets the error. + QUICHE_DCHECK_NE("", detailed_error_); QUIC_DLOG(WARNING) << ENDPOINT << "Unable to process frame data. Error: " << detailed_error_; return false; @@ -1896,8 +1911,9 @@ bool QuicFramer::ProcessIetfDataPacket(QuicDataReader* encrypted_reader, current_received_frame_type_ = 0; } else { if (!ProcessFrameData(&reader, *header)) { - DCHECK_NE(QUIC_NO_ERROR, error_); // ProcessFrameData sets the error. - DCHECK_NE("", detailed_error_); + QUICHE_DCHECK_NE(QUIC_NO_ERROR, + error_); // ProcessFrameData sets the error. + QUICHE_DCHECK_NE("", detailed_error_); QUIC_DLOG(WARNING) << ENDPOINT << "Unable to process frame data. Error: " << detailed_error_; return false; @@ -1914,7 +1930,7 @@ bool QuicFramer::ProcessDataPacket(QuicDataReader* encrypted_reader, char* decrypted_buffer, size_t buffer_length) { if (!ProcessUnauthenticatedHeader(encrypted_reader, header)) { - DCHECK_NE("", detailed_error_); + QUICHE_DCHECK_NE("", detailed_error_); QUIC_DVLOG(1) << ENDPOINT << "Unable to process packet header. Stopping parsing. Error: " @@ -1934,8 +1950,9 @@ bool QuicFramer::ProcessDataPacket(QuicDataReader* encrypted_reader, size_t decrypted_length = 0; EncryptionLevel decrypted_level; - if (!DecryptPayload(encrypted, associated_data, *header, decrypted_buffer, - buffer_length, &decrypted_length, &decrypted_level)) { + if (!DecryptPayload(packet.length(), encrypted, associated_data, *header, + decrypted_buffer, buffer_length, &decrypted_length, + &decrypted_level)) { const EncryptionLevel decryption_level = decrypter_level_; // This version uses trial decryption so we always report to our visitor // that we are not certain we have the correct decryption key. @@ -1944,9 +1961,9 @@ bool QuicFramer::ProcessDataPacket(QuicDataReader* encrypted_reader, QuicEncryptedPacket(encrypted_reader->FullPayload()), decryption_level, has_decryption_key); RecordDroppedPacketReason(DroppedPacketReason::DECRYPTION_FAILURE); - set_detailed_error(quiche::QuicheStrCat( - "Unable to decrypt ", EncryptionLevelToString(decryption_level), - " payload.")); + set_detailed_error(absl::StrCat("Unable to decrypt ", + EncryptionLevelToString(decryption_level), + " payload.")); return RaiseError(QUIC_DECRYPTION_FAILURE); } @@ -1974,8 +1991,9 @@ bool QuicFramer::ProcessDataPacket(QuicDataReader* encrypted_reader, // Handle the payload. if (!ProcessFrameData(&reader, *header)) { - DCHECK_NE(QUIC_NO_ERROR, error_); // ProcessFrameData sets the error. - DCHECK_NE("", detailed_error_); + QUICHE_DCHECK_NE(QUIC_NO_ERROR, + error_); // ProcessFrameData sets the error. + QUICHE_DCHECK_NE("", detailed_error_); QUIC_DLOG(WARNING) << ENDPOINT << "Unable to process frame data. Error: " << detailed_error_; return false; @@ -2076,14 +2094,14 @@ EncryptionLevel QuicFramer::GetEncryptionLevelToSendApplicationData() const { if (HasEncrypterOfEncryptionLevel(ENCRYPTION_FORWARD_SECURE)) { return ENCRYPTION_FORWARD_SECURE; } - DCHECK(HasEncrypterOfEncryptionLevel(ENCRYPTION_ZERO_RTT)); + QUICHE_DCHECK(HasEncrypterOfEncryptionLevel(ENCRYPTION_ZERO_RTT)); return ENCRYPTION_ZERO_RTT; } bool QuicFramer::AppendPacketHeader(const QuicPacketHeader& header, QuicDataWriter* writer, size_t* length_field_offset) { - if (VersionHasIetfInvariantHeader(transport_version())) { + if (version().HasIetfInvariantHeader()) { return AppendIetfPacketHeader(header, writer, length_field_offset); } QUIC_DVLOG(1) << ENDPOINT << "Appending header: " << header; @@ -2099,7 +2117,7 @@ bool QuicFramer::AppendPacketHeader(const QuicPacketHeader& header, << kPublicHeaderSequenceNumberShift; if (header.nonce != nullptr) { - DCHECK_EQ(Perspective::IS_SERVER, perspective_); + QUICHE_DCHECK_EQ(Perspective::IS_SERVER, perspective_); public_flags |= PACKET_PUBLIC_FLAGS_NONCE; } @@ -2107,8 +2125,8 @@ bool QuicFramer::AppendPacketHeader(const QuicPacketHeader& header, GetServerConnectionIdAsSender(header, perspective_); QuicConnectionIdIncluded server_connection_id_included = GetServerConnectionIdIncludedAsSender(header, perspective_); - DCHECK_EQ(CONNECTION_ID_ABSENT, - GetClientConnectionIdIncludedAsSender(header, perspective_)) + QUICHE_DCHECK_EQ(CONNECTION_ID_ABSENT, + GetClientConnectionIdIncludedAsSender(header, perspective_)) << ENDPOINT << ParsedQuicVersionToString(version_) << " invalid header: " << header; @@ -2124,7 +2142,7 @@ bool QuicFramer::AppendPacketHeader(const QuicPacketHeader& header, server_connection_id, transport_version())) << "AppendPacketHeader: attempted to use connection ID " << server_connection_id << " which is invalid with version " - << QuicVersionToString(transport_version()); + << version(); public_flags |= PACKET_PUBLIC_FLAGS_8BYTE_CONNECTION_ID; if (perspective_ == Perspective::IS_CLIENT) { @@ -2139,7 +2157,7 @@ bool QuicFramer::AppendPacketHeader(const QuicPacketHeader& header, last_serialized_server_connection_id_ = server_connection_id; if (header.version_flag) { - DCHECK_EQ(Perspective::IS_CLIENT, perspective_); + QUICHE_DCHECK_EQ(Perspective::IS_CLIENT, perspective_); QuicVersionLabel version_label = CreateQuicVersionLabel(version_); if (!writer->WriteUInt32(version_label)) { return false; @@ -2187,14 +2205,13 @@ bool QuicFramer::AppendIetfPacketHeader(const QuicPacketHeader& header, QUIC_BUG_IF(!QuicUtils::IsConnectionIdValidForVersion(server_connection_id, transport_version())) << "AppendIetfPacketHeader: attempted to use connection ID " - << server_connection_id << " which is invalid with version " - << QuicVersionToString(transport_version()); + << server_connection_id << " which is invalid with version " << version(); if (!AppendIetfHeaderTypeByte(header, writer)) { return false; } if (header.version_flag) { - DCHECK_NE(VERSION_NEGOTIATION, header.long_packet_type) + QUICHE_DCHECK_NE(VERSION_NEGOTIATION, header.long_packet_type) << "QuicFramer::AppendIetfPacketHeader does not support sending " "version negotiation packets, use " "QuicFramer::BuildVersionNegotiationPacket instead " @@ -2232,8 +2249,8 @@ bool QuicFramer::AppendIetfPacketHeader(const QuicPacketHeader& header, if (QuicVersionHasLongHeaderLengths(transport_version()) && header.version_flag) { if (header.long_packet_type == INITIAL) { - DCHECK_NE(VARIABLE_LENGTH_INTEGER_LENGTH_0, - header.retry_token_length_length) + QUICHE_DCHECK_NE(VARIABLE_LENGTH_INTEGER_LENGTH_0, + header.retry_token_length_length) << ENDPOINT << ParsedQuicVersionToString(version_) << " bad retry token length length in header: " << header; // Write retry token length. @@ -2268,9 +2285,9 @@ bool QuicFramer::AppendIetfPacketHeader(const QuicPacketHeader& header, } if (header.nonce != nullptr) { - DCHECK(header.version_flag); - DCHECK_EQ(ZERO_RTT_PROTECTED, header.long_packet_type); - DCHECK_EQ(Perspective::IS_SERVER, perspective_); + QUICHE_DCHECK(header.version_flag); + QUICHE_DCHECK_EQ(ZERO_RTT_PROTECTED, header.long_packet_type); + QUICHE_DCHECK_EQ(Perspective::IS_SERVER, perspective_); if (!writer->WriteBytes(header.nonce, kDiversificationNonceSize)) { return false; } @@ -2422,7 +2439,7 @@ bool QuicFramer::ProcessPublicHeader(QuicDataReader* reader, // static QuicPacketNumberLength QuicFramer::GetMinPacketNumberLength( QuicPacketNumber packet_number) { - DCHECK(packet_number.IsInitialized()); + QUICHE_DCHECK(packet_number.IsInitialized()); if (packet_number < QuicPacketNumber(1 << (PACKET_1BYTE_PACKET_NUMBER * 8))) { return PACKET_1BYTE_PACKET_NUMBER; } else if (packet_number < @@ -2713,12 +2730,12 @@ bool QuicFramer::ProcessIetfPacketHeader(QuicDataReader* reader, std::string detailed_error; QuicErrorCode parse_result = QuicFramer::ParsePublicHeader( reader, expected_destination_connection_id_length, - VersionHasIetfInvariantHeader(version_.transport_version), - &header->type_byte, &header->form, &header->version_flag, - &has_length_prefix, &version_label, &header->version, - &header->destination_connection_id, &header->source_connection_id, - &header->long_packet_type, &header->retry_token_length_length, - &header->retry_token, &detailed_error); + version_.HasIetfInvariantHeader(), &header->type_byte, &header->form, + &header->version_flag, &has_length_prefix, &version_label, + &header->version, &header->destination_connection_id, + &header->source_connection_id, &header->long_packet_type, + &header->retry_token_length_length, &header->retry_token, + &detailed_error); if (parse_result != QUIC_NO_ERROR) { set_detailed_error(detailed_error); return false; @@ -2727,7 +2744,7 @@ bool QuicFramer::ProcessIetfPacketHeader(QuicDataReader* reader, header->source_connection_id_included = header->version_flag ? CONNECTION_ID_PRESENT : CONNECTION_ID_ABSENT; if (header->source_connection_id_included == CONNECTION_ID_ABSENT) { - DCHECK(header->source_connection_id.IsEmpty()); + QUICHE_DCHECK(header->source_connection_id.IsEmpty()); if (perspective_ == Perspective::IS_CLIENT) { header->source_connection_id = last_serialized_server_connection_id_; } else { @@ -2817,7 +2834,7 @@ bool QuicFramer::ProcessIetfPacketHeader(QuicDataReader* reader, if (header->source_connection_id_included == CONNECTION_ID_ABSENT) { if (!header->source_connection_id.IsEmpty()) { - DCHECK(!version_.SupportsClientConnectionIds()); + QUICHE_DCHECK(!version_.SupportsClientConnectionIds()); set_detailed_error("Client connection ID not supported in this version."); return false; } @@ -2850,7 +2867,7 @@ bool QuicFramer::ProcessAndCalculatePacketNumber( bool QuicFramer::ProcessFrameData(QuicDataReader* reader, const QuicPacketHeader& header) { - DCHECK(!VersionHasIetfQuicFrames(version_.transport_version)) + QUICHE_DCHECK(!VersionHasIetfQuicFrames(version_.transport_version)) << "IETF QUIC Framing negotiated but attempting to process frames as " "non-IETF QUIC."; if (reader->IsDoneReading()) { @@ -3083,7 +3100,7 @@ bool QuicFramer::ProcessFrameData(QuicDataReader* reader, bool QuicFramer::ProcessIetfFrameData(QuicDataReader* reader, const QuicPacketHeader& header) { - DCHECK(VersionHasIetfQuicFrames(version_.transport_version)) + QUICHE_DCHECK(VersionHasIetfQuicFrames(version_.transport_version)) << "Attempt to process frames as IETF frames but version (" << version_.transport_version << ") does not support IETF Framing."; @@ -3456,7 +3473,7 @@ bool ExtractBit(uint8_t flags, uint8_t offset) { // Set |num_bits|, offset by |offset| to |val| in |flags|. void SetBits(uint8_t* flags, uint8_t val, uint8_t num_bits, uint8_t offset) { - DCHECK_LE(val, GetMaskFromNumBits(num_bits)); + QUICHE_DCHECK_LE(val, GetMaskFromNumBits(num_bits)); *flags |= val << offset; } @@ -3574,7 +3591,7 @@ bool QuicFramer::ProcessIetfStreamFrame(QuicDataReader* reader, return false; } frame->data_buffer = data.data(); - DCHECK_EQ(frame->data_length, data.length()); + QUICHE_DCHECK_EQ(frame->data_length, data.length()); return true; } @@ -3713,11 +3730,10 @@ bool QuicFramer::ProcessAckFrame(QuicDataReader* reader, uint8_t frame_type) { first_ack_block_underflow = true; } if (first_ack_block_underflow) { - set_detailed_error( - quiche::QuicheStrCat("Underflow with first ack block length ", - first_block_length, " largest acked is ", - largest_acked, ".") - .c_str()); + set_detailed_error(absl::StrCat("Underflow with first ack block length ", + first_block_length, " largest acked is ", + largest_acked, ".") + .c_str()); return false; } @@ -3749,11 +3765,11 @@ bool QuicFramer::ProcessAckFrame(QuicDataReader* reader, uint8_t frame_type) { ack_block_underflow = true; } if (ack_block_underflow) { - set_detailed_error( - quiche::QuicheStrCat("Underflow with ack block length ", - current_block_length, ", end of block is ", - first_received - gap, ".") - .c_str()); + set_detailed_error(absl::StrCat("Underflow with ack block length ", + current_block_length, + ", end of block is ", + first_received - gap, ".") + .c_str()); return false; } @@ -3807,9 +3823,9 @@ bool QuicFramer::ProcessTimestampsInAckFrame(uint8_t num_received_packets, if (largest_acked.ToUint64() <= delta_from_largest_observed) { set_detailed_error( - quiche::QuicheStrCat("delta_from_largest_observed too high: ", - delta_from_largest_observed, - ", largest_acked: ", largest_acked.ToUint64()) + absl::StrCat("delta_from_largest_observed too high: ", + delta_from_largest_observed, + ", largest_acked: ", largest_acked.ToUint64()) .c_str()); return false; } @@ -3835,9 +3851,9 @@ bool QuicFramer::ProcessTimestampsInAckFrame(uint8_t num_received_packets, } if (largest_acked.ToUint64() <= delta_from_largest_observed) { set_detailed_error( - quiche::QuicheStrCat("delta_from_largest_observed too high: ", - delta_from_largest_observed, - ", largest_acked: ", largest_acked.ToUint64()) + absl::StrCat("delta_from_largest_observed too high: ", + delta_from_largest_observed, + ", largest_acked: ", largest_acked.ToUint64()) .c_str()); return false; } @@ -3923,11 +3939,10 @@ bool QuicFramer::ProcessIetfAckFrame(QuicDataReader* reader, // error if the value is wrong. if (ack_block_value + first_sending_packet_number_.ToUint64() > largest_acked) { - set_detailed_error( - quiche::QuicheStrCat("Underflow with first ack block length ", - ack_block_value + 1, " largest acked is ", - largest_acked, ".") - .c_str()); + set_detailed_error(absl::StrCat("Underflow with first ack block length ", + ack_block_value + 1, " largest acked is ", + largest_acked, ".") + .c_str()); return false; } @@ -3957,9 +3972,8 @@ bool QuicFramer::ProcessIetfAckFrame(QuicDataReader* reader, // The test is written this way to detect wrap-arounds. if ((gap_block_value + 2) > block_low) { set_detailed_error( - quiche::QuicheStrCat("Underflow with gap block length ", - gap_block_value + 1, - " previous ack block start is ", block_low, ".") + absl::StrCat("Underflow with gap block length ", gap_block_value + 1, + " previous ack block start is ", block_low, ".") .c_str()); return false; } @@ -3979,9 +3993,8 @@ bool QuicFramer::ProcessIetfAckFrame(QuicDataReader* reader, if (ack_block_value + first_sending_packet_number_.ToUint64() > (block_high - 1)) { set_detailed_error( - quiche::QuicheStrCat("Underflow with ack block length ", - ack_block_value + 1, " latest ack block end is ", - block_high - 1, ".") + absl::StrCat("Underflow with ack block length ", ack_block_value + 1, + " latest ack block end is ", block_high - 1, ".") .c_str()); return false; } @@ -4087,15 +4100,6 @@ bool QuicFramer::ProcessConnectionCloseFrame(QuicDataReader* reader, return false; } - if (GetQuicReloadableFlag(quic_do_not_clip_received_error_code)) { - QUIC_CODE_COUNT_N(quic_do_not_clip_received_error_code, 1, 2); - } else { - if (error_code >= QUIC_LAST_ERROR) { - // Ignore invalid QUIC error code if any. - error_code = QUIC_LAST_ERROR; - } - } - // For Google QUIC connection closes, |wire_error_code| and |quic_error_code| // must have the same value. frame->wire_error_code = error_code; @@ -4119,14 +4123,6 @@ bool QuicFramer::ProcessGoAwayFrame(QuicDataReader* reader, return false; } - if (GetQuicReloadableFlag(quic_do_not_clip_received_error_code)) { - QUIC_CODE_COUNT_N(quic_do_not_clip_received_error_code, 2, 2); - } else { - if (error_code >= QUIC_LAST_ERROR) { - // Ignore invalid QUIC error code if any. - error_code = QUIC_LAST_ERROR; - } - } frame->error_code = static_cast<QuicErrorCode>(error_code); uint32_t stream_id; @@ -4163,7 +4159,7 @@ bool QuicFramer::ProcessWindowUpdateFrame(QuicDataReader* reader, bool QuicFramer::ProcessBlockedFrame(QuicDataReader* reader, QuicBlockedFrame* frame) { - DCHECK(!VersionHasIetfQuicFrames(version_.transport_version)) + QUICHE_DCHECK(!VersionHasIetfQuicFrames(version_.transport_version)) << "Attempt to process non-IETF QUIC frames in an IETF QUIC version."; if (!reader->ReadUInt32(&frame->stream_id)) { @@ -4181,7 +4177,7 @@ void QuicFramer::ProcessPaddingFrame(QuicDataReader* reader, uint8_t next_byte; while (!reader->IsDoneReading() && reader->PeekByte() == 0x00) { reader->ReadBytes(&next_byte, 1); - DCHECK_EQ(0x00, next_byte); + QUICHE_DCHECK_EQ(0x00, next_byte); ++frame->num_padding_bytes; } } @@ -4238,9 +4234,9 @@ absl::string_view QuicFramer::GetAssociatedDataFromEncryptedPacket( void QuicFramer::SetDecrypter(EncryptionLevel level, std::unique_ptr<QuicDecrypter> decrypter) { - DCHECK_EQ(alternative_decrypter_level_, NUM_ENCRYPTION_LEVELS); - DCHECK_GE(level, decrypter_level_); - DCHECK(!version_.KnowsWhichDecrypterToUse()); + QUICHE_DCHECK_EQ(alternative_decrypter_level_, NUM_ENCRYPTION_LEVELS); + QUICHE_DCHECK_GE(level, decrypter_level_); + QUICHE_DCHECK(!version_.KnowsWhichDecrypterToUse()); QUIC_DVLOG(1) << ENDPOINT << "Setting decrypter from level " << decrypter_level_ << " to " << level; decrypter_[decrypter_level_] = nullptr; @@ -4252,8 +4248,8 @@ void QuicFramer::SetAlternativeDecrypter( EncryptionLevel level, std::unique_ptr<QuicDecrypter> decrypter, bool latch_once_used) { - DCHECK_NE(level, decrypter_level_); - DCHECK(!version_.KnowsWhichDecrypterToUse()); + QUICHE_DCHECK_NE(level, decrypter_level_); + QUICHE_DCHECK(!version_.KnowsWhichDecrypterToUse()); QUIC_DVLOG(1) << ENDPOINT << "Setting alternative decrypter from level " << alternative_decrypter_level_ << " to " << level; if (alternative_decrypter_level_ != NUM_ENCRYPTION_LEVELS) { @@ -4266,13 +4262,13 @@ void QuicFramer::SetAlternativeDecrypter( void QuicFramer::InstallDecrypter(EncryptionLevel level, std::unique_ptr<QuicDecrypter> decrypter) { - DCHECK(version_.KnowsWhichDecrypterToUse()); + QUICHE_DCHECK(version_.KnowsWhichDecrypterToUse()); QUIC_DVLOG(1) << ENDPOINT << "Installing decrypter at level " << level; decrypter_[level] = std::move(decrypter); } void QuicFramer::RemoveDecrypter(EncryptionLevel level) { - DCHECK(version_.KnowsWhichDecrypterToUse()); + QUICHE_DCHECK(version_.KnowsWhichDecrypterToUse()); QUIC_DVLOG(1) << ENDPOINT << "Removing decrypter at level " << level; decrypter_[level] = nullptr; } @@ -4280,19 +4276,16 @@ void QuicFramer::RemoveDecrypter(EncryptionLevel level) { void QuicFramer::SetKeyUpdateSupportForConnection(bool enabled) { QUIC_DVLOG(1) << ENDPOINT << "SetKeyUpdateSupportForConnection: " << enabled; support_key_update_for_connection_ = enabled; - if (enabled) { - QUIC_RELOADABLE_FLAG_COUNT(quic_key_update_supported); - } } void QuicFramer::DiscardPreviousOneRttKeys() { - DCHECK(support_key_update_for_connection_); + QUICHE_DCHECK(support_key_update_for_connection_); QUIC_DVLOG(1) << ENDPOINT << "Discarding previous set of 1-RTT keys"; previous_decrypter_ = nullptr; } bool QuicFramer::DoKeyUpdate(KeyUpdateReason reason) { - DCHECK(support_key_update_for_connection_); + QUICHE_DCHECK(support_key_update_for_connection_); if (!next_decrypter_) { // If key update is locally initiated, next decrypter might not be created // yet. @@ -4320,7 +4313,7 @@ QuicPacketCount QuicFramer::PotentialPeerKeyUpdateAttemptCount() const { } const QuicDecrypter* QuicFramer::GetDecrypter(EncryptionLevel level) const { - DCHECK(version_.KnowsWhichDecrypterToUse()); + QUICHE_DCHECK(version_.KnowsWhichDecrypterToUse()); return decrypter_[level].get(); } @@ -4337,8 +4330,8 @@ const QuicDecrypter* QuicFramer::alternative_decrypter() const { void QuicFramer::SetEncrypter(EncryptionLevel level, std::unique_ptr<QuicEncrypter> encrypter) { - DCHECK_GE(level, 0); - DCHECK_LT(level, NUM_ENCRYPTION_LEVELS); + QUICHE_DCHECK_GE(level, 0); + QUICHE_DCHECK_LT(level, NUM_ENCRYPTION_LEVELS); QUIC_DVLOG(1) << ENDPOINT << "Setting encrypter at level " << level; encrypter_[level] = std::move(encrypter); } @@ -4362,7 +4355,7 @@ size_t QuicFramer::EncryptInPlace(EncryptionLevel level, size_t total_len, size_t buffer_len, char* buffer) { - DCHECK(packet_number.IsInitialized()); + QUICHE_DCHECK(packet_number.IsInitialized()); if (encrypter_[level] == nullptr) { QUIC_BUG << ENDPOINT << "Attempted to encrypt in place without encrypter at level " @@ -4617,7 +4610,7 @@ size_t QuicFramer::EncryptPayload(EncryptionLevel level, const QuicPacket& packet, char* buffer, size_t buffer_len) { - DCHECK(packet_number.IsInitialized()); + QUICHE_DCHECK(packet_number.IsInitialized()); if (encrypter_[level] == nullptr) { QUIC_BUG << ENDPOINT << "Attempted to encrypt without encrypter at level " << level; @@ -4694,7 +4687,8 @@ QuicPacketCount QuicFramer::GetOneRttEncrypterConfidentialityLimit() const { return encrypter_[ENCRYPTION_FORWARD_SECURE]->GetConfidentialityLimit(); } -bool QuicFramer::DecryptPayload(absl::string_view encrypted, +bool QuicFramer::DecryptPayload(size_t udp_packet_length, + absl::string_view encrypted, absl::string_view associated_data, const QuicPacketHeader& header, char* decrypted_buffer, @@ -4732,8 +4726,8 @@ bool QuicFramer::DecryptPayload(absl::string_view encrypted, } if (support_key_update_for_connection_ && header.form == IETF_QUIC_SHORT_HEADER_PACKET) { - DCHECK(version().UsesTls()); - DCHECK_EQ(level, ENCRYPTION_FORWARD_SECURE); + QUICHE_DCHECK(version().UsesTls()); + QUICHE_DCHECK_EQ(level, ENCRYPTION_FORWARD_SECURE); key_phase = (header.type_byte & FLAGS_KEY_PHASE_BIT) != 0; key_phase_parsed = true; QUIC_DVLOG(1) << ENDPOINT << "packet " << header.packet_number @@ -4788,7 +4782,23 @@ bool QuicFramer::DecryptPayload(absl::string_view encrypted, header.packet_number.ToUint64(), associated_data, encrypted, decrypted_buffer, decrypted_length, buffer_length); if (success) { - visitor_->OnDecryptedPacket(level); + visitor_->OnDecryptedPacket(udp_packet_length, level); + if (GetQuicReloadableFlag( + quic_close_connection_on_0rtt_packet_number_higher_than_1rtt)) { + QUIC_RELOADABLE_FLAG_COUNT( + quic_close_connection_on_0rtt_packet_number_higher_than_1rtt); + if (level == ENCRYPTION_ZERO_RTT && + current_key_phase_first_received_packet_number_.IsInitialized() && + header.packet_number > + current_key_phase_first_received_packet_number_) { + set_detailed_error(absl::StrCat( + "Decrypted a 0-RTT packet with a packet number ", + header.packet_number.ToString(), + " which is higher than a 1-RTT packet number ", + current_key_phase_first_received_packet_number_.ToString())); + return RaiseError(QUIC_INVALID_0RTT_PACKET_NUMBER_OUT_OF_ORDER); + } + } *decrypted_level = level; potential_peer_key_update_attempt_count_ = 0; if (attempt_key_update) { @@ -4796,7 +4806,7 @@ bool QuicFramer::DecryptPayload(absl::string_view encrypted, set_detailed_error("Key update failed due to internal error"); return RaiseError(QUIC_INTERNAL_ERROR); } - DCHECK_EQ(current_key_phase_bit_, key_phase); + QUICHE_DCHECK_EQ(current_key_phase_bit_, key_phase); } if (key_phase_parsed && !current_key_phase_first_received_packet_number_.IsInitialized() && @@ -4814,7 +4824,7 @@ bool QuicFramer::DecryptPayload(absl::string_view encrypted, } } else if (alternative_decrypter != nullptr) { if (header.nonce != nullptr) { - DCHECK_EQ(perspective_, Perspective::IS_CLIENT); + QUICHE_DCHECK_EQ(perspective_, Perspective::IS_CLIENT); alternative_decrypter->SetDiversificationNonce(*header.nonce); } bool try_alternative_decryption = true; @@ -4825,7 +4835,7 @@ bool QuicFramer::DecryptPayload(absl::string_view encrypted, try_alternative_decryption = false; } } else { - DCHECK(header.nonce == nullptr); + QUICHE_DCHECK(header.nonce == nullptr); } } @@ -4835,7 +4845,8 @@ bool QuicFramer::DecryptPayload(absl::string_view encrypted, decrypted_buffer, decrypted_length, buffer_length); } if (success) { - visitor_->OnDecryptedPacket(alternative_decrypter_level_); + visitor_->OnDecryptedPacket(udp_packet_length, + alternative_decrypter_level_); *decrypted_level = decrypter_level_; if (alternative_decrypter_latch_) { if (!EncryptionLevelIsValid(alternative_decrypter_level_)) { @@ -4913,7 +4924,7 @@ size_t QuicFramer::GetIetfAckFrameSize(const QuicAckFrame& frame) { size_t QuicFramer::GetAckFrameSize( const QuicAckFrame& ack, QuicPacketNumberLength /*packet_number_length*/) { - DCHECK(!ack.packets.Empty()); + QUICHE_DCHECK(!ack.packets.Empty()); size_t ack_size = 0; if (VersionHasIetfQuicFrames(version_.transport_version)) { @@ -4979,7 +4990,7 @@ size_t QuicFramer::ComputeFrameLength( last_frame_in_packet, frame.message_frame->message_length); case PADDING_FRAME: - DCHECK(false); + QUICHE_DCHECK(false); return 0; default: return GetRetransmittableControlFrameSize(version_.transport_version, @@ -5067,7 +5078,7 @@ bool QuicFramer::AppendIetfFrameType(const QuicFrame& frame, type_byte = IETF_CONNECTION_CLOSE; break; default: - set_detailed_error(quiche::QuicheStrCat( + set_detailed_error(absl::StrCat( "Invalid QuicConnectionCloseFrame type: ", static_cast<int>(frame.connection_close_frame->close_type))); return RaiseError(QUIC_INTERNAL_ERROR); @@ -5169,7 +5180,7 @@ bool QuicFramer::AppendIetfFrameType(const QuicFrame& frame, bool QuicFramer::AppendPacketNumber(QuicPacketNumberLength packet_number_length, QuicPacketNumber packet_number, QuicDataWriter* writer) { - DCHECK(packet_number.IsInitialized()); + QUICHE_DCHECK(packet_number.IsInitialized()); if (!IsValidPacketNumberLength(packet_number_length)) { QUIC_BUG << "Invalid packet_number_length: " << packet_number_length; return false; @@ -5247,7 +5258,7 @@ bool QuicFramer::AppendStreamFrame(const QuicStreamFrame& frame, } if (data_producer_ != nullptr) { - DCHECK_EQ(nullptr, frame.data_buffer); + QUICHE_DCHECK_EQ(nullptr, frame.data_buffer); if (frame.data_length == 0) { return true; } @@ -5336,7 +5347,7 @@ bool QuicFramer::AppendIetfStreamFrame(const QuicStreamFrame& frame, return false; } } else { - DCHECK_EQ(nullptr, frame.data_buffer); + QUICHE_DCHECK_EQ(nullptr, frame.data_buffer); if (data_producer_->WriteStreamData(frame.stream_id, frame.offset, frame.data_length, @@ -5365,7 +5376,7 @@ bool QuicFramer::AppendCryptoFrame(const QuicCryptoFrame& frame, return false; } } else { - DCHECK_EQ(nullptr, frame.data_buffer); + QUICHE_DCHECK_EQ(nullptr, frame.data_buffer); if (!data_producer_->WriteCryptoData(frame.level, frame.offset, frame.data_length, writer)) { return false; @@ -5398,7 +5409,8 @@ bool QuicFramer::AppendAckFrequencyFrame(const QuicAckFrequencyFrame& frame, } void QuicFramer::set_version(const ParsedQuicVersion version) { - DCHECK(IsSupportedVersion(version)) << ParsedQuicVersionToString(version); + QUICHE_DCHECK(IsSupportedVersion(version)) + << ParsedQuicVersionToString(version); version_ = version; } @@ -5420,7 +5432,7 @@ bool QuicFramer::AppendAckFrameAndTypeByte(const QuicAckFrame& frame, GetMinAckFrameSize(version_.transport_version, frame, local_ack_delay_exponent_) - (new_ack_info.num_ack_blocks != 0 ? kNumberOfAckBlocksSize : 0); - DCHECK_LE(0, available_timestamp_and_ack_block_bytes); + QUICHE_DCHECK_LE(0, available_timestamp_and_ack_block_bytes); uint8_t type_byte = 0; SetBit(&type_byte, new_ack_info.num_ack_blocks != 0, @@ -5456,7 +5468,7 @@ bool QuicFramer::AppendAckFrameAndTypeByte(const QuicAckFrame& frame, // Largest acked delta time. uint64_t ack_delay_time_us = kUFloat16MaxValue; if (!frame.ack_delay_time.IsInfinite()) { - DCHECK_LE(0u, frame.ack_delay_time.ToMicroseconds()); + QUICHE_DCHECK_LE(0u, frame.ack_delay_time.ToMicroseconds()); ack_delay_time_us = frame.ack_delay_time.ToMicroseconds(); } if (!writer->WriteUFloat16(ack_delay_time_us)) { @@ -5528,7 +5540,7 @@ bool QuicFramer::AppendAckFrameAndTypeByte(const QuicAckFrame& frame, } ++num_ack_blocks_written; } - DCHECK_EQ(num_ack_blocks, num_ack_blocks_written); + QUICHE_DCHECK_EQ(num_ack_blocks, num_ack_blocks_written); } // Timestamps. // If we don't process timestamps or if we don't have enough available space @@ -5550,8 +5562,8 @@ bool QuicFramer::AppendAckFrameAndTypeByte(const QuicAckFrame& frame, bool QuicFramer::AppendTimestampsToAckFrame(const QuicAckFrame& frame, QuicDataWriter* writer) { - DCHECK_GE(std::numeric_limits<uint8_t>::max(), - frame.received_packet_times.size()); + QUICHE_DCHECK_GE(std::numeric_limits<uint8_t>::max(), + frame.received_packet_times.size()); // num_received_packets is only 1 byte. if (frame.received_packet_times.size() > std::numeric_limits<uint8_t>::max()) { @@ -5570,7 +5582,8 @@ bool QuicFramer::AppendTimestampsToAckFrame(const QuicAckFrame& frame, QuicPacketNumber packet_number = it->first; uint64_t delta_from_largest_observed = LargestAcked(frame) - packet_number; - DCHECK_GE(std::numeric_limits<uint8_t>::max(), delta_from_largest_observed); + QUICHE_DCHECK_GE(std::numeric_limits<uint8_t>::max(), + delta_from_largest_observed); if (delta_from_largest_observed > std::numeric_limits<uint8_t>::max()) { return false; } @@ -5614,9 +5627,9 @@ bool QuicFramer::AppendTimestampsToAckFrame(const QuicAckFrame& frame, bool QuicFramer::AppendStopWaitingFrame(const QuicPacketHeader& header, const QuicStopWaitingFrame& frame, QuicDataWriter* writer) { - DCHECK(!VersionHasIetfInvariantHeader(version_.transport_version)); - DCHECK(frame.least_unacked.IsInitialized()); - DCHECK_GE(header.packet_number, frame.least_unacked); + QUICHE_DCHECK(!version_.HasIetfInvariantHeader()); + QUICHE_DCHECK(frame.least_unacked.IsInitialized()); + QUICHE_DCHECK_GE(header.packet_number, frame.least_unacked); const uint64_t least_unacked_delta = header.packet_number - frame.least_unacked; const uint64_t length_shift = header.packet_number_length * 8; @@ -5668,7 +5681,7 @@ bool QuicFramer::AppendIetfAckFrameAndTypeByte(const QuicAckFrame& frame, uint64_t ack_delay_time_us = kVarInt62MaxValue; if (!frame.ack_delay_time.IsInfinite()) { - DCHECK_LE(0u, frame.ack_delay_time.ToMicroseconds()); + QUICHE_DCHECK_LE(0u, frame.ack_delay_time.ToMicroseconds()); ack_delay_time_us = frame.ack_delay_time.ToMicroseconds(); ack_delay_time_us = ack_delay_time_us >> local_ack_delay_exponent_; } @@ -5714,7 +5727,7 @@ bool QuicFramer::AppendIetfAckFrameAndTypeByte(const QuicAckFrame& frame, } const bool success = writer->WriteVarInt62(gap) && writer->WriteVarInt62(ack_range); - DCHECK(success); + QUICHE_DCHECK(success); previous_smallest = iter->min(); ++appended_ack_blocks; } @@ -6075,24 +6088,8 @@ bool QuicFramer::ProcessStopSendingFrame( return false; } - if (GetQuicReloadableFlag(quic_stop_sending_uses_ietf_error_code)) { - QUIC_RELOADABLE_FLAG_COUNT_N(quic_stop_sending_uses_ietf_error_code, 2, 2); - stop_sending_frame->error_code = - IetfResetStreamErrorCodeToRstStreamErrorCode( - stop_sending_frame->ietf_error_code); - return true; - } - - // TODO(fkastenholz): when error codes go to uint64_t, remove this. - if (stop_sending_frame->ietf_error_code > 0xffff) { - stop_sending_frame->error_code = - static_cast<QuicRstStreamErrorCode>(0xffff); - QUIC_DLOG(ERROR) << "Stop sending error code (" - << stop_sending_frame->ietf_error_code << ") > 0xffff"; - } else { - stop_sending_frame->error_code = static_cast<QuicRstStreamErrorCode>( - stop_sending_frame->ietf_error_code); - } + stop_sending_frame->error_code = IetfResetStreamErrorCodeToRstStreamErrorCode( + stop_sending_frame->ietf_error_code); return true; } @@ -6385,7 +6382,7 @@ uint8_t QuicFramer::GetStreamFrameTypeByte(const QuicStreamFrame& frame, uint8_t QuicFramer::GetIetfStreamFrameTypeByte( const QuicStreamFrame& frame, bool last_frame_in_packet) const { - DCHECK(VersionHasIetfQuicFrames(version_.transport_version)); + QUICHE_DCHECK(VersionHasIetfQuicFrames(version_.transport_version)); uint8_t type_byte = IETF_STREAM; if (!last_frame_in_packet) { type_byte |= IETF_STREAM_FRAME_LEN_BIT; @@ -6402,8 +6399,8 @@ uint8_t QuicFramer::GetIetfStreamFrameTypeByte( void QuicFramer::InferPacketHeaderTypeFromVersion() { // This function should only be called when server connection negotiates the // version. - DCHECK_EQ(perspective_, Perspective::IS_SERVER); - DCHECK(!infer_packet_header_type_from_version_); + QUICHE_DCHECK_EQ(perspective_, Perspective::IS_SERVER); + QUICHE_DCHECK(!infer_packet_header_type_from_version_); infer_packet_header_type_from_version_ = true; } @@ -6640,7 +6637,7 @@ QuicErrorCode QuicFramer::ParsePublicHeader( return QUIC_NO_ERROR; } - DCHECK_EQ(IETF_QUIC_LONG_HEADER_PACKET, *format); + QUICHE_DCHECK_EQ(IETF_QUIC_LONG_HEADER_PACKET, *format); *version_present = true; if (!ProcessVersionLabel(reader, version_label)) { *detailed_error = "Unable to read protocol version."; @@ -6771,7 +6768,7 @@ bool QuicFramer::WriteClientVersionNegotiationProbePacket( } // Fill the rest of the packet with zeroes. writer.WritePadding(); - DCHECK_EQ(0u, writer.remaining()); + QUICHE_DCHECK_EQ(0u, writer.remaining()); return true; } @@ -6838,10 +6835,10 @@ bool QuicFramer::ParseServerVersionNegotiationProbeResponse( return false; } if (*source_connection_id_length_out < source_connection_id.length()) { - *detailed_error = quiche::QuicheStrCat( - "*source_connection_id_length_out too small ", - static_cast<int>(*source_connection_id_length_out), " < ", - static_cast<int>(source_connection_id.length())); + *detailed_error = + absl::StrCat("*source_connection_id_length_out too small ", + static_cast<int>(*source_connection_id_length_out), " < ", + static_cast<int>(source_connection_id.length())); return false; } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_framer.h b/chromium/net/third_party/quiche/src/quic/core/quic_framer.h index fba99f875d5..571278deab8 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_framer.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_framer.h @@ -11,13 +11,13 @@ #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -96,11 +96,11 @@ class QUIC_EXPORT_PRIVATE QuicFramerVisitorInterface { // Called only when |perspective_| is IS_CLIENT and a retry packet has been // parsed. |new_connection_id| contains the value of the Source Connection // ID field, and |retry_token| contains the value of the Retry Token field. - // On versions where HasRetryIntegrityTag() is false, + // On versions where UsesTls() is false, // |original_connection_id| contains the value of the Original Destination // Connection ID field, and both |retry_integrity_tag| and // |retry_without_tag| are empty. - // On versions where HasRetryIntegrityTag() is true, + // On versions where UsesTls() is true, // |original_connection_id| is empty, |retry_integrity_tag| contains the // value of the Retry Integrity Tag field, and |retry_without_tag| contains // the entire RETRY packet except the Retry Integrity Tag field. @@ -121,9 +121,9 @@ class QUIC_EXPORT_PRIVATE QuicFramerVisitorInterface { // cease. virtual bool OnUnauthenticatedHeader(const QuicPacketHeader& header) = 0; - // Called when a packet has been decrypted. |level| is the encryption level - // of the packet. - virtual void OnDecryptedPacket(EncryptionLevel level) = 0; + // Called when a packet has been decrypted. |length| is the packet length, + // and |level| is the encryption level of the packet. + virtual void OnDecryptedPacket(size_t length, EncryptionLevel level) = 0; // Called when the complete header of a packet had been parsed. // If OnPacketHeader returns false, framing for this packet will cease. @@ -299,8 +299,8 @@ class QUIC_EXPORT_PRIVATE QuicFramer { void set_version(const ParsedQuicVersion version); - // Does not DCHECK for supported version. Used by tests to set unsupported - // version to trigger version negotiation. + // Does not QUICHE_DCHECK for supported version. Used by tests to set + // unsupported version to trigger version negotiation. void set_version_for_tests(const ParsedQuicVersion version) { version_ = version; } @@ -520,10 +520,10 @@ class QUIC_EXPORT_PRIVATE QuicFramer { QuicDataWriter* writer); // SetDecrypter sets the primary decrypter, replacing any that already exists. - // If an alternative decrypter is in place then the function DCHECKs. This is - // intended for cases where one knows that future packets will be using the - // new decrypter and the previous decrypter is now obsolete. |level| indicates - // the encryption level of the new decrypter. + // If an alternative decrypter is in place then the function QUICHE_DCHECKs. + // This is intended for cases where one knows that future packets will be + // using the new decrypter and the previous decrypter is now obsolete. |level| + // indicates the encryption level of the new decrypter. void SetDecrypter(EncryptionLevel level, std::unique_ptr<QuicDecrypter> decrypter); @@ -705,6 +705,10 @@ class QUIC_EXPORT_PRIVATE QuicFramer { } uint32_t peer_ack_delay_exponent() const { return peer_ack_delay_exponent_; } + void set_drop_incoming_retry_packets(bool drop_incoming_retry_packets) { + drop_incoming_retry_packets_ = drop_incoming_retry_packets; + } + private: friend class test::QuicFramerPeer; @@ -849,7 +853,8 @@ class QUIC_EXPORT_PRIVATE QuicFramer { bool no_message_length, QuicMessageFrame* frame); - bool DecryptPayload(absl::string_view encrypted, + bool DecryptPayload(size_t udp_packet_length, + absl::string_view encrypted, absl::string_view associated_data, const QuicPacketHeader& header, char* decrypted_buffer, @@ -1150,6 +1155,9 @@ class QUIC_EXPORT_PRIVATE QuicFramer { // Indicates whether this framer supports multiple packet number spaces. bool supports_multiple_packet_number_spaces_; + // Indicates whether received RETRY packets should be dropped. + bool drop_incoming_retry_packets_ = false; + // The length in bytes of the last packet number written to an IETF-framed // packet. size_t last_written_packet_number_length_; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_framer_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_framer_test.cc index ba9a70e46fc..12b779ac8f9 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_framer_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_framer_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_framer.h" +#include "quic/core/quic_framer.h" #include <algorithm> #include <cstdint> @@ -16,26 +16,26 @@ #include "absl/strings/escaping.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#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_ptr_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_framer_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/simple_data_producer.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/core/crypto/null_decrypter.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_framer_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/simple_data_producer.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/test_tools/quiche_test_utils.h" using testing::_; using testing::Return; @@ -290,7 +290,8 @@ class TestQuicVisitor : public QuicFramerVisitorInterface { return true; } - void OnDecryptedPacket(EncryptionLevel /*level*/) override { + void OnDecryptedPacket(size_t /*length*/, + EncryptionLevel /*level*/) override { EXPECT_EQ(0u, framer_->current_received_frame_type()); } @@ -363,7 +364,7 @@ class TestQuicVisitor : public QuicFramerVisitorInterface { } bool OnAckRange(QuicPacketNumber start, QuicPacketNumber end) override { - DCHECK(!ack_frames_.empty()); + QUICHE_DCHECK(!ack_frames_.empty()); ack_frames_[ack_frames_.size() - 1]->packets.AddRange(start, end); if (VersionHasIetfQuicFrames(transport_version_)) { EXPECT_TRUE(IETF_ACK == framer_->current_received_frame_type() || @@ -432,7 +433,7 @@ class TestQuicVisitor : public QuicFramerVisitorInterface { ++frame_count_; handshake_done_frames_.push_back( std::make_unique<QuicHandshakeDoneFrame>(frame)); - DCHECK(VersionHasIetfQuicFrames(transport_version_)); + QUICHE_DCHECK(VersionHasIetfQuicFrames(transport_version_)); EXPECT_EQ(IETF_HANDSHAKE_DONE, framer_->current_received_frame_type()); return true; } @@ -441,7 +442,7 @@ class TestQuicVisitor : public QuicFramerVisitorInterface { ++frame_count_; ack_frequency_frames_.emplace_back( std::make_unique<QuicAckFrequencyFrame>(frame)); - DCHECK(VersionHasIetfQuicFrames(transport_version_)); + QUICHE_DCHECK(VersionHasIetfQuicFrames(transport_version_)); EXPECT_EQ(IETF_ACK_FREQUENCY, framer_->current_received_frame_type()); return true; } @@ -1361,11 +1362,10 @@ TEST_P(QuicFramerTest, ParsePublicHeader) { const QuicErrorCode parse_error = QuicFramer::ParsePublicHeader( &reader, kQuicDefaultConnectionIdLength, /*ietf_format=*/ - VersionHasIetfInvariantHeader(framer_.transport_version()), &first_byte, - &format, &version_present, &has_length_prefix, &version_label, - &parsed_version, &destination_connection_id, &source_connection_id, - &long_packet_type, &retry_token_length_length, &retry_token, - &detailed_error); + framer_.version().HasIetfInvariantHeader(), &first_byte, &format, + &version_present, &has_length_prefix, &version_label, &parsed_version, + &destination_connection_id, &source_connection_id, &long_packet_type, + &retry_token_length_length, &retry_token, &detailed_error); EXPECT_THAT(parse_error, IsQuicNoError()); EXPECT_EQ("", detailed_error); EXPECT_EQ(p[0], first_byte); @@ -1378,7 +1378,7 @@ TEST_P(QuicFramerTest, ParsePublicHeader) { EXPECT_EQ(EmptyQuicConnectionId(), source_connection_id); EXPECT_EQ(VARIABLE_LENGTH_INTEGER_LENGTH_0, retry_token_length_length); EXPECT_EQ(absl::string_view(), retry_token); - if (VersionHasIetfInvariantHeader(framer_.transport_version())) { + if (framer_.version().HasIetfInvariantHeader()) { EXPECT_EQ(IETF_QUIC_LONG_HEADER_PACKET, format); EXPECT_EQ(HANDSHAKE, long_packet_type); } else { @@ -2762,7 +2762,7 @@ TEST_P(QuicFramerTest, StreamFrameWithVersion) { // If IETF frames are in use then we must also have the IETF // header invariants. if (VersionHasIetfQuicFrames(framer_.transport_version())) { - DCHECK(VersionHasIetfInvariantHeader(framer_.transport_version())); + QUICHE_DCHECK(framer_.version().HasIetfInvariantHeader()); } SetDecrypterLevel(ENCRYPTION_ZERO_RTT); @@ -4605,15 +4605,8 @@ TEST_P(QuicFramerTest, ConnectionCloseFrameWithUnknownErrorCode) { } else { // For Google QUIC frame, |quic_error_code| and |wire_error_code| has the // same value. - if (GetQuicReloadableFlag(quic_do_not_clip_received_error_code)) { - EXPECT_EQ(0xC0DEu, visitor_.connection_close_frame_.wire_error_code); - EXPECT_EQ(0xC0DEu, visitor_.connection_close_frame_.quic_error_code); - } else { - EXPECT_EQ(QUIC_LAST_ERROR, - visitor_.connection_close_frame_.wire_error_code); - EXPECT_EQ(QUIC_LAST_ERROR, - visitor_.connection_close_frame_.quic_error_code); - } + EXPECT_EQ(0xC0DEu, visitor_.connection_close_frame_.wire_error_code); + EXPECT_EQ(0xC0DEu, visitor_.connection_close_frame_.quic_error_code); } ASSERT_EQ(0u, visitor_.ack_frames_.size()); @@ -5053,11 +5046,7 @@ TEST_P(QuicFramerTest, GoAwayFrameWithUnknownErrorCode) { PACKET_8BYTE_CONNECTION_ID, PACKET_0BYTE_CONNECTION_ID)); EXPECT_EQ(kStreamId, visitor_.goaway_frame_.last_good_stream_id); - if (GetQuicReloadableFlag(quic_do_not_clip_received_error_code)) { - EXPECT_EQ(0xC0DE, visitor_.goaway_frame_.error_code); - } else { - EXPECT_EQ(QUIC_LAST_ERROR, visitor_.goaway_frame_.error_code); - } + EXPECT_EQ(0xC0DE, visitor_.goaway_frame_.error_code); EXPECT_EQ("because I can", visitor_.goaway_frame_.reason_phrase); CheckFramingBoundaries(fragments, QUIC_INVALID_GOAWAY_DATA); @@ -6061,7 +6050,7 @@ TEST_P(QuicFramerTest, ParseIetfRetryPacket) { unsigned char* p = packet; size_t p_length = ABSL_ARRAYSIZE(packet); - if (framer_.version().HasRetryIntegrityTag()) { + if (framer_.version().UsesTls()) { p = packet_with_tag; p_length = ABSL_ARRAYSIZE(packet_with_tag); } else if (framer_.version().HasLongHeaderLengths()) { @@ -6078,7 +6067,7 @@ TEST_P(QuicFramerTest, ParseIetfRetryPacket) { ASSERT_TRUE(visitor_.retry_new_connection_id_.get()); ASSERT_TRUE(visitor_.retry_token_.get()); - if (framer_.version().HasRetryIntegrityTag()) { + if (framer_.version().UsesTls()) { ASSERT_TRUE(visitor_.retry_token_integrity_tag_.get()); static const unsigned char expected_integrity_tag[16] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, @@ -7820,8 +7809,9 @@ TEST_P(QuicFramerTest, BuildCloseFramePacket) { header.version_flag = false; header.packet_number = kPacketNumber; - QuicConnectionCloseFrame close_frame( - framer_.transport_version(), QUIC_INTERNAL_ERROR, "because I can", 0x05); + QuicConnectionCloseFrame close_frame(framer_.transport_version(), + QUIC_INTERNAL_ERROR, NO_IETF_QUIC_ERROR, + "because I can", 0x05); QuicFrames frames = {QuicFrame(&close_frame)}; // clang-format off @@ -7921,7 +7911,7 @@ TEST_P(QuicFramerTest, BuildCloseFramePacketExtendedInfo) { static_cast<QuicErrorCode>( VersionHasIetfQuicFrames(framer_.transport_version()) ? 0x01 : 0x05060708), - "because I can", 0x05); + NO_IETF_QUIC_ERROR, "because I can", 0x05); // Set this so that it is "there" for both Google QUIC and IETF QUIC // framing. It better not show up for Google QUIC! close_frame.quic_error_code = static_cast<QuicErrorCode>(0x4567); @@ -8023,7 +8013,7 @@ TEST_P(QuicFramerTest, BuildTruncatedCloseFramePacket) { header.packet_number = kPacketNumber; QuicConnectionCloseFrame close_frame(framer_.transport_version(), - QUIC_INTERNAL_ERROR, + QUIC_INTERNAL_ERROR, NO_IETF_QUIC_ERROR, std::string(2048, 'A'), 0x05); QuicFrames frames = {QuicFrame(&close_frame)}; @@ -9765,7 +9755,7 @@ TEST_P(QuicFramerTest, StopPacketProcessing) { EXPECT_CALL(visitor, OnPacketComplete()); EXPECT_CALL(visitor, OnUnauthenticatedPublicHeader(_)).WillOnce(Return(true)); EXPECT_CALL(visitor, OnUnauthenticatedHeader(_)).WillOnce(Return(true)); - EXPECT_CALL(visitor, OnDecryptedPacket(_)); + EXPECT_CALL(visitor, OnDecryptedPacket(_, _)); unsigned char* p = packet; size_t p_size = ABSL_ARRAYSIZE(packet); @@ -9824,7 +9814,7 @@ TEST_P(QuicFramerTest, ConstructEncryptedPacket) { .Times(1) .WillOnce(Return(true)); EXPECT_CALL(visitor, OnPacketHeader(_)).Times(1).WillOnce(Return(true)); - EXPECT_CALL(visitor, OnDecryptedPacket(_)).Times(1); + EXPECT_CALL(visitor, OnDecryptedPacket(_, _)).Times(1); EXPECT_CALL(visitor, OnError(_)).Times(0); EXPECT_CALL(visitor, OnStreamFrame(_)).Times(0); if (!QuicVersionUsesCryptoFrames(framer_.version().transport_version)) { @@ -9870,7 +9860,7 @@ TEST_P(QuicFramerTest, ConstructMisFramedEncryptedPacket) { .Times(1) .WillOnce(Return(true)); EXPECT_CALL(visitor, OnPacketHeader(_)).Times(1); - EXPECT_CALL(visitor, OnDecryptedPacket(_)).Times(1); + EXPECT_CALL(visitor, OnDecryptedPacket(_, _)).Times(1); EXPECT_CALL(visitor, OnError(_)).Times(1); EXPECT_CALL(visitor, OnStreamFrame(_)).Times(0); EXPECT_CALL(visitor, OnPacketComplete()).Times(0); @@ -11165,8 +11155,9 @@ TEST_P(QuicFramerTest, BuildNewTokenFramePacket) { uint8_t expected_token_value[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}; - QuicNewTokenFrame frame(0, std::string((const char*)(expected_token_value), - sizeof(expected_token_value))); + QuicNewTokenFrame frame(0, + absl::string_view((const char*)(expected_token_value), + sizeof(expected_token_value))); QuicFrames frames = {QuicFrame(&frame)}; @@ -11235,12 +11226,8 @@ TEST_P(QuicFramerTest, IetfStopSendingFrame) { PACKET_8BYTE_CONNECTION_ID, PACKET_0BYTE_CONNECTION_ID)); EXPECT_EQ(kStreamId, visitor_.stop_sending_frame_.stream_id); - if (GetQuicReloadableFlag(quic_stop_sending_uses_ietf_error_code)) { - EXPECT_EQ(QUIC_STREAM_UNKNOWN_APPLICATION_ERROR_CODE, - visitor_.stop_sending_frame_.error_code); - } else { - EXPECT_EQ(0x7654, visitor_.stop_sending_frame_.error_code); - } + EXPECT_EQ(QUIC_STREAM_UNKNOWN_APPLICATION_ERROR_CODE, + visitor_.stop_sending_frame_.error_code); EXPECT_EQ(static_cast<uint64_t>(0x7654), visitor_.stop_sending_frame_.ietf_error_code); @@ -11466,9 +11453,10 @@ TEST_P(QuicFramerTest, GetRetransmittableControlFrameSize) { framer_.transport_version(), QuicFrame(&rst_stream))); std::string error_detail(2048, 'e'); - QuicConnectionCloseFrame connection_close( - framer_.transport_version(), QUIC_NETWORK_IDLE_TIMEOUT, error_detail, - /*transport_close_frame_type=*/0); + QuicConnectionCloseFrame connection_close(framer_.transport_version(), + QUIC_NETWORK_IDLE_TIMEOUT, + NO_IETF_QUIC_ERROR, error_detail, + /*transport_close_frame_type=*/0); EXPECT_EQ(QuicFramer::GetConnectionCloseFrameSize(framer_.transport_version(), connection_close), diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_idle_network_detector.cc b/chromium/net/third_party/quiche/src/quic/core/quic_idle_network_detector.cc index f9b37cce3fc..8046e446cee 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_idle_network_detector.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_idle_network_detector.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_idle_network_detector.h" +#include "quic/core/quic_idle_network_detector.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" +#include "quic/core/quic_constants.h" namespace quic { @@ -112,7 +112,7 @@ void QuicIdleNetworkDetector::SetAlarm() { void QuicIdleNetworkDetector::MaybeSetAlarmOnSentPacket( QuicTime::Delta pto_delay) { - DCHECK(shorter_idle_timeout_on_sent_packet_); + QUICHE_DCHECK(shorter_idle_timeout_on_sent_packet_); if (!handshake_timeout_.IsInfinite() || !alarm_->IsSet()) { SetAlarm(); return; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_idle_network_detector.h b/chromium/net/third_party/quiche/src/quic/core/quic_idle_network_detector.h index 7d7797edb6c..e138d6a068e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_idle_network_detector.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_idle_network_detector.h @@ -5,11 +5,11 @@ #ifndef QUICHE_QUIC_CORE_QUIC_IDLE_NETWORK_DETECTOR_H_ #define QUICHE_QUIC_CORE_QUIC_IDLE_NETWORK_DETECTOR_H_ -#include "net/third_party/quiche/src/quic/core/quic_alarm.h" -#include "net/third_party/quiche/src/quic/core/quic_alarm_factory.h" -#include "net/third_party/quiche/src/quic/core/quic_one_block_arena.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_alarm.h" +#include "quic/core/quic_alarm_factory.h" +#include "quic/core/quic_one_block_arena.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_idle_network_detector_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_idle_network_detector_test.cc index 3fa4ebeb3b2..271247808c9 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_idle_network_detector_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_idle_network_detector_test.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_idle_network_detector.h" +#include "quic/core/quic_idle_network_detector.h" -#include "net/third_party/quiche/src/quic/core/quic_one_block_arena.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/quic_one_block_arena.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_interval.h b/chromium/net/third_party/quiche/src/quic/core/quic_interval.h index 9e87ecd051f..81a4d626883 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_interval.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_interval.h @@ -63,7 +63,7 @@ #include <utility> #include <vector> -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -152,6 +152,16 @@ class QUIC_NO_EXPORT QuicInterval { // *this was modified. bool IntersectWith(const QuicInterval& i); + // Returns true iff this and other have disjoint closures. For nonempty + // intervals, that means there is at least one point between this and other. + // Roughly speaking that means the intervals don't intersect, and they are not + // adjacent. Empty intervals are always separated from any other interval. + bool Separated(const QuicInterval& other) const { + if (Empty() || other.Empty()) + return true; + return other.max() < min() || max() < other.min(); + } + // Calculates the smallest QuicInterval containing both *this i, and updates // *this to represent that QuicInterval, and returns true iff *this was // modified. diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_interval_deque.h b/chromium/net/third_party/quiche/src/quic/core/quic_interval_deque.h index d469a083d9c..d4e82e2d1a2 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_interval_deque.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_interval_deque.h @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef QUICHE_QUIC_CORE_QUIC_SEEKER_H_ -#define QUICHE_QUIC_CORE_QUIC_SEEKER_H_ +#ifndef QUICHE_QUIC_CORE_QUIC_INTERVAL_DEQUE_H_ +#define QUICHE_QUIC_CORE_QUIC_INTERVAL_DEQUE_H_ #include <algorithm> #include "absl/types/optional.h" -#include "net/third_party/quiche/src/quic/core/quic_circular_deque.h" -#include "net/third_party/quiche/src/quic/core/quic_interval.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/quic_circular_deque.h" +#include "quic/core/quic_interval.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -198,12 +198,12 @@ class QUIC_NO_EXPORT QuicIntervalDeque { Iterator operator+(difference_type amount) const { Iterator copy = *this; copy.index_ += amount; - DCHECK(copy.index_ < copy.deque_->size()); + QUICHE_DCHECK(copy.index_ < copy.deque_->size()); return copy; } Iterator& operator+=(difference_type amount) { index_ += amount; - DCHECK(index_ < deque_->size()); + QUICHE_DCHECK(index_ < deque_->size()); return *this; } difference_type operator-(const Iterator& rhs) const { @@ -311,7 +311,7 @@ typename QuicIntervalDeque<T, C>::Iterator QuicIntervalDeque<T, C>::DataAt( } const std::size_t cached_index = cached_index_.value(); - DCHECK(cached_index < container_.size()); + QUICHE_DCHECK(cached_index < container_.size()); const QuicInterval<size_t> cached_interval = container_[cached_index].interval(); @@ -389,4 +389,4 @@ typename QuicIntervalDeque<T, C>::Iterator QuicIntervalDeque<T, C>::Search( } // namespace quic -#endif // QUICHE_QUIC_CORE_QUIC_SEEKER_H_ +#endif // QUICHE_QUIC_CORE_QUIC_INTERVAL_DEQUE_H_ diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_interval_deque_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_interval_deque_test.cc index 2539f1d1b65..71a69cc7793 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_interval_deque_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_interval_deque_test.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_interval_deque.h" +#include "quic/core/quic_interval_deque.h" #include <cstdint> #include <ostream> -#include "net/third_party/quiche/src/quic/core/quic_interval.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_interval_deque_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/quic_interval.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_interval_deque_peer.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_interval_set.h b/chromium/net/third_party/quiche/src/quic/core/quic_interval_set.h index 7ab06475792..fef089313fa 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_interval_set.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_interval_set.h @@ -59,8 +59,9 @@ #include <string> -#include "net/third_party/quiche/src/quic/core/quic_interval.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/quic_interval.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -71,24 +72,36 @@ class QUIC_NO_EXPORT QuicIntervalSet { private: struct QUIC_NO_EXPORT IntervalLess { + using is_transparent = void; bool operator()(const value_type& a, const value_type& b) const; + // These transparent overloads are used when we do all of our searches (via + // Set::lower_bound() and Set::upper_bound()), which avoids the need to + // construct an interval when we are looking for a point and also avoids + // needing to worry about comparing overlapping intervals in the overload + // that takes two value_types (the one just above this comment). + bool operator()(const value_type& a, const T& point) const; + bool operator()(const value_type& a, T&& point) const; + bool operator()(const T& point, const value_type& a) const; + bool operator()(T&& point, const value_type& a) const; }; - // TODO(wub): Switch to absl::btree_set when it is available in Chromium. - using Set = std::set<value_type, IntervalLess>; + + using Set = QuicOrderedSet<value_type, + IntervalLess, + QuicInlinedVector<value_type, 10>>; public: using const_iterator = typename Set::const_iterator; using const_reverse_iterator = typename Set::const_reverse_iterator; // Instantiates an empty QuicIntervalSet. - QuicIntervalSet() {} + QuicIntervalSet() = default; - // Instantiates an QuicIntervalSet containing exactly one initial half-open + // Instantiates a QuicIntervalSet containing exactly one initial half-open // interval [min, max), unless the given interval is empty, in which case the // QuicIntervalSet will be empty. explicit QuicIntervalSet(const value_type& interval) { Add(interval); } - // Instantiates an QuicIntervalSet containing the half-open interval [min, + // Instantiates a QuicIntervalSet containing the half-open interval [min, // max). QuicIntervalSet(const T& min, const T& max) { Add(min, max); } @@ -156,11 +169,11 @@ class QUIC_NO_EXPORT QuicIntervalSet { // Remove the first interval. // REQUIRES: !Empty() void PopFront() { - DCHECK(!Empty()); + QUICHE_DCHECK(!Empty()); intervals_.erase(intervals_.begin()); } - // Trim all values that is smaller than |value|. Which means + // Trim all values that are smaller than |value|. Which means // a) If all values in an interval is smaller than |value|, the entire // interval is removed. // b) If some but not all values in an interval is smaller than |value|, the @@ -233,7 +246,9 @@ class QUIC_NO_EXPORT QuicIntervalSet { // Returns true if for some interval in "other", there is some interval in // this QuicIntervalSet that intersects with it. See value_type::Intersects() - // for the definition of interval intersection. + // for the definition of interval intersection. Runs in time O(n+m) where n + // is the number of intervals in this and m is the number of intervals in + // other. bool Intersects(const QuicIntervalSet& other) const; // Returns an iterator to the value_type in the QuicIntervalSet that contains @@ -287,6 +302,15 @@ class QUIC_NO_EXPORT QuicIntervalSet { bool IsDisjoint(const value_type& interval) const; // Merges all the values contained in "other" into this QuicIntervalSet. + // + // Performance: Let n == Size() and m = other.Size(). Union() runs in O(m) + // Set operations, so that if Set is a tree, it runs in time O(m log(n+m)) and + // if Set is a flat_set it runs in time O(m(n+m)). In principle, for the + // flat_set, we should be able to make this run in time O(n+m). + // + // TODO(bradleybear): Make Union() run in time O(n+m) for flat_set. This may + // require an additional template parameter to indicate that the Set is a + // linear-time data structure instead of a log-time data structure. void Union(const QuicIntervalSet& other); // Modifies this QuicIntervalSet so that it contains only those values that @@ -302,7 +326,9 @@ class QUIC_NO_EXPORT QuicIntervalSet { void Difference(const T& min, const T& max); // Mutates this QuicIntervalSet so that it contains only those values that are - // currently in *this but not in the QuicIntervalSet "other". + // currently in *this but not in the QuicIntervalSet "other". Runs in time + // O(n+m) where n is this->Size(), m is other.Size(), regardless of whether + // the Set is a flat_set or a std::set. void Difference(const QuicIntervalSet& other); // Mutates this QuicIntervalSet so that it contains only those values that are @@ -367,20 +393,18 @@ class QUIC_NO_EXPORT QuicIntervalSet { } }; - // Removes overlapping ranges and coalesces adjacent intervals as needed. - void Compact(const typename Set::iterator& begin, - const typename Set::iterator& end); - // Returns true if this set is valid (i.e. all intervals in it are non-empty, // non-adjacent, and mutually disjoint). Currently this is used as an // integrity check by the Intersection() and Difference() methods, but is only - // invoked for debug builds (via DCHECK). + // invoked for debug builds (via QUICHE_DCHECK). bool Valid() const; // Finds the first interval that potentially intersects 'other'. const_iterator FindIntersectionCandidate(const QuicIntervalSet& other) const; - // Finds the first interval that potentially intersects 'interval'. + // Finds the first interval that potentially intersects 'interval'. More + // precisely, return an interator it pointing at the last interval J such that + // interval <= J. If all the intervals are > J then return begin(). const_iterator FindIntersectionCandidate(const value_type& interval) const; // Helper for Intersection() and Difference(): Finds the next pair of @@ -388,7 +412,9 @@ class QUIC_NO_EXPORT QuicIntervalSet { // over x->intervals_. 'theirs' is an iterator over y.intervals_. 'mine' // and 'theirs' are advanced until an intersecting pair is found. // Non-intersecting intervals (aka "holes") from x->intervals_ can be - // optionally erased by "on_hole". + // optionally erased by "on_hole". "on_hole" must return an iterator to the + // first element in 'x' after the hole, or x->intervals_.end() if no elements + // exist after the hole. template <typename X, typename Func> static bool FindNextIntersectingPairImpl(X* x, const QuicIntervalSet& y, @@ -402,7 +428,9 @@ class QUIC_NO_EXPORT QuicIntervalSet { const_iterator* theirs) const { return FindNextIntersectingPairImpl( this, other, mine, theirs, - [](const QuicIntervalSet*, const_iterator, const_iterator) {}); + [](const QuicIntervalSet*, const_iterator, const_iterator end) { + return end; + }); } // The variant of the above method that mutates this QuicIntervalSet by @@ -413,7 +441,7 @@ class QUIC_NO_EXPORT QuicIntervalSet { return FindNextIntersectingPairImpl( this, other, mine, theirs, [](QuicIntervalSet* x, const_iterator from, const_iterator to) { - x->intervals_.erase(from, to); + return x->intervals_.erase(from, to); }); } @@ -453,30 +481,31 @@ template <typename T> void QuicIntervalSet<T>::Add(const value_type& interval) { if (interval.Empty()) return; - std::pair<typename Set::iterator, bool> ins = intervals_.insert(interval); - if (!ins.second) { - // This interval already exists. - return; + const_iterator it = intervals_.lower_bound(interval.min()); + value_type the_union = interval; + if (it != intervals_.begin()) { + --it; + if (it->Separated(the_union)) { + ++it; + } } - // Determine the minimal range that will have to be compacted. We know that - // the QuicIntervalSet was valid before the addition of the interval, so only - // need to start with the interval itself (although Compact takes an open - // range so begin needs to be the interval to the left). We don't know how - // many ranges this interval may cover, so we need to find the appropriate - // interval to end with on the right. - typename Set::iterator begin = ins.first; - if (begin != intervals_.begin()) - --begin; - const value_type target_end(interval.max(), interval.max()); - const typename Set::iterator end = intervals_.upper_bound(target_end); - Compact(begin, end); + // Don't erase the elements one at a time, since that will produce quadratic + // work on a flat_set, and apparently an extra log-factor of work for a + // tree-based set. Instead identify the first and last intervals that need to + // be erased, and call erase only once. + const_iterator start = it; + while (it != intervals_.end() && !it->Separated(the_union)) { + the_union.SpanningUnion(*it); + ++it; + } + intervals_.erase(start, it); + intervals_.insert(the_union); } template <typename T> bool QuicIntervalSet<T>::Contains(const T& value) const { - value_type tmp(value, value); // Find the first interval with min() > value, then move back one step - const_iterator it = intervals_.upper_bound(tmp); + const_iterator it = intervals_.upper_bound(value); if (it == intervals_.begin()) return false; --it; @@ -486,7 +515,7 @@ bool QuicIntervalSet<T>::Contains(const T& value) const { template <typename T> bool QuicIntervalSet<T>::Contains(const value_type& interval) const { // Find the first interval with min() > value, then move back one step. - const_iterator it = intervals_.upper_bound(interval); + const_iterator it = intervals_.upper_bound(interval.min()); if (it == intervals_.begin()) return false; --it; @@ -514,45 +543,11 @@ bool QuicIntervalSet<T>::Contains(const QuicIntervalSet<T>& other) const { // and test it using Contains(). The candidate interval is the interval with the // largest min() having min() <= value. // -// Determining the candidate interval takes a couple of steps. First, since the -// underlying std::set stores intervals, not values, we need to create a "probe -// interval" suitable for use as a search key. The probe interval used is -// [value, value). Now we can restate the problem as finding the largest -// interval in the QuicIntervalSet that is <= the probe interval. -// -// This restatement only works if the set's comparator behaves in a certain way. -// In particular it needs to order first by ascending min(), and then by -// descending max(). The comparator used by this library is defined in exactly -// this way. To see why descending max() is required, consider the following -// example. Assume an QuicIntervalSet containing these intervals: -// -// [0, 5) [10, 20) [50, 60) -// -// Consider searching for the value 15. The probe interval [15, 15) is created, -// and [10, 20) is identified as the largest interval in the set <= the probe -// interval. This is the correct interval needed for the Contains() test, which -// will then return true. -// -// Now consider searching for the value 30. The probe interval [30, 30) is -// created, and again [10, 20] is identified as the largest interval <= the -// probe interval. This is again the correct interval needed for the Contains() -// test, which in this case returns false. -// -// Finally, consider searching for the value 10. The probe interval [10, 10) is -// created. Here the ordering relationship between [10, 10) and [10, 20) becomes -// vitally important. If [10, 10) were to come before [10, 20), then [0, 5) -// would be the largest interval <= the probe, leading to the wrong choice of -// interval for the Contains() test. Therefore [10, 10) needs to come after -// [10, 20). The simplest way to make this work in the general case is to order -// by ascending min() but descending max(). In this ordering, the empty interval -// is larger than any non-empty interval with the same min(). The comparator -// used by this library is careful to induce this ordering. -// -// Another detail involves the choice of which std::set method to use to try to -// find the candidate interval. The most appropriate entry point is -// set::upper_bound(), which finds the smallest interval which is > the probe -// interval. The semantics of upper_bound() are slightly different from what we -// want (namely, to find the largest interval which is <= the probe interval) +// Another detail involves the choice of which Set method to use to try to find +// the candidate interval. The most appropriate entry point is +// Set::upper_bound(), which finds the least interval with a min > the +// value. The semantics of upper_bound() are slightly different from what we +// want (namely, to find the greatest interval which is <= the probe interval) // but they are close enough; the interval found by upper_bound() will always be // one step past the interval we are looking for (if it exists) or at begin() // (if it does not). Getting to the proper interval is a simple matter of @@ -560,8 +555,7 @@ bool QuicIntervalSet<T>::Contains(const QuicIntervalSet<T>& other) const { template <typename T> typename QuicIntervalSet<T>::const_iterator QuicIntervalSet<T>::Find( const T& value) const { - value_type tmp(value, value); - const_iterator it = intervals_.upper_bound(tmp); + const_iterator it = intervals_.upper_bound(value); if (it == intervals_.begin()) return intervals_.end(); --it; @@ -574,51 +568,13 @@ typename QuicIntervalSet<T>::const_iterator QuicIntervalSet<T>::Find( // This method finds the interval that Contains() the interval "probe", if such // an interval exists in the QuicIntervalSet. The way this is done is to locate // the "candidate interval", the only interval that could *possibly* contain -// "probe", and test it using Contains(). The candidate interval is the largest -// interval that is <= the probe interval. -// -// The search for the candidate interval only works if the comparator used -// behaves in a certain way. In particular it needs to order first by ascending -// min(), and then by descending max(). The comparator used by this library is -// defined in exactly this way. To see why descending max() is required, -// consider the following example. Assume an QuicIntervalSet containing these -// intervals: -// -// [0, 5) [10, 20) [50, 60) -// -// Consider searching for the probe [15, 17). [10, 20) is the largest interval -// in the set which is <= the probe interval. This is the correct interval -// needed for the Contains() test, which will then return true, because [10, 20) -// contains [15, 17). -// -// Now consider searching for the probe [30, 32). Again [10, 20] is the largest -// interval <= the probe interval. This is again the correct interval needed for -// the Contains() test, which in this case returns false, because [10, 20) does -// not contain [30, 32). -// -// Finally, consider searching for the probe [10, 12). Here the ordering -// relationship between [10, 12) and [10, 20) becomes vitally important. If -// [10, 12) were to come before [10, 20), then [0, 5) would be the largest -// interval <= the probe, leading to the wrong choice of interval for the -// Contains() test. Therefore [10, 12) needs to come after [10, 20). The -// simplest way to make this work in the general case is to order by ascending -// min() but descending max(). In this ordering, given two intervals with the -// same min(), the wider one goes before the narrower one. The comparator used -// by this library is careful to induce this ordering. -// -// Another detail involves the choice of which std::set method to use to try to -// find the candidate interval. The most appropriate entry point is -// set::upper_bound(), which finds the smallest interval which is > the probe -// interval. The semantics of upper_bound() are slightly different from what we -// want (namely, to find the largest interval which is <= the probe interval) -// but they are close enough; the interval found by upper_bound() will always be -// one step past the interval we are looking for (if it exists) or at begin() -// (if it does not). Getting to the proper interval is a simple matter of -// decrementing the iterator. +// "probe", and test it using Contains(). We use the same algorithm as for +// Find(value), except that instead of checking that the value is contained, we +// check that the probe is contained. template <typename T> typename QuicIntervalSet<T>::const_iterator QuicIntervalSet<T>::Find( const value_type& probe) const { - const_iterator it = intervals_.upper_bound(probe); + const_iterator it = intervals_.upper_bound(probe.min()); if (it == intervals_.begin()) return intervals_.end(); --it; @@ -631,7 +587,7 @@ typename QuicIntervalSet<T>::const_iterator QuicIntervalSet<T>::Find( template <typename T> typename QuicIntervalSet<T>::const_iterator QuicIntervalSet<T>::LowerBound( const T& value) const { - const_iterator it = intervals_.lower_bound(value_type(value, value)); + const_iterator it = intervals_.lower_bound(value); if (it == intervals_.begin()) { return it; } @@ -650,16 +606,15 @@ typename QuicIntervalSet<T>::const_iterator QuicIntervalSet<T>::LowerBound( template <typename T> typename QuicIntervalSet<T>::const_iterator QuicIntervalSet<T>::UpperBound( const T& value) const { - return intervals_.upper_bound(value_type(value, value)); + return intervals_.upper_bound(value); } template <typename T> bool QuicIntervalSet<T>::IsDisjoint(const value_type& interval) const { if (interval.Empty()) return true; - value_type tmp(interval.min(), interval.min()); // Find the first interval with min() > interval.min() - const_iterator it = intervals_.upper_bound(tmp); + const_iterator it = intervals_.upper_bound(interval.min()); if (it != intervals_.end() && interval.max() > it->min()) return false; if (it == intervals_.begin()) @@ -670,8 +625,9 @@ bool QuicIntervalSet<T>::IsDisjoint(const value_type& interval) const { template <typename T> void QuicIntervalSet<T>::Union(const QuicIntervalSet& other) { - intervals_.insert(other.begin(), other.end()); - Compact(intervals_.begin(), intervals_.end()); + for (const value_type& interval : other.intervals_) { + Add(interval); + } } template <typename T> @@ -692,7 +648,7 @@ QuicIntervalSet<T>::FindIntersectionCandidate( // greater than interval.min(). // In other words, no interval before that can possibly intersect with any // of other.intervals_. - const_iterator mine = intervals_.upper_bound(interval); + const_iterator mine = intervals_.upper_bound(interval.min()); if (mine != intervals_.begin()) { --mine; } @@ -706,7 +662,7 @@ bool QuicIntervalSet<T>::FindNextIntersectingPairImpl(X* x, const_iterator* mine, const_iterator* theirs, Func on_hole) { - CHECK(x != nullptr); + QUICHE_CHECK(x != nullptr); if ((*mine == x->intervals_.end()) || (*theirs == y.intervals_.end())) { return false; } @@ -716,7 +672,7 @@ bool QuicIntervalSet<T>::FindNextIntersectingPairImpl(X* x, while (*mine != x->intervals_.end() && (**mine).max() <= (**theirs).min()) { ++(*mine); } - on_hole(x, erase_first, *mine); + *mine = on_hole(x, erase_first, *mine); // We're done if the end of intervals_ is reached. if (*mine == x->intervals_.end()) { return false; @@ -744,7 +700,7 @@ void QuicIntervalSet<T>::Intersection(const QuicIntervalSet& other) { const_iterator mine = FindIntersectionCandidate(other); // Remove any intervals that cannot possibly intersect with other.intervals_. - intervals_.erase(intervals_.begin(), mine); + mine = intervals_.erase(intervals_.begin(), mine); const_iterator theirs = other.FindIntersectionCandidate(*this); while (FindNextIntersectingPairAndEraseHoles(other, &mine, &theirs)) { @@ -760,32 +716,35 @@ void QuicIntervalSet<T>::Intersection(const QuicIntervalSet& other) { value_type intersection; while (theirs != other.intervals_.end() && i.Intersects(*theirs, &intersection)) { - std::pair<typename Set::iterator, bool> ins = - intervals_.insert(intersection); - DCHECK(ins.second); + std::pair<const_iterator, bool> ins = intervals_.insert(intersection); + QUICHE_DCHECK(ins.second); mine = ins.first; ++theirs; } - DCHECK(mine != intervals_.end()); + QUICHE_DCHECK(mine != intervals_.end()); --theirs; ++mine; } - DCHECK(Valid()); + QUICHE_DCHECK(Valid()); } template <typename T> bool QuicIntervalSet<T>::Intersects(const QuicIntervalSet& other) const { - if (!SpanningInterval().Intersects(other.SpanningInterval())) { - return false; - } - - const_iterator mine = FindIntersectionCandidate(other); - if (mine == intervals_.end()) { - return false; + // Don't bother to handle nonoverlapping spanning intervals as a special case. + // This code runs in time O(n+m), as guaranteed, even for that case . + // Handling the nonoverlapping spanning intervals as a special case doesn't + // improve the asymptotics but does make the code more complex. + auto mine = intervals_.begin(); + auto theirs = other.intervals_.begin(); + while (mine != intervals_.end() && theirs != other.intervals_.end()) { + if (mine->Intersects(*theirs)) + return true; + else if (*mine < *theirs) + ++mine; + else + ++theirs; } - const_iterator theirs = other.FindIntersectionCandidate(*mine); - - return FindNextIntersectingPair(other, &mine, &theirs); + return false; } template <typename T> @@ -803,41 +762,64 @@ void QuicIntervalSet<T>::Difference(const T& min, const T& max) { template <typename T> void QuicIntervalSet<T>::Difference(const QuicIntervalSet& other) { - if (!SpanningInterval().Intersects(other.SpanningInterval())) { - return; - } - - const_iterator mine = FindIntersectionCandidate(other); - // If no interval in mine reaches the first interval of theirs then we're - // done. - if (mine == intervals_.end()) { + // In order to avoid quadratic-time when using a flat set, we don't try to + // update intervals_ in place. Instead we build up a new result_, always + // inserting at the end which is O(1) time per insertion. Since the number of + // elements in the result is O(Size() + other.Size()), the cost for all the + // insertions is also O(Size() + other.Size()). + // + // We look at all the elements of intervals_, so that's O(Size()). + // + // We also look at all the elements of other.intervals_, for O(other.Size()). + if (Empty()) return; - } - const_iterator theirs = other.FindIntersectionCandidate(*this); - - while (FindNextIntersectingPair(other, &mine, &theirs)) { - // At this point *mine and *theirs overlap. Remove mine from - // intervals_ and replace it with the possibly two intervals that are - // the difference between mine and theirs. - value_type i(*mine); - intervals_.erase(mine++); - value_type lo; - value_type hi; - i.Difference(*theirs, &lo, &hi); - - if (!lo.Empty()) { - // We have a low end. This can't intersect anything else. - std::pair<typename Set::iterator, bool> ins = intervals_.insert(lo); - DCHECK(ins.second); + Set result; + const_iterator mine = intervals_.begin(); + value_type myinterval = *mine; + const_iterator theirs = other.intervals_.begin(); + while (mine != intervals_.end()) { + // Loop invariants: + // myinterval is nonempty. + // mine points at a range that is a suffix of myinterval. + QUICHE_DCHECK(!myinterval.Empty()); + QUICHE_DCHECK(myinterval.max() == mine->max()); + + // There are 3 cases. + // myinterval is completely before theirs (treat theirs==end() as if it is + // infinity). + // --> consume myinterval into result. + // myinterval is completely after theirs + // --> theirs can no longer affect us, so ++theirs. + // myinterval touches theirs with a prefix of myinterval not touching + // *theirs. + // --> consume the prefix of myinterval into the result. + // myinterval touches theirs, with the first element of myinterval in + // *theirs. + // -> reduce myinterval + if (theirs == other.intervals_.end() || myinterval.max() <= theirs->min()) { + // Keep all of my_interval. + result.insert(result.end(), myinterval); + myinterval.Clear(); + } else if (theirs->max() <= myinterval.min()) { + ++theirs; + } else if (myinterval.min() < theirs->min()) { + // Keep a nonempty prefix of my interval. + result.insert(result.end(), value_type(myinterval.min(), theirs->min())); + myinterval.SetMin(theirs->max()); + } else { + // myinterval starts at or after *theirs, chop down myinterval. + myinterval.SetMin(theirs->max()); } - - if (!hi.Empty()) { - std::pair<typename Set::iterator, bool> ins = intervals_.insert(hi); - DCHECK(ins.second); - mine = ins.first; + // if myinterval became empty, find the next interval + if (myinterval.Empty()) { + ++mine; + if (mine != intervals_.end()) { + myinterval = *mine; + } } } - DCHECK(Valid()); + std::swap(result, intervals_); + QUICHE_DCHECK(Valid()); } template <typename T> @@ -854,49 +836,6 @@ std::string QuicIntervalSet<T>::ToString() const { return os.str(); } -// This method compacts the QuicIntervalSet, merging pairs of overlapping -// intervals into a single interval. In the steady state, the QuicIntervalSet -// does not contain any such pairs. However, the way the Union() and Add() -// methods work is to temporarily put the QuicIntervalSet into such a state and -// then to call Compact() to "fix it up" so that it is no longer in that state. -// -// Compact() needs the interval set to allow two intervals [a,b) and [a,c) -// (having the same min() but different max()) to briefly coexist in the set at -// the same time, and be adjacent to each other, so that they can be efficiently -// located and merged into a single interval. This state would be impossible -// with a comparator which only looked at min(), as such a comparator would -// consider such pairs equal. Fortunately, the comparator used by -// QuicIntervalSet does exactly what is needed, ordering first by ascending -// min(), then by descending max(). -template <typename T> -void QuicIntervalSet<T>::Compact(const typename Set::iterator& begin, - const typename Set::iterator& end) { - if (begin == end) - return; - typename Set::iterator next = begin; - typename Set::iterator prev = begin; - typename Set::iterator it = begin; - ++it; - ++next; - while (it != end) { - ++next; - if (prev->max() >= it->min()) { - // Overlapping / coalesced range; merge the two intervals. - T min = prev->min(); - T max = std::max(prev->max(), it->max()); - value_type i(min, max); - intervals_.erase(prev); - intervals_.erase(it); - std::pair<typename Set::iterator, bool> ins = intervals_.insert(i); - DCHECK(ins.second); - prev = ins.first; - } else { - prev = it; - } - it = next; - } -} - template <typename T> bool QuicIntervalSet<T>::Valid() const { const_iterator prev = end(); @@ -912,34 +851,46 @@ bool QuicIntervalSet<T>::Valid() const { return true; } -// This comparator orders intervals first by ascending min() and then by -// descending max(). Readers who are satisified with that explanation can stop -// reading here. The remainder of this comment is for the benefit of future -// maintainers of this library. -// -// The reason for this ordering is that this comparator has to serve two -// masters. First, it has to maintain the intervals in its internal set in the -// order that clients expect to see them. Clients see these intervals via the -// iterators provided by begin()/end() or as a result of invoking Get(). For -// this reason, the comparator orders intervals by ascending min(). -// -// If client iteration were the only consideration, then ordering by ascending -// min() would be good enough. This is because the intervals in the -// QuicIntervalSet are non-empty, non-adjacent, and mutually disjoint; such -// intervals happen to always have disjoint min() values, so such a comparator -// would never even have to look at max() in order to work correctly for this -// class. -// -// However, in addition to ordering by ascending min(), this comparator also has -// a second responsibility: satisfying the special needs of this library's -// peculiar internal implementation. These needs require the comparator to order -// first by ascending min() and then by descending max(). The best way to -// understand why this is so is to check out the comments associated with the -// Find() and Compact() methods. +// This comparator orders intervals first by ascending min(). The Set never +// contains overlapping intervals, so that suffices. template <typename T> bool QuicIntervalSet<T>::IntervalLess::operator()(const value_type& a, const value_type& b) const { - return a.min() < b.min() || (a.min() == b.min() && a.max() > b.max()); + // This overload is probably used only by Set::insert(). + return a.min() < b.min(); +} + +// It appears that the Set::lower_bound(T) method uses only two overloads of the +// comparison operator that take a T as the second argument.. In contrast +// Set::upper_bound(T) uses the two overloads that take T as the first argument. +template <typename T> +bool QuicIntervalSet<T>::IntervalLess::operator()(const value_type& a, + const T& point) const { + // Compare an interval to a point. + return a.min() < point; +} + +template <typename T> +bool QuicIntervalSet<T>::IntervalLess::operator()(const value_type& a, + T&& point) const { + // Compare an interval to a point + return a.min() < point; +} + +// It appears that the Set::upper_bound(T) method uses only the next two +// overloads of the comparison operator. +template <typename T> +bool QuicIntervalSet<T>::IntervalLess::operator()(const T& point, + const value_type& a) const { + // Compare an interval to a point. + return point < a.min(); +} + +template <typename T> +bool QuicIntervalSet<T>::IntervalLess::operator()(T&& point, + const value_type& a) const { + // Compare an interval to a point. + return point < a.min(); } } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_interval_set_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_interval_set_test.cc index 30d08b8bc1e..14db466a926 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_interval_set_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_interval_set_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_interval_set.h" +#include "quic/core/quic_interval_set.h" #include <stdarg.h> @@ -13,7 +13,7 @@ #include <string> #include <vector> -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { @@ -162,6 +162,21 @@ static void TestNotContainsAndFind(const QuicIntervalSet<int>& is, << "and max " << max; } +TEST_F(QuicIntervalSetTest, AddInterval) { + QuicIntervalSet<int> s; + s.Add(QuicInterval<int>(0, 10)); + EXPECT_TRUE(Check(s, 1, 0, 10)); +} + +TEST_F(QuicIntervalSetTest, DecrementIterator) { + auto it = is.end(); + EXPECT_NE(it, is.begin()); + --it; + EXPECT_EQ(*it, QuicInterval<int>(2100, 2200)); + ++it; + EXPECT_EQ(it, is.end()); +} + TEST_F(QuicIntervalSetTest, AddOptimizedForAppend) { QuicIntervalSet<int> empty_one, empty_two; empty_one.AddOptimizedForAppend(QuicInterval<int>(0, 99)); @@ -350,6 +365,11 @@ TEST_F(QuicIntervalSetTest, QuicIntervalSetBasic) { EXPECT_FALSE(iset.Contains(iset_contains)); EXPECT_FALSE(iset.Contains(QuicInterval<int>())); EXPECT_FALSE(iset.Contains(QuicIntervalSet<int>())); + + // Check the case where the query set isn't contained, but the spanning + // intervals do overlap. + QuicIntervalSet<int> i2({{220, 230}}); + EXPECT_FALSE(iset.Contains(i2)); } TEST_F(QuicIntervalSetTest, QuicIntervalSetContainsEmpty) { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_interval_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_interval_test.cc index 209299d8321..4ec9fa69454 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_interval_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_interval_test.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_interval.h" +#include "quic/core/quic_interval.h" #include <sstream> #include <string> #include <type_traits> #include <utility> -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { @@ -375,6 +375,19 @@ TEST_F(QuicIntervalTest, CoveringOps) { EXPECT_TRUE(d.Difference(d8, &diff) && diff.empty()); } +TEST_F(QuicIntervalTest, Separated) { + using QI = QuicInterval<int>; + EXPECT_FALSE(QI(100, 200).Separated(QI(100, 200))); + EXPECT_FALSE(QI(100, 200).Separated(QI(200, 300))); + EXPECT_TRUE(QI(100, 200).Separated(QI(201, 300))); + EXPECT_FALSE(QI(100, 200).Separated(QI(0, 100))); + EXPECT_TRUE(QI(100, 200).Separated(QI(0, 99))); + EXPECT_FALSE(QI(100, 200).Separated(QI(150, 170))); + EXPECT_FALSE(QI(150, 170).Separated(QI(100, 200))); + EXPECT_FALSE(QI(100, 200).Separated(QI(150, 250))); + EXPECT_FALSE(QI(150, 250).Separated(QI(100, 200))); +} + TEST_F(QuicIntervalTest, Length) { const QuicInterval<int> empty1; const QuicInterval<int> empty2(1, 1); diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_legacy_version_encapsulator.cc b/chromium/net/third_party/quiche/src/quic/core/quic_legacy_version_encapsulator.cc index 8e9317271dc..bfe2df2fce0 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_legacy_version_encapsulator.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_legacy_version_encapsulator.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_legacy_version_encapsulator.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/quic_legacy_version_encapsulator.h" +#include "quic/core/crypto/crypto_handshake_message.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { @@ -99,8 +99,8 @@ QuicPacketLength QuicLegacyVersionEncapsulator::Encapsulate( outer_chlo.SetStringPiece(kSNI, sni); outer_chlo.SetStringPiece(kQLVE, inner_packet); const QuicData& serialized_outer_chlo = outer_chlo.GetSerialized(); - DCHECK(!LegacyVersionForEncapsulation().UsesCryptoFrames()); - DCHECK(LegacyVersionForEncapsulation().UsesQuicCrypto()); + QUICHE_DCHECK(!LegacyVersionForEncapsulation().UsesCryptoFrames()); + QUICHE_DCHECK(LegacyVersionForEncapsulation().UsesQuicCrypto()); QuicStreamFrame outer_stream_frame( QuicUtils::GetCryptoStreamId( LegacyVersionForEncapsulation().transport_version), diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_legacy_version_encapsulator.h b/chromium/net/third_party/quiche/src/quic/core/quic_legacy_version_encapsulator.h index 7a4ada68b9f..1d528fec62c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_legacy_version_encapsulator.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_legacy_version_encapsulator.h @@ -6,10 +6,10 @@ #define QUICHE_QUIC_CORE_QUIC_LEGACY_VERSION_ENCAPSULATOR_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_creator.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_packet_creator.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_legacy_version_encapsulator_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_legacy_version_encapsulator_test.cc index d765fff3ba6..1d855f2f55d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_legacy_version_encapsulator_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_legacy_version_encapsulator_test.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_legacy_version_encapsulator.h" +#include "quic/core/quic_legacy_version_encapsulator.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_linux_socket_utils.cc b/chromium/net/third_party/quiche/src/quic/core/quic_linux_socket_utils.cc index 6dd74c3b19c..c2931afe02e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_linux_socket_utils.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_linux_socket_utils.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_linux_socket_utils.h" +#include "quic/core/quic_linux_socket_utils.h" #include <linux/net_tstamp.h> #include <netinet/in.h> #include <cstdint> -#include "net/third_party/quiche/src/quic/core/quic_syscall_wrapper.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/quic_syscall_wrapper.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { @@ -25,7 +25,7 @@ QuicMsgHdr::QuicMsgHdr(const char* buffer, cbuf_size_(cbuf_size), cmsg_(nullptr) { // Only support unconnected sockets. - DCHECK(peer_address.IsInitialized()); + QUICHE_DCHECK(peer_address.IsInitialized()); raw_peer_address_ = peer_address.generic_address(); hdr_.msg_name = &raw_peer_address_; @@ -61,19 +61,19 @@ void* QuicMsgHdr::GetNextCmsgDataInternal(int cmsg_level, // msg_controllen needs to be increased first, otherwise CMSG_NXTHDR will // return nullptr. hdr_.msg_controllen += CMSG_SPACE(data_size); - DCHECK_LE(hdr_.msg_controllen, cbuf_size_); + QUICHE_DCHECK_LE(hdr_.msg_controllen, cbuf_size_); if (cmsg_ == nullptr) { - DCHECK_EQ(nullptr, hdr_.msg_control); + QUICHE_DCHECK_EQ(nullptr, hdr_.msg_control); memset(cbuf_, 0, cbuf_size_); hdr_.msg_control = cbuf_; cmsg_ = CMSG_FIRSTHDR(&hdr_); } else { - DCHECK_NE(nullptr, hdr_.msg_control); + QUICHE_DCHECK_NE(nullptr, hdr_.msg_control); cmsg_ = CMSG_NXTHDR(&hdr_, cmsg_); } - DCHECK_NE(nullptr, cmsg_) << "Insufficient control buffer space"; + QUICHE_DCHECK_NE(nullptr, cmsg_) << "Insufficient control buffer space"; cmsg_->cmsg_len = CMSG_LEN(data_size); cmsg_->cmsg_level = cmsg_level; @@ -95,7 +95,7 @@ void QuicMMsgHdr::InitOneHeader(int i, const BufferedWrite& buffered_write) { hdr->msg_controllen = 0; // Only support unconnected sockets. - DCHECK(buffered_write.peer_address.IsInitialized()); + QUICHE_DCHECK(buffered_write.peer_address.IsInitialized()); sockaddr_storage* peer_address_storage = GetPeerAddressStorage(i); *peer_address_storage = buffered_write.peer_address.generic_address(); @@ -131,18 +131,18 @@ void* QuicMMsgHdr::GetNextCmsgDataInternal(int i, // msg_controllen needs to be increased first, otherwise CMSG_NXTHDR will // return nullptr. hdr->msg_controllen += CMSG_SPACE(data_size); - DCHECK_LE(hdr->msg_controllen, cbuf_size_); + QUICHE_DCHECK_LE(hdr->msg_controllen, cbuf_size_); if (cmsg == nullptr) { - DCHECK_EQ(nullptr, hdr->msg_control); + QUICHE_DCHECK_EQ(nullptr, hdr->msg_control); hdr->msg_control = GetCbuf(i); cmsg = CMSG_FIRSTHDR(hdr); } else { - DCHECK_NE(nullptr, hdr->msg_control); + QUICHE_DCHECK_NE(nullptr, hdr->msg_control); cmsg = CMSG_NXTHDR(hdr, cmsg); } - DCHECK_NE(nullptr, cmsg) << "Insufficient control buffer space"; + QUICHE_DCHECK_NE(nullptr, cmsg) << "Insufficient control buffer space"; cmsg->cmsg_len = CMSG_LEN(data_size); cmsg->cmsg_level = cmsg_level; @@ -152,8 +152,8 @@ void* QuicMMsgHdr::GetNextCmsgDataInternal(int i, } int QuicMMsgHdr::num_bytes_sent(int num_packets_sent) { - DCHECK_LE(0, num_packets_sent); - DCHECK_LE(num_packets_sent, num_msgs_); + QUICHE_DCHECK_LE(0, num_packets_sent); + QUICHE_DCHECK_LE(num_packets_sent, num_msgs_); int bytes_sent = 0; iovec* iov = GetIov(0); @@ -219,7 +219,7 @@ bool QuicLinuxSocketUtils::GetTtlFromMsghdr(struct msghdr* hdr, int* ttl) { void QuicLinuxSocketUtils::SetIpInfoInCmsgData( const QuicIpAddress& self_address, void* cmsg_data) { - DCHECK(self_address.IsInitialized()); + QUICHE_DCHECK(self_address.IsInitialized()); const std::string& address_str = self_address.ToPackedString(); if (self_address.IsIPv4()) { in_pktinfo* pktinfo = static_cast<in_pktinfo*>(cmsg_data); diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_linux_socket_utils.h b/chromium/net/third_party/quiche/src/quic/core/quic_linux_socket_utils.h index fe186dfe872..14c26dc8d73 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_linux_socket_utils.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_linux_socket_utils.h @@ -17,12 +17,12 @@ #include <type_traits> #include <utility> -#include "net/third_party/quiche/src/quic/core/quic_packet_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/quic_packet_writer.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_socket_address.h" #ifndef SOL_UDP #define SOL_UDP 17 @@ -174,7 +174,7 @@ class QUIC_EXPORT_PRIVATE QuicMMsgHdr { BufferedWrite>::value, "Must iterate over a collection of BufferedWrite."); - DCHECK_LE(0, num_msgs_); + QUICHE_DCHECK_LE(0, num_msgs_); if (num_msgs_ == 0) { return; } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_linux_socket_utils_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_linux_socket_utils_test.cc index 32ad12f1473..84259583063 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_linux_socket_utils_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_linux_socket_utils_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_linux_socket_utils.h" +#include "quic/core/quic_linux_socket_utils.h" #include <netinet/in.h> #include <stdint.h> @@ -12,9 +12,9 @@ #include <string> -#include "net/third_party/quiche/src/quic/core/quic_circular_deque.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_mock_syscall_wrapper.h" +#include "quic/core/quic_circular_deque.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_mock_syscall_wrapper.h" using testing::_; using testing::InSequence; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_lru_cache.h b/chromium/net/third_party/quiche/src/quic/core/quic_lru_cache.h index 2ec089c820c..d4b11e0ce5f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_lru_cache.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_lru_cache.h @@ -7,10 +7,11 @@ #include <memory> -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -37,7 +38,7 @@ class QUIC_NO_EXPORT QuicLRUCache { if (cache_.size() > capacity_) { cache_.pop_front(); } - DCHECK_LE(cache_.size(), capacity_); + QUICHE_DCHECK_LE(cache_.size(), capacity_); } // If cache contains an entry for |key|, return a pointer to it. This returned @@ -52,7 +53,7 @@ class QUIC_NO_EXPORT QuicLRUCache { std::unique_ptr<V> value = std::move(it->second); cache_.erase(it); auto result = cache_.emplace(key, std::move(value)); - DCHECK(result.second); + QUICHE_DCHECK(result.second); return result.first->second.get(); } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_lru_cache_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_lru_cache_test.cc index 92f788b7af7..d2c05056c6e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_lru_cache_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_lru_cache_test.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_lru_cache.h" +#include "quic/core/quic_lru_cache.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_mtu_discovery.cc b/chromium/net/third_party/quiche/src/quic/core/quic_mtu_discovery.cc index bbf18b6d7a6..056a4bd5bde 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_mtu_discovery.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_mtu_discovery.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_mtu_discovery.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_stack_trace.h" +#include "quic/core/quic_mtu_discovery.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_stack_trace.h" namespace quic { @@ -17,7 +17,7 @@ QuicConnectionMtuDiscoverer::QuicConnectionMtuDiscoverer( void QuicConnectionMtuDiscoverer::Enable( QuicByteCount max_packet_length, QuicByteCount target_max_packet_length) { - DCHECK(!IsEnabled()); + QUICHE_DCHECK(!IsEnabled()); if (target_max_packet_length <= max_packet_length) { QUIC_DVLOG(1) << "MtuDiscoverer not enabled. target_max_packet_length:" @@ -28,7 +28,7 @@ void QuicConnectionMtuDiscoverer::Enable( min_probe_length_ = max_packet_length; max_probe_length_ = target_max_packet_length; - DCHECK(IsEnabled()); + QUICHE_DCHECK(IsEnabled()); QUIC_DVLOG(1) << "MtuDiscoverer enabled. min:" << min_probe_length_ << ", max:" << max_probe_length_ @@ -70,7 +70,7 @@ bool QuicConnectionMtuDiscoverer::ShouldProbeMtu( QuicPacketLength QuicConnectionMtuDiscoverer::GetUpdatedMtuProbeSize( QuicPacketNumber largest_sent_packet) { - DCHECK(ShouldProbeMtu(largest_sent_packet)); + QUICHE_DCHECK(ShouldProbeMtu(largest_sent_packet)); QuicPacketLength probe_packet_length = next_probe_packet_length(); if (probe_packet_length == last_probe_length_) { @@ -78,7 +78,7 @@ QuicPacketLength QuicConnectionMtuDiscoverer::GetUpdatedMtuProbeSize( // previous one exceeded MTU, we need to decrease the probe packet length. max_probe_length_ = probe_packet_length; } else { - DCHECK_GT(probe_packet_length, last_probe_length_); + QUICHE_DCHECK_GT(probe_packet_length, last_probe_length_); } last_probe_length_ = next_probe_packet_length(); @@ -93,14 +93,14 @@ QuicPacketLength QuicConnectionMtuDiscoverer::GetUpdatedMtuProbeSize( << ", New packets_between_probes_:" << packets_between_probes_ << ", next_probe_at_:" << next_probe_at_ << ", remaining_probe_count_:" << remaining_probe_count_; - DCHECK(!ShouldProbeMtu(largest_sent_packet)); + QUICHE_DCHECK(!ShouldProbeMtu(largest_sent_packet)); return last_probe_length_; } QuicPacketLength QuicConnectionMtuDiscoverer::next_probe_packet_length() const { - DCHECK_NE(min_probe_length_, 0); - DCHECK_NE(max_probe_length_, 0); - DCHECK_GE(max_probe_length_, min_probe_length_); + QUICHE_DCHECK_NE(min_probe_length_, 0); + QUICHE_DCHECK_NE(max_probe_length_, 0); + QUICHE_DCHECK_GE(max_probe_length_, min_probe_length_); const QuicPacketLength normal_next_probe_length = (min_probe_length_ + max_probe_length_ + 1) / 2; @@ -121,7 +121,7 @@ void QuicConnectionMtuDiscoverer::OnMaxPacketLengthUpdated( return; } - DCHECK_EQ(old_value, min_probe_length_); + QUICHE_DCHECK_EQ(old_value, min_probe_length_); min_probe_length_ = new_value; } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_mtu_discovery.h b/chromium/net/third_party/quiche/src/quic/core/quic_mtu_discovery.h index 5ec5133114c..b16cc6aedca 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_mtu_discovery.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_mtu_discovery.h @@ -7,8 +7,8 @@ #include <iostream> -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_types.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_network_blackhole_detector.cc b/chromium/net/third_party/quiche/src/quic/core/quic_network_blackhole_detector.cc index 79deba84848..a79810f9aa0 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_network_blackhole_detector.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_network_blackhole_detector.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_network_blackhole_detector.h" +#include "quic/core/quic_network_blackhole_detector.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" +#include "quic/core/quic_constants.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_network_blackhole_detector.h b/chromium/net/third_party/quiche/src/quic/core/quic_network_blackhole_detector.h index 6952c85d22b..7010eb581a8 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_network_blackhole_detector.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_network_blackhole_detector.h @@ -5,12 +5,12 @@ #ifndef QUICHE_QUIC_CORE_QUIC_NETWORK_BLACKHOLE_DETECTOR_H_ #define QUICHE_QUIC_CORE_QUIC_NETWORK_BLACKHOLE_DETECTOR_H_ -#include "net/third_party/quiche/src/quic/core/quic_alarm.h" -#include "net/third_party/quiche/src/quic/core/quic_alarm_factory.h" -#include "net/third_party/quiche/src/quic/core/quic_one_block_arena.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "quic/core/quic_alarm.h" +#include "quic/core/quic_alarm_factory.h" +#include "quic/core/quic_one_block_arena.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_flags.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_network_blackhole_detector_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_network_blackhole_detector_test.cc index d628d777396..3bc6ad73cbb 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_network_blackhole_detector_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_network_blackhole_detector_test.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_network_blackhole_detector.h" +#include "quic/core/quic_network_blackhole_detector.h" -#include "net/third_party/quiche/src/quic/core/quic_one_block_arena.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/quic_one_block_arena.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_one_block_arena.h b/chromium/net/third_party/quiche/src/quic/core/quic_one_block_arena.h index d8218036643..8311477219c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_one_block_arena.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_one_block_arena.h @@ -3,19 +3,19 @@ // found in the LICENSE file. // An arena that consists of a single inlined block of |ArenaSize|. Useful to -// avoid repeated calls to malloc/new and to improve memory locality. DCHECK's -// if an allocation out of the arena ever fails in debug builds; falls back to -// heap allocation in release builds. +// avoid repeated calls to malloc/new and to improve memory locality. +// QUICHE_DCHECK's if an allocation out of the arena ever fails in debug builds; +// falls back to heap allocation in release builds. #ifndef QUICHE_QUIC_CORE_QUIC_ONE_BLOCK_ARENA_H_ #define QUICHE_QUIC_CORE_QUIC_ONE_BLOCK_ARENA_H_ #include <cstdint> -#include "net/third_party/quiche/src/quic/core/quic_arena_scoped_ptr.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/quic_arena_scoped_ptr.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -24,7 +24,7 @@ class QUIC_EXPORT_PRIVATE QuicOneBlockArena { static const uint32_t kMaxAlign = 8; public: - QuicOneBlockArena(); + QuicOneBlockArena() : offset_(0) {} QuicOneBlockArena(const QuicOneBlockArena&) = delete; QuicOneBlockArena& operator=(const QuicOneBlockArena&) = delete; @@ -32,7 +32,24 @@ class QUIC_EXPORT_PRIVATE QuicOneBlockArena { // forwarded to |T|'s constructor. The returned pointer's lifetime is // controlled by QuicArenaScopedPtr. template <typename T, typename... Args> - QuicArenaScopedPtr<T> New(Args&&... args); + QuicArenaScopedPtr<T> New(Args&&... args) { + QUICHE_DCHECK_LT(AlignedSize<T>(), ArenaSize) + << "Object is too large for the arena."; + static_assert(alignof(T) > 1, + "Objects added to the arena must be at least 2B aligned."); + if (QUIC_PREDICT_FALSE(offset_ > ArenaSize - AlignedSize<T>())) { + QUIC_BUG << "Ran out of space in QuicOneBlockArena at " << this + << ", max size was " << ArenaSize << ", failing request was " + << AlignedSize<T>() << ", end of arena was " << offset_; + return QuicArenaScopedPtr<T>(new T(std::forward<Args>(args)...)); + } + + void* buf = &storage_[offset_]; + new (buf) T(std::forward<Args>(args)...); + offset_ += AlignedSize<T>(); + return QuicArenaScopedPtr<T>(buf, + QuicArenaScopedPtr<T>::ConstructFrom::kArena); + } private: // Returns the size of |T| aligned up to |kMaxAlign|. @@ -49,33 +66,9 @@ class QUIC_EXPORT_PRIVATE QuicOneBlockArena { uint32_t offset_; }; -template <uint32_t ArenaSize> -QuicOneBlockArena<ArenaSize>::QuicOneBlockArena() : offset_(0) {} - -template <uint32_t ArenaSize> -template <typename T, typename... Args> -QuicArenaScopedPtr<T> QuicOneBlockArena<ArenaSize>::New(Args&&... args) { - DCHECK_LT(AlignedSize<T>(), ArenaSize) - << "Object is too large for the arena."; - static_assert(alignof(T) > 1, - "Objects added to the arena must be at least 2B aligned."); - if (QUIC_PREDICT_FALSE(offset_ > ArenaSize - AlignedSize<T>())) { - QUIC_BUG << "Ran out of space in QuicOneBlockArena at " << this - << ", max size was " << ArenaSize << ", failing request was " - << AlignedSize<T>() << ", end of arena was " << offset_; - return QuicArenaScopedPtr<T>(new T(std::forward<Args>(args)...)); - } - - void* buf = &storage_[offset_]; - new (buf) T(std::forward<Args>(args)...); - offset_ += AlignedSize<T>(); - return QuicArenaScopedPtr<T>(buf, - QuicArenaScopedPtr<T>::ConstructFrom::kArena); -} - // QuicConnections currently use around 1KB of polymorphic types which would // ordinarily be on the heap. Instead, store them inline in an arena. -using QuicConnectionArena = QuicOneBlockArena<1024>; +using QuicConnectionArena = QuicOneBlockArena<1056>; } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_one_block_arena_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_one_block_arena_test.cc index 3175ac54abf..181ab3f852c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_one_block_arena_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_one_block_arena_test.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_one_block_arena.h" +#include "quic/core/quic_one_block_arena.h" #include <cstdint> -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_packet_creator.cc b/chromium/net/third_party/quiche/src/quic/core/quic_packet_creator.cc index 3db37eda64b..9dabd3af78f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_packet_creator.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_packet_creator.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_packet_creator.h" +#include "quic/core/quic_packet_creator.h" #include <algorithm> #include <cstddef> @@ -13,26 +13,26 @@ #include "absl/base/macros.h" #include "absl/base/optimization.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_path_challenge_frame.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_stream_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_exported_stats.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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_server_stats.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/frames/quic_frame.h" +#include "quic/core/frames/quic_path_challenge_frame.h" +#include "quic/core/frames/quic_stream_frame.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_exported_stats.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_server_stats.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { namespace { @@ -134,9 +134,6 @@ QuicPacketCreator::QuicPacketCreator(QuicConnectionId server_connection_id, fully_pad_crypto_handshake_packets_(true), latched_hard_max_packet_length_(0), max_datagram_frame_size_(0) { - if (let_connection_handle_pings_) { - QUIC_RELOADABLE_FLAG_COUNT(quic_let_connection_handle_pings); - } SetMaxPacketLength(kDefaultMaxPacketSize); if (!framer_->version().UsesTls()) { // QUIC+TLS negotiates the maximum datagram frame size via the @@ -162,7 +159,7 @@ bool QuicPacketCreator::CanSetMaxPacketLength() const { } void QuicPacketCreator::SetMaxPacketLength(QuicByteCount length) { - DCHECK(CanSetMaxPacketLength()); + QUICHE_DCHECK(CanSetMaxPacketLength()); // Avoid recomputing |max_plaintext_size_| if the length does not actually // change. @@ -195,7 +192,7 @@ void QuicPacketCreator::SetMaxDatagramFrameSize( } void QuicPacketCreator::SetSoftMaxPacketLength(QuicByteCount length) { - DCHECK(CanSetMaxPacketLength()); + QUICHE_DCHECK(CanSetMaxPacketLength()); if (length > max_packet_length_) { QUIC_BUG << ENDPOINT << "Try to increase max_packet_length_ in " @@ -220,18 +217,18 @@ void QuicPacketCreator::SetSoftMaxPacketLength(QuicByteCount length) { // A packet that is already open might send kQuicVersionSize bytes less than the // maximum packet size if we stop sending version before it is serialized. void QuicPacketCreator::StopSendingVersion() { - DCHECK(send_version_in_packet_); - DCHECK(!VersionHasIetfInvariantHeader(framer_->transport_version())); + QUICHE_DCHECK(send_version_in_packet_); + QUICHE_DCHECK(!version().HasIetfInvariantHeader()); send_version_in_packet_ = false; if (packet_size_ > 0) { - DCHECK_LT(kQuicVersionSize, packet_size_); + QUICHE_DCHECK_LT(kQuicVersionSize, packet_size_); packet_size_ -= kQuicVersionSize; } } void QuicPacketCreator::SetDiversificationNonce( const DiversificationNonce& nonce) { - DCHECK(!have_diversification_nonce_); + QUICHE_DCHECK(!have_diversification_nonce_); have_diversification_nonce_ = true; diversification_nonce_ = nonce; } @@ -249,7 +246,7 @@ void QuicPacketCreator::UpdatePacketNumberLength( } const QuicPacketNumber next_packet_number = NextSendingPacketNumber(); - DCHECK_LE(least_packet_awaited_by_peer, next_packet_number); + QUICHE_DCHECK_LE(least_packet_awaited_by_peer, next_packet_number); const uint64_t current_delta = next_packet_number - least_packet_awaited_by_peer; const uint64_t delta = std::max(current_delta, max_packets_in_flight); @@ -258,13 +255,13 @@ void QuicPacketCreator::UpdatePacketNumberLength( if (packet_.packet_number_length == packet_number_length) { return; } - QUIC_DLOG(INFO) << ENDPOINT << "Updating packet number length from " - << static_cast<int>(packet_.packet_number_length) << " to " - << static_cast<int>(packet_number_length) - << ", least_packet_awaited_by_peer: " - << least_packet_awaited_by_peer - << " max_packets_in_flight: " << max_packets_in_flight - << " next_packet_number: " << next_packet_number; + QUIC_DVLOG(1) << ENDPOINT << "Updating packet number length from " + << static_cast<int>(packet_.packet_number_length) << " to " + << static_cast<int>(packet_number_length) + << ", least_packet_awaited_by_peer: " + << least_packet_awaited_by_peer + << " max_packets_in_flight: " << max_packets_in_flight + << " next_packet_number: " << next_packet_number; packet_.packet_number_length = packet_number_length; } @@ -417,14 +414,14 @@ void QuicPacketCreator::CreateStreamFrame(QuicStreamId id, QuicFrame* frame) { // Make sure max_packet_length_ is greater than the largest possible overhead // or max_packet_length_ is set to the soft limit. - DCHECK(max_packet_length_ > - StreamFramePacketOverhead( - framer_->transport_version(), - GetDestinationConnectionIdLength(), - GetSourceConnectionIdLength(), kIncludeVersion, - IncludeNonceInPublicHeader(), PACKET_6BYTE_PACKET_NUMBER, - GetRetryTokenLengthLength(), GetLengthLength(), offset) || - latched_hard_max_packet_length_ > 0); + QUICHE_DCHECK( + max_packet_length_ > + StreamFramePacketOverhead( + framer_->transport_version(), GetDestinationConnectionIdLength(), + GetSourceConnectionIdLength(), kIncludeVersion, + IncludeNonceInPublicHeader(), PACKET_6BYTE_PACKET_NUMBER, + GetRetryTokenLengthLength(), GetLengthLength(), offset) || + latched_hard_max_packet_length_ > 0); QUIC_BUG_IF(!HasRoomForStreamFrame(id, offset, data_size)) << "No room for Stream frame, BytesFree: " << BytesFree() @@ -474,7 +471,7 @@ void QuicPacketCreator::FlushCurrentPacket() { external_buffer.release_buffer = nullptr; } - DCHECK_EQ(nullptr, packet_.encrypted_buffer); + QUICHE_DCHECK_EQ(nullptr, packet_.encrypted_buffer); if (!SerializePacket(std::move(external_buffer), kMaxOutgoingPacketSize)) { return; } @@ -503,8 +500,8 @@ void QuicPacketCreator::ClearPacket() { QUIC_BUG_IF(packet_.release_encrypted_buffer != nullptr) << "packet_.release_encrypted_buffer should be empty"; packet_.release_encrypted_buffer = nullptr; - DCHECK(packet_.retransmittable_frames.empty()); - DCHECK(packet_.nonretransmittable_frames.empty()); + QUICHE_DCHECK(packet_.retransmittable_frames.empty()); + QUICHE_DCHECK(packet_.nonretransmittable_frames.empty()); packet_.largest_acked.Clear(); needs_full_padding_ = false; } @@ -567,8 +564,8 @@ void QuicPacketCreator::CreateAndSerializeStreamFrame( TransmissionType transmission_type, size_t* num_bytes_consumed) { // TODO(b/167222597): consider using ScopedSerializationFailureHandler. - DCHECK(queued_frames_.empty()); - DCHECK(!QuicUtils::IsCryptoStreamId(transport_version(), id)); + QUICHE_DCHECK(queued_frames_.empty()); + QUICHE_DCHECK(!QuicUtils::IsCryptoStreamId(transport_version(), id)); // Write out the packet header QuicPacketHeader header; FillPacketHeader(&header); @@ -654,8 +651,8 @@ void QuicPacketCreator::CreateAndSerializeStreamFrame( packet_.transmission_type = transmission_type; - DCHECK(packet_.encryption_level == ENCRYPTION_FORWARD_SECURE || - packet_.encryption_level == ENCRYPTION_ZERO_RTT) + QUICHE_DCHECK(packet_.encryption_level == ENCRYPTION_FORWARD_SECURE || + packet_.encryption_level == ENCRYPTION_ZERO_RTT) << packet_.encryption_level; size_t encrypted_length = framer_->EncryptInPlace( packet_.encryption_level, packet_.packet_number, @@ -724,7 +721,7 @@ size_t QuicPacketCreator::ExpansionOnNewFrameWithLastFrame( } size_t QuicPacketCreator::BytesFree() const { - DCHECK_GE(max_plaintext_size_, PacketSize()); + QUICHE_DCHECK_GE(max_plaintext_size_, PacketSize()); return max_plaintext_size_ - std::min(max_plaintext_size_, PacketSize() + ExpansionOnNewFrame()); } @@ -755,7 +752,7 @@ bool QuicPacketCreator::SerializePacket(QuicOwnedPacketBuffer encrypted_buffer, } ScopedSerializationFailureHandler handler(this); - DCHECK_LT(0u, encrypted_buffer_len); + QUICHE_DCHECK_LT(0u, encrypted_buffer_len); QUIC_BUG_IF(queued_frames_.empty() && pending_padding_bytes_ == 0) << "Attempt to serialize empty packet"; QuicPacketHeader header; @@ -788,7 +785,7 @@ bool QuicPacketCreator::SerializePacket(QuicOwnedPacketBuffer encrypted_buffer, return false; } - DCHECK_GE(max_plaintext_size_, packet_size_); + QUICHE_DCHECK_GE(max_plaintext_size_, packet_size_); // Use the packet_size_ instead of the buffer size to ensure smaller // packet sizes are properly used. size_t length = @@ -816,7 +813,7 @@ bool QuicPacketCreator::SerializePacket(QuicOwnedPacketBuffer encrypted_buffer, // Because of possible truncation, we can't be confident that our // packet size calculation worked correctly. if (!possibly_truncated_by_length) { - DCHECK_EQ(packet_size_, length); + QUICHE_DCHECK_EQ(packet_size_, length); } const size_t encrypted_length = framer_->EncryptInPlace( packet_.encryption_level, packet_.packet_number, @@ -851,14 +848,14 @@ QuicPacketCreator::SerializeConnectivityProbingPacket() { std::unique_ptr<char[]> buffer(new char[kMaxOutgoingPacketSize]); size_t length = BuildConnectivityProbingPacket( header, buffer.get(), max_plaintext_size_, packet_.encryption_level); - DCHECK(length); + QUICHE_DCHECK(length); - DCHECK_EQ(packet_.encryption_level, ENCRYPTION_FORWARD_SECURE); + QUICHE_DCHECK_EQ(packet_.encryption_level, ENCRYPTION_FORWARD_SECURE); const size_t encrypted_length = framer_->EncryptInPlace( packet_.encryption_level, packet_.packet_number, GetStartOfEncryptedData(framer_->transport_version(), header), length, kMaxOutgoingPacketSize, buffer.get()); - DCHECK(encrypted_length); + QUICHE_DCHECK(encrypted_length); std::unique_ptr<SerializedPacket> serialize_packet(new SerializedPacket( header.packet_number, header.packet_number_length, buffer.release(), @@ -875,7 +872,7 @@ QuicPacketCreator::SerializeConnectivityProbingPacket() { std::unique_ptr<SerializedPacket> QuicPacketCreator::SerializePathChallengeConnectivityProbingPacket( - QuicPathFrameBuffer* payload) { + const QuicPathFrameBuffer& payload) { QUIC_BUG_IF(!VersionHasIetfQuicFrames(framer_->transport_version())) << "Must be version 99 to serialize path challenge connectivity probe, " "is version " @@ -888,17 +885,17 @@ QuicPacketCreator::SerializePathChallengeConnectivityProbingPacket( QUIC_DVLOG(2) << ENDPOINT << "Serializing path challenge packet " << header; std::unique_ptr<char[]> buffer(new char[kMaxOutgoingPacketSize]); - size_t length = BuildPaddedPathChallengePacket( - header, buffer.get(), max_plaintext_size_, payload, random_, - packet_.encryption_level); - DCHECK(length); + size_t length = + BuildPaddedPathChallengePacket(header, buffer.get(), max_plaintext_size_, + payload, packet_.encryption_level); + QUICHE_DCHECK(length); - DCHECK_EQ(packet_.encryption_level, ENCRYPTION_FORWARD_SECURE); + QUICHE_DCHECK_EQ(packet_.encryption_level, ENCRYPTION_FORWARD_SECURE); const size_t encrypted_length = framer_->EncryptInPlace( packet_.encryption_level, packet_.packet_number, GetStartOfEncryptedData(framer_->transport_version(), header), length, kMaxOutgoingPacketSize, buffer.get()); - DCHECK(encrypted_length); + QUICHE_DCHECK(encrypted_length); std::unique_ptr<SerializedPacket> serialize_packet( new SerializedPacket(header.packet_number, header.packet_number_length, @@ -933,14 +930,14 @@ QuicPacketCreator::SerializePathResponseConnectivityProbingPacket( size_t length = BuildPathResponsePacket(header, buffer.get(), max_plaintext_size_, payloads, is_padded, packet_.encryption_level); - DCHECK(length); + QUICHE_DCHECK(length); - DCHECK_EQ(packet_.encryption_level, ENCRYPTION_FORWARD_SECURE); + QUICHE_DCHECK_EQ(packet_.encryption_level, ENCRYPTION_FORWARD_SECURE); const size_t encrypted_length = framer_->EncryptInPlace( packet_.encryption_level, packet_.packet_number, GetStartOfEncryptedData(framer_->transport_version(), header), length, kMaxOutgoingPacketSize, buffer.get()); - DCHECK(encrypted_length); + QUICHE_DCHECK(encrypted_length); std::unique_ptr<SerializedPacket> serialize_packet( new SerializedPacket(header.packet_number, header.packet_number_length, @@ -960,15 +957,13 @@ size_t QuicPacketCreator::BuildPaddedPathChallengePacket( const QuicPacketHeader& header, char* buffer, size_t packet_length, - QuicPathFrameBuffer* payload, - QuicRandom* randomizer, + const QuicPathFrameBuffer& payload, EncryptionLevel level) { - DCHECK(VersionHasIetfQuicFrames(framer_->transport_version())); + QUICHE_DCHECK(VersionHasIetfQuicFrames(framer_->transport_version())); QuicFrames frames; // Write a PATH_CHALLENGE frame, which has a random 8-byte payload - randomizer->RandBytes(payload->data(), payload->size()); - QuicPathChallengeFrame path_challenge_frame(0, *payload); + QuicPathChallengeFrame path_challenge_frame(0, payload); frames.push_back(QuicFrame(&path_challenge_frame)); if (debug_delegate_ != nullptr) { @@ -995,7 +990,7 @@ size_t QuicPacketCreator::BuildPathResponsePacket( << "Attempt to generate connectivity response with no request payloads"; return 0; } - DCHECK(VersionHasIetfQuicFrames(framer_->transport_version())); + QUICHE_DCHECK(VersionHasIetfQuicFrames(framer_->transport_version())); std::vector<std::unique_ptr<QuicPathResponseFrame>> path_response_frames; for (const QuicPathFrameBuffer& payload : payloads) { @@ -1134,8 +1129,8 @@ QuicConnectionIdIncluded QuicPacketCreator::GetSourceConnectionIdIncluded() QuicConnectionIdLength QuicPacketCreator::GetDestinationConnectionIdLength() const { - DCHECK(QuicUtils::IsConnectionIdValidForVersion(server_connection_id_, - transport_version())); + QUICHE_DCHECK(QuicUtils::IsConnectionIdValidForVersion(server_connection_id_, + transport_version())); return GetDestinationConnectionIdIncluded() == CONNECTION_ID_PRESENT ? static_cast<QuicConnectionIdLength>( GetDestinationConnectionId().length()) @@ -1143,8 +1138,8 @@ QuicConnectionIdLength QuicPacketCreator::GetDestinationConnectionIdLength() } QuicConnectionIdLength QuicPacketCreator::GetSourceConnectionIdLength() const { - DCHECK(QuicUtils::IsConnectionIdValidForVersion(server_connection_id_, - transport_version())); + QUICHE_DCHECK(QuicUtils::IsConnectionIdValidForVersion(server_connection_id_, + transport_version())); return GetSourceConnectionIdIncluded() == CONNECTION_ID_PRESENT ? static_cast<QuicConnectionIdLength>( GetSourceConnectionId().length()) @@ -1193,9 +1188,9 @@ void QuicPacketCreator::SetRetryToken(absl::string_view retry_token) { bool QuicPacketCreator::ConsumeRetransmittableControlFrame( const QuicFrame& frame) { QUIC_BUG_IF(IsControlFrame(frame.type) && !GetControlFrameId(frame) && - (!let_connection_handle_pings_ || frame.type != PING_FRAME)) + frame.type != PING_FRAME) << "Adding a control frame with no control frame id: " << frame; - DCHECK(QuicUtils::IsRetransmittableFrame(frame.type)) << frame; + QUICHE_DCHECK(QuicUtils::IsRetransmittableFrame(frame.type)) << frame; MaybeBundleAckOpportunistically(); if (HasPendingFrames()) { if (AddFrame(frame, next_transmission_type_)) { @@ -1203,7 +1198,7 @@ bool QuicPacketCreator::ConsumeRetransmittableControlFrame( return true; } } - DCHECK(!HasPendingFrames()); + QUICHE_DCHECK(!HasPendingFrames()); if (frame.type != PING_FRAME && frame.type != CONNECTION_CLOSE_FRAME && !delegate_->ShouldGeneratePacket(HAS_RETRANSMITTABLE_DATA, NOT_HANDSHAKE)) { @@ -1275,8 +1270,8 @@ QuicConsumedData QuicPacketCreator::ConsumeData(QuicStreamId id, if (fin_consumed && state == FIN_AND_PADDING) { AddRandomPadding(); } - DCHECK(total_bytes_consumed == write_length || - (bytes_consumed > 0 && HasPendingFrames())); + QUICHE_DCHECK(total_bytes_consumed == write_length || + (bytes_consumed > 0 && HasPendingFrames())); if (total_bytes_consumed == write_length) { // We're done writing the data. Exit the loop. @@ -1311,7 +1306,7 @@ QuicConsumedData QuicPacketCreator::ConsumeDataFastPath( QuicStreamOffset offset, bool fin, size_t total_bytes_consumed) { - DCHECK(!QuicUtils::IsCryptoStreamId(transport_version(), id)); + QUICHE_DCHECK(!QuicUtils::IsCryptoStreamId(transport_version(), id)); if (AttemptingToSendUnencryptedStreamData()) { return QuicConsumedData(total_bytes_consumed, fin && (total_bytes_consumed == write_length)); @@ -1428,15 +1423,20 @@ void QuicPacketCreator::MaybeBundleAckOpportunistically() { bool QuicPacketCreator::FlushAckFrame(const QuicFrames& frames) { QUIC_BUG_IF(!flusher_attached_) << "Packet flusher is not attached when " "generator tries to send ACK frame."; + // MaybeBundleAckOpportunistically could be called nestedly when sending a + // control frame causing another control frame to be sent. + QUIC_BUG_IF(GetQuicReloadableFlag(quic_single_ack_in_packet2) && + !frames.empty() && has_ack()) + << "Trying to flush " << frames << " when there is ACK queued"; for (const auto& frame : frames) { - DCHECK(frame.type == ACK_FRAME || frame.type == STOP_WAITING_FRAME); + QUICHE_DCHECK(frame.type == ACK_FRAME || frame.type == STOP_WAITING_FRAME); if (HasPendingFrames()) { if (AddFrame(frame, next_transmission_type_)) { // There is pending frames and current frame fits. continue; } } - DCHECK(!HasPendingFrames()); + QUICHE_DCHECK(!HasPendingFrames()); // There is no pending frames, consult the delegate whether a packet can be // generated. if (!delegate_->ShouldGeneratePacket(NO_RETRANSMITTABLE_DATA, @@ -1541,7 +1541,7 @@ void QuicPacketCreator::FillPacketHeader(QuicPacketHeader* header) { header->reset_flag = false; header->version_flag = IncludeVersionInHeader(); if (IncludeNonceInPublicHeader()) { - DCHECK_EQ(Perspective::IS_SERVER, framer_->perspective()); + QUICHE_DCHECK_EQ(Perspective::IS_SERVER, framer_->perspective()); header->nonce = &diversification_nonce_; } else { header->nonce = nullptr; @@ -1615,9 +1615,9 @@ bool QuicPacketCreator::AddFrame(const QuicFrame& frame, // If this is an ACK frame, validate that it is non-empty and that // largest_acked matches the max packet number. - DCHECK(frame.type != ACK_FRAME || - (!frame.ack_frame->packets.Empty() && - frame.ack_frame->packets.Max() == frame.ack_frame->largest_acked)) + QUICHE_DCHECK(frame.type != ACK_FRAME || (!frame.ack_frame->packets.Empty() && + frame.ack_frame->packets.Max() == + frame.ack_frame->largest_acked)) << "Invalid ACK frame: " << frame; size_t frame_len = GetSerializedFrameLength(frame); @@ -1634,7 +1634,7 @@ bool QuicPacketCreator::AddFrame(const QuicFrame& frame, if (queued_frames_.empty()) { packet_size_ = PacketHeaderSize(); } - DCHECK_LT(0u, packet_size_); + QUICHE_DCHECK_LT(0u, packet_size_); packet_size_ += ExpansionOnNewFrame() + frame_len; @@ -1711,12 +1711,12 @@ bool QuicPacketCreator::MaybeCoalesceStreamFrame(const QuicStreamFrame& frame) { // The back of retransmittable frames must be the same as the original // queued frames' back. - DCHECK_EQ(packet_.retransmittable_frames.back().type, STREAM_FRAME); + QUICHE_DCHECK_EQ(packet_.retransmittable_frames.back().type, STREAM_FRAME); QuicStreamFrame* retransmittable = &packet_.retransmittable_frames.back().stream_frame; - DCHECK_EQ(retransmittable->stream_id, frame.stream_id); - DCHECK_EQ(retransmittable->offset + retransmittable->data_length, - frame.offset); + QUICHE_DCHECK_EQ(retransmittable->stream_id, frame.stream_id); + QUICHE_DCHECK_EQ(retransmittable->offset + retransmittable->data_length, + frame.offset); retransmittable->data_length = candidate->data_length; retransmittable->fin = candidate->fin; packet_size_ += frame.data_length; @@ -1785,7 +1785,7 @@ bool QuicPacketCreator::IncludeNonceInPublicHeader() const { } bool QuicPacketCreator::IncludeVersionInHeader() const { - if (VersionHasIetfInvariantHeader(framer_->transport_version())) { + if (version().HasIetfInvariantHeader()) { return packet_.encryption_level < ENCRYPTION_FORWARD_SECURE; } return send_version_in_packet_; @@ -1808,10 +1808,10 @@ bool QuicPacketCreator::StreamFrameIsClientHello( void QuicPacketCreator::SetServerConnectionIdIncluded( QuicConnectionIdIncluded server_connection_id_included) { - DCHECK(server_connection_id_included == CONNECTION_ID_PRESENT || - server_connection_id_included == CONNECTION_ID_ABSENT); - DCHECK(framer_->perspective() == Perspective::IS_SERVER || - server_connection_id_included != CONNECTION_ID_ABSENT); + QUICHE_DCHECK(server_connection_id_included == CONNECTION_ID_PRESENT || + server_connection_id_included == CONNECTION_ID_ABSENT); + QUICHE_DCHECK(framer_->perspective() == Perspective::IS_SERVER || + server_connection_id_included != CONNECTION_ID_ABSENT); server_connection_id_included_ = server_connection_id_included; } @@ -1822,8 +1822,8 @@ void QuicPacketCreator::SetServerConnectionId( void QuicPacketCreator::SetClientConnectionId( QuicConnectionId client_connection_id) { - DCHECK(client_connection_id.IsEmpty() || - framer_->version().SupportsClientConnectionIds()); + QUICHE_DCHECK(client_connection_id.IsEmpty() || + framer_->version().SupportsClientConnectionIds()); client_connection_id_ = client_connection_id; } @@ -1889,7 +1889,7 @@ QuicPacketLength QuicPacketCreator::GetGuaranteedLargestMessagePayload() const { const QuicPacketLength largest_payload = largest_frame - std::min(largest_frame, kQuicFrameTypeSize); // This must always be less than or equal to GetCurrentLargestMessagePayload. - DCHECK_LE(largest_payload, GetCurrentLargestMessagePayload()); + QUICHE_DCHECK_LE(largest_payload, GetCurrentLargestMessagePayload()); return largest_payload; } @@ -1899,8 +1899,8 @@ bool QuicPacketCreator::AttemptingToSendUnencryptedStreamData() { return false; } const std::string error_details = - quiche::QuicheStrCat("Cannot send stream data with level: ", - EncryptionLevelToString(packet_.encryption_level)); + absl::StrCat("Cannot send stream data with level: ", + EncryptionLevelToString(packet_.encryption_level)); QUIC_BUG << error_details; delegate_->OnUnrecoverableError(QUIC_ATTEMPT_TO_SEND_UNENCRYPTED_STREAM_DATA, error_details); @@ -1908,7 +1908,7 @@ bool QuicPacketCreator::AttemptingToSendUnencryptedStreamData() { } bool QuicPacketCreator::HasIetfLongHeader() const { - return VersionHasIetfInvariantHeader(framer_->transport_version()) && + return version().HasIetfInvariantHeader() && packet_.encryption_level < ENCRYPTION_FORWARD_SECURE; } @@ -2001,17 +2001,17 @@ QuicPacketCreator::ScopedSerializationFailureHandler:: } void QuicPacketCreator::set_encryption_level(EncryptionLevel level) { - DCHECK(level == packet_.encryption_level || !HasPendingFrames()) + QUICHE_DCHECK(level == packet_.encryption_level || !HasPendingFrames()) << "Cannot update encryption level from " << packet_.encryption_level << " to " << level << " when we already have pending frames: " << QuicFramesToString(queued_frames_); packet_.encryption_level = level; } -void QuicPacketCreator::AddPathChallengeFrame(QuicPathFrameBuffer* payload) { +void QuicPacketCreator::AddPathChallengeFrame( + const QuicPathFrameBuffer& payload) { // Write a PATH_CHALLENGE frame, which has a random 8-byte payload. - random_->RandBytes(payload->data(), payload->size()); - auto path_challenge_frame = new QuicPathChallengeFrame(0, *payload); + auto path_challenge_frame = new QuicPathChallengeFrame(0, payload); QuicFrame frame(path_challenge_frame); if (AddPaddedFrameWithRetry(frame)) { return; @@ -2048,7 +2048,7 @@ bool QuicPacketCreator::AddPaddedFrameWithRetry(const QuicFrame& frame) { } } // Frame was not queued but queued frames were flushed. - DCHECK(!HasPendingFrames()); + QUICHE_DCHECK(!HasPendingFrames()); if (!delegate_->ShouldGeneratePacket(NO_RETRANSMITTABLE_DATA, NOT_HANDSHAKE)) { return false; @@ -2058,5 +2058,9 @@ bool QuicPacketCreator::AddPaddedFrameWithRetry(const QuicFrame& frame) { return true; } +bool QuicPacketCreator::HasRetryToken() const { + return !retry_token_.empty(); +} + #undef ENDPOINT // undef for jumbo builds } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_packet_creator.h b/chromium/net/third_party/quiche/src/quic/core/quic_packet_creator.h index 54da59c05f3..5e0c65e35fc 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_packet_creator.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_packet_creator.h @@ -22,13 +22,13 @@ #include "absl/base/attributes.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_stream_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_circular_deque.h" -#include "net/third_party/quiche/src/quic/core/quic_coalesced_packet.h" -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/frames/quic_stream_frame.h" +#include "quic/core/quic_circular_deque.h" +#include "quic/core/quic_coalesced_packet.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { namespace test { @@ -239,7 +239,8 @@ class QUIC_EXPORT_PRIVATE QuicPacketCreator { // SerializePathChallengeConnectivityProbingPacket will pad the packet to be // MTU bytes long. std::unique_ptr<SerializedPacket> - SerializePathChallengeConnectivityProbingPacket(QuicPathFrameBuffer* payload); + SerializePathChallengeConnectivityProbingPacket( + const QuicPathFrameBuffer& payload); // If |is_padded| is true then SerializePathResponseConnectivityProbingPacket // will pad the packet to be MTU bytes long, else it will not pad the packet. @@ -255,7 +256,7 @@ class QUIC_EXPORT_PRIVATE QuicPacketCreator { // Add PATH_CHALLENGE to current packet, flush before or afterwards if needed. // This is a best effort adding. It may fail becasue of delegate state, but // it's okay because of path validation retry mechanism. - void AddPathChallengeFrame(QuicPathFrameBuffer* payload); + void AddPathChallengeFrame(const QuicPathFrameBuffer& payload); // Returns a dummy packet that is valid but contains no useful information. static SerializedPacket NoPacket(); @@ -432,8 +433,7 @@ class QUIC_EXPORT_PRIVATE QuicPacketCreator { size_t BuildPaddedPathChallengePacket(const QuicPacketHeader& header, char* buffer, size_t packet_length, - QuicPathFrameBuffer* payload, - QuicRandom* randomizer, + const QuicPathFrameBuffer& payload, EncryptionLevel level); // Serialize a probing response packet that uses IETF QUIC's PATH RESPONSE @@ -468,9 +468,10 @@ class QUIC_EXPORT_PRIVATE QuicPacketCreator { // different from the current one, flush all the queue frames first. void SetDefaultPeerAddress(QuicSocketAddress address); - bool let_connection_handle_pings() const { - return let_connection_handle_pings_; - } + // Return true if retry_token_ is not empty. + bool HasRetryToken() const; + + const QuicSocketAddress& peer_address() const { return packet_.peer_address; } private: friend class test::QuicPacketCreatorPeer; @@ -670,9 +671,6 @@ class QUIC_EXPORT_PRIVATE QuicPacketCreator { // accept. There is no limit for QUIC_CRYPTO connections, but QUIC+TLS // negotiates this during the handshake. QuicByteCount max_datagram_frame_size_; - - const bool let_connection_handle_pings_ = - GetQuicReloadableFlag(quic_let_connection_handle_pings); }; } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_packet_creator_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_packet_creator_test.cc index d76f1985ad6..8ff44c1f96f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_packet_creator_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_packet_creator_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_packet_creator.h" +#include "quic/core/quic_packet_creator.h" #include <cstdint> #include <limits> @@ -12,28 +12,28 @@ #include <utility> #include "absl/base/macros.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_stream_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.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/quic_framer_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_packet_creator_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/simple_data_producer.h" -#include "net/third_party/quiche/src/quic/test_tools/simple_quic_framer.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/core/crypto/null_decrypter.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/frames/quic_stream_frame.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_simple_buffer_allocator.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_framer_peer.h" +#include "quic/test_tools/quic_packet_creator_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/simple_data_producer.h" +#include "quic/test_tools/simple_quic_framer.h" +#include "common/test_tools/quiche_test_utils.h" using testing::_; using testing::DoAll; @@ -66,9 +66,8 @@ struct TestParams { // Used by ::testing::PrintToStringParamName(). std::string PrintToString(const TestParams& p) { - return quiche::QuicheStrCat(ParsedQuicVersionToString(p.version), "_", - (p.version_serialization ? "Include" : "No"), - "Version"); + return absl::StrCat(ParsedQuicVersionToString(p.version), "_", + (p.version_serialization ? "Include" : "No"), "Version"); } // Constructs various test permutations. @@ -102,7 +101,7 @@ class TestPacketCreator : public QuicPacketCreator { SimpleDataProducer* producer) : QuicPacketCreator(connection_id, framer, delegate), producer_(producer), - version_(framer->transport_version()) {} + version_(framer->version()) {} bool ConsumeDataToFillCurrentPacket(QuicStreamId id, const struct iovec* iov, @@ -125,7 +124,7 @@ class TestPacketCreator : public QuicPacketCreator { } void StopSendingVersion() { - if (VersionHasIetfInvariantHeader(version_)) { + if (version_.HasIetfInvariantHeader()) { set_encryption_level(ENCRYPTION_FORWARD_SECURE); return; } @@ -133,7 +132,7 @@ class TestPacketCreator : public QuicPacketCreator { } SimpleDataProducer* producer_; - QuicTransportVersion version_; + ParsedQuicVersion version_; }; class QuicPacketCreatorTest : public QuicTestWithParam<TestParams> { @@ -317,7 +316,7 @@ TEST_P(QuicPacketCreatorTest, SerializeFrames) { EXPECT_CALL(framer_visitor_, OnPacket()); EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); EXPECT_CALL(framer_visitor_, OnUnauthenticatedHeader(_)); - EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); + EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_, _)); EXPECT_CALL(framer_visitor_, OnPacketHeader(_)); EXPECT_CALL(framer_visitor_, OnAckFrameStart(_, _)) .WillOnce(Return(true)); @@ -341,7 +340,7 @@ TEST_P(QuicPacketCreatorTest, SerializeFrames) { TEST_P(QuicPacketCreatorTest, SerializeConnectionClose) { QuicConnectionCloseFrame* frame = new QuicConnectionCloseFrame( - creator_.transport_version(), QUIC_NO_ERROR, "error", + creator_.transport_version(), QUIC_NO_ERROR, NO_IETF_QUIC_ERROR, "error", /*transport_close_frame_type=*/0); QuicFrames frames; @@ -355,7 +354,7 @@ TEST_P(QuicPacketCreatorTest, SerializeConnectionClose) { EXPECT_CALL(framer_visitor_, OnPacket()); EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); EXPECT_CALL(framer_visitor_, OnUnauthenticatedHeader(_)); - EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); + EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_, _)); EXPECT_CALL(framer_visitor_, OnPacketHeader(_)); EXPECT_CALL(framer_visitor_, OnConnectionCloseFrame(_)); EXPECT_CALL(framer_visitor_, OnPacketComplete()); @@ -592,7 +591,9 @@ TEST_P(QuicPacketCreatorTest, BuildPathChallengePacket) { header.reset_flag = false; header.version_flag = false; header.packet_number = kPacketNumber; + MockRandom randomizer; QuicPathFrameBuffer payload; + randomizer.RandBytes(payload.data(), payload.size()); // clang-format off unsigned char packet[] = { @@ -614,10 +615,9 @@ TEST_P(QuicPacketCreatorTest, BuildPathChallengePacket) { // clang-format on std::unique_ptr<char[]> buffer(new char[kMaxOutgoingPacketSize]); - MockRandom randomizer; size_t length = creator_.BuildPaddedPathChallengePacket( - header, buffer.get(), ABSL_ARRAYSIZE(packet), &payload, &randomizer, + header, buffer.get(), ABSL_ARRAYSIZE(packet), payload, ENCRYPTION_INITIAL); EXPECT_EQ(length, ABSL_ARRAYSIZE(packet)); @@ -921,7 +921,7 @@ TEST_P(QuicPacketCreatorTest, SerializeConnectivityProbingPacket) { QuicPathFrameBuffer payload = { {0xde, 0xad, 0xbe, 0xef, 0xba, 0xdc, 0x0f, 0xfe}}; encrypted = - creator_.SerializePathChallengeConnectivityProbingPacket(&payload); + creator_.SerializePathChallengeConnectivityProbingPacket(payload); } else { encrypted = creator_.SerializeConnectivityProbingPacket(); } @@ -930,7 +930,7 @@ TEST_P(QuicPacketCreatorTest, SerializeConnectivityProbingPacket) { EXPECT_CALL(framer_visitor_, OnPacket()); EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); EXPECT_CALL(framer_visitor_, OnUnauthenticatedHeader(_)); - EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); + EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_, _)); EXPECT_CALL(framer_visitor_, OnPacketHeader(_)); if (VersionHasIetfQuicFrames(creator_.transport_version())) { EXPECT_CALL(framer_visitor_, OnPathChallengeFrame(_)); @@ -956,13 +956,13 @@ TEST_P(QuicPacketCreatorTest, SerializePathChallengeProbePacket) { creator_.set_encryption_level(ENCRYPTION_FORWARD_SECURE); std::unique_ptr<SerializedPacket> encrypted( - creator_.SerializePathChallengeConnectivityProbingPacket(&payload)); + creator_.SerializePathChallengeConnectivityProbingPacket(payload)); { InSequence s; EXPECT_CALL(framer_visitor_, OnPacket()); EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); EXPECT_CALL(framer_visitor_, OnUnauthenticatedHeader(_)); - EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); + EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_, _)); EXPECT_CALL(framer_visitor_, OnPacketHeader(_)); EXPECT_CALL(framer_visitor_, OnPathChallengeFrame(_)); EXPECT_CALL(framer_visitor_, OnPaddingFrame(_)); @@ -992,7 +992,7 @@ TEST_P(QuicPacketCreatorTest, SerializePathResponseProbePacket1PayloadPadded) { EXPECT_CALL(framer_visitor_, OnPacket()); EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); EXPECT_CALL(framer_visitor_, OnUnauthenticatedHeader(_)); - EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); + EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_, _)); EXPECT_CALL(framer_visitor_, OnPacketHeader(_)); EXPECT_CALL(framer_visitor_, OnPathResponseFrame(_)); EXPECT_CALL(framer_visitor_, OnPaddingFrame(_)); @@ -1022,7 +1022,7 @@ TEST_P(QuicPacketCreatorTest, EXPECT_CALL(framer_visitor_, OnPacket()); EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); EXPECT_CALL(framer_visitor_, OnUnauthenticatedHeader(_)); - EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); + EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_, _)); EXPECT_CALL(framer_visitor_, OnPacketHeader(_)); EXPECT_CALL(framer_visitor_, OnPathResponseFrame(_)); EXPECT_CALL(framer_visitor_, OnPacketComplete()); @@ -1053,7 +1053,7 @@ TEST_P(QuicPacketCreatorTest, SerializePathResponseProbePacket2PayloadsPadded) { EXPECT_CALL(framer_visitor_, OnPacket()); EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); EXPECT_CALL(framer_visitor_, OnUnauthenticatedHeader(_)); - EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); + EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_, _)); EXPECT_CALL(framer_visitor_, OnPacketHeader(_)); EXPECT_CALL(framer_visitor_, OnPathResponseFrame(_)).Times(2); EXPECT_CALL(framer_visitor_, OnPaddingFrame(_)); @@ -1086,7 +1086,7 @@ TEST_P(QuicPacketCreatorTest, EXPECT_CALL(framer_visitor_, OnPacket()); EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); EXPECT_CALL(framer_visitor_, OnUnauthenticatedHeader(_)); - EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); + EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_, _)); EXPECT_CALL(framer_visitor_, OnPacketHeader(_)); EXPECT_CALL(framer_visitor_, OnPathResponseFrame(_)).Times(2); EXPECT_CALL(framer_visitor_, OnPacketComplete()); @@ -1120,7 +1120,7 @@ TEST_P(QuicPacketCreatorTest, SerializePathResponseProbePacket3PayloadsPadded) { EXPECT_CALL(framer_visitor_, OnPacket()); EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); EXPECT_CALL(framer_visitor_, OnUnauthenticatedHeader(_)); - EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); + EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_, _)); EXPECT_CALL(framer_visitor_, OnPacketHeader(_)); EXPECT_CALL(framer_visitor_, OnPathResponseFrame(_)).Times(3); EXPECT_CALL(framer_visitor_, OnPaddingFrame(_)); @@ -1155,7 +1155,7 @@ TEST_P(QuicPacketCreatorTest, EXPECT_CALL(framer_visitor_, OnPacket()); EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); EXPECT_CALL(framer_visitor_, OnUnauthenticatedHeader(_)); - EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); + EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_, _)); EXPECT_CALL(framer_visitor_, OnPacketHeader(_)); EXPECT_CALL(framer_visitor_, OnPathResponseFrame(_)).Times(3); EXPECT_CALL(framer_visitor_, OnPacketComplete()); @@ -1165,7 +1165,7 @@ TEST_P(QuicPacketCreatorTest, } TEST_P(QuicPacketCreatorTest, UpdatePacketSequenceNumberLengthLeastAwaiting) { - if (VersionHasIetfInvariantHeader(creator_.transport_version()) && + if (creator_.version().HasIetfInvariantHeader() && !GetParam().version.SendsVariableLengthPacketNumberInLongHeader()) { EXPECT_EQ(PACKET_4BYTE_PACKET_NUMBER, QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); @@ -1203,7 +1203,7 @@ TEST_P(QuicPacketCreatorTest, UpdatePacketSequenceNumberLengthLeastAwaiting) { TEST_P(QuicPacketCreatorTest, UpdatePacketSequenceNumberLengthCwnd) { QuicPacketCreatorPeer::SetPacketNumber(&creator_, 1); - if (VersionHasIetfInvariantHeader(creator_.transport_version()) && + if (creator_.version().HasIetfInvariantHeader() && !GetParam().version.SendsVariableLengthPacketNumberInLongHeader()) { EXPECT_EQ(PACKET_4BYTE_PACKET_NUMBER, QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); @@ -1237,7 +1237,7 @@ TEST_P(QuicPacketCreatorTest, UpdatePacketSequenceNumberLengthCwnd) { TEST_P(QuicPacketCreatorTest, SkipNPacketNumbers) { QuicPacketCreatorPeer::SetPacketNumber(&creator_, 1); - if (VersionHasIetfInvariantHeader(creator_.transport_version()) && + if (creator_.version().HasIetfInvariantHeader() && !GetParam().version.SendsVariableLengthPacketNumberInLongHeader()) { EXPECT_EQ(PACKET_4BYTE_PACKET_NUMBER, QuicPacketCreatorPeer::GetPacketNumberLength(&creator_)); @@ -1288,7 +1288,7 @@ TEST_P(QuicPacketCreatorTest, SerializeFrame) { EXPECT_CALL(framer_visitor_, OnPacket()); EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); EXPECT_CALL(framer_visitor_, OnUnauthenticatedHeader(_)); - EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); + EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_, _)); EXPECT_CALL(framer_visitor_, OnPacketHeader(_)) .WillOnce(DoAll(SaveArg<0>(&header), Return(true))); if (QuicVersionUsesCryptoFrames(client_framer_.transport_version())) { @@ -1325,7 +1325,7 @@ TEST_P(QuicPacketCreatorTest, SerializeFrameShortData) { EXPECT_CALL(framer_visitor_, OnPacket()); EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); EXPECT_CALL(framer_visitor_, OnUnauthenticatedHeader(_)); - EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); + EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_, _)); EXPECT_CALL(framer_visitor_, OnPacketHeader(_)) .WillOnce(DoAll(SaveArg<0>(&header), Return(true))); if (QuicVersionUsesCryptoFrames(client_framer_.transport_version())) { @@ -1513,7 +1513,7 @@ TEST_P(QuicPacketCreatorTest, SerializeStreamFrameWithPadding) { EXPECT_CALL(framer_visitor_, OnPacket()); EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); EXPECT_CALL(framer_visitor_, OnUnauthenticatedHeader(_)); - EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); + EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_, _)); EXPECT_CALL(framer_visitor_, OnPacketHeader(_)); EXPECT_CALL(framer_visitor_, OnStreamFrame(_)); if (client_framer_.version().HasHeaderProtection()) { @@ -1603,7 +1603,7 @@ TEST_P(QuicPacketCreatorTest, PendingPadding) { EXPECT_CALL(framer_visitor_, OnPacket()); EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); EXPECT_CALL(framer_visitor_, OnUnauthenticatedHeader(_)); - EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); + EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_, _)); EXPECT_CALL(framer_visitor_, OnPacketHeader(_)); EXPECT_CALL(framer_visitor_, OnPaddingFrame(_)); EXPECT_CALL(framer_visitor_, OnPacketComplete()); @@ -1968,7 +1968,7 @@ TEST_P(QuicPacketCreatorTest, RetryToken) { EXPECT_CALL(framer_visitor_, OnPacket()); EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); EXPECT_CALL(framer_visitor_, OnUnauthenticatedHeader(_)); - EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); + EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_, _)); EXPECT_CALL(framer_visitor_, OnPacketHeader(_)) .WillOnce(DoAll(SaveArg<0>(&header), Return(true))); if (QuicVersionUsesCryptoFrames(client_framer_.transport_version())) { @@ -2077,7 +2077,7 @@ TEST_P(QuicPacketCreatorTest, CoalesceStreamFrames) { EXPECT_CALL(framer_visitor_, OnPacket()); EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); EXPECT_CALL(framer_visitor_, OnUnauthenticatedHeader(_)); - EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); + EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_, _)); EXPECT_CALL(framer_visitor_, OnPacketHeader(_)); // The packet should only have 2 stream frames. EXPECT_CALL(framer_visitor_, OnStreamFrame(_)); @@ -2154,7 +2154,7 @@ TEST_P(QuicPacketCreatorTest, SerializeCoalescedPacket) { })); } EXPECT_CALL(framer_visitor_, OnUnauthenticatedHeader(_)); - EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); + EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_, _)); EXPECT_CALL(framer_visitor_, OnPacketHeader(_)); EXPECT_CALL(framer_visitor_, OnAckFrameStart(_, _)).WillOnce(Return(true)); EXPECT_CALL(framer_visitor_, @@ -2442,7 +2442,7 @@ class QuicPacketCreatorMultiplePacketsTest : public QuicTest { ~QuicPacketCreatorMultiplePacketsTest() override {} void SavePacket(SerializedPacket packet) { - DCHECK(packet.release_encrypted_buffer == nullptr); + QUICHE_DCHECK(packet.release_encrypted_buffer == nullptr); packet.encrypted_buffer = CopyBuffer(packet); packet.release_encrypted_buffer = [](const char* p) { delete[] p; }; packets_.push_back(std::move(packet)); @@ -3229,7 +3229,7 @@ TEST_F(QuicPacketCreatorMultiplePacketsTest, TestConnectionIdLength) { for (size_t i = 1; i < 10; i++) { creator_.SetServerConnectionIdLength(i); - if (VersionHasIetfInvariantHeader(framer_.transport_version())) { + if (framer_.version().HasIetfInvariantHeader()) { EXPECT_EQ(PACKET_0BYTE_CONNECTION_ID, creator_.GetDestinationConnectionIdLength()); } else { @@ -3413,7 +3413,7 @@ TEST_F(QuicPacketCreatorMultiplePacketsTest, QuicPathFrameBuffer payload = { {0xde, 0xad, 0xbe, 0xef, 0xba, 0xdc, 0x0f, 0xfe}}; probing_packet = - creator_.SerializePathChallengeConnectivityProbingPacket(&payload); + creator_.SerializePathChallengeConnectivityProbingPacket(payload); } else { probing_packet = creator_.SerializeConnectivityProbingPacket(); } @@ -3554,7 +3554,8 @@ TEST_F(QuicPacketCreatorMultiplePacketsTest, const QuicErrorCode kQuicErrorCode = QUIC_PACKET_WRITE_ERROR; QuicConnectionCloseFrame* frame = new QuicConnectionCloseFrame( - framer_.transport_version(), kQuicErrorCode, std::string(error_details), + framer_.transport_version(), kQuicErrorCode, NO_IETF_QUIC_ERROR, + std::string(error_details), /*transport_close_frame_type=*/0); creator_.ConsumeRetransmittableControlFrame(QuicFrame(frame), /*bundle_ack=*/false); diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_packet_number.cc b/chromium/net/third_party/quiche/src/quic/core/quic_packet_number.cc index d25b34d9765..ba1c509360b 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_packet_number.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_packet_number.cc @@ -4,8 +4,8 @@ #include <algorithm> -#include "net/third_party/quiche/src/quic/core/quic_packet_number.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/quic_packet_number.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { @@ -25,12 +25,12 @@ void QuicPacketNumber::UpdateMax(QuicPacketNumber new_value) { } uint64_t QuicPacketNumber::Hash() const { - DCHECK(IsInitialized()); + QUICHE_DCHECK(IsInitialized()); return packet_number_; } uint64_t QuicPacketNumber::ToUint64() const { - DCHECK(IsInitialized()); + QUICHE_DCHECK(IsInitialized()); return packet_number_; } @@ -40,8 +40,8 @@ bool QuicPacketNumber::IsInitialized() const { QuicPacketNumber& QuicPacketNumber::operator++() { #ifndef NDEBUG - DCHECK(IsInitialized()); - DCHECK_LT(ToUint64(), std::numeric_limits<uint64_t>::max() - 1); + QUICHE_DCHECK(IsInitialized()); + QUICHE_DCHECK_LT(ToUint64(), std::numeric_limits<uint64_t>::max() - 1); #endif packet_number_++; return *this; @@ -49,8 +49,8 @@ QuicPacketNumber& QuicPacketNumber::operator++() { QuicPacketNumber QuicPacketNumber::operator++(int) { #ifndef NDEBUG - DCHECK(IsInitialized()); - DCHECK_LT(ToUint64(), std::numeric_limits<uint64_t>::max() - 1); + QUICHE_DCHECK(IsInitialized()); + QUICHE_DCHECK_LT(ToUint64(), std::numeric_limits<uint64_t>::max() - 1); #endif QuicPacketNumber previous(*this); packet_number_++; @@ -59,8 +59,8 @@ QuicPacketNumber QuicPacketNumber::operator++(int) { QuicPacketNumber& QuicPacketNumber::operator--() { #ifndef NDEBUG - DCHECK(IsInitialized()); - DCHECK_GE(ToUint64(), 1UL); + QUICHE_DCHECK(IsInitialized()); + QUICHE_DCHECK_GE(ToUint64(), 1UL); #endif packet_number_--; return *this; @@ -68,8 +68,8 @@ QuicPacketNumber& QuicPacketNumber::operator--() { QuicPacketNumber QuicPacketNumber::operator--(int) { #ifndef NDEBUG - DCHECK(IsInitialized()); - DCHECK_GE(ToUint64(), 1UL); + QUICHE_DCHECK(IsInitialized()); + QUICHE_DCHECK_GE(ToUint64(), 1UL); #endif QuicPacketNumber previous(*this); packet_number_--; @@ -78,8 +78,8 @@ QuicPacketNumber QuicPacketNumber::operator--(int) { QuicPacketNumber& QuicPacketNumber::operator+=(uint64_t delta) { #ifndef NDEBUG - DCHECK(IsInitialized()); - DCHECK_GT(std::numeric_limits<uint64_t>::max() - ToUint64(), delta); + QUICHE_DCHECK(IsInitialized()); + QUICHE_DCHECK_GT(std::numeric_limits<uint64_t>::max() - ToUint64(), delta); #endif packet_number_ += delta; return *this; @@ -87,8 +87,8 @@ QuicPacketNumber& QuicPacketNumber::operator+=(uint64_t delta) { QuicPacketNumber& QuicPacketNumber::operator-=(uint64_t delta) { #ifndef NDEBUG - DCHECK(IsInitialized()); - DCHECK_GE(ToUint64(), delta); + QUICHE_DCHECK(IsInitialized()); + QUICHE_DCHECK_GE(ToUint64(), delta); #endif packet_number_ -= delta; return *this; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_packet_number.h b/chromium/net/third_party/quiche/src/quic/core/quic_packet_number.h index e977febfc0e..a1ea62fbec1 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_packet_number.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_packet_number.h @@ -9,9 +9,9 @@ #include <ostream> #include <string> -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_uint128.h" namespace quic { @@ -27,7 +27,7 @@ class QUIC_EXPORT_PRIVATE QuicPacketNumber { // sentinel value. explicit constexpr QuicPacketNumber(uint64_t packet_number) : packet_number_(packet_number) { - DCHECK_NE(UninitializedPacketNumber(), packet_number) + QUICHE_DCHECK_NE(UninitializedPacketNumber(), packet_number) << "Use default constructor for uninitialized packet number"; } @@ -103,53 +103,60 @@ class QUIC_EXPORT_PRIVATE QuicPacketNumberHash { }; inline bool operator==(QuicPacketNumber lhs, QuicPacketNumber rhs) { - DCHECK(lhs.IsInitialized() && rhs.IsInitialized()) << lhs << " vs. " << rhs; + QUICHE_DCHECK(lhs.IsInitialized() && rhs.IsInitialized()) + << lhs << " vs. " << rhs; return lhs.packet_number_ == rhs.packet_number_; } inline bool operator!=(QuicPacketNumber lhs, QuicPacketNumber rhs) { - DCHECK(lhs.IsInitialized() && rhs.IsInitialized()) << lhs << " vs. " << rhs; + QUICHE_DCHECK(lhs.IsInitialized() && rhs.IsInitialized()) + << lhs << " vs. " << rhs; return lhs.packet_number_ != rhs.packet_number_; } inline bool operator<(QuicPacketNumber lhs, QuicPacketNumber rhs) { - DCHECK(lhs.IsInitialized() && rhs.IsInitialized()) << lhs << " vs. " << rhs; + QUICHE_DCHECK(lhs.IsInitialized() && rhs.IsInitialized()) + << lhs << " vs. " << rhs; return lhs.packet_number_ < rhs.packet_number_; } inline bool operator<=(QuicPacketNumber lhs, QuicPacketNumber rhs) { - DCHECK(lhs.IsInitialized() && rhs.IsInitialized()) << lhs << " vs. " << rhs; + QUICHE_DCHECK(lhs.IsInitialized() && rhs.IsInitialized()) + << lhs << " vs. " << rhs; return lhs.packet_number_ <= rhs.packet_number_; } inline bool operator>(QuicPacketNumber lhs, QuicPacketNumber rhs) { - DCHECK(lhs.IsInitialized() && rhs.IsInitialized()) << lhs << " vs. " << rhs; + QUICHE_DCHECK(lhs.IsInitialized() && rhs.IsInitialized()) + << lhs << " vs. " << rhs; return lhs.packet_number_ > rhs.packet_number_; } inline bool operator>=(QuicPacketNumber lhs, QuicPacketNumber rhs) { - DCHECK(lhs.IsInitialized() && rhs.IsInitialized()) << lhs << " vs. " << rhs; + QUICHE_DCHECK(lhs.IsInitialized() && rhs.IsInitialized()) + << lhs << " vs. " << rhs; return lhs.packet_number_ >= rhs.packet_number_; } inline QuicPacketNumber operator+(QuicPacketNumber lhs, uint64_t delta) { #ifndef NDEBUG - DCHECK(lhs.IsInitialized()); - DCHECK_GT(std::numeric_limits<uint64_t>::max() - lhs.ToUint64(), delta); + QUICHE_DCHECK(lhs.IsInitialized()); + QUICHE_DCHECK_GT(std::numeric_limits<uint64_t>::max() - lhs.ToUint64(), + delta); #endif return QuicPacketNumber(lhs.packet_number_ + delta); } inline QuicPacketNumber operator-(QuicPacketNumber lhs, uint64_t delta) { #ifndef NDEBUG - DCHECK(lhs.IsInitialized()); - DCHECK_GE(lhs.ToUint64(), delta); + QUICHE_DCHECK(lhs.IsInitialized()); + QUICHE_DCHECK_GE(lhs.ToUint64(), delta); #endif return QuicPacketNumber(lhs.packet_number_ - delta); } inline uint64_t operator-(QuicPacketNumber lhs, QuicPacketNumber rhs) { - DCHECK(lhs.IsInitialized() && rhs.IsInitialized() && lhs >= rhs) + QUICHE_DCHECK(lhs.IsInitialized() && rhs.IsInitialized() && lhs >= rhs) << lhs << " vs. " << rhs; return lhs.packet_number_ - rhs.packet_number_; } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_packet_number_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_packet_number_test.cc index e0184a81d44..b696025094d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_packet_number_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_packet_number_test.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_packet_number.h" +#include "quic/core/quic_packet_number.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_packet_reader.cc b/chromium/net/third_party/quiche/src/quic/core/quic_packet_reader.cc index 2902f998b6e..4b0eb4b12ee 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_packet_reader.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_packet_reader.cc @@ -2,25 +2,25 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_packet_reader.h" +#include "quic/core/quic_packet_reader.h" #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_process_packet_interface.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_server_stats.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_process_packet_interface.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_server_stats.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { QuicPacketReader::QuicPacketReader() : read_buffers_(kNumPacketsPerReadMmsgCall), read_results_(kNumPacketsPerReadMmsgCall) { - DCHECK_EQ(read_buffers_.size(), read_results_.size()); + QUICHE_DCHECK_EQ(read_buffers_.size(), read_results_.size()); for (size_t i = 0; i < read_results_.size(); ++i) { read_results_[i].packet_buffer.buffer = read_buffers_[i].packet_buffer; read_results_[i].packet_buffer.buffer_len = diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_packet_reader.h b/chromium/net/third_party/quiche/src/quic/core/quic_packet_reader.h index 6edf1f1dd29..1c93722f9ed 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_packet_reader.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_packet_reader.h @@ -8,12 +8,12 @@ #define QUICHE_QUIC_CORE_QUIC_PACKET_READER_H_ #include "absl/base/optimization.h" -#include "net/third_party/quiche/src/quic/core/quic_clock.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_process_packet_interface.h" -#include "net/third_party/quiche/src/quic/core/quic_udp_socket.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/quic_clock.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_process_packet_interface.h" +#include "quic/core/quic_udp_socket.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_packet_writer.h b/chromium/net/third_party/quiche/src/quic/core/quic_packet_writer.h index 6efdb6005d8..875f25a8f9a 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_packet_writer.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_packet_writer.h @@ -8,9 +8,9 @@ #include <cstddef> #include <utility> -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.cc b/chromium/net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.cc index d2b54d1b175..6f7c54ef4a4 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.h" +#include "quic/core/quic_packet_writer_wrapper.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/quic_types.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.h b/chromium/net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.h index afd360580b4..e6dac045a89 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.h @@ -8,7 +8,7 @@ #include <cstddef> #include <memory> -#include "net/third_party/quiche/src/quic/core/quic_packet_writer.h" +#include "quic/core/quic_packet_writer.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_packets.cc b/chromium/net/third_party/quiche/src/quic/core/quic_packets.cc index 3d6228e6847..5f3e5a2697f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_packets.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_packets.cc @@ -2,21 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_packets.h" +#include "quic/core/quic_packets.h" #include <utility> #include "absl/strings/escaping.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { @@ -75,8 +74,8 @@ QuicConnectionIdIncluded GetClientConnectionIdIncludedAsSender( QuicConnectionIdLength GetIncludedConnectionIdLength( QuicConnectionId connection_id, QuicConnectionIdIncluded connection_id_included) { - DCHECK(connection_id_included == CONNECTION_ID_PRESENT || - connection_id_included == CONNECTION_ID_ABSENT); + QUICHE_DCHECK(connection_id_included == CONNECTION_ID_PRESENT || + connection_id_included == CONNECTION_ID_ABSENT); return connection_id_included == CONNECTION_ID_PRESENT ? static_cast<QuicConnectionIdLength>(connection_id.length()) : PACKET_0BYTE_CONNECTION_ID; @@ -128,9 +127,9 @@ size_t GetPacketHeaderSize( if (VersionHasLengthPrefixedConnectionIds(version)) { size += kConnectionIdLengthSize; } - DCHECK(QuicVersionHasLongHeaderLengths(version) || - retry_token_length_length + retry_token_length + length_length == - 0); + QUICHE_DCHECK( + QuicVersionHasLongHeaderLengths(version) || + retry_token_length_length + retry_token_length + length_length == 0); if (QuicVersionHasLongHeaderLengths(version)) { size += retry_token_length_length + retry_token_length + length_length; } @@ -141,8 +140,8 @@ size_t GetPacketHeaderSize( packet_number_length; } // Google QUIC versions <= 43 can only carry one connection ID. - DCHECK(destination_connection_id_length == 0 || - source_connection_id_length == 0); + QUICHE_DCHECK(destination_connection_id_length == 0 || + source_connection_id_length == 0); return kPublicFlagsSize + destination_connection_id_length + source_connection_id_length + (include_version ? kQuicVersionSize : 0) + packet_number_length + @@ -535,7 +534,7 @@ SerializedPacket* CopySerializedPacket(const SerializedPacket& serialized, // Copy underlying frames. copy->retransmittable_frames = CopyQuicFrames(allocator, serialized.retransmittable_frames); - DCHECK(copy->nonretransmittable_frames.empty()); + QUICHE_DCHECK(copy->nonretransmittable_frames.empty()); for (const auto& frame : serialized.nonretransmittable_frames) { if (frame.type == ACK_FRAME) { copy->has_ack_frame_copy = true; @@ -574,15 +573,15 @@ ReceivedPacketInfo::ReceivedPacketInfo(const QuicSocketAddress& self_address, ReceivedPacketInfo::~ReceivedPacketInfo() {} std::string ReceivedPacketInfo::ToString() const { - std::string output = quiche::QuicheStrCat( - "{ self_address: ", self_address.ToString(), - ", peer_address: ", peer_address.ToString(), - ", packet_length: ", packet.length(), ", header_format: ", form, - ", version_flag: ", version_flag); + std::string output = + absl::StrCat("{ self_address: ", self_address.ToString(), + ", peer_address: ", peer_address.ToString(), + ", packet_length: ", packet.length(), + ", header_format: ", form, ", version_flag: ", version_flag); if (version_flag) { - QuicStrAppend(&output, ", version: ", ParsedQuicVersionToString(version)); + absl::StrAppend(&output, ", version: ", ParsedQuicVersionToString(version)); } - QuicStrAppend( + absl::StrAppend( &output, ", destination_connection_id: ", destination_connection_id.ToString(), ", source_connection_id: ", source_connection_id.ToString(), " }\n"); diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_packets.h b/chromium/net/third_party/quiche/src/quic/core/quic_packets.h index 8cf7305a84f..4643ebcba6e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_packets.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_packets.h @@ -15,17 +15,17 @@ #include <vector> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_ack_listener_interface.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h" +#include "quic/core/frames/quic_frame.h" +#include "quic/core/quic_ack_listener_interface.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_uint128.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_packets_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_packets_test.cc index b2bccbeeb72..5e206f46827 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_packets_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_packets_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_packets.h" +#include "quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/test_tools/quiche_test_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_path_validator.cc b/chromium/net/third_party/quiche/src/quic/core/quic_path_validator.cc index 5d5e7206d54..f2abef0543f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_path_validator.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_path_validator.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_path_validator.h" +#include "quic/core/quic_path_validator.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { @@ -30,7 +30,7 @@ std::ostream& operator<<(std::ostream& os, } QuicPathValidator::QuicPathValidator(QuicAlarmFactory* alarm_factory, - QuicOneBlockArena<1024>* arena, + QuicConnectionArena* arena, SendDelegate* send_delegate, QuicRandom* random) : send_delegate_(send_delegate), @@ -59,16 +59,22 @@ void QuicPathValidator::OnPathResponse(const QuicPathFrameBuffer& probing_data, probing_data_.end()) { result_delegate_->OnPathValidationSuccess(std::move(path_context_)); ResetPathValidation(); + } else { + QUIC_DVLOG(1) << "PATH_RESPONSE with payload " << probing_data.data() + << " doesn't match the probing data."; } } -void QuicPathValidator::StartValidingPath( +void QuicPathValidator::StartPathValidation( std::unique_ptr<QuicPathValidationContext> context, std::unique_ptr<ResultDelegate> result_delegate) { - CancelPathValidation(); - DCHECK_NE(nullptr, context); + QUICHE_DCHECK(context); QUIC_DLOG(INFO) << "Start validating path " << *context << " via writer: " << context->WriterToUse(); + if (path_context_ != nullptr) { + QUIC_BUG << "There is an on-going validation on path " << *path_context_; + ResetPathValidation(); + } path_context_ = std::move(context); result_delegate_ = std::move(result_delegate); @@ -87,6 +93,7 @@ void QuicPathValidator::CancelPathValidation() { return; } QUIC_DVLOG(1) << "Cancel validation on path" << *path_context_; + result_delegate_->OnPathValidationFailure(std::move(path_context_)); ResetPathValidation(); } @@ -94,6 +101,10 @@ bool QuicPathValidator::HasPendingPathValidation() const { return path_context_ != nullptr; } +QuicPathValidationContext* QuicPathValidator::GetContext() const { + return path_context_.get(); +} + const QuicPathFrameBuffer& QuicPathValidator::GeneratePathChallengePayload() { probing_data_.push_back(QuicPathFrameBuffer()); random_->RandBytes(probing_data_.back().data(), sizeof(QuicPathFrameBuffer)); @@ -103,7 +114,6 @@ const QuicPathFrameBuffer& QuicPathValidator::GeneratePathChallengePayload() { void QuicPathValidator::OnRetryTimeout() { ++retry_count_; if (retry_count_ > kMaxRetryTimes) { - result_delegate_->OnPathValidationFailure(std::move(path_context_)); CancelPathValidation(); return; } @@ -114,7 +124,8 @@ void QuicPathValidator::OnRetryTimeout() { void QuicPathValidator::SendPathChallengeAndSetAlarm() { bool should_continue = send_delegate_->SendPathChallenge( GeneratePathChallengePayload(), path_context_->self_address(), - path_context_->peer_address(), path_context_->WriterToUse()); + path_context_->peer_address(), path_context_->effective_peer_address(), + path_context_->WriterToUse()); if (!should_continue) { // The delegate doesn't want to continue the path validation. @@ -125,4 +136,10 @@ void QuicPathValidator::SendPathChallengeAndSetAlarm() { path_context_->peer_address(), path_context_->WriterToUse())); } +bool QuicPathValidator::IsValidatingPeerAddress( + const QuicSocketAddress& effective_peer_address) { + return path_context_ != nullptr && + path_context_->effective_peer_address() == effective_peer_address; +} + } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_path_validator.h b/chromium/net/third_party/quiche/src/quic/core/quic_path_validator.h index 8cfa81d733a..ccd3a6cbcaf 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_path_validator.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_path_validator.h @@ -7,16 +7,16 @@ #include <ostream> -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/quic_alarm.h" -#include "net/third_party/quiche/src/quic/core/quic_alarm_factory.h" -#include "net/third_party/quiche/src/quic/core/quic_arena_scoped_ptr.h" -#include "net/third_party/quiche/src/quic/core/quic_clock.h" -#include "net/third_party/quiche/src/quic/core/quic_one_block_arena.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/quic/platform/impl/quic_export_impl.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/quic_alarm.h" +#include "quic/core/quic_alarm_factory.h" +#include "quic/core/quic_arena_scoped_ptr.h" +#include "quic/core/quic_clock.h" +#include "quic/core/quic_one_block_arena.h" +#include "quic/core/quic_packet_writer.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { @@ -31,7 +31,16 @@ class QUIC_EXPORT_PRIVATE QuicPathValidationContext { public: QuicPathValidationContext(const QuicSocketAddress& self_address, const QuicSocketAddress& peer_address) - : self_address_(self_address), peer_address_(peer_address) {} + : self_address_(self_address), + peer_address_(peer_address), + effective_peer_address_(peer_address) {} + + QuicPathValidationContext(const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address, + const QuicSocketAddress& effective_peer_address) + : self_address_(self_address), + peer_address_(peer_address), + effective_peer_address_(effective_peer_address) {} virtual ~QuicPathValidationContext() = default; @@ -39,6 +48,9 @@ class QUIC_EXPORT_PRIVATE QuicPathValidationContext { const QuicSocketAddress& self_address() const { return self_address_; } const QuicSocketAddress& peer_address() const { return peer_address_; } + const QuicSocketAddress& effective_peer_address() const { + return effective_peer_address_; + } private: QUIC_EXPORT_PRIVATE friend std::ostream& operator<<( @@ -46,7 +58,11 @@ class QUIC_EXPORT_PRIVATE QuicPathValidationContext { const QuicPathValidationContext& context); QuicSocketAddress self_address_; + // The address to send PATH_CHALLENGE. QuicSocketAddress peer_address_; + // The actual peer address which is different from |peer_address_| if the peer + // is behind a proxy. + QuicSocketAddress effective_peer_address_; }; // Used to validate a path by sending up to 3 PATH_CHALLENGE frames before @@ -64,10 +80,12 @@ class QUIC_EXPORT_PRIVATE QuicPathValidator { // Send a PATH_CHALLENGE with |data_buffer| as the frame payload using given // path information. Return false if the delegate doesn't want to continue // the validation. - virtual bool SendPathChallenge(const QuicPathFrameBuffer& data_buffer, - const QuicSocketAddress& self_address, - const QuicSocketAddress& peer_address, - QuicPacketWriter* writer) = 0; + virtual bool SendPathChallenge( + const QuicPathFrameBuffer& data_buffer, + const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address, + const QuicSocketAddress& effective_peer_address, + QuicPacketWriter* writer) = 0; // Return the time to retry sending PATH_CHALLENGE again based on given peer // address and writer. virtual QuicTime GetRetryTimeout(const QuicSocketAddress& peer_address, @@ -75,6 +93,8 @@ class QUIC_EXPORT_PRIVATE QuicPathValidator { }; // Handles the validation result. + // TODO(danzh) consider to simplify this interface and its life time to + // outlive a validation. class QUIC_EXPORT_PRIVATE ResultDelegate { public: virtual ~ResultDelegate() = default; @@ -92,8 +112,8 @@ class QUIC_EXPORT_PRIVATE QuicPathValidator { QuicRandom* random); // Send PATH_CHALLENGE and start the retry timer. - void StartValidingPath(std::unique_ptr<QuicPathValidationContext> context, - std::unique_ptr<ResultDelegate> result_delegate); + void StartPathValidation(std::unique_ptr<QuicPathValidationContext> context, + std::unique_ptr<ResultDelegate> result_delegate); // Called when a PATH_RESPONSE frame has been received. Matches the received // PATH_RESPONSE payload with the payloads previously sent in PATH_CHALLANGE @@ -106,10 +126,14 @@ class QUIC_EXPORT_PRIVATE QuicPathValidator { bool HasPendingPathValidation() const; + QuicPathValidationContext* GetContext() const; + // Send another PATH_CHALLENGE on the same path. After retrying // |kMaxRetryTimes| times, fail the current path validation. void OnRetryTimeout(); + bool IsValidatingPeerAddress(const QuicSocketAddress& effective_peer_address); + private: friend class test::QuicPathValidatorPeer; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_path_validator_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_path_validator_test.cc index 656292eb149..e433f0c07be 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_path_validator_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_path_validator_test.cc @@ -2,21 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_path_validator.h" +#include "quic/core/quic_path_validator.h" #include <memory> -#include "net/third_party/quiche/src/quic/core/frames/quic_path_challenge_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.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" -#include "net/third_party/quiche/src/quic/test_tools/quic_path_validator_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_transport_test_tools.h" +#include "quic/core/frames/quic_path_challenge_frame.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" +#include "quic/test_tools/mock_random.h" +#include "quic/test_tools/quic_path_validator_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/quic_transport_test_tools.h" using testing::_; using testing::Invoke; @@ -35,6 +35,7 @@ class MockSendDelegate : public QuicPathValidator::SendDelegate { (const QuicPathFrameBuffer&, const QuicSocketAddress&, const QuicSocketAddress&, + const QuicSocketAddress&, QuicPacketWriter*), (override)); @@ -50,8 +51,10 @@ class QuicPathValidatorTest : public QuicTest { : path_validator_(&alarm_factory_, &arena_, &send_delegate_, &random_), context_(new MockQuicPathValidationContext(self_address_, peer_address_, + effective_peer_address_, &writer_)), - result_delegate_(new MockQuicPathValidationResultDelegate()) { + result_delegate_( + new testing::StrictMock<MockQuicPathValidationResultDelegate>()) { clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); ON_CALL(send_delegate_, GetRetryTimeout(_, _)) .WillByDefault( @@ -68,6 +71,7 @@ class QuicPathValidatorTest : public QuicTest { QuicPathValidator path_validator_; QuicSocketAddress self_address_{QuicIpAddress::Any4(), 443}; QuicSocketAddress peer_address_{QuicIpAddress::Loopback4(), 443}; + QuicSocketAddress effective_peer_address_{QuicIpAddress::Loopback4(), 12345}; MockPacketWriter writer_; MockQuicPathValidationContext* context_; MockQuicPathValidationResultDelegate* result_delegate_; @@ -76,18 +80,20 @@ class QuicPathValidatorTest : public QuicTest { TEST_F(QuicPathValidatorTest, PathValidationSuccessOnFirstRound) { QuicPathFrameBuffer challenge_data; EXPECT_CALL(send_delegate_, - SendPathChallenge(_, self_address_, peer_address_, &writer_)) + SendPathChallenge(_, self_address_, peer_address_, + effective_peer_address_, &writer_)) .WillOnce(Invoke([&](const QuicPathFrameBuffer& payload, const QuicSocketAddress&, const QuicSocketAddress&, - QuicPacketWriter*) { + const QuicSocketAddress&, QuicPacketWriter*) { memcpy(challenge_data.data(), payload.data(), payload.size()); return true; })); EXPECT_CALL(send_delegate_, GetRetryTimeout(peer_address_, &writer_)); - path_validator_.StartValidingPath( + path_validator_.StartPathValidation( std::unique_ptr<QuicPathValidationContext>(context_), std::unique_ptr<MockQuicPathValidationResultDelegate>(result_delegate_)); EXPECT_TRUE(path_validator_.HasPendingPathValidation()); + EXPECT_TRUE(path_validator_.IsValidatingPeerAddress(effective_peer_address_)); EXPECT_CALL(*result_delegate_, OnPathValidationSuccess(_)) .WillOnce(Invoke([=](std::unique_ptr<QuicPathValidationContext> context) { EXPECT_EQ(context.get(), context_); @@ -99,15 +105,16 @@ TEST_F(QuicPathValidatorTest, PathValidationSuccessOnFirstRound) { TEST_F(QuicPathValidatorTest, RespondWithDifferentSelfAddress) { QuicPathFrameBuffer challenge_data; EXPECT_CALL(send_delegate_, - SendPathChallenge(_, self_address_, peer_address_, &writer_)) + SendPathChallenge(_, self_address_, peer_address_, + effective_peer_address_, &writer_)) .WillOnce(Invoke([&](const QuicPathFrameBuffer payload, const QuicSocketAddress&, const QuicSocketAddress&, - QuicPacketWriter*) { + const QuicSocketAddress&, QuicPacketWriter*) { memcpy(challenge_data.data(), payload.data(), payload.size()); return true; })); EXPECT_CALL(send_delegate_, GetRetryTimeout(peer_address_, &writer_)); - path_validator_.StartValidingPath( + path_validator_.StartPathValidation( std::unique_ptr<QuicPathValidationContext>(context_), std::unique_ptr<MockQuicPathValidationResultDelegate>(result_delegate_)); @@ -126,23 +133,24 @@ TEST_F(QuicPathValidatorTest, RespondWithDifferentSelfAddress) { TEST_F(QuicPathValidatorTest, RespondAfter1stRetry) { QuicPathFrameBuffer challenge_data; EXPECT_CALL(send_delegate_, - SendPathChallenge(_, self_address_, peer_address_, &writer_)) + SendPathChallenge(_, self_address_, peer_address_, + effective_peer_address_, &writer_)) .WillOnce(Invoke([&](const QuicPathFrameBuffer& payload, const QuicSocketAddress&, const QuicSocketAddress&, - QuicPacketWriter*) { + const QuicSocketAddress&, QuicPacketWriter*) { // Store up the 1st PATH_CHALLANGE payload. memcpy(challenge_data.data(), payload.data(), payload.size()); return true; })) .WillOnce(Invoke([&](const QuicPathFrameBuffer& payload, const QuicSocketAddress&, const QuicSocketAddress&, - QuicPacketWriter*) { + const QuicSocketAddress&, QuicPacketWriter*) { EXPECT_NE(payload, challenge_data); return true; })); EXPECT_CALL(send_delegate_, GetRetryTimeout(peer_address_, &writer_)) .Times(2u); - path_validator_.StartValidingPath( + path_validator_.StartPathValidation( std::unique_ptr<QuicPathValidationContext>(context_), std::unique_ptr<MockQuicPathValidationResultDelegate>(result_delegate_)); @@ -160,23 +168,24 @@ TEST_F(QuicPathValidatorTest, RespondAfter1stRetry) { TEST_F(QuicPathValidatorTest, RespondToRetryChallenge) { QuicPathFrameBuffer challenge_data; EXPECT_CALL(send_delegate_, - SendPathChallenge(_, self_address_, peer_address_, &writer_)) + SendPathChallenge(_, self_address_, peer_address_, + effective_peer_address_, &writer_)) .WillOnce(Invoke([&](const QuicPathFrameBuffer& payload, const QuicSocketAddress&, const QuicSocketAddress&, - QuicPacketWriter*) { + const QuicSocketAddress&, QuicPacketWriter*) { memcpy(challenge_data.data(), payload.data(), payload.size()); return true; })) .WillOnce(Invoke([&](const QuicPathFrameBuffer& payload, const QuicSocketAddress&, const QuicSocketAddress&, - QuicPacketWriter*) { + const QuicSocketAddress&, QuicPacketWriter*) { EXPECT_NE(challenge_data, payload); memcpy(challenge_data.data(), payload.data(), payload.size()); return true; })); EXPECT_CALL(send_delegate_, GetRetryTimeout(peer_address_, &writer_)) .Times(2u); - path_validator_.StartValidingPath( + path_validator_.StartPathValidation( std::unique_ptr<QuicPathValidationContext>(context_), std::unique_ptr<MockQuicPathValidationResultDelegate>(result_delegate_)); @@ -193,12 +202,13 @@ TEST_F(QuicPathValidatorTest, RespondToRetryChallenge) { TEST_F(QuicPathValidatorTest, ValidationTimeOut) { EXPECT_CALL(send_delegate_, - SendPathChallenge(_, self_address_, peer_address_, &writer_)) + SendPathChallenge(_, self_address_, peer_address_, + effective_peer_address_, &writer_)) .Times(3u) .WillRepeatedly(Return(true)); EXPECT_CALL(send_delegate_, GetRetryTimeout(peer_address_, &writer_)) .Times(3u); - path_validator_.StartValidingPath( + path_validator_.StartPathValidation( std::unique_ptr<QuicPathValidationContext>(context_), std::unique_ptr<MockQuicPathValidationResultDelegate>(result_delegate_)); @@ -221,9 +231,11 @@ TEST_F(QuicPathValidatorTest, ValidationTimeOut) { TEST_F(QuicPathValidatorTest, SendPathChallengeError) { EXPECT_CALL(send_delegate_, - SendPathChallenge(_, self_address_, peer_address_, &writer_)) + SendPathChallenge(_, self_address_, peer_address_, + effective_peer_address_, &writer_)) .WillOnce(Invoke([&](const QuicPathFrameBuffer&, const QuicSocketAddress&, - const QuicSocketAddress&, QuicPacketWriter*) { + const QuicSocketAddress&, const QuicSocketAddress&, + QuicPacketWriter*) { // Abandon this validation in the call stack shouldn't cause crash and // should cancel the alarm. path_validator_.CancelPathValidation(); @@ -231,7 +243,8 @@ TEST_F(QuicPathValidatorTest, SendPathChallengeError) { })); EXPECT_CALL(send_delegate_, GetRetryTimeout(peer_address_, &writer_)) .Times(0u); - path_validator_.StartValidingPath( + EXPECT_CALL(*result_delegate_, OnPathValidationFailure(_)); + path_validator_.StartPathValidation( std::unique_ptr<QuicPathValidationContext>(context_), std::unique_ptr<MockQuicPathValidationResultDelegate>(result_delegate_)); EXPECT_FALSE(path_validator_.HasPendingPathValidation()); diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_process_packet_interface.h b/chromium/net/third_party/quiche/src/quic/core/quic_process_packet_interface.h index 3cd87ef33c0..cbe257f269f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_process_packet_interface.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_process_packet_interface.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_CORE_QUIC_PROCESS_PACKET_INTERFACE_H_ #define QUICHE_QUIC_CORE_QUIC_PROCESS_PACKET_INTERFACE_H_ -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_protocol_flags_list.h b/chromium/net/third_party/quiche/src/quic/core/quic_protocol_flags_list.h index b9d0a2d68a3..14ed8cd6931 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_protocol_flags_list.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_protocol_flags_list.h @@ -243,4 +243,9 @@ QUIC_PROTOCOL_FLAG(bool, "If true, QUIC server will disable TLS resumption by not " "issuing or processing session tickets.") +QUIC_PROTOCOL_FLAG(bool, + quic_defer_send_in_response, + true, + "If true, QUIC servers will defer sending in response to " + "incoming packets by default.") #endif diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_received_packet_manager.cc b/chromium/net/third_party/quiche/src/quic/core/quic_received_packet_manager.cc index 98f450cbf37..2b434424833 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_received_packet_manager.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_received_packet_manager.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_received_packet_manager.h" +#include "quic/core/quic_received_packet_manager.h" #include <algorithm> #include <limits> #include <utility> -#include "net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_stats.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#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 "quic/core/congestion_control/rtt_stats.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/quic_connection_stats.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -72,7 +72,8 @@ void QuicReceivedPacketManager::RecordPacketReceived( const QuicPacketHeader& header, QuicTime receipt_time) { const QuicPacketNumber packet_number = header.packet_number; - DCHECK(IsAwaitingPacket(packet_number)) << " packet_number:" << packet_number; + QUICHE_DCHECK(IsAwaitingPacket(packet_number)) + << " packet_number:" << packet_number; was_last_packet_missing_ = IsMissing(packet_number); if (!ack_frame_updated_) { ack_frame_.received_packet_times.clear(); @@ -174,8 +175,8 @@ void QuicReceivedPacketManager::DontWaitForPacketsBefore( return; } // ValidateAck() should fail if peer_least_packet_awaiting_ack shrinks. - DCHECK(!peer_least_packet_awaiting_ack_.IsInitialized() || - peer_least_packet_awaiting_ack_ <= least_unacked); + QUICHE_DCHECK(!peer_least_packet_awaiting_ack_.IsInitialized() || + peer_least_packet_awaiting_ack_ <= least_unacked); if (!peer_least_packet_awaiting_ack_.IsInitialized() || least_unacked > peer_least_packet_awaiting_ack_) { peer_least_packet_awaiting_ack_ = least_unacked; @@ -186,9 +187,9 @@ void QuicReceivedPacketManager::DontWaitForPacketsBefore( ack_frame_updated_ = true; } } - DCHECK(ack_frame_.packets.Empty() || - !peer_least_packet_awaiting_ack_.IsInitialized() || - ack_frame_.packets.Min() >= peer_least_packet_awaiting_ack_); + QUICHE_DCHECK(ack_frame_.packets.Empty() || + !peer_least_packet_awaiting_ack_.IsInitialized() || + ack_frame_.packets.Min() >= peer_least_packet_awaiting_ack_); } QuicTime::Delta QuicReceivedPacketManager::GetMaxAckDelay( diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_received_packet_manager.h b/chromium/net/third_party/quiche/src/quic/core/quic_received_packet_manager.h index 78ed4111585..822725db6aa 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_received_packet_manager.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_received_packet_manager.h @@ -6,11 +6,11 @@ #define QUICHE_QUIC_CORE_QUIC_RECEIVED_PACKET_MANAGER_H_ #include <cstddef> -#include "net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/frames/quic_ack_frequency_frame.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -115,7 +115,7 @@ class QUIC_EXPORT_PRIVATE QuicReceivedPacketManager { } void set_ack_frequency(size_t new_value) { - DCHECK_GT(new_value, 0u); + QUICHE_DCHECK_GT(new_value, 0u); ack_frequency_ = new_value; } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_received_packet_manager_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_received_packet_manager_test.cc index c8d16388470..3cfa0ce0a43 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_received_packet_manager_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_received_packet_manager_test.cc @@ -2,21 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_received_packet_manager.h" +#include "quic/core/quic_received_packet_manager.h" #include <algorithm> #include <cstddef> #include <ostream> #include <vector> -#include "net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_stats.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.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 "quic/core/congestion_control/rtt_stats.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/quic_connection_stats.h" +#include "quic/core/quic_constants.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" namespace quic { namespace test { @@ -41,28 +41,7 @@ const QuicTime::Delta kMinRttMs = QuicTime::Delta::FromMilliseconds(40); const QuicTime::Delta kDelayedAckTime = QuicTime::Delta::FromMilliseconds(kDefaultDelayedAckTimeMs); -struct TestParams { - explicit TestParams(QuicTransportVersion version) : version(version) {} - - QuicTransportVersion version; -}; - -// Used by ::testing::PrintToStringParamName(). -std::string PrintToString(const TestParams& p) { - return QuicVersionToString(p.version); -} - -std::vector<TestParams> GetTestParams() { - std::vector<TestParams> params; - QuicTransportVersionVector all_supported_versions = - AllSupportedTransportVersions(); - for (size_t i = 0; i < all_supported_versions.size(); ++i) { - params.push_back(TestParams(all_supported_versions[i])); - } - return params; -} - -class QuicReceivedPacketManagerTest : public QuicTestWithParam<TestParams> { +class QuicReceivedPacketManagerTest : public QuicTest { protected: QuicReceivedPacketManagerTest() : received_manager_(&stats_) { clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); @@ -93,12 +72,12 @@ class QuicReceivedPacketManagerTest : public QuicTestWithParam<TestParams> { } void CheckAckTimeout(QuicTime time) { - DCHECK(HasPendingAck()); - DCHECK_EQ(received_manager_.ack_timeout(), time); + QUICHE_DCHECK(HasPendingAck()); + QUICHE_DCHECK_EQ(received_manager_.ack_timeout(), time); if (time <= clock_.ApproximateNow()) { // ACK timeout expires, send an ACK. received_manager_.ResetAckStates(); - DCHECK(!HasPendingAck()); + QUICHE_DCHECK(!HasPendingAck()); } } @@ -108,12 +87,7 @@ class QuicReceivedPacketManagerTest : public QuicTestWithParam<TestParams> { QuicReceivedPacketManager received_manager_; }; -INSTANTIATE_TEST_SUITE_P(QuicReceivedPacketManagerTest, - QuicReceivedPacketManagerTest, - ::testing::ValuesIn(GetTestParams()), - ::testing::PrintToStringParamName()); - -TEST_P(QuicReceivedPacketManagerTest, DontWaitForPacketsBefore) { +TEST_F(QuicReceivedPacketManagerTest, DontWaitForPacketsBefore) { QuicPacketHeader header; header.packet_number = QuicPacketNumber(2u); received_manager_.RecordPacketReceived(header, QuicTime::Zero()); @@ -126,7 +100,7 @@ TEST_P(QuicReceivedPacketManagerTest, DontWaitForPacketsBefore) { EXPECT_TRUE(received_manager_.IsAwaitingPacket(QuicPacketNumber(6u))); } -TEST_P(QuicReceivedPacketManagerTest, GetUpdatedAckFrame) { +TEST_F(QuicReceivedPacketManagerTest, GetUpdatedAckFrame) { QuicPacketHeader header; header.packet_number = QuicPacketNumber(2u); QuicTime two_ms = QuicTime::Zero() + QuicTime::Delta::FromMilliseconds(2); @@ -168,7 +142,7 @@ TEST_P(QuicReceivedPacketManagerTest, GetUpdatedAckFrame) { EXPECT_EQ(2u, ack.ack_frame->received_packet_times.size()); } -TEST_P(QuicReceivedPacketManagerTest, UpdateReceivedConnectionStats) { +TEST_F(QuicReceivedPacketManagerTest, UpdateReceivedConnectionStats) { EXPECT_FALSE(received_manager_.ack_frame_updated()); RecordPacketReceipt(1); EXPECT_TRUE(received_manager_.ack_frame_updated()); @@ -181,7 +155,7 @@ TEST_P(QuicReceivedPacketManagerTest, UpdateReceivedConnectionStats) { EXPECT_EQ(1u, stats_.packets_reordered); } -TEST_P(QuicReceivedPacketManagerTest, LimitAckRanges) { +TEST_F(QuicReceivedPacketManagerTest, LimitAckRanges) { received_manager_.set_max_ack_ranges(10); EXPECT_FALSE(received_manager_.ack_frame_updated()); for (int i = 0; i < 100; ++i) { @@ -203,7 +177,7 @@ TEST_P(QuicReceivedPacketManagerTest, LimitAckRanges) { } } -TEST_P(QuicReceivedPacketManagerTest, IgnoreOutOfOrderTimestamps) { +TEST_F(QuicReceivedPacketManagerTest, IgnoreOutOfOrderTimestamps) { EXPECT_FALSE(received_manager_.ack_frame_updated()); RecordPacketReceipt(1, QuicTime::Zero()); EXPECT_TRUE(received_manager_.ack_frame_updated()); @@ -215,7 +189,7 @@ TEST_P(QuicReceivedPacketManagerTest, IgnoreOutOfOrderTimestamps) { EXPECT_EQ(2u, received_manager_.ack_frame().received_packet_times.size()); } -TEST_P(QuicReceivedPacketManagerTest, HasMissingPackets) { +TEST_F(QuicReceivedPacketManagerTest, HasMissingPackets) { EXPECT_QUIC_BUG(received_manager_.PeerFirstSendingPacketNumber(), "No packets have been received yet"); RecordPacketReceipt(4, QuicTime::Zero()); @@ -236,7 +210,7 @@ TEST_P(QuicReceivedPacketManagerTest, HasMissingPackets) { EXPECT_FALSE(received_manager_.HasMissingPackets()); } -TEST_P(QuicReceivedPacketManagerTest, OutOfOrderReceiptCausesAckSent) { +TEST_F(QuicReceivedPacketManagerTest, OutOfOrderReceiptCausesAckSent) { EXPECT_FALSE(HasPendingAck()); RecordPacketReceipt(3, clock_.ApproximateNow()); @@ -269,7 +243,7 @@ TEST_P(QuicReceivedPacketManagerTest, OutOfOrderReceiptCausesAckSent) { CheckAckTimeout(clock_.ApproximateNow()); } -TEST_P(QuicReceivedPacketManagerTest, OutOfOrderReceiptCausesAckSent1Ack) { +TEST_F(QuicReceivedPacketManagerTest, OutOfOrderReceiptCausesAckSent1Ack) { QuicReceivedPacketManagerPeer::SetOneImmediateAck(&received_manager_, true); EXPECT_FALSE(HasPendingAck()); @@ -303,7 +277,7 @@ TEST_P(QuicReceivedPacketManagerTest, OutOfOrderReceiptCausesAckSent1Ack) { CheckAckTimeout(clock_.ApproximateNow() + kDelayedAckTime); } -TEST_P(QuicReceivedPacketManagerTest, OutOfOrderAckReceiptCausesNoAck) { +TEST_F(QuicReceivedPacketManagerTest, OutOfOrderAckReceiptCausesNoAck) { EXPECT_FALSE(HasPendingAck()); RecordPacketReceipt(2, clock_.ApproximateNow()); @@ -315,7 +289,7 @@ TEST_P(QuicReceivedPacketManagerTest, OutOfOrderAckReceiptCausesNoAck) { EXPECT_FALSE(HasPendingAck()); } -TEST_P(QuicReceivedPacketManagerTest, AckReceiptCausesAckSend) { +TEST_F(QuicReceivedPacketManagerTest, AckReceiptCausesAckSend) { EXPECT_FALSE(HasPendingAck()); RecordPacketReceipt(1, clock_.ApproximateNow()); @@ -342,7 +316,7 @@ TEST_P(QuicReceivedPacketManagerTest, AckReceiptCausesAckSend) { EXPECT_FALSE(HasPendingAck()); } -TEST_P(QuicReceivedPacketManagerTest, AckSentEveryNthPacket) { +TEST_F(QuicReceivedPacketManagerTest, AckSentEveryNthPacket) { EXPECT_FALSE(HasPendingAck()); received_manager_.set_ack_frequency(3); @@ -358,7 +332,7 @@ TEST_P(QuicReceivedPacketManagerTest, AckSentEveryNthPacket) { } } -TEST_P(QuicReceivedPacketManagerTest, AckDecimationReducesAcks) { +TEST_F(QuicReceivedPacketManagerTest, AckDecimationReducesAcks) { EXPECT_FALSE(HasPendingAck()); // Start ack decimation from 10th packet. @@ -391,7 +365,7 @@ TEST_P(QuicReceivedPacketManagerTest, AckDecimationReducesAcks) { CheckAckTimeout(clock_.ApproximateNow()); } -TEST_P(QuicReceivedPacketManagerTest, SendDelayedAckDecimation) { +TEST_F(QuicReceivedPacketManagerTest, SendDelayedAckDecimation) { EXPECT_FALSE(HasPendingAck()); // The ack time should be based on min_rtt * 1/4, since it's less than the // default delayed ack time. @@ -422,7 +396,7 @@ TEST_P(QuicReceivedPacketManagerTest, SendDelayedAckDecimation) { CheckAckTimeout(clock_.ApproximateNow()); } -TEST_P(QuicReceivedPacketManagerTest, SendDelayedAckDecimationMin1ms) { +TEST_F(QuicReceivedPacketManagerTest, SendDelayedAckDecimationMin1ms) { if (!GetQuicReloadableFlag(quic_ack_delay_alarm_granularity)) { return; } @@ -458,7 +432,7 @@ TEST_P(QuicReceivedPacketManagerTest, SendDelayedAckDecimationMin1ms) { CheckAckTimeout(clock_.ApproximateNow()); } -TEST_P(QuicReceivedPacketManagerTest, +TEST_F(QuicReceivedPacketManagerTest, SendDelayedAckDecimationUnlimitedAggregation) { EXPECT_FALSE(HasPendingAck()); QuicConfig config; @@ -499,7 +473,7 @@ TEST_P(QuicReceivedPacketManagerTest, CheckAckTimeout(ack_time); } -TEST_P(QuicReceivedPacketManagerTest, SendDelayedAckDecimationEighthRtt) { +TEST_F(QuicReceivedPacketManagerTest, SendDelayedAckDecimationEighthRtt) { EXPECT_FALSE(HasPendingAck()); QuicReceivedPacketManagerPeer::SetAckDecimationDelay(&received_manager_, 0.125); diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_sent_packet_manager.cc b/chromium/net/third_party/quiche/src/quic/core/quic_sent_packet_manager.cc index 592faa14baa..97c7c250aa3 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_sent_packet_manager.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_sent_packet_manager.cc @@ -2,28 +2,29 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_sent_packet_manager.h" +#include "quic/core/quic_sent_packet_manager.h" #include <algorithm> #include <cstddef> #include <string> -#include "net/third_party/quiche/src/quic/core/congestion_control/general_loss_algorithm.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/pacing_sender.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.h" -#include "net/third_party/quiche/src/quic/core/proto/cached_network_parameters_proto.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_stats.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_number.h" -#include "net/third_party/quiche/src/quic/core/quic_transmission_info.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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_map_util.h" +#include "quic/core/congestion_control/general_loss_algorithm.h" +#include "quic/core/congestion_control/pacing_sender.h" +#include "quic/core/congestion_control/send_algorithm_interface.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/frames/quic_ack_frequency_frame.h" +#include "quic/core/proto/cached_network_parameters_proto.h" +#include "quic/core/quic_connection_stats.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_packet_number.h" +#include "quic/core/quic_transmission_info.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_map_util.h" namespace quic { @@ -112,10 +113,11 @@ QuicSentPacketManager::QuicSentPacketManager( handshake_packet_acked_(false), zero_rtt_packet_acked_(false), one_rtt_packet_acked_(false), - one_rtt_packet_sent_(false), first_pto_srtt_multiplier_(0), use_standard_deviation_for_pto_(false), - pto_multiplier_without_rtt_samples_(3) { + pto_multiplier_without_rtt_samples_(3), + num_ptos_for_path_degrading_(0), + ignore_pings_(false) { SetSendAlgorithm(congestion_control_type); if (pto_enabled_) { QUIC_RELOADABLE_FLAG_COUNT_N(quic_default_on_pto, 1, 2); @@ -219,6 +221,18 @@ void QuicSentPacketManager::SetFromConfig(const QuicConfig& config) { use_standard_deviation_for_pto_ = true; rtt_stats_.EnableStandardDeviationCalculation(); } + if (config.HasClientRequestedIndependentOption(kPDP2, perspective)) { + num_ptos_for_path_degrading_ = 2; + } + if (config.HasClientRequestedIndependentOption(kPDP3, perspective)) { + num_ptos_for_path_degrading_ = 3; + } + if (config.HasClientRequestedIndependentOption(kPDP4, perspective)) { + num_ptos_for_path_degrading_ = 4; + } + if (config.HasClientRequestedIndependentOption(kPDP5, perspective)) { + num_ptos_for_path_degrading_ = 5; + } } // Configure congestion control. @@ -263,6 +277,10 @@ void QuicSentPacketManager::SetFromConfig(const QuicConfig& config) { send_algorithm_->SetInitialCongestionWindowInPackets(10); } + if (config.HasClientRequestedIndependentOption(kIGNP, perspective)) { + ignore_pings_ = true; + } + using_pacing_ = !GetQuicFlag(FLAGS_quic_disable_pacing_for_perf_tests); if (config.HasClientSentConnectionOption(kNTLP, perspective)) { @@ -476,41 +494,43 @@ void QuicSentPacketManager::MaybeInvokeCongestionEvent( } } -void QuicSentPacketManager::MarkZeroRttPacketsForRetransmission() { - if (unacked_packets_.use_circular_deque()) { - if (unacked_packets_.empty()) { - return; - } - QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); - QuicPacketNumber largest_sent_packet = - unacked_packets_.largest_sent_packet(); - for (; packet_number <= largest_sent_packet; ++packet_number) { - QuicTransmissionInfo* transmission_info = - unacked_packets_.GetMutableTransmissionInfo(packet_number); - if (transmission_info->encryption_level == ENCRYPTION_ZERO_RTT) { - if (transmission_info->in_flight) { - // Remove 0-RTT packets and packets of the wrong version from flight, - // because neither can be processed by the peer. - unacked_packets_.RemoveFromInFlight(transmission_info); - } - if (unacked_packets_.HasRetransmittableFrames(*transmission_info)) { - MarkForRetransmission(packet_number, ALL_ZERO_RTT_RETRANSMISSION); - } +void QuicSentPacketManager::MarkInitialPacketsForRetransmission() { + if (unacked_packets_.empty()) { + return; + } + QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); + QuicPacketNumber largest_sent_packet = unacked_packets_.largest_sent_packet(); + for (; packet_number <= largest_sent_packet; ++packet_number) { + QuicTransmissionInfo* transmission_info = + unacked_packets_.GetMutableTransmissionInfo(packet_number); + if (transmission_info->encryption_level == ENCRYPTION_INITIAL) { + if (transmission_info->in_flight) { + unacked_packets_.RemoveFromInFlight(transmission_info); + } + if (unacked_packets_.HasRetransmittableFrames(*transmission_info)) { + MarkForRetransmission(packet_number, ALL_INITIAL_RETRANSMISSION); } } - } else { - QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); - for (QuicUnackedPacketMap::iterator it = unacked_packets_.begin(); - it != unacked_packets_.end(); ++it, ++packet_number) { - if (it->encryption_level == ENCRYPTION_ZERO_RTT) { - if (it->in_flight) { - // Remove 0-RTT packets and packets of the wrong version from - // flight, because neither can be processed by the peer. - unacked_packets_.RemoveFromInFlight(&*it); - } - if (unacked_packets_.HasRetransmittableFrames(*it)) { - MarkForRetransmission(packet_number, ALL_ZERO_RTT_RETRANSMISSION); - } + } +} + +void QuicSentPacketManager::MarkZeroRttPacketsForRetransmission() { + if (unacked_packets_.empty()) { + return; + } + QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); + QuicPacketNumber largest_sent_packet = unacked_packets_.largest_sent_packet(); + for (; packet_number <= largest_sent_packet; ++packet_number) { + QuicTransmissionInfo* transmission_info = + unacked_packets_.GetMutableTransmissionInfo(packet_number); + if (transmission_info->encryption_level == ENCRYPTION_ZERO_RTT) { + if (transmission_info->in_flight) { + // Remove 0-RTT packets and packets of the wrong version from flight, + // because neither can be processed by the peer. + unacked_packets_.RemoveFromInFlight(transmission_info); + } + if (unacked_packets_.HasRetransmittableFrames(*transmission_info)) { + MarkForRetransmission(packet_number, ALL_ZERO_RTT_RETRANSMISSION); } } } @@ -540,7 +560,7 @@ void QuicSentPacketManager::NeuterHandshakePackets() { bool QuicSentPacketManager::ShouldAddMaxAckDelay( PacketNumberSpace space) const { - DCHECK(pto_enabled_); + QUICHE_DCHECK(pto_enabled_); if (supports_multiple_packet_number_spaces() && space != APPLICATION_DATA) { // When the PTO is armed for Initial or Handshake packet number spaces, // the max_ack_delay is 0. @@ -577,12 +597,13 @@ bool QuicSentPacketManager::ShouldAddMaxAckDelay( QuicTime QuicSentPacketManager::GetEarliestPacketSentTimeForPto( PacketNumberSpace* packet_number_space) const { - DCHECK(supports_multiple_packet_number_spaces()); + QUICHE_DCHECK(supports_multiple_packet_number_spaces()); QuicTime earliest_sent_time = QuicTime::Zero(); for (int8_t i = 0; i < NUM_PACKET_NUMBER_SPACES; ++i) { const QuicTime sent_time = unacked_packets_.GetLastInFlightPacketSentTime( static_cast<PacketNumberSpace>(i)); - if (!ShouldArmPtoForApplicationData() && i == APPLICATION_DATA) { + if (!handshake_finished_ && i == APPLICATION_DATA) { + // Do not arm PTO for application data until handshake gets confirmed. continue; } if (!sent_time.IsInitialized() || (earliest_sent_time.IsInitialized() && @@ -596,24 +617,6 @@ QuicTime QuicSentPacketManager::GetEarliestPacketSentTimeForPto( return earliest_sent_time; } -bool QuicSentPacketManager::ShouldArmPtoForApplicationData() const { - DCHECK(supports_multiple_packet_number_spaces()); - if (GetQuicReloadableFlag(quic_fix_arm_pto_for_application_data)) { - QUIC_RELOADABLE_FLAG_COUNT(quic_fix_arm_pto_for_application_data); - // Do not arm PTO for application data until handshake gets confirmed. - return handshake_finished_; - } - // Application data must be ignored before handshake completes (1-RTT key - // is available). Not arming PTO for application data to prioritize the - // completion of handshake. On the server side, handshake_finished_ - // indicates handshake complete (and confirmed). On the client side, - // one_rtt_packet_sent_ indicates handshake complete (while handshake - // confirmation will happen later). - return handshake_finished_ || - (unacked_packets_.perspective() == Perspective::IS_CLIENT && - one_rtt_packet_sent_); -} - void QuicSentPacketManager::MarkForRetransmission( QuicPacketNumber packet_number, TransmissionType transmission_type) { @@ -624,10 +627,12 @@ void QuicSentPacketManager::MarkForRetransmission( QUIC_BUG_IF(transmission_type != LOSS_RETRANSMISSION && transmission_type != RTO_RETRANSMISSION && !unacked_packets_.HasRetransmittableFrames(*transmission_info)) - << "transmission_type: " << transmission_type; + << "packet number " << packet_number + << " transmission_type: " << transmission_type << " transmission_info " + << transmission_info->DebugString(); // Handshake packets should never be sent as probing retransmissions. - DCHECK(!transmission_info->has_crypto_handshake || - transmission_type != PROBING_RETRANSMISSION); + QUICHE_DCHECK(!transmission_info->has_crypto_handshake || + transmission_type != PROBING_RETRANSMISSION); HandleRetransmission(transmission_type, transmission_info); @@ -653,7 +658,12 @@ void QuicSentPacketManager::HandleRetransmission( // applications may want to use higher priority stream data for bandwidth // probing, and some applications want to consider RTO is an indication of // loss, etc. - unacked_packets_.RetransmitFrames(*transmission_info, transmission_type); + // transmission_info owning these frames may be deallocated after each + // retransimission. Make a copy of retransmissible frames to prevent the + // invalidation. + unacked_packets_.RetransmitFrames( + QuicFrames(transmission_info->retransmittable_frames), + transmission_type); return; } @@ -777,14 +787,20 @@ bool QuicSentPacketManager::OnPacketSent( bool measure_rtt) { const SerializedPacket& packet = *mutable_packet; QuicPacketNumber packet_number = packet.packet_number; - DCHECK_LE(FirstSendingPacketNumber(), packet_number); - DCHECK(!unacked_packets_.IsUnacked(packet_number)); + QUICHE_DCHECK_LE(FirstSendingPacketNumber(), packet_number); + QUICHE_DCHECK(!unacked_packets_.IsUnacked(packet_number)); QUIC_BUG_IF(packet.encrypted_length == 0) << "Cannot send empty packets."; if (pending_timer_transmission_count_ > 0) { --pending_timer_transmission_count_; } bool in_flight = has_retransmittable_data == HAS_RETRANSMITTABLE_DATA; + if (ignore_pings_ && mutable_packet->retransmittable_frames.size() == 1 && + mutable_packet->retransmittable_frames[0].type == PING_FRAME) { + // Dot not use PING only packet for RTT measure or congestion control. + in_flight = false; + measure_rtt = false; + } if (using_pacing_) { pacing_sender_.OnPacketSent(sent_time, unacked_packets_.bytes_in_flight(), packet_number, packet.encrypted_length, @@ -795,20 +811,13 @@ bool QuicSentPacketManager::OnPacketSent( has_retransmittable_data); } - if (packet.encryption_level == ENCRYPTION_FORWARD_SECURE) { - one_rtt_packet_sent_ = true; - } - - if (GetQuicReloadableFlag(quic_deallocate_message_right_after_sent)) { - QUIC_RELOADABLE_FLAG_COUNT(quic_deallocate_message_right_after_sent); - // Deallocate message data in QuicMessageFrame immediately after packet - // sent. - if (packet.has_message) { - for (auto& frame : mutable_packet->retransmittable_frames) { - if (frame.type == MESSAGE_FRAME) { - frame.message_frame->message_data.clear(); - frame.message_frame->message_length = 0; - } + // Deallocate message data in QuicMessageFrame immediately after packet + // sent. + if (packet.has_message) { + for (auto& frame : mutable_packet->retransmittable_frames) { + if (frame.type == MESSAGE_FRAME) { + frame.message_frame->message_data.clear(); + frame.message_frame->message_length = 0; } } } @@ -828,9 +837,9 @@ bool QuicSentPacketManager::OnPacketSent( QuicSentPacketManager::RetransmissionTimeoutMode QuicSentPacketManager::OnRetransmissionTimeout() { - DCHECK(unacked_packets_.HasInFlightPackets() || - (handshake_mode_disabled_ && !handshake_finished_)); - DCHECK_EQ(0u, pending_timer_transmission_count_); + QUICHE_DCHECK(unacked_packets_.HasInFlightPackets() || + (handshake_mode_disabled_ && !handshake_finished_)); + QUICHE_DCHECK_EQ(0u, pending_timer_transmission_count_); // Handshake retransmission, timer based loss detection, TLP, and RTO are // implemented with a single alarm. The handshake alarm is set when the // handshake has not completed, the loss alarm is set when the loss detection @@ -838,7 +847,7 @@ QuicSentPacketManager::OnRetransmissionTimeout() { // The TLP alarm is always set to run for under an RTO. switch (GetRetransmissionMode()) { case HANDSHAKE_MODE: - DCHECK(!handshake_mode_disabled_); + QUICHE_DCHECK(!handshake_mode_disabled_); ++stats_->crypto_retransmit_count; RetransmitCryptoPackets(); return HANDSHAKE_MODE; @@ -864,7 +873,7 @@ QuicSentPacketManager::OnRetransmissionTimeout() { case PTO_MODE: QUIC_DVLOG(1) << ENDPOINT << "PTO mode"; ++stats_->pto_count; - if (handshake_mode_disabled_ && !ShouldArmPtoForApplicationData()) { + if (handshake_mode_disabled_ && !handshake_finished_) { ++stats_->crypto_retransmit_count; } ++consecutive_pto_count_; @@ -876,40 +885,23 @@ QuicSentPacketManager::OnRetransmissionTimeout() { } void QuicSentPacketManager::RetransmitCryptoPackets() { - DCHECK_EQ(HANDSHAKE_MODE, GetRetransmissionMode()); + QUICHE_DCHECK_EQ(HANDSHAKE_MODE, GetRetransmissionMode()); ++consecutive_crypto_retransmission_count_; bool packet_retransmitted = false; std::vector<QuicPacketNumber> crypto_retransmissions; - if (unacked_packets_.use_circular_deque()) { - if (!unacked_packets_.empty()) { - QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); - QuicPacketNumber largest_sent_packet = - unacked_packets_.largest_sent_packet(); - for (; packet_number <= largest_sent_packet; ++packet_number) { - QuicTransmissionInfo* transmission_info = - unacked_packets_.GetMutableTransmissionInfo(packet_number); - // Only retransmit frames which are in flight, and therefore have been - // sent. - if (!transmission_info->in_flight || - transmission_info->state != OUTSTANDING || - !transmission_info->has_crypto_handshake || - !unacked_packets_.HasRetransmittableFrames(*transmission_info)) { - continue; - } - packet_retransmitted = true; - crypto_retransmissions.push_back(packet_number); - ++pending_timer_transmission_count_; - } - } - } else { + if (!unacked_packets_.empty()) { QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); - for (auto it = unacked_packets_.begin(); it != unacked_packets_.end(); - ++it, ++packet_number) { + QuicPacketNumber largest_sent_packet = + unacked_packets_.largest_sent_packet(); + for (; packet_number <= largest_sent_packet; ++packet_number) { + QuicTransmissionInfo* transmission_info = + unacked_packets_.GetMutableTransmissionInfo(packet_number); // Only retransmit frames which are in flight, and therefore have been // sent. - if (!it->in_flight || it->state != OUTSTANDING || - !it->has_crypto_handshake || - !unacked_packets_.HasRetransmittableFrames(*it)) { + if (!transmission_info->in_flight || + transmission_info->state != OUTSTANDING || + !transmission_info->has_crypto_handshake || + !unacked_packets_.HasRetransmittableFrames(*transmission_info)) { continue; } packet_retransmitted = true; @@ -917,14 +909,15 @@ void QuicSentPacketManager::RetransmitCryptoPackets() { ++pending_timer_transmission_count_; } } - DCHECK(packet_retransmitted) << "No crypto packets found to retransmit."; + QUICHE_DCHECK(packet_retransmitted) + << "No crypto packets found to retransmit."; for (QuicPacketNumber retransmission : crypto_retransmissions) { MarkForRetransmission(retransmission, HANDSHAKE_RETRANSMISSION); } } bool QuicSentPacketManager::MaybeRetransmitTailLossProbe() { - DCHECK(!pto_enabled_); + QUICHE_DCHECK(!pto_enabled_); if (pending_timer_transmission_count_ == 0) { return false; } @@ -935,33 +928,18 @@ bool QuicSentPacketManager::MaybeRetransmitTailLossProbe() { } bool QuicSentPacketManager::MaybeRetransmitOldestPacket(TransmissionType type) { - if (unacked_packets_.use_circular_deque()) { - if (!unacked_packets_.empty()) { - QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); - QuicPacketNumber largest_sent_packet = - unacked_packets_.largest_sent_packet(); - for (; packet_number <= largest_sent_packet; ++packet_number) { - QuicTransmissionInfo* transmission_info = - unacked_packets_.GetMutableTransmissionInfo(packet_number); - // Only retransmit frames which are in flight, and therefore have been - // sent. - if (!transmission_info->in_flight || - transmission_info->state != OUTSTANDING || - !unacked_packets_.HasRetransmittableFrames(*transmission_info)) { - continue; - } - MarkForRetransmission(packet_number, type); - return true; - } - } - } else { + if (!unacked_packets_.empty()) { QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); - for (auto it = unacked_packets_.begin(); it != unacked_packets_.end(); - ++it, ++packet_number) { + QuicPacketNumber largest_sent_packet = + unacked_packets_.largest_sent_packet(); + for (; packet_number <= largest_sent_packet; ++packet_number) { + QuicTransmissionInfo* transmission_info = + unacked_packets_.GetMutableTransmissionInfo(packet_number); // Only retransmit frames which are in flight, and therefore have been // sent. - if (!it->in_flight || it->state != OUTSTANDING || - !unacked_packets_.HasRetransmittableFrames(*it)) { + if (!transmission_info->in_flight || + transmission_info->state != OUTSTANDING || + !unacked_packets_.HasRetransmittableFrames(*transmission_info)) { continue; } MarkForRetransmission(packet_number, type); @@ -974,36 +952,22 @@ bool QuicSentPacketManager::MaybeRetransmitOldestPacket(TransmissionType type) { } void QuicSentPacketManager::RetransmitRtoPackets() { - DCHECK(!pto_enabled_); + QUICHE_DCHECK(!pto_enabled_); QUIC_BUG_IF(pending_timer_transmission_count_ > 0) << "Retransmissions already queued:" << pending_timer_transmission_count_; // Mark two packets for retransmission. std::vector<QuicPacketNumber> retransmissions; - if (unacked_packets_.use_circular_deque()) { - if (!unacked_packets_.empty()) { - QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); - QuicPacketNumber largest_sent_packet = - unacked_packets_.largest_sent_packet(); - for (; packet_number <= largest_sent_packet; ++packet_number) { - QuicTransmissionInfo* transmission_info = - unacked_packets_.GetMutableTransmissionInfo(packet_number); - if (transmission_info->state == OUTSTANDING && - unacked_packets_.HasRetransmittableFrames(*transmission_info) && - pending_timer_transmission_count_ < max_rto_packets_) { - DCHECK(transmission_info->in_flight); - retransmissions.push_back(packet_number); - ++pending_timer_transmission_count_; - } - } - } - } else { + if (!unacked_packets_.empty()) { QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); - for (auto it = unacked_packets_.begin(); it != unacked_packets_.end(); - ++it, ++packet_number) { - if (it->state == OUTSTANDING && - unacked_packets_.HasRetransmittableFrames(*it) && + QuicPacketNumber largest_sent_packet = + unacked_packets_.largest_sent_packet(); + for (; packet_number <= largest_sent_packet; ++packet_number) { + QuicTransmissionInfo* transmission_info = + unacked_packets_.GetMutableTransmissionInfo(packet_number); + if (transmission_info->state == OUTSTANDING && + unacked_packets_.HasRetransmittableFrames(*transmission_info) && pending_timer_transmission_count_ < max_rto_packets_) { - DCHECK(it->in_flight); + QUICHE_DCHECK(transmission_info->in_flight); retransmissions.push_back(packet_number); ++pending_timer_transmission_count_; } @@ -1043,37 +1007,19 @@ void QuicSentPacketManager::MaybeSendProbePackets() { } } std::vector<QuicPacketNumber> probing_packets; - if (unacked_packets_.use_circular_deque()) { - if (!unacked_packets_.empty()) { - QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); - QuicPacketNumber largest_sent_packet = - unacked_packets_.largest_sent_packet(); - for (; packet_number <= largest_sent_packet; ++packet_number) { - QuicTransmissionInfo* transmission_info = - unacked_packets_.GetMutableTransmissionInfo(packet_number); - if (transmission_info->state == OUTSTANDING && - unacked_packets_.HasRetransmittableFrames(*transmission_info) && - (!supports_multiple_packet_number_spaces() || - unacked_packets_.GetPacketNumberSpace( - transmission_info->encryption_level) == packet_number_space)) { - DCHECK(transmission_info->in_flight); - probing_packets.push_back(packet_number); - if (probing_packets.size() == pending_timer_transmission_count_) { - break; - } - } - } - } - } else { + if (!unacked_packets_.empty()) { QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); - for (auto it = unacked_packets_.begin(); it != unacked_packets_.end(); - ++it, ++packet_number) { - if (it->state == OUTSTANDING && - unacked_packets_.HasRetransmittableFrames(*it) && + QuicPacketNumber largest_sent_packet = + unacked_packets_.largest_sent_packet(); + for (; packet_number <= largest_sent_packet; ++packet_number) { + QuicTransmissionInfo* transmission_info = + unacked_packets_.GetMutableTransmissionInfo(packet_number); + if (transmission_info->state == OUTSTANDING && + unacked_packets_.HasRetransmittableFrames(*transmission_info) && (!supports_multiple_packet_number_spaces() || - unacked_packets_.GetPacketNumberSpace(it->encryption_level) == - packet_number_space)) { - DCHECK(it->in_flight); + unacked_packets_.GetPacketNumberSpace( + transmission_info->encryption_level) == packet_number_space)) { + QUICHE_DCHECK(transmission_info->in_flight); probing_packets.push_back(packet_number); if (probing_packets.size() == pending_timer_transmission_count_) { break; @@ -1115,10 +1061,7 @@ void QuicSentPacketManager::EnableIetfPtoAndLossDetection() { max_probe_packets_per_pto_ = 1; skip_packet_number_for_pto_ = true; first_pto_srtt_multiplier_ = 1.5; - if (GetQuicReloadableFlag(quic_default_to_2_rttvar)) { - QUIC_RELOADABLE_FLAG_COUNT(quic_default_to_2_rttvar); - pto_rttvar_multiplier_ = 2; - } + pto_rttvar_multiplier_ = 2; } void QuicSentPacketManager::StartExponentialBackoffAfterNthPto( @@ -1128,60 +1071,37 @@ void QuicSentPacketManager::StartExponentialBackoffAfterNthPto( void QuicSentPacketManager::RetransmitDataOfSpaceIfAny( PacketNumberSpace space) { - DCHECK(supports_multiple_packet_number_spaces()); + QUICHE_DCHECK(supports_multiple_packet_number_spaces()); if (!unacked_packets_.GetLastInFlightPacketSentTime(space).IsInitialized()) { // No in flight data of space. return; } - if (unacked_packets_.use_circular_deque()) { - if (unacked_packets_.empty()) { - return; - } - QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); - QuicPacketNumber largest_sent_packet = - unacked_packets_.largest_sent_packet(); - for (; packet_number <= largest_sent_packet; ++packet_number) { - QuicTransmissionInfo* transmission_info = - unacked_packets_.GetMutableTransmissionInfo(packet_number); - if (transmission_info->state == OUTSTANDING && - unacked_packets_.HasRetransmittableFrames(*transmission_info) && - unacked_packets_.GetPacketNumberSpace( - transmission_info->encryption_level) == space) { - DCHECK(transmission_info->in_flight); - if (GetQuicReloadableFlag(quic_fix_pto_pending_timer_count) && - pending_timer_transmission_count_ == 0) { - QUIC_RELOADABLE_FLAG_COUNT(quic_fix_pto_pending_timer_count); - pending_timer_transmission_count_ = 1; - } - MarkForRetransmission(packet_number, PTO_RETRANSMISSION); - return; - } - } - } else { - QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); - for (auto it = unacked_packets_.begin(); it != unacked_packets_.end(); - ++it, ++packet_number) { - if (it->state == OUTSTANDING && - unacked_packets_.HasRetransmittableFrames(*it) && - unacked_packets_.GetPacketNumberSpace(it->encryption_level) == - space) { - DCHECK(it->in_flight); - if (GetQuicReloadableFlag(quic_fix_pto_pending_timer_count) && - pending_timer_transmission_count_ == 0) { - QUIC_RELOADABLE_FLAG_COUNT(quic_fix_pto_pending_timer_count); - pending_timer_transmission_count_ = 1; - } - MarkForRetransmission(packet_number, PTO_RETRANSMISSION); - return; + if (unacked_packets_.empty()) { + return; + } + QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); + QuicPacketNumber largest_sent_packet = unacked_packets_.largest_sent_packet(); + for (; packet_number <= largest_sent_packet; ++packet_number) { + QuicTransmissionInfo* transmission_info = + unacked_packets_.GetMutableTransmissionInfo(packet_number); + if (transmission_info->state == OUTSTANDING && + unacked_packets_.HasRetransmittableFrames(*transmission_info) && + unacked_packets_.GetPacketNumberSpace( + transmission_info->encryption_level) == space) { + QUICHE_DCHECK(transmission_info->in_flight); + if (pending_timer_transmission_count_ == 0) { + pending_timer_transmission_count_ = 1; } + MarkForRetransmission(packet_number, PTO_RETRANSMISSION); + return; } } } QuicSentPacketManager::RetransmissionTimeoutMode QuicSentPacketManager::GetRetransmissionMode() const { - DCHECK(unacked_packets_.HasInFlightPackets() || - (handshake_mode_disabled_ && !handshake_finished_)); + QUICHE_DCHECK(unacked_packets_.HasInFlightPackets() || + (handshake_mode_disabled_ && !handshake_finished_)); if (!handshake_mode_disabled_ && !handshake_finished_ && unacked_packets_.HasPendingCryptoPackets()) { return HANDSHAKE_MODE; @@ -1202,8 +1122,8 @@ QuicSentPacketManager::GetRetransmissionMode() const { void QuicSentPacketManager::InvokeLossDetection(QuicTime time) { if (!packets_acked_.empty()) { - DCHECK_LE(packets_acked_.front().packet_number, - packets_acked_.back().packet_number); + QUICHE_DCHECK_LE(packets_acked_.front().packet_number, + packets_acked_.back().packet_number); largest_newly_acked_ = packets_acked_.back().packet_number; } LossDetectionInterface::DetectionStats detection_stats = @@ -1242,7 +1162,8 @@ bool QuicSentPacketManager::MaybeUpdateRTT(QuicPacketNumber largest_acked, QuicTime::Delta ack_delay_time, QuicTime ack_receive_time) { // We rely on ack_delay_time to compute an RTT estimate, so we - // only update rtt when the largest observed gets acked. + // only update rtt when the largest observed gets acked and the acked packet + // is not useless. if (!unacked_packets_.IsUnacked(largest_acked)) { return false; } @@ -1256,6 +1177,9 @@ bool QuicSentPacketManager::MaybeUpdateRTT(QuicPacketNumber largest_acked, << largest_acked; return false; } + if (transmission_info.state == NOT_CONTRIBUTING_RTT) { + return false; + } if (transmission_info.sent_time > ack_receive_time) { QUIC_CODE_COUNT(quic_receive_acked_before_sending); } @@ -1312,7 +1236,7 @@ const QuicTime QuicSentPacketManager::GetRetransmissionTime() const { case LOSS_MODE: return loss_algorithm_->GetLossTimeout(); case TLP_MODE: { - DCHECK(!pto_enabled_); + QUICHE_DCHECK(!pto_enabled_); // TODO(ianswett): When CWND is available, it would be preferable to // set the timer based on the earliest retransmittable packet. // Base the updated timer on the send time of the last packet. @@ -1323,7 +1247,7 @@ const QuicTime QuicSentPacketManager::GetRetransmissionTime() const { return std::max(clock_->ApproximateNow(), tlp_time); } case RTO_MODE: { - DCHECK(!pto_enabled_); + QUICHE_DCHECK(!pto_enabled_); // The RTO is based on the first outstanding packet. const QuicTime sent_time = unacked_packets_.GetLastInFlightPacketSentTime(); @@ -1388,11 +1312,14 @@ const QuicTime QuicSentPacketManager::GetRetransmissionTime() const { earliest_right_edge + GetProbeTimeoutDelay(packet_number_space)); } } - DCHECK(false); + QUICHE_DCHECK(false); return QuicTime::Zero(); } const QuicTime::Delta QuicSentPacketManager::GetPathDegradingDelay() const { + if (num_ptos_for_path_degrading_ > 0) { + return num_ptos_for_path_degrading_ * GetPtoDelay(); + } return GetNConsecutiveRetransmissionTimeoutDelay( max_tail_loss_probes_ + kNumRetransmissionDelaysForPathDegradingDelay); } @@ -1471,7 +1398,7 @@ const QuicTime::Delta QuicSentPacketManager::GetRetransmissionDelay() const { const QuicTime::Delta QuicSentPacketManager::GetProbeTimeoutDelay( PacketNumberSpace space) const { - DCHECK(pto_enabled_); + QUICHE_DCHECK(pto_enabled_); if (rtt_stats_.smoothed_rtt().IsZero()) { // Respect kMinHandshakeTimeoutMs to avoid a potential amplification attack. QUIC_BUG_IF(rtt_stats_.initial_rtt().IsZero()); @@ -1539,24 +1466,46 @@ void QuicSentPacketManager::SetSendAlgorithm( pacing_sender_.set_sender(send_algorithm); } -void QuicSentPacketManager::OnConnectionMigration(AddressChangeType type) { - if (type == PORT_CHANGE || type == IPV4_SUBNET_CHANGE) { - // Rtt and cwnd do not need to be reset when the peer address change is - // considered to be caused by NATs. - return; - } +std::unique_ptr<SendAlgorithmInterface> +QuicSentPacketManager::OnConnectionMigration(bool reset_send_algorithm) { consecutive_rto_count_ = 0; consecutive_tlp_count_ = 0; consecutive_pto_count_ = 0; rtt_stats_.OnConnectionMigration(); - send_algorithm_->OnConnectionMigration(); + if (!reset_send_algorithm) { + send_algorithm_->OnConnectionMigration(); + return nullptr; + } + + std::unique_ptr<SendAlgorithmInterface> old_send_algorithm = + std::move(send_algorithm_); + SetSendAlgorithm(old_send_algorithm->GetCongestionControlType()); + // Treat all in flight packets sent to the old peer address as lost and + // retransmit them. + QuicPacketNumber packet_number = unacked_packets_.GetLeastUnacked(); + for (auto it = unacked_packets_.begin(); it != unacked_packets_.end(); + ++it, ++packet_number) { + if (it->in_flight) { + // Proactively retransmit any packet which is in flight on the old path. + // As a result, these packets will not contribute to congestion control. + unacked_packets_.RemoveFromInFlight(packet_number); + // Retransmitting these packets with PATH_CHANGE_RETRANSMISSION will mark + // them as useless, thus not contributing to RTT stats. + if (unacked_packets_.HasRetransmittableFrames(packet_number)) { + MarkForRetransmission(packet_number, PATH_RETRANSMISSION); + QUICHE_DCHECK_EQ(it->state, NOT_CONTRIBUTING_RTT); + } + } + it->state = NOT_CONTRIBUTING_RTT; + } + return old_send_algorithm; } void QuicSentPacketManager::OnAckFrameStart(QuicPacketNumber largest_acked, QuicTime::Delta ack_delay_time, QuicTime ack_receive_time) { - DCHECK(packets_acked_.empty()); - DCHECK_LE(largest_acked, unacked_packets_.largest_sent_packet()); + QUICHE_DCHECK(packets_acked_.empty()); + QUICHE_DCHECK_LE(largest_acked, unacked_packets_.largest_sent_packet()); if (ack_delay_time > peer_max_ack_delay()) { ack_delay_time = peer_max_ack_delay(); } @@ -1729,7 +1678,7 @@ void QuicSentPacketManager::EnableMultiplePacketNumberSpacesSupport() { QuicPacketNumber QuicSentPacketManager::GetLargestAckedPacket( EncryptionLevel decrypted_packet_level) const { - DCHECK(supports_multiple_packet_number_spaces()); + QUICHE_DCHECK(supports_multiple_packet_number_spaces()); return unacked_packets_.GetLargestAckedOfPacketNumberSpace( QuicUtils::GetPacketNumberSpace(decrypted_packet_level)); } @@ -1757,7 +1706,7 @@ QuicPacketNumber QuicSentPacketManager::GetLeastPacketAwaitedByPeer( QuicPacketNumber QuicSentPacketManager::GetLargestPacketPeerKnowsIsAcked( EncryptionLevel decrypted_packet_level) const { - DCHECK(supports_multiple_packet_number_spaces()); + QUICHE_DCHECK(supports_multiple_packet_number_spaces()); return largest_packets_peer_knows_is_acked_[QuicUtils::GetPacketNumberSpace( decrypted_packet_level)]; } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_sent_packet_manager.h b/chromium/net/third_party/quiche/src/quic/core/quic_sent_packet_manager.h index df18f2a22c1..13e2396fd86 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_sent_packet_manager.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_sent_packet_manager.h @@ -14,20 +14,20 @@ #include <utility> #include <vector> -#include "net/third_party/quiche/src/quic/core/congestion_control/pacing_sender.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/uber_loss_algorithm.h" -#include "net/third_party/quiche/src/quic/core/proto/cached_network_parameters_proto.h" -#include "net/third_party/quiche/src/quic/core/quic_circular_deque.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_sustained_bandwidth_recorder.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_transmission_info.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_unacked_packet_map.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/congestion_control/pacing_sender.h" +#include "quic/core/congestion_control/rtt_stats.h" +#include "quic/core/congestion_control/send_algorithm_interface.h" +#include "quic/core/congestion_control/uber_loss_algorithm.h" +#include "quic/core/proto/cached_network_parameters_proto.h" +#include "quic/core/quic_circular_deque.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_sustained_bandwidth_recorder.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_transmission_info.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_unacked_packet_map.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -155,6 +155,9 @@ class QUIC_EXPORT_PRIVATE QuicSentPacketManager { // data needs to be encrypted with a new key. void MarkZeroRttPacketsForRetransmission(); + // Request retransmission of all unacked INITIAL packets. + void MarkInitialPacketsForRetransmission(); + // Notify the sent packet manager of an external network measurement or // prediction for either |bandwidth| or |rtt|; either can be empty. void AdjustNetworkParameters( @@ -237,6 +240,10 @@ class QUIC_EXPORT_PRIVATE QuicSentPacketManager { const RttStats* GetRttStats() const { return &rtt_stats_; } + void SetRttStats(const RttStats& rtt_stats) { + rtt_stats_.CloneFrom(rtt_stats); + } + // Returns the estimated bandwidth calculated by the congestion algorithm. QuicBandwidth BandwidthEstimate() const { return send_algorithm_->BandwidthEstimate(); @@ -295,8 +302,12 @@ class QUIC_EXPORT_PRIVATE QuicSentPacketManager { return unacked_packets_.bytes_in_flight(); } - // Called when peer address changes and the connection migrates. - void OnConnectionMigration(AddressChangeType type); + // Called when peer address changes. Must be called IFF the address change is + // not NAT rebinding. If reset_send_algorithm is true, switch to a new send + // algorithm object and retransmit all the in-flight packets. Return the send + // algorithm object used on the previous path. + std::unique_ptr<SendAlgorithmInterface> OnConnectionMigration( + bool reset_send_algorithm); // Called when an ack frame is initially parsed. void OnAckFrameStart(QuicPacketNumber largest_acked, @@ -345,8 +356,8 @@ class QUIC_EXPORT_PRIVATE QuicSentPacketManager { EncryptionLevel decrypted_packet_level) const; void SetNetworkChangeVisitor(NetworkChangeVisitor* visitor) { - DCHECK(!network_change_visitor_); - DCHECK(visitor); + QUICHE_DCHECK(!network_change_visitor_); + QUICHE_DCHECK(visitor); network_change_visitor_ = visitor; } @@ -375,7 +386,7 @@ class QUIC_EXPORT_PRIVATE QuicSentPacketManager { } QuicPacketNumber largest_packet_peer_knows_is_acked() const { - DCHECK(!supports_multiple_packet_number_spaces()); + QUICHE_DCHECK(!supports_multiple_packet_number_spaces()); return largest_packet_peer_knows_is_acked_; } @@ -387,7 +398,7 @@ class QUIC_EXPORT_PRIVATE QuicSentPacketManager { void set_peer_max_ack_delay(QuicTime::Delta peer_max_ack_delay) { // The delayed ack time should never be more than one half the min RTO time. - DCHECK_LE(peer_max_ack_delay, (min_rto_timeout_ * 0.5)); + QUICHE_DCHECK_LE(peer_max_ack_delay, (min_rto_timeout_ * 0.5)); peer_max_ack_delay_ = peer_max_ack_delay; } @@ -456,10 +467,6 @@ class QUIC_EXPORT_PRIVATE QuicSentPacketManager { QuicTime GetEarliestPacketSentTimeForPto( PacketNumberSpace* packet_number_space) const; - bool give_sent_packet_to_debug_visitor_after_sent() const { - return give_sent_packet_to_debug_visitor_after_sent_; - } - private: friend class test::QuicConnectionPeer; friend class test::QuicSentPacketManagerPeer; @@ -555,10 +562,6 @@ class QUIC_EXPORT_PRIVATE QuicSentPacketManager { // timeout. bool ShouldAddMaxAckDelay(PacketNumberSpace space) const; - // Returns true if application data should be used to arm PTO. Only used when - // multiple packet number space is enabled. - bool ShouldArmPtoForApplicationData() const; - // A helper function to return total delay of |num_timeouts| retransmission // timeout with TLP and RTO mode. QuicTime::Delta GetNConsecutiveRetransmissionTimeoutDelay( @@ -722,9 +725,6 @@ class QUIC_EXPORT_PRIVATE QuicSentPacketManager { // True if any 1-RTT packet gets acknowledged. bool one_rtt_packet_acked_; - // True if any 1-RTT packet gets sent. - bool one_rtt_packet_sent_; - // If > 0, arm the 1st PTO with max of earliest in flight sent time + PTO // delay and multiplier * srtt from last in flight packet. float first_pto_srtt_multiplier_; @@ -737,8 +737,13 @@ class QUIC_EXPORT_PRIVATE QuicSentPacketManager { // available. float pto_multiplier_without_rtt_samples_; - const bool give_sent_packet_to_debug_visitor_after_sent_ = - GetQuicReloadableFlag(quic_give_sent_packet_to_debug_visitor_after_sent); + // The number of PTOs needed for path degrading alarm. If equals to 0, the + // traditional path degrading mechanism will be used. + int num_ptos_for_path_degrading_; + + // If true, do not use PING only packets for RTT measurement or congestion + // control. + bool ignore_pings_; }; } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_sent_packet_manager_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_sent_packet_manager_test.cc index 3975809ac09..388a662096e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_sent_packet_manager_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_sent_packet_manager_test.cc @@ -2,22 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_sent_packet_manager.h" +#include "quic/core/quic_sent_packet_manager.h" #include <memory> #include <utility> #include "absl/base/macros.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/frames/quic_ack_frequency_frame.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_sent_packet_manager_peer.h" +#include "quic/test_tools/quic_test_utils.h" using testing::_; using testing::AnyNumber; @@ -337,10 +337,7 @@ class QuicSentPacketManagerTest : public QuicTest { } int GetPtoRttvarMultiplier() { - if (GetQuicReloadableFlag(quic_default_on_pto)) { - return 2; - } - if (GetQuicReloadableFlag(quic_default_to_2_rttvar) && + if (GetQuicReloadableFlag(quic_default_on_pto) || manager_.handshake_mode_disabled()) { return 2; } @@ -2238,14 +2235,21 @@ TEST_F(QuicSentPacketManagerTest, ConnectionMigrationUnspecifiedChange) { EXPECT_EQ(2u, manager_.GetConsecutiveTlpCount()); EXPECT_CALL(*send_algorithm_, OnConnectionMigration()); - manager_.OnConnectionMigration(IPV4_TO_IPV4_CHANGE); + EXPECT_EQ(nullptr, + manager_.OnConnectionMigration(/*reset_send_algorithm=*/false)); EXPECT_EQ(default_init_rtt, rtt_stats->initial_rtt()); EXPECT_EQ(0u, manager_.GetConsecutiveRtoCount()); EXPECT_EQ(0u, manager_.GetConsecutiveTlpCount()); } -TEST_F(QuicSentPacketManagerTest, ConnectionMigrationIPSubnetChange) { +// Tests that ResetCongestionControlUponPeerAddressChange() resets send +// algorithm and RTT. And unACK'ed packets are handled correctly. +TEST_F(QuicSentPacketManagerTest, + ConnectionMigrationUnspecifiedChangeResetSendAlgorithm) { + auto loss_algorithm = std::make_unique<MockLossAlgorithm>(); + QuicSentPacketManagerPeer::SetLossAlgorithm(&manager_, loss_algorithm.get()); + RttStats* rtt_stats = const_cast<RttStats*>(manager_.GetRttStats()); QuicTime::Delta default_init_rtt = rtt_stats->initial_rtt(); rtt_stats->set_initial_rtt(default_init_rtt * 2); @@ -2256,29 +2260,201 @@ TEST_F(QuicSentPacketManagerTest, ConnectionMigrationIPSubnetChange) { QuicSentPacketManagerPeer::SetConsecutiveTlpCount(&manager_, 2); EXPECT_EQ(2u, manager_.GetConsecutiveTlpCount()); - manager_.OnConnectionMigration(IPV4_SUBNET_CHANGE); + SendDataPacket(1, ENCRYPTION_FORWARD_SECURE); - EXPECT_EQ(2 * default_init_rtt, rtt_stats->initial_rtt()); - EXPECT_EQ(1u, manager_.GetConsecutiveRtoCount()); - EXPECT_EQ(2u, manager_.GetConsecutiveTlpCount()); -} + RttStats old_rtt_stats; + old_rtt_stats.CloneFrom(*manager_.GetRttStats()); -TEST_F(QuicSentPacketManagerTest, ConnectionMigrationPortChange) { - RttStats* rtt_stats = const_cast<RttStats*>(manager_.GetRttStats()); - QuicTime::Delta default_init_rtt = rtt_stats->initial_rtt(); - rtt_stats->set_initial_rtt(default_init_rtt * 2); - EXPECT_EQ(2 * default_init_rtt, rtt_stats->initial_rtt()); + // Packet1 will be mark for retransmission upon migration. + EXPECT_CALL(notifier_, OnFrameLost(_)); + std::unique_ptr<SendAlgorithmInterface> old_send_algorithm = + manager_.OnConnectionMigration(/*reset_send_algorithm=*/true); - QuicSentPacketManagerPeer::SetConsecutiveRtoCount(&manager_, 1); - EXPECT_EQ(1u, manager_.GetConsecutiveRtoCount()); - QuicSentPacketManagerPeer::SetConsecutiveTlpCount(&manager_, 2); - EXPECT_EQ(2u, manager_.GetConsecutiveTlpCount()); + EXPECT_NE(old_send_algorithm.get(), manager_.GetSendAlgorithm()); + EXPECT_EQ(old_send_algorithm->GetCongestionControlType(), + manager_.GetSendAlgorithm()->GetCongestionControlType()); + EXPECT_EQ(default_init_rtt, rtt_stats->initial_rtt()); + EXPECT_EQ(0u, manager_.GetConsecutiveRtoCount()); + EXPECT_EQ(0u, manager_.GetConsecutiveTlpCount()); + // Packets sent earlier shouldn't be regarded as in flight. + EXPECT_EQ(0u, BytesInFlight()); - manager_.OnConnectionMigration(PORT_CHANGE); + // Replace the new send algorithm with the mock object. + manager_.SetSendAlgorithm(old_send_algorithm.release()); - EXPECT_EQ(2 * default_init_rtt, rtt_stats->initial_rtt()); - EXPECT_EQ(1u, manager_.GetConsecutiveRtoCount()); - EXPECT_EQ(2u, manager_.GetConsecutiveTlpCount()); + clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(10)); + // Application retransmit the data as LOSS_RETRANSMISSION. + RetransmitDataPacket(2, LOSS_RETRANSMISSION, ENCRYPTION_FORWARD_SECURE); + EXPECT_EQ(kDefaultLength, BytesInFlight()); + + clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(10)); + // Receiving an ACK for packet1 20s later shouldn't update the RTT, and + // shouldn't be treated as spurious retransmission. + EXPECT_CALL(*send_algorithm_, + OnCongestionEvent(/*rtt_updated=*/false, kDefaultLength, _, _, _)) + .WillOnce(testing::WithArg<3>( + Invoke([](const AckedPacketVector& acked_packets) { + EXPECT_EQ(1u, acked_packets.size()); + EXPECT_EQ(QuicPacketNumber(1), acked_packets[0].packet_number); + // The bytes in packet1 shouldn't contribute to congestion control. + EXPECT_EQ(0u, acked_packets[0].bytes_acked); + }))); + EXPECT_CALL(*network_change_visitor_, OnCongestionChange()); + manager_.OnAckFrameStart(QuicPacketNumber(1), QuicTime::Delta::Infinite(), + clock_.Now()); + manager_.OnAckRange(QuicPacketNumber(1), QuicPacketNumber(2)); + EXPECT_CALL(*loss_algorithm, DetectLosses(_, _, _, _, _, _)); + EXPECT_CALL(*loss_algorithm, SpuriousLossDetected(_, _, _, _, _)).Times(0u); + EXPECT_EQ(PACKETS_NEWLY_ACKED, + manager_.OnAckFrameEnd(clock_.Now(), QuicPacketNumber(1), + ENCRYPTION_FORWARD_SECURE)); + EXPECT_TRUE(manager_.GetRttStats()->latest_rtt().IsZero()); + + // Receiving an ACK for packet2 should update RTT and congestion control. + manager_.OnAckFrameStart(QuicPacketNumber(2), QuicTime::Delta::Infinite(), + clock_.Now()); + manager_.OnAckRange(QuicPacketNumber(2), QuicPacketNumber(3)); + EXPECT_CALL(*loss_algorithm, DetectLosses(_, _, _, _, _, _)); + EXPECT_CALL(*send_algorithm_, + OnCongestionEvent(/*rtt_updated=*/true, kDefaultLength, _, _, _)) + .WillOnce(testing::WithArg<3>( + Invoke([](const AckedPacketVector& acked_packets) { + EXPECT_EQ(1u, acked_packets.size()); + EXPECT_EQ(QuicPacketNumber(2), acked_packets[0].packet_number); + // The bytes in packet2 should contribute to congestion control. + EXPECT_EQ(kDefaultLength, acked_packets[0].bytes_acked); + }))); + EXPECT_CALL(*network_change_visitor_, OnCongestionChange()); + EXPECT_EQ(PACKETS_NEWLY_ACKED, + manager_.OnAckFrameEnd(clock_.Now(), QuicPacketNumber(2), + ENCRYPTION_FORWARD_SECURE)); + EXPECT_EQ(0u, BytesInFlight()); + EXPECT_EQ(QuicTime::Delta::FromMilliseconds(10), + manager_.GetRttStats()->latest_rtt()); + + SendDataPacket(3, ENCRYPTION_FORWARD_SECURE); + // Trigger loss timeout and mark packet3 for retransmission. + EXPECT_CALL(*loss_algorithm, GetLossTimeout()) + .WillOnce(Return(clock_.Now() + QuicTime::Delta::FromMilliseconds(10))); + EXPECT_CALL(*loss_algorithm, DetectLosses(_, _, _, _, _, _)) + .WillOnce(WithArgs<5>(Invoke([](LostPacketVector* packet_lost) { + packet_lost->emplace_back(QuicPacketNumber(3u), kDefaultLength); + return LossDetectionInterface::DetectionStats(); + }))); + EXPECT_CALL(notifier_, OnFrameLost(_)); + EXPECT_CALL(*send_algorithm_, + OnCongestionEvent(false, kDefaultLength, _, _, _)); + EXPECT_CALL(*network_change_visitor_, OnCongestionChange()); + manager_.OnRetransmissionTimeout(); + EXPECT_EQ(0u, BytesInFlight()); + + // Migrate again with unACK'ed but not in-flight packet. + // Packet3 shouldn't be marked for retransmission again as it is not in + // flight. + old_send_algorithm = + manager_.OnConnectionMigration(/*reset_send_algorithm=*/true); + + EXPECT_NE(old_send_algorithm.get(), manager_.GetSendAlgorithm()); + EXPECT_EQ(old_send_algorithm->GetCongestionControlType(), + manager_.GetSendAlgorithm()->GetCongestionControlType()); + EXPECT_EQ(default_init_rtt, rtt_stats->initial_rtt()); + EXPECT_EQ(0u, manager_.GetConsecutiveRtoCount()); + EXPECT_EQ(0u, manager_.GetConsecutiveTlpCount()); + EXPECT_EQ(0u, BytesInFlight()); + EXPECT_TRUE(manager_.GetRttStats()->latest_rtt().IsZero()); + + manager_.SetSendAlgorithm(old_send_algorithm.release()); + + clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(30)); + // Receiving an ACK for packet3 shouldn't update RTT. Though packet 3 was + // marked lost, this spurious retransmission shouldn't be reported to the loss + // algorithm. + manager_.OnAckFrameStart(QuicPacketNumber(3), QuicTime::Delta::Infinite(), + clock_.Now()); + manager_.OnAckRange(QuicPacketNumber(3), QuicPacketNumber(4)); + EXPECT_CALL(*loss_algorithm, DetectLosses(_, _, _, _, _, _)); + EXPECT_CALL(*loss_algorithm, SpuriousLossDetected(_, _, _, _, _)).Times(0u); + EXPECT_CALL(*send_algorithm_, + OnCongestionEvent(/*rtt_updated=*/false, 0, _, _, _)); + EXPECT_CALL(*network_change_visitor_, OnCongestionChange()); + EXPECT_EQ(PACKETS_NEWLY_ACKED, + manager_.OnAckFrameEnd(clock_.Now(), QuicPacketNumber(3), + ENCRYPTION_FORWARD_SECURE)); + EXPECT_EQ(0u, BytesInFlight()); + EXPECT_TRUE(manager_.GetRttStats()->latest_rtt().IsZero()); + + SendDataPacket(4, ENCRYPTION_FORWARD_SECURE); + // Trigger loss timeout and mark packet4 for retransmission. + EXPECT_CALL(*loss_algorithm, GetLossTimeout()) + .WillOnce(Return(clock_.Now() + QuicTime::Delta::FromMilliseconds(10))); + EXPECT_CALL(*loss_algorithm, DetectLosses(_, _, _, _, _, _)) + .WillOnce(WithArgs<5>(Invoke([](LostPacketVector* packet_lost) { + packet_lost->emplace_back(QuicPacketNumber(4u), kDefaultLength); + return LossDetectionInterface::DetectionStats(); + }))); + EXPECT_CALL(notifier_, OnFrameLost(_)); + EXPECT_CALL(*send_algorithm_, + OnCongestionEvent(false, kDefaultLength, _, _, _)); + EXPECT_CALL(*network_change_visitor_, OnCongestionChange()); + manager_.OnRetransmissionTimeout(); + EXPECT_EQ(0u, BytesInFlight()); + + // Application retransmit the data as LOSS_RETRANSMISSION. + RetransmitDataPacket(5, LOSS_RETRANSMISSION, ENCRYPTION_FORWARD_SECURE); + EXPECT_EQ(kDefaultLength, BytesInFlight()); + + clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(30)); + // Receiving an ACK for packet4 should update RTT, but not bytes in flight. + // This spurious retransmission should be reported to the loss algorithm. + manager_.OnAckFrameStart(QuicPacketNumber(4), QuicTime::Delta::Infinite(), + clock_.Now()); + manager_.OnAckRange(QuicPacketNumber(4), QuicPacketNumber(5)); + EXPECT_CALL(*loss_algorithm, DetectLosses(_, _, _, _, _, _)); + EXPECT_CALL(*loss_algorithm, SpuriousLossDetected(_, _, _, _, _)); + EXPECT_CALL(*send_algorithm_, + OnCongestionEvent(/*rtt_updated=*/true, kDefaultLength, _, _, _)); + EXPECT_CALL(*network_change_visitor_, OnCongestionChange()); + EXPECT_CALL(notifier_, OnFrameAcked(_, _, _)); + EXPECT_EQ(PACKETS_NEWLY_ACKED, + manager_.OnAckFrameEnd(clock_.Now(), QuicPacketNumber(3), + ENCRYPTION_FORWARD_SECURE)); + EXPECT_EQ(kDefaultLength, BytesInFlight()); + EXPECT_EQ(QuicTime::Delta::FromMilliseconds(30), + manager_.GetRttStats()->latest_rtt()); + + // Migrate again with in-flight packet5 whose retransmittable frames are all + // ACKed. Packet5 should be marked for retransmission but nothing to + // retransmit. + EXPECT_CALL(notifier_, IsFrameOutstanding(_)).WillOnce(Return(false)); + EXPECT_CALL(notifier_, OnFrameLost(_)).Times(0u); + old_send_algorithm = + manager_.OnConnectionMigration(/*reset_send_algorithm=*/true); + EXPECT_EQ(default_init_rtt, rtt_stats->initial_rtt()); + EXPECT_EQ(0u, manager_.GetConsecutiveRtoCount()); + EXPECT_EQ(0u, manager_.GetConsecutiveTlpCount()); + EXPECT_EQ(0u, BytesInFlight()); + EXPECT_TRUE(manager_.GetRttStats()->latest_rtt().IsZero()); + + manager_.SetSendAlgorithm(old_send_algorithm.release()); + + clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(10)); + // Receiving an ACK for packet5 shouldn't update RTT. Though packet 5 was + // marked for retransmission, this spurious retransmission shouldn't be + // reported to the loss algorithm. + manager_.OnAckFrameStart(QuicPacketNumber(5), QuicTime::Delta::Infinite(), + clock_.Now()); + manager_.OnAckRange(QuicPacketNumber(5), QuicPacketNumber(6)); + EXPECT_CALL(*loss_algorithm, DetectLosses(_, _, _, _, _, _)); + EXPECT_CALL(*loss_algorithm, SpuriousLossDetected(_, _, _, _, _)).Times(0u); + EXPECT_CALL(*send_algorithm_, + OnCongestionEvent(/*rtt_updated=*/false, 0, _, _, _)); + EXPECT_CALL(*network_change_visitor_, OnCongestionChange()); + EXPECT_CALL(notifier_, OnFrameAcked(_, _, _)); + EXPECT_EQ(PACKETS_NEWLY_ACKED, + manager_.OnAckFrameEnd(clock_.Now(), QuicPacketNumber(3), + ENCRYPTION_FORWARD_SECURE)); + EXPECT_EQ(0u, BytesInFlight()); + EXPECT_TRUE(manager_.GetRttStats()->latest_rtt().IsZero()); } TEST_F(QuicSentPacketManagerTest, PathMtuIncreased) { @@ -3321,7 +3497,6 @@ TEST_F(QuicSentPacketManagerTest, ClientMultiplePacketNumberSpacePtoTimeout) { // Send packet 6 in 1-RTT. clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(10)); SendDataPacket(6, ENCRYPTION_FORWARD_SECURE); - const QuicTime packet6_sent_time = clock_.Now(); // Verify PTO timeout is now based on packet 5. EXPECT_EQ(packet5_sent_time + expected_pto_delay * 2, manager_.GetRetransmissionTime()); @@ -3331,21 +3506,11 @@ TEST_F(QuicSentPacketManagerTest, ClientMultiplePacketNumberSpacePtoTimeout) { const QuicTime packet7_sent_time = clock_.Now(); SendDataPacket(7, ENCRYPTION_HANDSHAKE); - if (GetQuicReloadableFlag(quic_fix_arm_pto_for_application_data)) { - expected_pto_delay = - srtt + GetPtoRttvarMultiplier() * rtt_stats->mean_deviation(); - // Verify PTO timeout is now based on packet 7. - EXPECT_EQ(packet7_sent_time + expected_pto_delay * 2, - manager_.GetRetransmissionTime()); - - } else { - expected_pto_delay = - srtt + GetPtoRttvarMultiplier() * rtt_stats->mean_deviation() + - QuicTime::Delta::FromMilliseconds(kDefaultDelayedAckTimeMs); - // Verify PTO timeout is now based on packet 6. - EXPECT_EQ(packet6_sent_time + expected_pto_delay * 2, - manager_.GetRetransmissionTime()); - } + expected_pto_delay = + srtt + GetPtoRttvarMultiplier() * rtt_stats->mean_deviation(); + // Verify PTO timeout is now based on packet 7. + EXPECT_EQ(packet7_sent_time + expected_pto_delay * 2, + manager_.GetRetransmissionTime()); // Neuter handshake key. manager_.SetHandshakeConfirmed(); @@ -3806,6 +3971,14 @@ TEST_F(QuicSentPacketManagerTest, NeuterUnencryptedPackets) { manager_.NeuterUnencryptedPackets(); } +TEST_F(QuicSentPacketManagerTest, MarkInitialPacketsForRetransmission) { + SendCryptoPacket(1); + SendPingPacket(2, ENCRYPTION_HANDSHAKE); + // Only the INITIAL packet will be retransmitted. + EXPECT_CALL(notifier_, OnFrameLost(_)).Times(1); + manager_.MarkInitialPacketsForRetransmission(); +} + TEST_F(QuicSentPacketManagerTest, NoPacketThresholdDetectionForRuntPackets) { EXPECT_TRUE( QuicSentPacketManagerPeer::UsePacketThresholdForRuntPackets(&manager_)); @@ -3865,6 +4038,72 @@ TEST_F(QuicSentPacketManagerTest, GetPathDegradingDelay) { EXPECT_EQ(expected_delay, manager_.GetPathDegradingDelay()); } +TEST_F(QuicSentPacketManagerTest, GetPathDegradingDelayUsingPTO) { + QuicConfig client_config; + QuicTagVector options; + options.push_back(k1PTO); + QuicTagVector client_options; + client_options.push_back(kPDP2); + QuicSentPacketManagerPeer::SetPerspective(&manager_, Perspective::IS_CLIENT); + client_config.SetConnectionOptionsToSend(options); + client_config.SetClientConnectionOptions(client_options); + EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); + EXPECT_CALL(*network_change_visitor_, OnCongestionChange()); + manager_.SetFromConfig(client_config); + EXPECT_TRUE(manager_.pto_enabled()); + QuicTime::Delta expected_delay = 2 * manager_.GetPtoDelay(); + EXPECT_EQ(expected_delay, manager_.GetPathDegradingDelay()); +} + +TEST_F(QuicSentPacketManagerTest, ClientsIgnorePings) { + QuicSentPacketManagerPeer::SetPerspective(&manager_, Perspective::IS_CLIENT); + QuicConfig client_config; + QuicTagVector options; + QuicTagVector client_options; + client_options.push_back(kIGNP); + client_config.SetConnectionOptionsToSend(options); + client_config.SetClientConnectionOptions(client_options); + EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); + EXPECT_CALL(*network_change_visitor_, OnCongestionChange()); + manager_.SetFromConfig(client_config); + + EXPECT_CALL(*send_algorithm_, PacingRate(_)) + .WillRepeatedly(Return(QuicBandwidth::Zero())); + EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) + .WillRepeatedly(Return(10 * kDefaultTCPMSS)); + EXPECT_CALL(*send_algorithm_, CanSend(_)).WillRepeatedly(Return(true)); + + SendPingPacket(1, ENCRYPTION_INITIAL); + // Verify PING only packet is not considered in flight. + EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime()); + SendDataPacket(2, ENCRYPTION_INITIAL); + EXPECT_NE(QuicTime::Zero(), manager_.GetRetransmissionTime()); + + uint64_t acked[] = {1}; + ExpectAcksAndLosses(/*rtt_updated=*/false, acked, ABSL_ARRAYSIZE(acked), + nullptr, 0); + clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(90)); + manager_.OnAckFrameStart(QuicPacketNumber(1), QuicTime::Delta::Infinite(), + clock_.Now()); + manager_.OnAckRange(QuicPacketNumber(1), QuicPacketNumber(2)); + EXPECT_EQ(PACKETS_NEWLY_ACKED, + manager_.OnAckFrameEnd(clock_.Now(), QuicPacketNumber(1), + ENCRYPTION_INITIAL)); + RttStats* rtt_stats = const_cast<RttStats*>(manager_.GetRttStats()); + // Verify no RTT samples for PING only packet. + EXPECT_TRUE(rtt_stats->smoothed_rtt().IsZero()); + + ExpectAck(2); + clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(10)); + manager_.OnAckFrameStart(QuicPacketNumber(2), QuicTime::Delta::Infinite(), + clock_.Now()); + manager_.OnAckRange(QuicPacketNumber(1), QuicPacketNumber(3)); + EXPECT_EQ(PACKETS_NEWLY_ACKED, + manager_.OnAckFrameEnd(clock_.Now(), QuicPacketNumber(2), + ENCRYPTION_INITIAL)); + EXPECT_EQ(QuicTime::Delta::FromMilliseconds(100), rtt_stats->smoothed_rtt()); +} + // Regression test for b/154050235. TEST_F(QuicSentPacketManagerTest, ExponentialBackoffWithNoRttMeasurement) { QuicSentPacketManagerPeer::SetPerspective(&manager_, Perspective::IS_CLIENT); @@ -4393,8 +4632,6 @@ TEST_F(QuicSentPacketManagerTest, } TEST_F(QuicSentPacketManagerTest, ClearDataInMessageFrameAfterPacketSent) { - SetQuicReloadableFlag(quic_deallocate_message_right_after_sent, true); - EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); QuicMessageFrame* message_frame = nullptr; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_server_id.cc b/chromium/net/third_party/quiche/src/quic/core/quic_server_id.cc index 653152df84b..1d2a2adb8c9 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_server_id.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_server_id.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" +#include "quic/core/quic_server_id.h" #include <string> #include <tuple> -#include "net/third_party/quiche/src/quic/platform/api/quic_estimate_memory_usage.h" +#include "quic/platform/api/quic_estimate_memory_usage.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_server_id.h b/chromium/net/third_party/quiche/src/quic/core/quic_server_id.h index 7adeb86b817..01320014585 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_server_id.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_server_id.h @@ -8,7 +8,7 @@ #include <cstdint> #include <string> -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_server_id_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_server_id_test.cc index cb519b85d17..67231abf866 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_server_id_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_server_id_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" +#include "quic/core/quic_server_id.h" #include <string> -#include "net/third_party/quiche/src/quic/platform/api/quic_estimate_memory_usage.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_estimate_memory_usage.h" +#include "quic/platform/api/quic_test.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_session.cc b/chromium/net/third_party/quiche/src/quic/core/quic_session.cc index 6b4c5170f12..8cd0a57a366 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_session.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_session.cc @@ -2,29 +2,29 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_session.h" +#include "quic/core/quic_session.h" #include <cstdint> #include <string> #include <utility> +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_flow_controller.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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_map_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_server_stats.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_stack_trace.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "quic/core/frames/quic_ack_frequency_frame.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_flow_controller.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_map_util.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/platform/api/quic_server_stats.h" +#include "quic/platform/api/quic_stack_trace.h" using spdy::SpdyPriority; @@ -57,6 +57,20 @@ QuicSession::QuicSession( const QuicConfig& config, const ParsedQuicVersionVector& supported_versions, QuicStreamCount num_expected_unidirectional_static_streams) + : QuicSession(connection, + owner, + config, + supported_versions, + num_expected_unidirectional_static_streams, + nullptr) {} + +QuicSession::QuicSession( + QuicConnection* connection, + Visitor* owner, + const QuicConfig& config, + const ParsedQuicVersionVector& supported_versions, + QuicStreamCount num_expected_unidirectional_static_streams, + std::unique_ptr<QuicDatagramQueue::Observer> datagram_observer) : connection_(connection), perspective_(connection->perspective()), visitor_(owner), @@ -94,12 +108,10 @@ QuicSession::QuicSession( transport_goaway_received_(false), control_frame_manager_(this), last_message_id_(0), - datagram_queue_(this), + datagram_queue_(this, std::move(datagram_observer)), closed_streams_clean_up_alarm_(nullptr), supported_versions_(supported_versions), - use_http2_priority_write_scheduler_(false), is_configured_(false), - enable_round_robin_scheduling_(false), was_zero_rtt_rejected_(false), liveness_testing_in_progress_(false) { closed_streams_clean_up_alarm_ = @@ -120,6 +132,7 @@ void QuicSession::Initialize() { connection_->set_visitor(this); connection_->SetSessionNotifier(this); connection_->SetDataProducer(this); + connection_->SetUnackedMapInitialCapacity(); connection_->SetFromConfig(config_); if (perspective_ == Perspective::IS_CLIENT && config_.HasClientRequestedIndependentOption(kAFFE, perspective_) && @@ -127,10 +140,6 @@ void QuicSession::Initialize() { connection_->set_can_receive_ack_frequency_frame(); config_.SetMinAckDelayMs(kDefaultMinAckDelayTimeMs); } - if (perspective() == Perspective::IS_CLIENT && version().UsesTls() && - !version().HasHandshakeDone()) { - config_.SetSupportHandshakeDone(); - } // On the server side, version negotiation has been done by the dispatcher, // and the server session is created with the right version. @@ -138,8 +147,7 @@ void QuicSession::Initialize() { connection_->OnSuccessfulVersionNegotiation(); } - if (GetQuicReloadableFlag(quic_key_update_supported) && - GetMutableCryptoStream()->KeyUpdateSupportedLocally()) { + if (GetMutableCryptoStream()->KeyUpdateSupportedLocally()) { config_.SetKeyUpdateSupportedLocally(); } @@ -147,14 +155,14 @@ void QuicSession::Initialize() { return; } - DCHECK_EQ(QuicUtils::GetCryptoStreamId(transport_version()), - GetMutableCryptoStream()->id()); + QUICHE_DCHECK_EQ(QuicUtils::GetCryptoStreamId(transport_version()), + GetMutableCryptoStream()->id()); } QuicSession::~QuicSession() {} void QuicSession::PendingStreamOnStreamFrame(const QuicStreamFrame& frame) { - DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); QuicStreamId stream_id = frame.stream_id; PendingStream* pending = GetOrCreatePendingStream(stream_id); @@ -173,7 +181,7 @@ void QuicSession::PendingStreamOnStreamFrame(const QuicStreamFrame& frame) { } if (ProcessPendingStream(pending)) { // The pending stream should now be in the scope of normal streams. - DCHECK(IsClosedStream(stream_id) || IsOpenStream(stream_id)) + QUICHE_DCHECK(IsClosedStream(stream_id) || IsOpenStream(stream_id)) << "Stream " << stream_id << " not created"; pending_stream_map_.erase(stream_id); return; @@ -222,13 +230,13 @@ void QuicSession::OnCryptoFrame(const QuicCryptoFrame& frame) { void QuicSession::OnStopSendingFrame(const QuicStopSendingFrame& frame) { // STOP_SENDING is in IETF QUIC only. - DCHECK(VersionHasIetfQuicFrames(transport_version())); - DCHECK(QuicVersionUsesCryptoFrames(transport_version())); + QUICHE_DCHECK(VersionHasIetfQuicFrames(transport_version())); + QUICHE_DCHECK(QuicVersionUsesCryptoFrames(transport_version())); QuicStreamId stream_id = frame.stream_id; // If Stream ID is invalid then close the connection. // TODO(ianswett): This check is redundant to checks for IsClosedStream, - // but removing it requires removing multiple DCHECKs. + // but removing it requires removing multiple QUICHE_DCHECKs. // TODO(ianswett): Multiple QUIC_DVLOGs could be QUIC_PEER_BUGs. if (stream_id == QuicUtils::GetInvalidStreamId(transport_version())) { QUIC_DVLOG(1) << ENDPOINT @@ -292,7 +300,7 @@ std::unique_ptr<QuicEncrypter> QuicSession::CreateCurrentOneRttEncrypter() { } void QuicSession::PendingStreamOnRstStream(const QuicRstStreamFrame& frame) { - DCHECK(VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(VersionUsesHttp3(transport_version())); QuicStreamId stream_id = frame.stream_id; PendingStream* pending = GetOrCreatePendingStream(stream_id); @@ -304,9 +312,10 @@ void QuicSession::PendingStreamOnRstStream(const QuicRstStreamFrame& frame) { pending->OnRstStreamFrame(frame); // Pending stream is currently read only. We can safely close the stream. - DCHECK_EQ(READ_UNIDIRECTIONAL, - QuicUtils::GetStreamType(pending->id(), perspective(), - /*peer_initiated = */ true, version())); + QUICHE_DCHECK_EQ( + READ_UNIDIRECTIONAL, + QuicUtils::GetStreamType(pending->id(), perspective(), + /*peer_initiated = */ true, version())); ClosePendingStream(stream_id); } @@ -368,6 +377,11 @@ void QuicSession::OnHandshakeDoneReceived() { GetMutableCryptoStream()->OnHandshakeDoneReceived(); } +void QuicSession::OnNewTokenReceived(absl::string_view token) { + QUICHE_DCHECK_EQ(perspective_, Perspective::IS_CLIENT); + GetMutableCryptoStream()->OnNewTokenReceived(token); +} + // static void QuicSession::RecordConnectionCloseAtServer(QuicErrorCode error, ConnectionCloseSource source) { @@ -386,7 +400,7 @@ void QuicSession::RecordConnectionCloseAtServer(QuicErrorCode error, void QuicSession::OnConnectionClosed(const QuicConnectionCloseFrame& frame, ConnectionCloseSource source) { - DCHECK(!connection_->connected()); + QUICHE_DCHECK(!connection_->connected()); if (perspective() == Perspective::IS_SERVER) { RecordConnectionCloseAtServer(frame.quic_error_code, source); } @@ -598,9 +612,7 @@ void QuicSession::OnCanWrite() { << ", finished_writes: " << i << ", connected: " << connection_->connected() << ", connection level flow control blocked: " - << flow_controller_.IsBlocked() << ", scheduler type: " - << spdy::WriteSchedulerTypeToString( - write_blocked_streams_.scheduler_type()); + << flow_controller_.IsBlocked(); for (QuicStreamId id : last_writing_stream_ids) { QUIC_LOG(WARNING) << "last_writing_stream_id: " << id; } @@ -626,9 +638,9 @@ void QuicSession::OnCanWrite() { << " bytes_written " << previous_bytes_written << " fin " << previous_fin_sent; stream->OnCanWrite(); - DCHECK(CheckStreamWriteBlocked(stream)); - DCHECK(CheckStreamNotBusyLooping(stream, previous_bytes_written, - previous_fin_sent)); + QUICHE_DCHECK(CheckStreamWriteBlocked(stream)); + QUICHE_DCHECK(CheckStreamNotBusyLooping(stream, previous_bytes_written, + previous_fin_sent)); } currently_writing_stream_id_ = 0; } @@ -677,7 +689,7 @@ bool QuicSession::WillingAndAbleToWrite() const { } std::string QuicSession::GetStreamsInfoForLogging() const { - std::string info = quiche::QuicheStrCat( + std::string info = absl::StrCat( "num_active_streams: ", GetNumActiveStreams(), ", num_pending_streams: ", pending_streams_size(), ", num_outgoing_draining_streams: ", num_outgoing_draining_streams(), @@ -691,8 +703,8 @@ std::string QuicSession::GetStreamsInfoForLogging() const { // Calculate the stream creation delay. const QuicTime::Delta delay = connection_->clock()->ApproximateNow() - it.second->creation_time(); - info = quiche::QuicheStrCat( - info, "{", it.second->id(), ":", delay.ToDebuggingValue(), ";", + absl::StrAppend( + &info, "{", it.second->id(), ":", delay.ToDebuggingValue(), ";", it.second->stream_bytes_written(), ",", it.second->fin_sent(), ",", it.second->HasBufferedData(), ",", it.second->fin_buffered(), ";", it.second->stream_bytes_read(), ",", it.second->fin_received(), "}"); @@ -728,15 +740,16 @@ QuicConsumedData QuicSession::WritevData( StreamSendingState state, TransmissionType type, absl::optional<EncryptionLevel> level) { - DCHECK(connection_->connected()) + QUICHE_DCHECK(connection_->connected()) << ENDPOINT << "Try to write stream data when connection is closed."; - DCHECK(!use_write_or_buffer_data_at_level_ || level.has_value()); + QUICHE_DCHECK(!use_write_or_buffer_data_at_level_ || level.has_value()); if (!IsEncryptionEstablished() && !QuicUtils::IsCryptoStreamId(transport_version(), id)) { // Do not let streams write without encryption. The calling stream will end // up write blocked until OnCanWrite is next called. if (was_zero_rtt_rejected_ && !OneRttKeysAvailable()) { - DCHECK(version().UsesTls() && perspective() == Perspective::IS_CLIENT); + QUICHE_DCHECK(version().UsesTls() && + perspective() == Perspective::IS_CLIENT); QUIC_BUG_IF(type == NOT_RETRANSMISSION) << ENDPOINT << "Try to send new data on stream " << id << "before 1-RTT keys are available while 0-RTT is rejected."; @@ -780,10 +793,9 @@ size_t QuicSession::SendCryptoData(EncryptionLevel level, size_t write_length, QuicStreamOffset offset, TransmissionType type) { - DCHECK(QuicVersionUsesCryptoFrames(transport_version())); - if (connection()->check_keys_before_writing() && - !connection()->framer().HasEncrypterOfEncryptionLevel(level)) { - const std::string error_details = quiche::QuicheStrCat( + QUICHE_DCHECK(QuicVersionUsesCryptoFrames(transport_version())); + if (!connection()->framer().HasEncrypterOfEncryptionLevel(level)) { + const std::string error_details = absl::StrCat( "Try to send crypto data with missing keys of encryption level: ", EncryptionLevelToString(level)); QUIC_BUG << ENDPOINT << error_details; @@ -817,7 +829,7 @@ void QuicSession::OnControlFrameManagerError(QuicErrorCode error_code, bool QuicSession::WriteControlFrame(const QuicFrame& frame, TransmissionType type) { - DCHECK(connection()->connected()) + QUICHE_DCHECK(connection()->connected()) << ENDPOINT << "Try to write control frames when connection is closed."; if (connection_->encrypted_control_frames()) { QUIC_RELOADABLE_FLAG_COUNT(quic_encrypted_control_frames); @@ -835,32 +847,6 @@ bool QuicSession::WriteControlFrame(const QuicFrame& frame, return connection_->SendControlFrame(frame); } -void QuicSession::SendRstStream(QuicStreamId id, - QuicRstStreamErrorCode error, - QuicStreamOffset bytes_written, - bool send_rst_only) { - DCHECK(!split_up_send_rst()); - if (!connection()->connected()) { - return; - } - - QuicConnection::ScopedPacketFlusher flusher(connection()); - if (!VersionHasIetfQuicFrames(transport_version()) || - QuicUtils::GetStreamType(id, perspective(), IsIncomingStream(id), - version()) != READ_UNIDIRECTIONAL) { - control_frame_manager_.WriteOrBufferRstStream(id, error, bytes_written); - } - if (!send_rst_only) { - if (VersionHasIetfQuicFrames(transport_version()) && - QuicUtils::GetStreamType(id, perspective(), IsIncomingStream(id), - version()) != WRITE_UNIDIRECTIONAL) { - control_frame_manager_.WriteOrBufferStopSending(error, id); - } - } - - connection_->OnStreamReset(id, error); -} - void QuicSession::ResetStream(QuicStreamId id, QuicRstStreamErrorCode error) { QuicStream* stream = GetStream(id); if (stream != nullptr && stream->is_static()) { @@ -875,19 +861,14 @@ void QuicSession::ResetStream(QuicStreamId id, QuicRstStreamErrorCode error) { return; } - if (split_up_send_rst()) { - QuicConnection::ScopedPacketFlusher flusher(connection()); - MaybeSendStopSendingFrame(id, error); - MaybeSendRstStreamFrame(id, error, 0); - } else { - SendRstStream(id, error, 0, /*send_rst_only = */ false); - } + QuicConnection::ScopedPacketFlusher flusher(connection()); + MaybeSendStopSendingFrame(id, error); + MaybeSendRstStreamFrame(id, error, 0); } void QuicSession::MaybeSendRstStreamFrame(QuicStreamId id, QuicRstStreamErrorCode error, QuicStreamOffset bytes_written) { - DCHECK(split_up_send_rst()); if (!connection()->connected()) { return; } @@ -902,7 +883,6 @@ void QuicSession::MaybeSendRstStreamFrame(QuicStreamId id, void QuicSession::MaybeSendStopSendingFrame(QuicStreamId id, QuicRstStreamErrorCode error) { - DCHECK(split_up_send_rst()); if (!connection()->connected()) { return; } @@ -916,13 +896,23 @@ void QuicSession::MaybeSendStopSendingFrame(QuicStreamId id, void QuicSession::SendGoAway(QuicErrorCode error_code, const std::string& reason) { // GOAWAY frame is not supported in IETF QUIC. - DCHECK(!VersionHasIetfQuicFrames(transport_version())); + QUICHE_DCHECK(!VersionHasIetfQuicFrames(transport_version())); + if (GetQuicReloadableFlag(quic_encrypted_goaway)) { + QUIC_RELOADABLE_FLAG_COUNT_N(quic_encrypted_goaway, 1, 2); + if (!IsEncryptionEstablished()) { + QUIC_CODE_COUNT(quic_goaway_before_encryption_established); + connection_->CloseConnection( + error_code, reason, + ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); + return; + } + } if (transport_goaway_sent_) { return; } transport_goaway_sent_ = true; if (GetQuicReloadableFlag(quic_goaway_with_max_stream_id)) { - DCHECK_EQ(perspective(), Perspective::IS_SERVER); + QUICHE_DCHECK_EQ(perspective(), Perspective::IS_SERVER); QUIC_RELOADABLE_FLAG_COUNT_N(quic_goaway_with_max_stream_id, 2, 2); control_frame_manager_.WriteOrBufferGoAway( error_code, @@ -952,6 +942,14 @@ void QuicSession::OnStreamError(QuicErrorCode error_code, ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); } +void QuicSession::OnStreamError(QuicErrorCode error_code, + QuicIetfTransportErrorCodes ietf_error, + std::string error_details) { + connection_->CloseConnection( + error_code, ietf_error, error_details, + ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); +} + void QuicSession::SendMaxStreams(QuicStreamCount stream_count, bool unidirectional) { if (!is_configured_) { @@ -998,7 +996,7 @@ void QuicSession::OnStreamClosed(QuicStreamId stream_id) { // received, for accurate connection level flow control accounting. // If this is an outgoing stream, it is technically open from peer's // perspective. Do not inform stream Id manager yet. - DCHECK(!stream->was_draining()); + QUICHE_DCHECK(!stream->was_draining()); InsertLocallyClosedStreamsHighestOffset( stream_id, stream->highest_received_byte_offset()); return; @@ -1038,7 +1036,7 @@ void QuicSession::OnStreamClosed(QuicStreamId stream_id) { void QuicSession::ClosePendingStream(QuicStreamId stream_id) { QUIC_DVLOG(1) << ENDPOINT << "Closing stream " << stream_id; - DCHECK(VersionHasIetfQuicFrames(transport_version())); + QUICHE_DCHECK(VersionHasIetfQuicFrames(transport_version())); pending_stream_map_.erase(stream_id); if (connection_->connected()) { ietf_streamid_manager_.OnStreamClosed(stream_id); @@ -1126,7 +1124,7 @@ void QuicSession::OnConfigNegotiated() { ietf_streamid_manager_.outgoing_bidirectional_stream_count()) { connection_->CloseConnection( QUIC_ZERO_RTT_UNRETRANSMITTABLE, - quiche::QuicheStrCat( + absl::StrCat( "Server rejected 0-RTT, aborting because new bidirectional " "initial stream limit ", max_streams, " is less than current open streams: ", @@ -1143,7 +1141,7 @@ void QuicSession::OnConfigNegotiated() { connection_->CloseConnection( was_zero_rtt_rejected_ ? QUIC_ZERO_RTT_REJECTION_LIMIT_REDUCED : QUIC_ZERO_RTT_RESUMPTION_LIMIT_REDUCED, - quiche::QuicheStrCat( + absl::StrCat( was_zero_rtt_rejected_ ? "Server rejected 0-RTT, aborting because " : "", @@ -1168,7 +1166,7 @@ void QuicSession::OnConfigNegotiated() { ietf_streamid_manager_.outgoing_unidirectional_stream_count()) { connection_->CloseConnection( QUIC_ZERO_RTT_UNRETRANSMITTABLE, - quiche::QuicheStrCat( + absl::StrCat( "Server rejected 0-RTT, aborting because new unidirectional " "initial stream limit ", max_streams, " is less than current open streams: ", @@ -1182,7 +1180,7 @@ void QuicSession::OnConfigNegotiated() { connection_->CloseConnection( was_zero_rtt_rejected_ ? QUIC_ZERO_RTT_REJECTION_LIMIT_REDUCED : QUIC_ZERO_RTT_RESUMPTION_LIMIT_REDUCED, - quiche::QuicheStrCat( + absl::StrCat( was_zero_rtt_rejected_ ? "Server rejected 0-RTT, aborting because " : "", @@ -1210,7 +1208,7 @@ void QuicSession::OnConfigNegotiated() { max_streams < stream_id_manager_.num_open_outgoing_streams()) { connection_->CloseConnection( QUIC_INTERNAL_ERROR, - quiche::QuicheStrCat( + absl::StrCat( "Server rejected 0-RTT, aborting because new stream limit ", max_streams, " is less than current open streams: ", stream_id_manager_.num_open_outgoing_streams()), @@ -1239,25 +1237,6 @@ void QuicSession::OnConfigNegotiated() { if (ContainsQuicTag(config_.ReceivedConnectionOptions(), kIFWA)) { AdjustInitialFlowControlWindows(1024 * 1024); } - if (ContainsQuicTag(config_.ReceivedConnectionOptions(), kH2PR) && - !VersionHasIetfQuicFrames(transport_version())) { - // Enable HTTP2 (tree-style) priority write scheduler. - use_http2_priority_write_scheduler_ = - write_blocked_streams_.SwitchWriteScheduler( - spdy::WriteSchedulerType::HTTP2, transport_version()); - } else if (ContainsQuicTag(config_.ReceivedConnectionOptions(), kFIFO)) { - // Enable FIFO write scheduler. - write_blocked_streams_.SwitchWriteScheduler( - spdy::WriteSchedulerType::FIFO, transport_version()); - } else if (ContainsQuicTag(config_.ReceivedConnectionOptions(), kLIFO)) { - // Enable LIFO write scheduler. - write_blocked_streams_.SwitchWriteScheduler( - spdy::WriteSchedulerType::LIFO, transport_version()); - } else if (ContainsQuicTag(config_.ReceivedConnectionOptions(), kRRWS) && - write_blocked_streams_.scheduler_type() == - spdy::WriteSchedulerType::SPDY) { - enable_round_robin_scheduling_ = true; - } } config_.SetStatelessResetTokenToSend(GetStatelessResetToken()); @@ -1325,6 +1304,12 @@ void QuicSession::OnConfigNegotiated() { } } +absl::optional<std::string> QuicSession::OnAlpsData( + const uint8_t* /*alps_data*/, + size_t /*alps_length*/) { + return absl::nullopt; +} + void QuicSession::AdjustInitialFlowControlWindows(size_t stream_window) { const float session_window_multiplier = config_.GetInitialStreamFlowControlWindowToSend() @@ -1352,7 +1337,7 @@ void QuicSession::AdjustInitialFlowControlWindows(size_t stream_window) { void QuicSession::HandleFrameOnNonexistentOutgoingStream( QuicStreamId stream_id) { - DCHECK(!IsClosedStream(stream_id)); + QUICHE_DCHECK(!IsClosedStream(stream_id)); // Received a frame for a locally-created stream that is not currently // active. This is an error. if (VersionHasIetfQuicFrames(transport_version())) { @@ -1379,7 +1364,7 @@ void QuicSession::HandleRstOnValidNonexistentStream( } void QuicSession::OnNewStreamFlowControlWindow(QuicStreamOffset new_window) { - DCHECK(version().UsesQuicCrypto()); + QUICHE_DCHECK(version().UsesQuicCrypto()); QUIC_DVLOG(1) << ENDPOINT << "OnNewStreamFlowControlWindow " << new_window; if (new_window < kMinimumFlowControlSendWindow) { QUIC_LOG_FIRST_N(ERROR, 1) @@ -1412,7 +1397,7 @@ void QuicSession::OnNewStreamFlowControlWindow(QuicStreamOffset new_window) { void QuicSession::OnNewStreamUnidirectionalFlowControlWindow( QuicStreamOffset new_window) { - DCHECK_EQ(connection_->version().handshake_protocol, PROTOCOL_TLS1_3); + QUICHE_DCHECK_EQ(connection_->version().handshake_protocol, PROTOCOL_TLS1_3); QUIC_DVLOG(1) << ENDPOINT << "OnNewStreamUnidirectionalFlowControlWindow " << new_window; // Inform all existing outgoing unidirectional streams about the new window. @@ -1442,7 +1427,7 @@ void QuicSession::OnNewStreamUnidirectionalFlowControlWindow( void QuicSession::OnNewStreamOutgoingBidirectionalFlowControlWindow( QuicStreamOffset new_window) { - DCHECK_EQ(connection_->version().handshake_protocol, PROTOCOL_TLS1_3); + QUICHE_DCHECK_EQ(connection_->version().handshake_protocol, PROTOCOL_TLS1_3); QUIC_DVLOG(1) << ENDPOINT << "OnNewStreamOutgoingBidirectionalFlowControlWindow " << new_window; @@ -1473,7 +1458,7 @@ void QuicSession::OnNewStreamOutgoingBidirectionalFlowControlWindow( void QuicSession::OnNewStreamIncomingBidirectionalFlowControlWindow( QuicStreamOffset new_window) { - DCHECK_EQ(connection_->version().handshake_protocol, PROTOCOL_TLS1_3); + QUICHE_DCHECK_EQ(connection_->version().handshake_protocol, PROTOCOL_TLS1_3); QUIC_DVLOG(1) << ENDPOINT << "OnNewStreamIncomingBidirectionalFlowControlWindow " << new_window; @@ -1506,7 +1491,7 @@ void QuicSession::OnNewSessionFlowControlWindow(QuicStreamOffset new_window) { QUIC_DVLOG(1) << ENDPOINT << "OnNewSessionFlowControlWindow " << new_window; if (was_zero_rtt_rejected_ && new_window < flow_controller_.bytes_sent()) { - std::string error_details = quiche::QuicheStrCat( + std::string error_details = absl::StrCat( "Server rejected 0-RTT. Aborting because the client received session " "flow control send window: ", new_window, @@ -1519,7 +1504,7 @@ void QuicSession::OnNewSessionFlowControlWindow(QuicStreamOffset new_window) { } if (!connection_->version().AllowsLowFlowControlLimits() && new_window < kMinimumFlowControlSendWindow) { - std::string error_details = quiche::QuicheStrCat( + std::string error_details = absl::StrCat( "Peer sent us an invalid session flow control send window: ", new_window, ", below minimum: ", kMinimumFlowControlSendWindow); QUIC_LOG_FIRST_N(ERROR, 1) << error_details; @@ -1532,7 +1517,7 @@ void QuicSession::OnNewSessionFlowControlWindow(QuicStreamOffset new_window) { new_window < flow_controller_.send_window_offset()) { // The client receives a lower limit than remembered, violating // https://tools.ietf.org/html/draft-ietf-quic-transport-27#section-7.3.1 - std::string error_details = quiche::QuicheStrCat( + std::string error_details = absl::StrCat( was_zero_rtt_rejected_ ? "Server rejected 0-RTT, aborting because " : "", "new session max data ", new_window, @@ -1604,7 +1589,8 @@ void QuicSession::OnNewEncryptionKeyAvailable( } void QuicSession::SetDefaultEncryptionLevel(EncryptionLevel level) { - DCHECK_EQ(PROTOCOL_QUIC_CRYPTO, connection_->version().handshake_protocol); + QUICHE_DCHECK_EQ(PROTOCOL_QUIC_CRYPTO, + connection_->version().handshake_protocol); QUIC_DVLOG(1) << ENDPOINT << "Set default encryption level to " << level; connection()->SetDefaultEncryptionLevel(level); @@ -1634,20 +1620,42 @@ void QuicSession::SetDefaultEncryptionLevel(EncryptionLevel level) { } void QuicSession::OnTlsHandshakeComplete() { - DCHECK_EQ(PROTOCOL_TLS1_3, connection_->version().handshake_protocol); + QUICHE_DCHECK_EQ(PROTOCOL_TLS1_3, connection_->version().handshake_protocol); QUIC_BUG_IF(!GetCryptoStream()->crypto_negotiated_params().cipher_suite) << ENDPOINT << "Handshake completes without cipher suite negotiation."; QUIC_BUG_IF(!config_.negotiated()) << ENDPOINT << "Handshake completes without parameter negotiation."; connection()->mutable_stats().handshake_completion_time = connection()->clock()->ApproximateNow(); - if ((connection()->version().HasHandshakeDone() || - config_.PeerSupportsHandshakeDone()) && + if (connection()->version().UsesTls() && perspective_ == Perspective::IS_SERVER) { // Server sends HANDSHAKE_DONE to signal confirmation of the handshake // to the client. control_frame_manager_.WriteOrBufferHandshakeDone(); + if (GetQuicReloadableFlag(quic_enable_token_based_address_validation) && + connection()->version().HasIetfQuicFrames()) { + QUIC_RELOADABLE_FLAG_COUNT_N(quic_enable_token_based_address_validation, + 1, 2); + MaybeSendAddressToken(); + } + } +} + +void QuicSession::MaybeSendAddressToken() { + QUICHE_DCHECK(perspective_ == Perspective::IS_SERVER && + connection()->version().HasIetfQuicFrames()); + std::string address_token = GetCryptoStream()->GetAddressToken(); + if (address_token.empty()) { + return; } + const size_t buf_len = address_token.length() + 1; + auto buffer = std::make_unique<char[]>(buf_len); + QuicDataWriter writer(buf_len, buffer.get()); + // Add prefix 0 for token sent in NEW_TOKEN frame. + writer.WriteUInt8(0); + writer.WriteBytes(address_token.data(), address_token.length()); + control_frame_manager_.WriteOrBufferNewToken( + absl::string_view(buffer.get(), buf_len)); } void QuicSession::DiscardOldDecryptionKey(EncryptionLevel level) { @@ -1699,7 +1707,7 @@ void QuicSession::OnZeroRttRejected(int reason) { } bool QuicSession::FillTransportParameters(TransportParameters* params) { - if (version().AuthenticatesHandshakeConnectionIds()) { + if (version().UsesTls()) { if (perspective() == Perspective::IS_SERVER) { config_.SetOriginalConnectionIdToSend( connection_->GetOriginalDestinationConnectionId()); @@ -1740,13 +1748,6 @@ void QuicSession::RegisterStreamPriority( QuicStreamId id, bool is_static, const spdy::SpdyStreamPrecedence& precedence) { - if (enable_round_robin_scheduling_) { - // Ignore provided precedence, instead, put all streams at the same priority - // bucket. - write_blocked_streams()->RegisterStream( - id, is_static, spdy::SpdyStreamPrecedence(spdy::kV3LowestPriority)); - return; - } write_blocked_streams()->RegisterStream(id, is_static, precedence); } @@ -1757,10 +1758,6 @@ void QuicSession::UnregisterStreamPriority(QuicStreamId id, bool is_static) { void QuicSession::UpdateStreamPriority( QuicStreamId id, const spdy::SpdyStreamPrecedence& new_precedence) { - if (enable_round_robin_scheduling_) { - // Ignore updated precedence. - return; - } write_blocked_streams()->UpdateStreamPriority(id, new_precedence); } @@ -1773,7 +1770,7 @@ void QuicSession::ActivateStream(std::unique_ptr<QuicStream> stream) { bool is_static = stream->is_static(); QUIC_DVLOG(1) << ENDPOINT << "num_streams: " << stream_map_.size() << ". activating stream " << stream_id; - DCHECK(!QuicContainsKey(stream_map_, stream_id)); + QUICHE_DCHECK(!QuicContainsKey(stream_map_, stream_id)); stream_map_[stream_id] = std::move(stream); if (is_static) { ++num_static_streams_; @@ -1802,7 +1799,7 @@ QuicStreamId QuicSession::GetNextOutgoingUnidirectionalStreamId() { bool QuicSession::CanOpenNextOutgoingBidirectionalStream() { if (liveness_testing_in_progress_) { - DCHECK_EQ(Perspective::IS_CLIENT, perspective()); + QUICHE_DCHECK_EQ(Perspective::IS_CLIENT, perspective()); return false; } if (!VersionHasIetfQuicFrames(transport_version())) { @@ -1848,12 +1845,12 @@ bool QuicSession::CanOpenNextOutgoingUnidirectionalStream() { QuicStreamCount QuicSession::GetAdvertisedMaxIncomingBidirectionalStreams() const { - DCHECK(VersionHasIetfQuicFrames(transport_version())); + QUICHE_DCHECK(VersionHasIetfQuicFrames(transport_version())); return ietf_streamid_manager_.advertised_max_incoming_bidirectional_streams(); } QuicStream* QuicSession::GetOrCreateStream(const QuicStreamId stream_id) { - DCHECK(!QuicContainsKey(pending_stream_map_, stream_id)); + QUICHE_DCHECK(!QuicContainsKey(pending_stream_map_, stream_id)); if (QuicUtils::IsCryptoStreamId(transport_version(), stream_id)) { return GetMutableCryptoStream(); } @@ -1892,7 +1889,7 @@ QuicStream* QuicSession::GetOrCreateStream(const QuicStreamId stream_id) { } void QuicSession::StreamDraining(QuicStreamId stream_id, bool unidirectional) { - DCHECK(QuicContainsKey(stream_map_, stream_id)); + QUICHE_DCHECK(QuicContainsKey(stream_map_, stream_id)); QUIC_DVLOG(1) << ENDPOINT << "Stream " << stream_id << " is draining"; if (VersionHasIetfQuicFrames(transport_version())) { ietf_streamid_manager_.OnStreamClosed(stream_id); @@ -1923,8 +1920,8 @@ bool QuicSession::MaybeIncreaseLargestPeerStreamId( if (!stream_id_manager_.MaybeIncreaseLargestPeerStreamId(stream_id)) { connection()->CloseConnection( QUIC_TOO_MANY_AVAILABLE_STREAMS, - quiche::QuicheStrCat(stream_id, " exceeds available streams ", - stream_id_manager_.MaxAvailableStreams()), + absl::StrCat(stream_id, " exceeds available streams ", + stream_id_manager_.MaxAvailableStreams()), ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); return false; } @@ -1957,7 +1954,7 @@ PendingStream* QuicSession::GetOrCreatePendingStream(QuicStreamId stream_id) { void QuicSession::set_largest_peer_created_stream_id( QuicStreamId largest_peer_created_stream_id) { - DCHECK(!VersionHasIetfQuicFrames(transport_version())); + QUICHE_DCHECK(!VersionHasIetfQuicFrames(transport_version())); stream_id_manager_.set_largest_peer_created_stream_id( largest_peer_created_stream_id); } @@ -1965,7 +1962,7 @@ void QuicSession::set_largest_peer_created_stream_id( QuicStreamId QuicSession::GetLargestPeerCreatedStreamId( bool unidirectional) const { // This method is only used in IETF QUIC. - DCHECK(VersionHasIetfQuicFrames(transport_version())); + QUICHE_DCHECK(VersionHasIetfQuicFrames(transport_version())); return ietf_streamid_manager_.GetLargestPeerCreatedStreamId(unidirectional); } @@ -1989,7 +1986,7 @@ bool QuicSession::MaybeSetStreamPriority( } bool QuicSession::IsClosedStream(QuicStreamId id) { - DCHECK_NE(QuicUtils::GetInvalidStreamId(transport_version()), id); + QUICHE_DCHECK_NE(QuicUtils::GetInvalidStreamId(transport_version()), id); if (IsOpenStream(id)) { // Stream is active return false; @@ -2003,7 +2000,7 @@ bool QuicSession::IsClosedStream(QuicStreamId id) { } bool QuicSession::IsOpenStream(QuicStreamId id) { - DCHECK_NE(QuicUtils::GetInvalidStreamId(transport_version()), id); + QUICHE_DCHECK_NE(QuicUtils::GetInvalidStreamId(transport_version()), id); const StreamMap::iterator it = stream_map_.find(id); if (it != stream_map_.end()) { return !it->second->IsZombie(); @@ -2025,8 +2022,9 @@ bool QuicSession::IsStaticStream(QuicStreamId id) const { } size_t QuicSession::GetNumActiveStreams() const { - DCHECK_GE(static_cast<QuicStreamCount>(stream_map_.size()), - num_static_streams_ + num_draining_streams_ + num_zombie_streams_); + QUICHE_DCHECK_GE( + static_cast<QuicStreamCount>(stream_map_.size()), + num_static_streams_ + num_draining_streams_ + num_zombie_streams_); return stream_map_.size() - num_draining_streams_ - num_static_streams_ - num_zombie_streams_; } @@ -2055,10 +2053,6 @@ void QuicSession::OnAckNeedsRetransmittableFrame() { flow_controller_.SendWindowUpdate(); } -void QuicSession::SendPing() { - control_frame_manager_.WritePing(); -} - void QuicSession::SendAckFrequency(const QuicAckFrequencyFrame& frame) { control_frame_manager_.WriteOrBufferAckFrequency(frame); } @@ -2333,7 +2327,7 @@ bool QuicSession::RetransmitLostData() { QuicStream* crypto_stream = GetStream(QuicUtils::GetCryptoStreamId(transport_version())); crypto_stream->OnCanWrite(); - DCHECK(CheckStreamWriteBlocked(crypto_stream)); + QUICHE_DCHECK(CheckStreamWriteBlocked(crypto_stream)); if (crypto_stream->HasPendingRetransmission()) { // Connection is write blocked. return false; @@ -2357,7 +2351,7 @@ bool QuicSession::RetransmitLostData() { QuicStream* stream = GetStream(id); if (stream != nullptr) { stream->OnCanWrite(); - DCHECK(CheckStreamWriteBlocked(stream)); + QUICHE_DCHECK(CheckStreamWriteBlocked(stream)); if (stream->HasPendingRetransmission()) { // Connection is write blocked. break; @@ -2397,7 +2391,7 @@ MessageResult QuicSession::SendMessage(QuicMemSliceSpan message) { } MessageResult QuicSession::SendMessage(QuicMemSliceSpan message, bool flush) { - DCHECK(connection_->connected()) + QUICHE_DCHECK(connection_->connected()) << ENDPOINT << "Try to write messages when connection is closed."; if (!IsEncryptionEstablished()) { return {MESSAGE_STATUS_ENCRYPTION_NOT_ESTABLISHED, 0}; @@ -2540,5 +2534,32 @@ EncryptionLevel QuicSession::GetEncryptionLevelToSendApplicationData() const { return connection_->framer().GetEncryptionLevelToSendApplicationData(); } +void QuicSession::ValidatePath( + std::unique_ptr<QuicPathValidationContext> context, + std::unique_ptr<QuicPathValidator::ResultDelegate> result_delegate) { + connection_->ValidatePath(std::move(context), std::move(result_delegate)); +} + +bool QuicSession::HasPendingPathValidation() const { + return connection_->HasPendingPathValidation(); +} + +void QuicSession::MigratePath(const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address, + QuicPacketWriter* writer, + bool owns_writer) { + connection_->MigratePath(self_address, peer_address, writer, owns_writer); +} + +bool QuicSession::ValidateToken(absl::string_view token) const { + QUICHE_DCHECK_EQ(perspective_, Perspective::IS_SERVER); + if (token.empty() || token[0] != 0) { + // Validate the prefix for token received in NEW_TOKEN frame. + return false; + } + return GetCryptoStream()->ValidateAddressToken( + absl::string_view(token.data() + 1, token.length() - 1)); +} + #undef ENDPOINT // undef for jumbo builds } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_session.h b/chromium/net/third_party/quiche/src/quic/core/quic_session.h index e454892ac5c..cf7f9f725b4 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_session.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_session.h @@ -14,29 +14,31 @@ #include <string> #include <vector> +#include "absl/container/flat_hash_map.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.h" -#include "net/third_party/quiche/src/quic/core/handshaker_delegate_interface.h" -#include "net/third_party/quiche/src/quic/core/legacy_quic_stream_id_manager.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_control_frame_manager.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_datagram_queue.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_creator.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_stream_frame_data_producer.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_write_blocked_list.h" -#include "net/third_party/quiche/src/quic/core/session_notifier_interface.h" -#include "net/third_party/quiche/src/quic/core/stream_delegate_interface.h" -#include "net/third_party/quiche/src/quic/core/uber_quic_stream_id_manager.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/frames/quic_ack_frequency_frame.h" +#include "quic/core/handshaker_delegate_interface.h" +#include "quic/core/legacy_quic_stream_id_manager.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_control_frame_manager.h" +#include "quic/core/quic_crypto_stream.h" +#include "quic/core/quic_datagram_queue.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_packet_creator.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_path_validator.h" +#include "quic/core/quic_stream.h" +#include "quic/core/quic_stream_frame_data_producer.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_write_blocked_list.h" +#include "quic/core/session_notifier_interface.h" +#include "quic/core/stream_delegate_interface.h" +#include "quic/core/uber_quic_stream_id_manager.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { @@ -80,6 +82,15 @@ class QUIC_EXPORT_PRIVATE QuicSession // Called when the session receives a STOP_SENDING for a stream from the // peer. virtual void OnStopSendingReceived(const QuicStopSendingFrame& frame) = 0; + + // Called when a NewConnectionId frame has been sent. + virtual void OnNewConnectionIdSent( + const QuicConnectionId& server_connection_id, + const QuicConnectionId& new_connection_id) = 0; + + // Called when a ConnectionId has been retired. + virtual void OnConnectionIdRetired( + const QuicConnectionId& server_connection_id) = 0; }; // Does not take ownership of |connection| or |visitor|. @@ -88,6 +99,12 @@ class QUIC_EXPORT_PRIVATE QuicSession const QuicConfig& config, const ParsedQuicVersionVector& supported_versions, QuicStreamCount num_expected_unidirectional_static_streams); + QuicSession(QuicConnection* connection, + Visitor* owner, + const QuicConfig& config, + const ParsedQuicVersionVector& supported_versions, + QuicStreamCount num_expected_unidirectional_static_streams, + std::unique_ptr<QuicDatagramQueue::Observer> datagram_observer); QuicSession(const QuicSession&) = delete; QuicSession& operator=(const QuicSession&) = delete; @@ -95,6 +112,9 @@ class QUIC_EXPORT_PRIVATE QuicSession virtual void Initialize(); + // Return the reserved crypto stream as a constant pointer. + virtual const QuicCryptoStream* GetCryptoStream() const = 0; + // QuicConnectionVisitorInterface methods: void OnStreamFrame(const QuicStreamFrame& frame) override; void OnCryptoFrame(const QuicCryptoFrame& frame) override; @@ -102,6 +122,7 @@ class QUIC_EXPORT_PRIVATE QuicSession void OnGoAway(const QuicGoAwayFrame& frame) override; void OnMessageReceived(absl::string_view message) override; void OnHandshakeDoneReceived() override; + void OnNewTokenReceived(absl::string_view token) override; void OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) override; void OnBlockedFrame(const QuicBlockedFrame& frame) override; void OnConnectionClosed(const QuicConnectionCloseFrame& frame, @@ -123,7 +144,6 @@ class QUIC_EXPORT_PRIVATE QuicSession void OnConnectionMigration(AddressChangeType /*type*/) override {} // Adds a connection level WINDOW_UPDATE frame. void OnAckNeedsRetransmittableFrame() override; - void SendPing() override; void SendAckFrequency(const QuicAckFrequencyFrame& frame) override; bool WillingAndAbleToWrite() const override; std::string GetStreamsInfoForLogging() const override; @@ -142,6 +162,8 @@ class QUIC_EXPORT_PRIVATE QuicSession override; std::unique_ptr<QuicEncrypter> CreateCurrentOneRttEncrypter() override; void BeforeConnectionCloseSent() override {} + bool ValidateToken(absl::string_view token) const override; + void MaybeSendAddressToken() override; // QuicStreamFrameDataProducer WriteStreamDataResult WriteStreamData(QuicStreamId id, @@ -219,15 +241,6 @@ class QUIC_EXPORT_PRIVATE QuicSession bool WriteControlFrame(const QuicFrame& frame, TransmissionType type) override; - // Called by stream to send RST_STREAM (and STOP_SENDING in IETF QUIC). - // if |send_rst_only|, STOP_SENDING will not be sent for IETF QUIC. - // TODO(b/170233449): Delete this method when flag quic_split_up_send_rst_2 is - // deprecated. - virtual void SendRstStream(QuicStreamId id, - QuicRstStreamErrorCode error, - QuicStreamOffset bytes_written, - bool send_rst_only); - // Called to send RST_STREAM (and STOP_SENDING) and close stream. If stream // |id| does not exist, just send RST_STREAM (and STOP_SENDING). virtual void ResetStream(QuicStreamId id, QuicRstStreamErrorCode error); @@ -258,6 +271,11 @@ class QUIC_EXPORT_PRIVATE QuicSession // Called by the QuicCryptoStream when a new QuicConfig has been negotiated. virtual void OnConfigNegotiated(); + // Called by the TLS handshaker when ALPS data is received. + // Returns an error message if an error has occurred, or nullopt otherwise. + virtual absl::optional<std::string> OnAlpsData(const uint8_t* alps_data, + size_t alps_length); + // From HandshakerDelegateInterface bool OnNewDecryptionKeyAvailable(EncryptionLevel level, std::unique_ptr<QuicDecrypter> decrypter, @@ -282,6 +300,9 @@ class QUIC_EXPORT_PRIVATE QuicSession // Implement StreamDelegateInterface. void OnStreamError(QuicErrorCode error_code, std::string error_details) override; + void OnStreamError(QuicErrorCode error_code, + QuicIetfTransportErrorCodes ietf_error, + std::string error_details) override; // Sets priority in the write blocked list. void RegisterStreamPriority( QuicStreamId id, @@ -340,8 +361,6 @@ class QUIC_EXPORT_PRIVATE QuicSession return connection_->connection_id(); } - bool split_up_send_rst() const { return split_up_send_rst_; } - // Returns the number of currently open streams, excluding static streams, and // never counting unfinished streams. size_t GetNumActiveStreams() const; @@ -363,6 +382,77 @@ class QUIC_EXPORT_PRIVATE QuicSession // connection, or in a write-blocked stream. bool HasDataToWrite() const; + // Initiates a path validation on the path described in the given context, + // asynchronously calls |result_delegate| upon success or failure. + // The initiator should extend QuicPathValidationContext to provide the writer + // and ResultDelegate to react upon the validation result. + // Example implementations of these for path validation for connection + // migration could be: + // class QUIC_EXPORT_PRIVATE PathMigrationContext + // : public QuicPathValidationContext { + // public: + // PathMigrationContext(std::unique_ptr<QuicPacketWriter> writer, + // const QuicSocketAddress& self_address, + // const QuicSocketAddress& peer_address) + // : QuicPathValidationContext(self_address, peer_address), + // alternative_writer_(std::move(writer)) {} + // + // QuicPacketWriter* WriterToUse() override { + // return alternative_writer_.get(); + // } + // + // QuicPacketWriter* ReleaseWriter() { + // return alternative_writer_.release(); + // } + // + // private: + // std::unique_ptr<QuicPacketWriter> alternative_writer_; + // }; + // + // class PathMigrationValidationResultDelegate + // : public QuicPathValidator::ResultDelegate { + // public: + // PathMigrationValidationResultDelegate(QuicConnection* connection) + // : QuicPathValidator::ResultDelegate(), connection_(connection) {} + // + // void OnPathValidationSuccess( + // std::unique_ptr<QuicPathValidationContext> context) override { + // // Do some work to prepare for migration. + // // ... + // + // // Actually migrate to the validated path. + // auto migration_context = std::unique_ptr<PathMigrationContext>( + // static_cast<PathMigrationContext*>(context.release())); + // connection_->MigratePath(migration_context->self_address(), + // migration_context->peer_address(), + // migration_context->ReleaseWriter(), + // /*owns_writer=*/true); + // + // // Post-migration actions + // // ... + // } + // + // void OnPathValidationFailure( + // std::unique_ptr<QuicPathValidationContext> /*context*/) override { + // // Handle validation failure. + // } + // + // private: + // QuicConnection* connection_; + // }; + void ValidatePath( + std::unique_ptr<QuicPathValidationContext> context, + std::unique_ptr<QuicPathValidator::ResultDelegate> result_delegate); + + // Return true if there is a path being validated. + bool HasPendingPathValidation() const; + + // Switch to the path described in |context| without validating the path. + void MigratePath(const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address, + QuicPacketWriter* writer, + bool owns_writer); + // Returns the largest payload that will fit into a single MESSAGE frame. // Because overhead can vary during a connection, this method should be // checked for every message. @@ -443,10 +533,6 @@ class QUIC_EXPORT_PRIVATE QuicSession inline ParsedQuicVersion version() const { return connection_->version(); } - bool use_http2_priority_write_scheduler() const { - return use_http2_priority_write_scheduler_; - } - bool is_configured() const { return is_configured_; } // Called to neuter crypto data of encryption |level|. @@ -505,6 +591,10 @@ class QUIC_EXPORT_PRIVATE QuicSession connection()->OnUserAgentIdKnown(); } + void SetSourceAddressTokenToSend(absl::string_view token) { + connection()->SetSourceAddressTokenToSend(token); + } + const QuicClock* GetClock() const { return connection()->helper()->GetClock(); } @@ -523,15 +613,16 @@ class QUIC_EXPORT_PRIVATE QuicSession } protected: - using StreamMap = QuicHashMap<QuicStreamId, std::unique_ptr<QuicStream>>; + using StreamMap = + absl::flat_hash_map<QuicStreamId, std::unique_ptr<QuicStream>>; using PendingStreamMap = - QuicHashMap<QuicStreamId, std::unique_ptr<PendingStream>>; + absl::flat_hash_map<QuicStreamId, std::unique_ptr<PendingStream>>; using ClosedStreams = std::vector<std::unique_ptr<QuicStream>>; using ZombieStreamMap = - QuicHashMap<QuicStreamId, std::unique_ptr<QuicStream>>; + absl::flat_hash_map<QuicStreamId, std::unique_ptr<QuicStream>>; // Creates a new stream to handle a peer-initiated stream. // Caller does not own the returned stream. @@ -542,9 +633,6 @@ class QUIC_EXPORT_PRIVATE QuicSession // Return the reserved crypto stream. virtual QuicCryptoStream* GetMutableCryptoStream() = 0; - // Return the reserved crypto stream as a constant pointer. - virtual const QuicCryptoStream* GetCryptoStream() const = 0; - // Adds |stream| to the stream map. virtual void ActivateStream(std::unique_ptr<QuicStream> stream); @@ -586,8 +674,6 @@ class QUIC_EXPORT_PRIVATE QuicSession return write_blocked_streams_.GetSpdyPriorityofStream(stream_id); } - StreamMap& stream_map() { return stream_map_; } - size_t pending_streams_size() const { return pending_stream_map_.size(); } ClosedStreams* closed_streams() { return &closed_streams_; } @@ -749,7 +835,7 @@ class QUIC_EXPORT_PRIVATE QuicSession // Keep track of highest received byte offset of locally closed streams, while // waiting for a definitive final highest offset from the peer. - QuicHashMap<QuicStreamId, QuicStreamOffset> + absl::flat_hash_map<QuicStreamId, QuicStreamOffset> locally_closed_streams_highest_offset_; QuicConnection* connection_; @@ -842,17 +928,10 @@ class QUIC_EXPORT_PRIVATE QuicSession absl::optional<std::string> user_agent_id_; - // If true, write_blocked_streams_ uses HTTP2 (tree-style) priority write - // scheduler. - bool use_http2_priority_write_scheduler_; - // Initialized to false. Set to true when the session has been properly // configured and is ready for general operation. bool is_configured_; - // If true, enables round robin scheduling. - bool enable_round_robin_scheduling_; - // Whether the session has received a 0-RTT rejection (QUIC+TLS only). bool was_zero_rtt_rejected_; @@ -860,9 +939,6 @@ class QUIC_EXPORT_PRIVATE QuicSession // creation of new outgoing bidirectional streams. bool liveness_testing_in_progress_; - const bool split_up_send_rst_ = - GetQuicReloadableFlag(quic_split_up_send_rst_2); - const bool use_write_or_buffer_data_at_level_ = GetQuicReloadableFlag(quic_use_write_or_buffer_data_at_level); }; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_session_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_session_test.cc index 06225086ed7..7daec2bbe00 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_session_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_session_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_session.h" +#include "quic/core/quic_session.h" #include <cstdint> #include <set> @@ -10,37 +10,36 @@ #include <utility> #include "absl/base/macros.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/transport_parameters.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_max_streams_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_mem_slice_storage.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test_mem_slice_vector.h" -#include "net/third_party/quiche/src/quic/test_tools/mock_quic_session_visitor.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_flow_controller_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_id_manager_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_send_buffer_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/null_decrypter.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/crypto/transport_parameters.h" +#include "quic/core/frames/quic_max_streams_frame.h" +#include "quic/core/quic_crypto_stream.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_stream.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_map_util.h" +#include "quic/platform/api/quic_mem_slice_storage.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test_mem_slice_vector.h" +#include "quic/test_tools/mock_quic_session_visitor.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_flow_controller_peer.h" +#include "quic/test_tools/quic_session_peer.h" +#include "quic/test_tools/quic_stream_id_manager_peer.h" +#include "quic/test_tools/quic_stream_peer.h" +#include "quic/test_tools/quic_stream_send_buffer_peer.h" +#include "quic/test_tools/quic_test_utils.h" using spdy::kV3HighestPriority; using spdy::SpdyPriority; @@ -86,7 +85,7 @@ class TestCryptoStream : public QuicCryptoStream, public QuicCryptoHandshaker { kInitialStreamFlowControlWindowForTest); session()->config()->SetInitialSessionFlowControlWindowToSend( kInitialSessionFlowControlWindowForTest); - if (session()->version().AuthenticatesHandshakeConnectionIds()) { + if (session()->version().UsesTls()) { if (session()->perspective() == Perspective::IS_CLIENT) { session()->config()->SetOriginalConnectionIdToSend( session()->connection()->connection_id()); @@ -96,9 +95,6 @@ class TestCryptoStream : public QuicCryptoStream, public QuicCryptoHandshaker { session()->config()->SetInitialSourceConnectionIdToSend( session()->connection()->client_connection_id()); } - } - if (session()->connection()->version().handshake_protocol == - PROTOCOL_TLS1_3) { TransportParameters transport_parameters; EXPECT_TRUE( session()->config()->FillTransportParameters(&transport_parameters)); @@ -145,6 +141,11 @@ class TestCryptoStream : public QuicCryptoStream, public QuicCryptoHandshaker { void OnOneRttPacketAcknowledged() override {} void OnHandshakePacketSent() override {} void OnHandshakeDoneReceived() override {} + void OnNewTokenReceived(absl::string_view /*token*/) override {} + std::string GetAddressToken() const override { return ""; } + bool ValidateAddressToken(absl::string_view /*token*/) const override { + return true; + } HandshakeState GetHandshakeState() const override { return one_rtt_keys_available() ? HANDSHAKE_COMPLETE : HANDSHAKE_START; } @@ -366,7 +367,7 @@ class TestSession : public QuicSession { } QuicConsumedData SendLargeFakeData(QuicStream* stream, int bytes) { - DCHECK(writev_consumes_all_data_); + QUICHE_DCHECK(writev_consumes_all_data_); return WritevData(stream->id(), bytes, 0, FIN, NOT_RETRANSMISSION, GetEncryptionLevelToSendApplicationData()); } @@ -387,7 +388,6 @@ class TestSession : public QuicSession { using QuicSession::closed_streams; using QuicSession::GetNextOutgoingBidirectionalStreamId; using QuicSession::GetNextOutgoingUnidirectionalStreamId; - using QuicSession::stream_map; private: StrictMock<TestCryptoStream> crypto_stream_; @@ -500,8 +500,9 @@ class QuicSessionTestBase : public QuicTestWithParam<ParsedQuicVersion> { void CompleteHandshake() { CryptoHandshakeMessage msg; - if (connection_->version().HasHandshakeDone() && + if (connection_->version().UsesTls() && connection_->perspective() == Perspective::IS_SERVER) { + // HANDSHAKE_DONE frame. EXPECT_CALL(*connection_, SendControlFrame(_)) .WillOnce(Invoke(&ClearControlFrame)); } @@ -578,7 +579,7 @@ class QuicSessionTestServer : public QuicSessionTestBase { EXPECT_CALL(framer_visitor_, OnPacket()); EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); EXPECT_CALL(framer_visitor_, OnUnauthenticatedHeader(_)); - EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); + EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_, _)); EXPECT_CALL(framer_visitor_, OnPacketHeader(_)); EXPECT_CALL(framer_visitor_, OnPathResponseFrame(_)) .WillOnce( @@ -942,8 +943,8 @@ TEST_P(QuicSessionTestServer, DebugDFatalIfMarkingClosedStreamWriteBlocked) { EXPECT_CALL(*connection_, SendControlFrame(_)); EXPECT_CALL(*connection_, OnStreamReset(closed_stream_id, _)); stream2->Reset(QUIC_BAD_APPLICATION_PAYLOAD); - std::string msg = quiche::QuicheStrCat("Marking unknown stream ", - closed_stream_id, " blocked."); + std::string msg = + absl::StrCat("Marking unknown stream ", closed_stream_id, " blocked."); EXPECT_QUIC_BUG(session_.MarkConnectionLevelWriteBlocked(closed_stream_id), msg); } @@ -1044,134 +1045,6 @@ TEST_P(QuicSessionTestServer, TestBatchedWrites) { session_.OnCanWrite(); } -TEST_P(QuicSessionTestServer, Http2Priority) { - if (VersionHasIetfQuicFrames(GetParam().transport_version)) { - // The test is using HTTP/2 priority which is not supported in IETF QUIC. - return; - } - QuicTagVector copt; - copt.push_back(kH2PR); - QuicConfigPeer::SetReceivedConnectionOptions(session_.config(), copt); - connection_->SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); - session_.OnConfigNegotiated(); - ASSERT_TRUE(session_.use_http2_priority_write_scheduler()); - - session_.set_writev_consumes_all_data(true); - TestStream* stream2 = session_.CreateOutgoingBidirectionalStream(); - TestStream* stream4 = session_.CreateOutgoingBidirectionalStream(); - TestStream* stream6 = session_.CreateOutgoingBidirectionalStream(); - - session_.set_writev_consumes_all_data(true); - /* - 0 - /|\ - 2 4 6 - */ - session_.MarkConnectionLevelWriteBlocked(stream2->id()); - session_.MarkConnectionLevelWriteBlocked(stream4->id()); - session_.MarkConnectionLevelWriteBlocked(stream6->id()); - - // Verify streams are scheduled round robin. - InSequence s; - EXPECT_CALL(*stream2, OnCanWrite()); - EXPECT_CALL(*stream4, OnCanWrite()); - EXPECT_CALL(*stream6, OnCanWrite()); - session_.OnCanWrite(); - - /* - 0 - | - 4 - / \ - 2 6 - */ - // Update stream 4's priority. - stream4->SetPriority( - spdy::SpdyStreamPrecedence(0, spdy::kHttp2DefaultStreamWeight, true)); - session_.MarkConnectionLevelWriteBlocked(stream2->id()); - session_.MarkConnectionLevelWriteBlocked(stream4->id()); - session_.MarkConnectionLevelWriteBlocked(stream6->id()); - - EXPECT_CALL(*stream4, OnCanWrite()).WillOnce(Invoke([this, stream4]() { - session_.MarkConnectionLevelWriteBlocked(stream4->id()); - })); - EXPECT_CALL(*stream4, OnCanWrite()); - EXPECT_CALL(*stream2, OnCanWrite()); - session_.OnCanWrite(); - EXPECT_CALL(*stream6, OnCanWrite()); - session_.OnCanWrite(); - - /* - 0 - | - 6 - | - 4 - | - 2 - */ - // Update stream 6's priority. - stream6->SetPriority( - spdy::SpdyStreamPrecedence(0, spdy::kHttp2DefaultStreamWeight, true)); - session_.MarkConnectionLevelWriteBlocked(stream2->id()); - session_.MarkConnectionLevelWriteBlocked(stream4->id()); - session_.MarkConnectionLevelWriteBlocked(stream6->id()); - - EXPECT_CALL(*stream6, OnCanWrite()).WillOnce(Invoke([this, stream6]() { - session_.MarkConnectionLevelWriteBlocked(stream6->id()); - })); - EXPECT_CALL(*stream6, OnCanWrite()); - EXPECT_CALL(*stream4, OnCanWrite()); - session_.OnCanWrite(); - EXPECT_CALL(*stream2, OnCanWrite()); - session_.OnCanWrite(); -} - -TEST_P(QuicSessionTestServer, RoundRobinScheduling) { - if (VersionHasIetfQuicFrames(GetParam().transport_version)) { - // IETF QUIC currently doesn't support PRIORITY. - return; - } - QuicTagVector copt; - copt.push_back(kRRWS); - QuicConfigPeer::SetReceivedConnectionOptions(session_.config(), copt); - connection_->SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); - session_.OnConfigNegotiated(); - - session_.set_writev_consumes_all_data(true); - TestStream* stream2 = session_.CreateOutgoingBidirectionalStream(); - TestStream* stream4 = session_.CreateOutgoingBidirectionalStream(); - TestStream* stream6 = session_.CreateOutgoingBidirectionalStream(); - - session_.set_writev_consumes_all_data(true); - session_.MarkConnectionLevelWriteBlocked(stream2->id()); - session_.MarkConnectionLevelWriteBlocked(stream4->id()); - session_.MarkConnectionLevelWriteBlocked(stream6->id()); - - // Verify streams are scheduled round robin. - InSequence s; - EXPECT_CALL(*stream2, OnCanWrite()); - EXPECT_CALL(*stream4, OnCanWrite()); - EXPECT_CALL(*stream6, OnCanWrite()); - session_.OnCanWrite(); - - /* 2, 4, 6, 8 */ - TestStream* stream8 = session_.CreateOutgoingBidirectionalStream(); - - // Verify updated priority is ignored. - stream4->SetPriority(spdy::SpdyStreamPrecedence(spdy::kV3HighestPriority)); - session_.MarkConnectionLevelWriteBlocked(stream8->id()); - session_.MarkConnectionLevelWriteBlocked(stream4->id()); - session_.MarkConnectionLevelWriteBlocked(stream2->id()); - session_.MarkConnectionLevelWriteBlocked(stream6->id()); - - EXPECT_CALL(*stream8, OnCanWrite()); - EXPECT_CALL(*stream4, OnCanWrite()); - EXPECT_CALL(*stream2, OnCanWrite()); - EXPECT_CALL(*stream6, OnCanWrite()); - session_.OnCanWrite(); -} - TEST_P(QuicSessionTestServer, OnCanWriteBundlesStreams) { // Encryption needs to be established before data can be sent. CompleteHandshake(); @@ -2165,7 +2038,7 @@ TEST_P(QuicSessionTestClient, InvalidStreamFlowControlWindowInHandshake) { EXPECT_CALL(*connection_, CloseConnection(_, _, _)) .WillOnce( Invoke(connection_, &MockQuicConnection::ReallyCloseConnection)); - EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _)); + EXPECT_CALL(*connection_, SendConnectionClosePacket(_, _, _)); connection_->SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); session_.OnConfigNegotiated(); @@ -2265,24 +2138,14 @@ TEST_P(QuicSessionTestClient, MinAckDelaySetOnTheClientQuicConfig) { ASSERT_TRUE(session_.connection()->can_receive_ack_frequency_frame()); } -TEST_P(QuicSessionTestClient, KeyUpdateFlagNotSet) { - SetQuicReloadableFlag(quic_key_update_supported, false); - EXPECT_CALL(*session_.GetMutableCryptoStream(), KeyUpdateSupportedLocally()) - .Times(0); - session_.Initialize(); - EXPECT_FALSE(session_.config()->KeyUpdateSupportedLocally()); -} - -TEST_P(QuicSessionTestClient, KeyUpdateNotSupportedLocallyAndFlagSet) { - SetQuicReloadableFlag(quic_key_update_supported, true); +TEST_P(QuicSessionTestClient, KeyUpdateNotSupportedLocally) { EXPECT_CALL(*session_.GetMutableCryptoStream(), KeyUpdateSupportedLocally()) .WillOnce(Return(false)); session_.Initialize(); EXPECT_FALSE(session_.config()->KeyUpdateSupportedLocally()); } -TEST_P(QuicSessionTestClient, KeyUpdateSupportedLocallyAndFlagSet) { - SetQuicReloadableFlag(quic_key_update_supported, true); +TEST_P(QuicSessionTestClient, KeyUpdateSupportedLocally) { EXPECT_CALL(*session_.GetMutableCryptoStream(), KeyUpdateSupportedLocally()) .WillOnce(Return(true)); session_.Initialize(); @@ -2644,8 +2507,9 @@ TEST_P(QuicSessionTestServer, LocallyResetZombieStreams) { stream2->WriteOrBufferData(body, true, nullptr); EXPECT_TRUE(stream2->IsWaitingForAcks()); // Verify stream2 is a zombie streams. - ASSERT_TRUE(QuicContainsKey(session_.stream_map(), stream2->id())); - auto* stream = session_.stream_map().find(stream2->id())->second.get(); + auto& stream_map = QuicSessionPeer::stream_map(&session_); + ASSERT_TRUE(QuicContainsKey(stream_map, stream2->id())); + auto* stream = stream_map.find(stream2->id())->second.get(); EXPECT_TRUE(stream->IsZombie()); QuicStreamFrame frame(stream2->id(), true, 0, 100); @@ -2692,8 +2556,9 @@ TEST_P(QuicSessionTestServer, WriteUnidirectionalStream) { std::string body(100, '.'); stream4->WriteOrBufferData(body, false, nullptr); stream4->WriteOrBufferData(body, true, nullptr); - ASSERT_TRUE(QuicContainsKey(session_.stream_map(), stream4->id())); - auto* stream = session_.stream_map().find(stream4->id())->second.get(); + auto& stream_map = QuicSessionPeer::stream_map(&session_); + ASSERT_TRUE(QuicContainsKey(stream_map, stream4->id())); + auto* stream = stream_map.find(stream4->id())->second.get(); EXPECT_TRUE(stream->IsZombie()); } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.cc b/chromium/net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.cc index 3056c3347c9..aba8c437f3e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.h" +#include "quic/core/quic_simple_buffer_allocator.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.h b/chromium/net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.h index e681e806a7c..cbf73b3dcf4 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_CORE_QUIC_SIMPLE_BUFFER_ALLOCATOR_H_ #define QUICHE_QUIC_CORE_QUIC_SIMPLE_BUFFER_ALLOCATOR_H_ -#include "net/third_party/quiche/src/quic/core/quic_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_buffer_allocator.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator_test.cc index 747d7333f5f..bc3f84437f8 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator_test.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.h" +#include "quic/core/quic_simple_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_socket_address_coder.cc b/chromium/net/third_party/quiche/src/quic/core/quic_socket_address_coder.cc index b26103d9af9..5eeb95d3bcb 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_socket_address_coder.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_socket_address_coder.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_socket_address_coder.h" +#include "quic/core/quic_socket_address_coder.h" #include <cstring> #include <string> diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_socket_address_coder.h b/chromium/net/third_party/quiche/src/quic/core/quic_socket_address_coder.h index d8401c62f8d..468e6d88755 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_socket_address_coder.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_socket_address_coder.h @@ -8,8 +8,8 @@ #include <cstdint> #include <string> -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_socket_address_coder_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_socket_address_coder_test.cc index 4f3c3fe26b3..0287cd37010 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_socket_address_coder_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_socket_address_coder_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_socket_address_coder.h" +#include "quic/core/quic_socket_address_coder.h" #include <string> #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_stream.cc b/chromium/net/third_party/quiche/src/quic/core/quic_stream.cc index aaef261106b..b8ac8ccccae 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_stream.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_stream.cc @@ -2,23 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_stream.h" +#include "quic/core/quic_stream.h" #include <limits> #include <string> +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_flow_controller.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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/common/platform/api/quiche_str_cat.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_flow_controller.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" using spdy::SpdyPriority; @@ -113,6 +113,7 @@ const int QuicStream::kDefaultUrgency; PendingStream::PendingStream(QuicStreamId id, QuicSession* session) : id_(id), + version_(session->version()), stream_delegate_(session), stream_bytes_read_(0), fin_received_(false), @@ -133,7 +134,7 @@ void PendingStream::OnDataAvailable() { } void PendingStream::OnFinRead() { - DCHECK(sequencer_.IsClosed()); + QUICHE_DCHECK(sequencer_.IsClosed()); } void PendingStream::AddBytesConsumed(QuicByteCount bytes) { @@ -153,12 +154,22 @@ void PendingStream::OnUnrecoverableError(QuicErrorCode error, stream_delegate_->OnStreamError(error, details); } +void PendingStream::OnUnrecoverableError(QuicErrorCode error, + QuicIetfTransportErrorCodes ietf_error, + const std::string& details) { + stream_delegate_->OnStreamError(error, ietf_error, details); +} + QuicStreamId PendingStream::id() const { return id_; } +ParsedQuicVersion PendingStream::version() const { + return version_; +} + void PendingStream::OnStreamFrame(const QuicStreamFrame& frame) { - DCHECK_EQ(frame.stream_id, id_); + QUICHE_DCHECK_EQ(frame.stream_id, id_); bool is_stream_too_long = (frame.offset > kMaxStreamLength) || @@ -176,7 +187,7 @@ void PendingStream::OnStreamFrame(const QuicStreamFrame& frame) { if (frame.offset + frame.data_length > sequencer_.close_offset()) { OnUnrecoverableError( QUIC_STREAM_DATA_BEYOND_CLOSE_OFFSET, - quiche::QuicheStrCat( + absl::StrCat( "Stream ", id_, " received data with offset: ", frame.offset + frame.data_length, ", which is beyond close offset: ", sequencer()->close_offset())); @@ -209,7 +220,7 @@ void PendingStream::OnStreamFrame(const QuicStreamFrame& frame) { } void PendingStream::OnRstStreamFrame(const QuicRstStreamFrame& frame) { - DCHECK_EQ(frame.stream_id, id_); + QUICHE_DCHECK_EQ(frame.stream_id, id_); if (frame.byte_offset > kMaxStreamLength) { // Peer are not suppose to write bytes more than maxium allowed. @@ -224,10 +235,10 @@ void PendingStream::OnRstStreamFrame(const QuicRstStreamFrame& frame) { frame.byte_offset != sequencer()->close_offset()) { OnUnrecoverableError( QUIC_STREAM_MULTIPLE_OFFSET, - quiche::QuicheStrCat("Stream ", id_, - " received new final offset: ", frame.byte_offset, - ", which is different from close offset: ", - sequencer()->close_offset())); + absl::StrCat("Stream ", id_, + " received new final offset: ", frame.byte_offset, + ", which is different from close offset: ", + sequencer()->close_offset())); return; } @@ -392,9 +403,9 @@ QuicStream::~QuicStream() { } void QuicStream::OnStreamFrame(const QuicStreamFrame& frame) { - DCHECK_EQ(frame.stream_id, id_); + QUICHE_DCHECK_EQ(frame.stream_id, id_); - DCHECK(!(read_side_closed_ && write_side_closed_)); + QUICHE_DCHECK(!(read_side_closed_ && write_side_closed_)); if (frame.fin && is_static_) { OnUnrecoverableError(QUIC_INVALID_STREAM_ID, @@ -419,17 +430,16 @@ void QuicStream::OnStreamFrame(const QuicStreamFrame& frame) { << sequencer_.DebugString(); OnUnrecoverableError( QUIC_STREAM_LENGTH_OVERFLOW, - quiche::QuicheStrCat("Peer sends more data than allowed on stream ", - id_, ". frame: offset = ", frame.offset, - ", length = ", frame.data_length, ". ", - sequencer_.DebugString())); + absl::StrCat("Peer sends more data than allowed on stream ", id_, + ". frame: offset = ", frame.offset, ", length = ", + frame.data_length, ". ", sequencer_.DebugString())); return; } if (frame.offset + frame.data_length > sequencer_.close_offset()) { OnUnrecoverableError( QUIC_STREAM_DATA_BEYOND_CLOSE_OFFSET, - quiche::QuicheStrCat( + absl::StrCat( "Stream ", id_, " received data with offset: ", frame.offset + frame.data_length, ", which is beyond close offset: ", sequencer_.close_offset())); @@ -439,7 +449,7 @@ void QuicStream::OnStreamFrame(const QuicStreamFrame& frame) { if (frame.fin && !fin_received_) { fin_received_ = true; if (fin_sent_) { - DCHECK(!was_draining_); + QUICHE_DCHECK(!was_draining_); session_->StreamDraining(id_, /*unidirectional=*/type_ != BIDIRECTIONAL); was_draining_ = true; @@ -497,16 +507,7 @@ bool QuicStream::OnStopSending(QuicRstStreamErrorCode code) { } stream_error_ = code; - - if (session()->split_up_send_rst()) { - QUIC_RELOADABLE_FLAG_COUNT_N(quic_split_up_send_rst_2, 1, 3); - MaybeSendRstStream(code); - } else { - session()->SendRstStream(id(), code, stream_bytes_written(), - /*send_rst_only = */ true); - rst_sent_ = true; - CloseWriteSide(); - } + MaybeSendRstStream(code); return true; } @@ -533,10 +534,10 @@ void QuicStream::OnStreamReset(const QuicRstStreamFrame& frame) { frame.byte_offset != sequencer()->close_offset()) { OnUnrecoverableError( QUIC_STREAM_MULTIPLE_OFFSET, - quiche::QuicheStrCat("Stream ", id_, - " received new final offset: ", frame.byte_offset, - ", which is different from close offset: ", - sequencer_.close_offset())); + absl::StrCat("Stream ", id_, + " received new final offset: ", frame.byte_offset, + ", which is different from close offset: ", + sequencer_.close_offset())); return; } @@ -575,7 +576,7 @@ void QuicStream::OnConnectionClosed(QuicErrorCode error, } void QuicStream::OnFinRead() { - DCHECK(sequencer_.IsClosed()); + QUICHE_DCHECK(sequencer_.IsClosed()); // OnFinRead can be called due to a FIN flag in a headers block, so there may // have been no OnStreamFrame call with a FIN in the frame. fin_received_ = true; @@ -586,30 +587,20 @@ void QuicStream::OnFinRead() { } void QuicStream::SetFinSent() { - DCHECK(!VersionUsesHttp3(transport_version())); + QUICHE_DCHECK(!VersionUsesHttp3(transport_version())); fin_sent_ = true; } void QuicStream::Reset(QuicRstStreamErrorCode error) { stream_error_ = error; - if (session()->split_up_send_rst()) { - QUIC_RELOADABLE_FLAG_COUNT_N(quic_split_up_send_rst_2, 2, 3); - QuicConnection::ScopedPacketFlusher flusher(session()->connection()); - MaybeSendStopSending(error); - MaybeSendRstStream(error); - } else { - session()->SendRstStream(id(), error, stream_bytes_written(), - /*send_rst_only = */ false); - rst_sent_ = true; - } + QuicConnection::ScopedPacketFlusher flusher(session()->connection()); + MaybeSendStopSending(error); + MaybeSendRstStream(error); + if (read_side_closed_ && write_side_closed_ && !IsWaitingForAcks()) { session()->MaybeCloseZombieStream(id_); return; } - if (!session()->split_up_send_rst()) { - CloseReadSide(); - CloseWriteSide(); - } } void QuicStream::OnUnrecoverableError(QuicErrorCode error, @@ -617,6 +608,12 @@ void QuicStream::OnUnrecoverableError(QuicErrorCode error, stream_delegate_->OnStreamError(error, details); } +void QuicStream::OnUnrecoverableError(QuicErrorCode error, + QuicIetfTransportErrorCodes ietf_error, + const std::string& details) { + stream_delegate_->OnStreamError(error, ietf_error, details); +} + const spdy::SpdyStreamPrecedence& QuicStream::precedence() const { return precedence_; } @@ -681,7 +678,7 @@ void QuicStream::WriteOrBufferDataInner( QUIC_BUG << "Write too many data via stream " << id_; OnUnrecoverableError( QUIC_STREAM_LENGTH_OVERFLOW, - quiche::QuicheStrCat("Write too many data via stream ", id_)); + absl::StrCat("Write too many data via stream ", id_)); return; } send_buffer_.SaveStreamData(&iov, 1, 0, data.length()); @@ -698,7 +695,7 @@ void QuicStream::WriteOrBufferDataAtLevel( bool fin, EncryptionLevel level, QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener) { - DCHECK(session()->use_write_or_buffer_data_at_level()); + QUICHE_DCHECK(session()->use_write_or_buffer_data_at_level()); QUIC_RELOADABLE_FLAG_COUNT(quic_use_write_or_buffer_data_at_level); return WriteOrBufferDataInner(data, fin, level, ack_listener); } @@ -794,7 +791,7 @@ QuicConsumedData QuicStream::WriteMemSlices(QuicMemSliceSpan span, bool fin) { QUIC_BUG << "Write too many data via stream " << id_; OnUnrecoverableError( QUIC_STREAM_LENGTH_OVERFLOW, - quiche::QuicheStrCat("Write too many data via stream ", id_)); + absl::StrCat("Write too many data via stream ", id_)); return consumed_data; } OnDataBuffered(offset, consumed_data.bytes_consumed, nullptr); @@ -856,7 +853,6 @@ void QuicStream::CloseWriteSide() { } void QuicStream::MaybeSendStopSending(QuicRstStreamErrorCode error) { - DCHECK(session()->split_up_send_rst()); if (stop_sending_sent_) { return; } @@ -869,7 +865,7 @@ void QuicStream::MaybeSendStopSending(QuicRstStreamErrorCode error) { if (session()->version().UsesHttp3()) { session()->MaybeSendStopSendingFrame(id(), error); } else { - DCHECK_EQ(QUIC_STREAM_NO_ERROR, error); + QUICHE_DCHECK_EQ(QUIC_STREAM_NO_ERROR, error); session()->MaybeSendRstStreamFrame(id(), QUIC_STREAM_NO_ERROR, stream_bytes_written()); } @@ -878,7 +874,6 @@ void QuicStream::MaybeSendStopSending(QuicRstStreamErrorCode error) { } void QuicStream::MaybeSendRstStream(QuicRstStreamErrorCode error) { - DCHECK(session()->split_up_send_rst()); if (rst_sent_) { return; } @@ -894,10 +889,14 @@ void QuicStream::MaybeSendRstStream(QuicRstStreamErrorCode error) { } bool QuicStream::HasBufferedData() const { - DCHECK_GE(send_buffer_.stream_offset(), stream_bytes_written()); + QUICHE_DCHECK_GE(send_buffer_.stream_offset(), stream_bytes_written()); return send_buffer_.stream_offset() > stream_bytes_written(); } +ParsedQuicVersion QuicStream::version() const { + return session_->version(); +} + QuicTransportVersion QuicStream::transport_version() const { return session_->transport_version(); } @@ -912,28 +911,18 @@ void QuicStream::StopReading() { } void QuicStream::OnClose() { - DCHECK(read_side_closed_ && write_side_closed_); + QUICHE_DCHECK(read_side_closed_ && write_side_closed_); if (!fin_sent_ && !rst_sent_) { - if (!session()->split_up_send_rst()) { - // For flow control accounting, tell the peer how many bytes have been - // written on this stream before termination. Done here if needed, using a - // RST_STREAM frame. - QUIC_DLOG(INFO) << ENDPOINT << "Sending RST_STREAM in OnClose: " << id(); - session_->SendRstStream(id(), QUIC_RST_ACKNOWLEDGEMENT, - stream_bytes_written(), - /*send_rst_only = */ false); - session_->MaybeCloseZombieStream(id_); - rst_sent_ = true; - } else { - QUIC_RELOADABLE_FLAG_COUNT_N(quic_split_up_send_rst_2, 3, 3); - QUIC_BUG_IF(session()->connection()->connected() && - session()->version().UsesHttp3()) - << "The stream should've already sent RST in response to " - "STOP_SENDING"; - MaybeSendRstStream(QUIC_RST_ACKNOWLEDGEMENT); - session_->MaybeCloseZombieStream(id_); - } + QUIC_BUG_IF(session()->connection()->connected() && + session()->version().UsesHttp3()) + << "The stream should've already sent RST in response to " + "STOP_SENDING"; + // For flow control accounting, tell the peer how many bytes have been + // written on this stream before termination. Done here if needed, using a + // RST_STREAM frame. + MaybeSendRstStream(QUIC_RST_ACKNOWLEDGEMENT); + session_->MaybeCloseZombieStream(id_); } if (!flow_controller_.has_value() || @@ -1041,7 +1030,7 @@ bool QuicStream::MaybeConfigSendWindowOffset(QuicStreamOffset new_offset, // The validation code below is for QUIC with TLS only. if (new_offset < flow_controller_->send_window_offset()) { - DCHECK(session()->version().UsesTls()); + QUICHE_DCHECK(session()->version().UsesTls()); if (was_zero_rtt_rejected && new_offset < flow_controller_->bytes_sent()) { // The client is given flow control window lower than what's written in // 0-RTT. This QUIC implementation is unable to retransmit them. @@ -1049,7 +1038,7 @@ bool QuicStream::MaybeConfigSendWindowOffset(QuicStreamOffset new_offset, << "Server streams' flow control should never be configured twice."; OnUnrecoverableError( QUIC_ZERO_RTT_UNRETRANSMITTABLE, - quiche::QuicheStrCat( + absl::StrCat( "Server rejected 0-RTT, aborting because new stream max data ", new_offset, " for stream ", id_, " is less than currently used: ", flow_controller_->bytes_sent())); @@ -1063,7 +1052,7 @@ bool QuicStream::MaybeConfigSendWindowOffset(QuicStreamOffset new_offset, OnUnrecoverableError( was_zero_rtt_rejected ? QUIC_ZERO_RTT_REJECTION_LIMIT_REDUCED : QUIC_ZERO_RTT_RESUMPTION_LIMIT_REDUCED, - quiche::QuicheStrCat( + absl::StrCat( was_zero_rtt_rejected ? "Server rejected 0-RTT, aborting because " : "", "new stream max data ", new_offset, " decreases current limit: ", @@ -1142,8 +1131,8 @@ bool QuicStream::RetransmitStreamData(QuicStreamOffset offset, QuicByteCount data_length, bool fin, TransmissionType type) { - DCHECK(type == PTO_RETRANSMISSION || type == RTO_RETRANSMISSION || - type == TLP_RETRANSMISSION || type == PROBING_RETRANSMISSION); + QUICHE_DCHECK(type == PTO_RETRANSMISSION || type == RTO_RETRANSMISSION || + type == TLP_RETRANSMISSION || type == PROBING_RETRANSMISSION); if (HasDeadlinePassed()) { OnDeadlinePassed(); return true; @@ -1210,14 +1199,14 @@ QuicByteCount QuicStream::ReadableBytes() const { bool QuicStream::WriteStreamData(QuicStreamOffset offset, QuicByteCount data_length, QuicDataWriter* writer) { - DCHECK_LT(0u, data_length); + QUICHE_DCHECK_LT(0u, data_length); QUIC_DVLOG(2) << ENDPOINT << "Write stream " << id_ << " data from offset " << offset << " length " << data_length; return send_buffer_.WriteStreamData(offset, data_length, writer); } void QuicStream::WriteBufferedData(absl::optional<EncryptionLevel> level) { - DCHECK(!write_side_closed_ && (HasBufferedData() || fin_buffered_)); + QUICHE_DCHECK(!write_side_closed_ && (HasBufferedData() || fin_buffered_)); if (session_->ShouldYield(id())) { session_->MarkConnectionLevelWriteBlocked(id()); @@ -1290,11 +1279,11 @@ void QuicStream::WriteBufferedData(absl::optional<EncryptionLevel> level) { MaybeSendBlocked(); } if (fin && consumed_data.fin_consumed) { - DCHECK(!fin_sent_); + QUICHE_DCHECK(!fin_sent_); fin_sent_ = true; fin_outstanding_ = true; if (fin_received_) { - DCHECK(!was_draining_); + QUICHE_DCHECK(!was_draining_); session_->StreamDraining(id_, /*unidirectional=*/type_ != BIDIRECTIONAL); was_draining_ = true; @@ -1312,7 +1301,7 @@ void QuicStream::WriteBufferedData(absl::optional<EncryptionLevel> level) { } uint64_t QuicStream::BufferedDataBytes() const { - DCHECK_GE(send_buffer_.stream_offset(), stream_bytes_written()); + QUICHE_DCHECK_GE(send_buffer_.stream_offset(), stream_bytes_written()); return send_buffer_.stream_offset() - stream_bytes_written(); } @@ -1438,16 +1427,23 @@ void QuicStream::UpdateReceiveWindowSize(QuicStreamOffset size) { // static spdy::SpdyStreamPrecedence QuicStream::CalculateDefaultPriority( const QuicSession* session) { - if (VersionUsesHttp3(session->transport_version())) { - return spdy::SpdyStreamPrecedence(kDefaultUrgency); - } + return spdy::SpdyStreamPrecedence( + VersionUsesHttp3(session->transport_version()) + ? kDefaultUrgency + : QuicStream::kDefaultPriority); +} - if (session->use_http2_priority_write_scheduler()) { - return spdy::SpdyStreamPrecedence(0, spdy::kHttp2DefaultStreamWeight, - false); - } +absl::optional<QuicByteCount> QuicStream::GetSendWindow() const { + return flow_controller_.has_value() + ? absl::optional<QuicByteCount>(flow_controller_->SendWindowSize()) + : absl::nullopt; +} - return spdy::SpdyStreamPrecedence(QuicStream::kDefaultPriority); +absl::optional<QuicByteCount> QuicStream::GetReceiveWindow() const { + return flow_controller_.has_value() + ? absl::optional<QuicByteCount>( + flow_controller_->receive_window_size()) + : absl::nullopt; } } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_stream.h b/chromium/net/third_party/quiche/src/quic/core/quic_stream.h index 50fc5e1a182..d89e4602909 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_stream.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_stream.h @@ -24,17 +24,17 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include "net/third_party/quiche/src/quic/core/quic_flow_controller.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_stream_send_buffer.h" -#include "net/third_party/quiche/src/quic/core/quic_stream_sequencer.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/session_notifier_interface.h" -#include "net/third_party/quiche/src/quic/core/stream_delegate_interface.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_mem_slice_span.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_reference_counted.h" -#include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" +#include "quic/core/quic_flow_controller.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_stream_send_buffer.h" +#include "quic/core/quic_stream_sequencer.h" +#include "quic/core/quic_types.h" +#include "quic/core/session_notifier_interface.h" +#include "quic/core/stream_delegate_interface.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_mem_slice_span.h" +#include "quic/platform/api/quic_reference_counted.h" +#include "spdy/core/spdy_protocol.h" namespace quic { @@ -61,7 +61,11 @@ class QUIC_EXPORT_PRIVATE PendingStream void Reset(QuicRstStreamErrorCode error) override; void OnUnrecoverableError(QuicErrorCode error, const std::string& details) override; + void OnUnrecoverableError(QuicErrorCode error, + QuicIetfTransportErrorCodes ietf_error, + const std::string& details) override; QuicStreamId id() const override; + ParsedQuicVersion version() const override; // Buffers the contents of |frame|. Frame must have a non-zero offset. // If the data violates flow control, the connection will be closed. @@ -90,6 +94,9 @@ class QUIC_EXPORT_PRIVATE PendingStream // ID of this stream. QuicStreamId id_; + // QUIC version being used by this stream. + ParsedQuicVersion version_; + // |stream_delegate_| must outlive this stream. StreamDelegateInterface* stream_delegate_; @@ -146,6 +153,7 @@ class QUIC_EXPORT_PRIVATE QuicStream // QuicStreamSequencer::StreamInterface implementation. QuicStreamId id() const override { return id_; } + ParsedQuicVersion version() const override; // Called by the stream subclass after it has consumed the final incoming // data. void OnFinRead() override; @@ -158,6 +166,9 @@ class QUIC_EXPORT_PRIVATE QuicStream // this end. void OnUnrecoverableError(QuicErrorCode error, const std::string& details) override; + void OnUnrecoverableError(QuicErrorCode error, + QuicIetfTransportErrorCodes ietf_error, + const std::string& details) override; // Called by the session when a (potentially duplicate) stream frame has been // received for this stream. @@ -441,6 +452,10 @@ class QUIC_EXPORT_PRIVATE QuicStream QuicStreamSendBuffer& send_buffer() { return send_buffer_; } + // Return the current flow control send window in bytes. + absl::optional<QuicByteCount> GetSendWindow() const; + absl::optional<QuicByteCount> GetReceiveWindow() const; + private: friend class test::QuicStreamPeer; friend class QuicStreamUtils; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_stream_frame_data_producer.h b/chromium/net/third_party/quiche/src/quic/core/quic_stream_frame_data_producer.h index ab67d54d542..edcc84b55ce 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_stream_frame_data_producer.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_stream_frame_data_producer.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_CORE_QUIC_STREAM_FRAME_DATA_PRODUCER_H_ #define QUICHE_QUIC_CORE_QUIC_STREAM_FRAME_DATA_PRODUCER_H_ -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/quic_types.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_stream_id_manager.cc b/chromium/net/third_party/quiche/src/quic/core/quic_stream_id_manager.cc index 8a54e3173cb..397eb71269b 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_stream_id_manager.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_stream_id_manager.cc @@ -1,20 +1,20 @@ // Copyright (c) 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_stream_id_manager.h" +#include "quic/core/quic_stream_id_manager.h" #include <cstdint> #include <string> -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_cat.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -47,15 +47,16 @@ QuicStreamIdManager::~QuicStreamIdManager() {} bool QuicStreamIdManager::OnStreamsBlockedFrame( const QuicStreamsBlockedFrame& frame, std::string* error_details) { - DCHECK_EQ(frame.unidirectional, unidirectional_); + QUICHE_DCHECK_EQ(frame.unidirectional, unidirectional_); if (frame.stream_count > incoming_advertised_max_streams_) { // Peer thinks it can send more streams that we've told it. - *error_details = quiche::QuicheStrCat( + *error_details = absl::StrCat( "StreamsBlockedFrame's stream count ", frame.stream_count, " exceeds incoming max stream ", incoming_advertised_max_streams_); return false; } - DCHECK_LE(incoming_advertised_max_streams_, incoming_actual_max_streams_); + QUICHE_DCHECK_LE(incoming_advertised_max_streams_, + incoming_actual_max_streams_); if (incoming_advertised_max_streams_ == incoming_actual_max_streams_) { // We have told peer about current max. return true; @@ -89,21 +90,24 @@ void QuicStreamIdManager::SetMaxOpenIncomingStreams( << "non-zero incoming stream count " << incoming_stream_count_ << " when setting max incoming stream to " << max_open_streams; QUIC_DLOG_IF(WARNING, incoming_initial_max_open_streams_ != max_open_streams) - << quiche::QuicheStrCat( - unidirectional_ ? "unidirectional " : "bidirectional: ", - "incoming stream limit changed from ", - incoming_initial_max_open_streams_, " to ", max_open_streams); + << absl::StrCat(unidirectional_ ? "unidirectional " : "bidirectional: ", + "incoming stream limit changed from ", + incoming_initial_max_open_streams_, " to ", + max_open_streams); incoming_actual_max_streams_ = max_open_streams; incoming_advertised_max_streams_ = max_open_streams; incoming_initial_max_open_streams_ = max_open_streams; } void QuicStreamIdManager::MaybeSendMaxStreamsFrame() { - if ((incoming_advertised_max_streams_ - incoming_stream_count_) > - (incoming_initial_max_open_streams_ / - GetQuicFlag(FLAGS_quic_max_streams_window_divisor))) { - // window too large, no advertisement - return; + int divisor = GetQuicFlag(FLAGS_quic_max_streams_window_divisor); + + if (divisor > 0) { + if ((incoming_advertised_max_streams_ - incoming_stream_count_) > + (incoming_initial_max_open_streams_ / divisor)) { + // window too large, no advertisement + return; + } } SendMaxStreamsFrame(); } @@ -115,8 +119,8 @@ void QuicStreamIdManager::SendMaxStreamsFrame() { } void QuicStreamIdManager::OnStreamClosed(QuicStreamId stream_id) { - DCHECK_NE(QuicUtils::IsBidirectionalStreamId(stream_id, version_), - unidirectional_); + QUICHE_DCHECK_NE(QuicUtils::IsBidirectionalStreamId(stream_id, version_), + unidirectional_); if (QuicUtils::IsOutgoingStreamId(version_, stream_id, perspective_)) { // Nothing to do for outgoing streams. return; @@ -146,7 +150,7 @@ QuicStreamId QuicStreamIdManager::GetNextOutgoingStreamId() { } bool QuicStreamIdManager::CanOpenNextOutgoingStream() const { - DCHECK(VersionHasIetfQuicFrames(version_.transport_version)); + QUICHE_DCHECK(VersionHasIetfQuicFrames(version_.transport_version)); return outgoing_stream_count_ < outgoing_max_streams_; } @@ -154,11 +158,11 @@ bool QuicStreamIdManager::MaybeIncreaseLargestPeerStreamId( const QuicStreamId stream_id, std::string* error_details) { // |stream_id| must be an incoming stream of the right directionality. - DCHECK_NE(QuicUtils::IsBidirectionalStreamId(stream_id, version_), - unidirectional_); - DCHECK_NE(QuicUtils::IsServerInitiatedStreamId(version_.transport_version, - stream_id), - perspective_ == Perspective::IS_SERVER); + QUICHE_DCHECK_NE(QuicUtils::IsBidirectionalStreamId(stream_id, version_), + unidirectional_); + QUICHE_DCHECK_NE(QuicUtils::IsServerInitiatedStreamId( + version_.transport_version, stream_id), + perspective_ == Perspective::IS_SERVER); if (available_streams_.erase(stream_id) == 1) { // stream_id is available. return true; @@ -166,7 +170,7 @@ bool QuicStreamIdManager::MaybeIncreaseLargestPeerStreamId( if (largest_peer_created_stream_id_ != QuicUtils::GetInvalidStreamId(version_.transport_version)) { - DCHECK_GT(stream_id, largest_peer_created_stream_id_); + QUICHE_DCHECK_GT(stream_id, largest_peer_created_stream_id_); } // Calculate increment of incoming_stream_count_ by creating stream_id. @@ -186,9 +190,9 @@ bool QuicStreamIdManager::MaybeIncreaseLargestPeerStreamId( << "Failed to create a new incoming stream with id:" << stream_id << ", reaching MAX_STREAMS limit: " << incoming_advertised_max_streams_ << "."; - *error_details = quiche::QuicheStrCat("Stream id ", stream_id, - " would exceed stream count limit ", - incoming_advertised_max_streams_); + *error_details = absl::StrCat("Stream id ", stream_id, + " would exceed stream count limit ", + incoming_advertised_max_streams_); return false; } @@ -201,7 +205,8 @@ bool QuicStreamIdManager::MaybeIncreaseLargestPeerStreamId( } bool QuicStreamIdManager::IsAvailableStream(QuicStreamId id) const { - DCHECK_NE(QuicUtils::IsBidirectionalStreamId(id, version_), unidirectional_); + QUICHE_DCHECK_NE(QuicUtils::IsBidirectionalStreamId(id, version_), + unidirectional_); if (QuicUtils::IsOutgoingStreamId(version_, id, perspective_)) { // Stream IDs under next_ougoing_stream_id_ are either open or previously // open but now closed. diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_stream_id_manager.h b/chromium/net/third_party/quiche/src/quic/core/quic_stream_id_manager.h index 9e6ef20112a..4261f43982b 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_stream_id_manager.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_stream_id_manager.h @@ -4,11 +4,12 @@ #ifndef QUICHE_QUIC_CORE_QUIC_STREAM_ID_MANAGER_H_ #define QUICHE_QUIC_CORE_QUIC_STREAM_ID_MANAGER_H_ -#include "net/third_party/quiche/src/quic/core/frames/quic_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "absl/container/flat_hash_set.h" +#include "absl/strings/str_cat.h" +#include "quic/core/frames/quic_frame.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -41,7 +42,7 @@ class QUIC_EXPORT_PRIVATE QuicStreamIdManager { // Generate a string suitable for sending to the log/etc to show current state // of the stream ID manager. std::string DebugString() const { - return quiche::QuicheStrCat( + return absl::StrCat( " { unidirectional_: ", unidirectional_, ", perspective: ", perspective_, ", outgoing_max_streams_: ", outgoing_max_streams_, @@ -176,7 +177,7 @@ class QUIC_EXPORT_PRIVATE QuicStreamIdManager { // Set of stream ids that are less than the largest stream id that has been // received, but are nonetheless available to be created. - QuicHashSet<QuicStreamId> available_streams_; + absl::flat_hash_set<QuicStreamId> available_streams_; QuicStreamId largest_peer_created_stream_id_; }; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_stream_id_manager_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_stream_id_manager_test.cc index e95f553f4a6..47ba76faf79 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_stream_id_manager_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_stream_id_manager_test.cc @@ -1,19 +1,19 @@ // Copyright (c) 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_stream_id_manager.h" +#include "quic/core/quic_stream_id_manager.h" #include <cstdint> #include <string> #include <utility> -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_id_manager_peer.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_cat.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_stream_id_manager_peer.h" using testing::_; using testing::StrictMock; @@ -45,7 +45,7 @@ struct TestParams { // Used by ::testing::PrintToStringParamName(). std::string PrintToString(const TestParams& p) { - return quiche::QuicheStrCat( + return absl::StrCat( ParsedQuicVersionToString(p.version), "_", (p.perspective == Perspective::IS_CLIENT ? "Client" : "Server"), (p.is_unidirectional ? "Unidirectional" : "Bidirectional")); @@ -76,7 +76,7 @@ class QuicStreamIdManagerTest : public QuicTestWithParam<TestParams> { GetParam().version, 0, kDefaultMaxStreamsPerConnection) { - DCHECK(VersionHasIetfQuicFrames(transport_version())); + QUICHE_DCHECK(VersionHasIetfQuicFrames(transport_version())); } QuicTransportVersion transport_version() const { @@ -205,8 +205,8 @@ TEST_P(QuicStreamIdManagerTest, IsIncomingStreamIdInValidAboveLimit) { EXPECT_FALSE(stream_id_manager_.MaybeIncreaseLargestPeerStreamId( stream_id, &error_details)); EXPECT_EQ(error_details, - quiche::QuicheStrCat("Stream id ", stream_id, - " would exceed stream count limit 100")); + absl::StrCat("Stream id ", stream_id, + " would exceed stream count limit 100")); } TEST_P(QuicStreamIdManagerTest, OnStreamsBlockedFrame) { @@ -315,7 +315,7 @@ TEST_P(QuicStreamIdManagerTest, MaybeIncreaseLargestPeerStreamId) { max_stream_id + QuicUtils::StreamIdDelta(transport_version()), &error_details)); EXPECT_EQ(error_details, - quiche::QuicheStrCat( + absl::StrCat( "Stream id ", max_stream_id + QuicUtils::StreamIdDelta(transport_version()), " would exceed stream count limit 100")); @@ -470,8 +470,8 @@ TEST_P(QuicStreamIdManagerTest, ExtremeMaybeIncreaseLargestPeerStreamId) { EXPECT_FALSE(stream_id_manager_.MaybeIncreaseLargestPeerStreamId( too_big_stream_id, &error_details)); EXPECT_EQ(error_details, - quiche::QuicheStrCat("Stream id ", too_big_stream_id, - " would exceed stream count limit 100")); + absl::StrCat("Stream id ", too_big_stream_id, + " would exceed stream count limit 100")); } } // namespace diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_stream_send_buffer.cc b/chromium/net/third_party/quiche/src/quic/core/quic_stream_send_buffer.cc index 7b8a23b86c4..219eacdbd60 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_stream_send_buffer.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_stream_send_buffer.cc @@ -4,14 +4,14 @@ #include <algorithm> -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_interval.h" -#include "net/third_party/quiche/src/quic/core/quic_stream_send_buffer.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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 "quic/core/quic_data_writer.h" +#include "quic/core/quic_interval.h" +#include "quic/core/quic_stream_send_buffer.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -58,7 +58,7 @@ void QuicStreamSendBuffer::SaveStreamData(const struct iovec* iov, int iov_count, size_t iov_offset, QuicByteCount data_length) { - DCHECK_LT(0u, data_length); + QUICHE_DCHECK_LT(0u, data_length); // Latch the maximum data slice size. const QuicByteCount max_data_slice_size = GetQuicFlag(FLAGS_quic_send_buffer_max_data_slice_size); diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_stream_send_buffer.h b/chromium/net/third_party/quiche/src/quic/core/quic_stream_send_buffer.h index 71448944521..cb6e3aa943c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_stream_send_buffer.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_stream_send_buffer.h @@ -5,14 +5,14 @@ #ifndef QUICHE_QUIC_CORE_QUIC_STREAM_SEND_BUFFER_H_ #define QUICHE_QUIC_CORE_QUIC_STREAM_SEND_BUFFER_H_ -#include "net/third_party/quiche/src/quic/core/frames/quic_stream_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_circular_deque.h" -#include "net/third_party/quiche/src/quic/core/quic_interval_deque.h" -#include "net/third_party/quiche/src/quic/core/quic_interval_set.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_iovec.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_mem_slice.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_mem_slice_span.h" +#include "quic/core/frames/quic_stream_frame.h" +#include "quic/core/quic_circular_deque.h" +#include "quic/core/quic_interval_deque.h" +#include "quic/core/quic_interval_set.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_iovec.h" +#include "quic/platform/api/quic_mem_slice.h" +#include "quic/platform/api/quic_mem_slice_span.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_stream_send_buffer_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_stream_send_buffer_test.cc index 0d5471e2aee..25dda04c566 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_stream_send_buffer_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_stream_send_buffer_test.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_stream_send_buffer.h" +#include "quic/core/quic_stream_send_buffer.h" #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test_mem_slice_vector.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_send_buffer_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_simple_buffer_allocator.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test_mem_slice_vector.h" +#include "quic/test_tools/quic_stream_send_buffer_peer.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer.cc b/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer.cc index 7d1c237bb40..e702f714747 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_stream_sequencer.h" +#include "quic/core/quic_stream_sequencer.h" #include <algorithm> #include <cstddef> @@ -10,19 +10,20 @@ #include <string> #include <utility> +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_clock.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_stream_sequencer_buffer.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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/common/platform/api/quiche_str_cat.h" +#include "quic/core/quic_clock.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_stream.h" +#include "quic/core/quic_stream_sequencer_buffer.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_stack_trace.h" namespace quic { @@ -37,10 +38,16 @@ QuicStreamSequencer::QuicStreamSequencer(StreamInterface* quic_stream) ignore_read_data_(false), level_triggered_(false) {} -QuicStreamSequencer::~QuicStreamSequencer() {} +QuicStreamSequencer::~QuicStreamSequencer() { + if (stream_ == nullptr) { + QUIC_BUG << "Double free'ing QuicStreamSequencer at " << this << ". " + << QuicStackTrace(); + } + stream_ = nullptr; +} void QuicStreamSequencer::OnStreamFrame(const QuicStreamFrame& frame) { - DCHECK_LE(frame.offset + frame.data_length, close_offset_); + QUICHE_DCHECK_LE(frame.offset + frame.data_length, close_offset_); ++num_frames_received_; const QuicStreamOffset byte_offset = frame.offset; const size_t data_len = frame.data_length; @@ -49,6 +56,14 @@ void QuicStreamSequencer::OnStreamFrame(const QuicStreamFrame& frame) { (!CloseStreamAtOffset(frame.offset + data_len) || data_len == 0)) { return; } + if (GetQuicReloadableFlag(quic_accept_empty_stream_frame_with_no_fin)) { + QUIC_RELOADABLE_FLAG_COUNT(quic_accept_empty_stream_frame_with_no_fin); + if (stream_->version().HasIetfQuicFrames() && data_len == 0) { + QUICHE_DCHECK(!frame.fin); + // Ignore empty frame with no fin. + return; + } + } OnFrameData(byte_offset, data_len, frame.data_buffer); } @@ -68,9 +83,9 @@ void QuicStreamSequencer::OnFrameData(QuicStreamOffset byte_offset, byte_offset, absl::string_view(data_buffer, data_len), &bytes_written, &error_details); if (result != QUIC_NO_ERROR) { - std::string details = quiche::QuicheStrCat("Stream ", stream_->id(), ": ", - QuicErrorCodeToString(result), - ": ", error_details); + std::string details = + absl::StrCat("Stream ", stream_->id(), ": ", + QuicErrorCodeToString(result), ": ", error_details); QUIC_LOG_FIRST_N(WARNING, 50) << QuicErrorCodeToString(result); QUIC_LOG_FIRST_N(WARNING, 50) << details; stream_->OnUnrecoverableError(result, details); @@ -118,7 +133,7 @@ bool QuicStreamSequencer::CloseStreamAtOffset(QuicStreamOffset offset) { if (close_offset_ != kMaxOffset && offset != close_offset_) { stream_->OnUnrecoverableError( QUIC_STREAM_SEQUENCER_INVALID_STATE, - quiche::QuicheStrCat( + absl::StrCat( "Stream ", stream_->id(), " received new final offset: ", offset, ", which is different from close offset: ", close_offset_)); return false; @@ -129,7 +144,7 @@ bool QuicStreamSequencer::CloseStreamAtOffset(QuicStreamOffset offset) { if (offset < highest_offset_) { stream_->OnUnrecoverableError( QUIC_STREAM_SEQUENCER_INVALID_STATE, - quiche::QuicheStrCat( + absl::StrCat( "Stream ", stream_->id(), " received fin with offset: ", offset, ", which reduces current highest offset: ", highest_offset_)); return false; @@ -163,23 +178,23 @@ void QuicStreamSequencer::MaybeCloseStream() { } int QuicStreamSequencer::GetReadableRegions(iovec* iov, size_t iov_len) const { - DCHECK(!blocked_); + QUICHE_DCHECK(!blocked_); return buffered_frames_.GetReadableRegions(iov, iov_len); } bool QuicStreamSequencer::GetReadableRegion(iovec* iov) const { - DCHECK(!blocked_); + QUICHE_DCHECK(!blocked_); return buffered_frames_.GetReadableRegion(iov); } bool QuicStreamSequencer::PeekRegion(QuicStreamOffset offset, iovec* iov) const { - DCHECK(!blocked_); + QUICHE_DCHECK(!blocked_); return buffered_frames_.PeekRegion(offset, iov); } void QuicStreamSequencer::Read(std::string* buffer) { - DCHECK(!blocked_); + QUICHE_DCHECK(!blocked_); buffer->resize(buffer->size() + ReadableBytes()); iovec iov; iov.iov_len = ReadableBytes(); @@ -188,14 +203,14 @@ void QuicStreamSequencer::Read(std::string* buffer) { } size_t QuicStreamSequencer::Readv(const struct iovec* iov, size_t iov_len) { - DCHECK(!blocked_); + QUICHE_DCHECK(!blocked_); std::string error_details; size_t bytes_read; QuicErrorCode read_error = buffered_frames_.Readv(iov, iov_len, &bytes_read, &error_details); if (read_error != QUIC_NO_ERROR) { std::string details = - quiche::QuicheStrCat("Stream ", stream_->id(), ": ", error_details); + absl::StrCat("Stream ", stream_->id(), ": ", error_details); stream_->OnUnrecoverableError(read_error, details); return bytes_read; } @@ -217,7 +232,7 @@ bool QuicStreamSequencer::IsClosed() const { } void QuicStreamSequencer::MarkConsumed(size_t num_bytes_consumed) { - DCHECK(!blocked_); + QUICHE_DCHECK(!blocked_); bool result = buffered_frames_.MarkConsumed(num_bytes_consumed); if (!result) { QUIC_BUG << "Invalid argument to MarkConsumed." @@ -259,7 +274,7 @@ void QuicStreamSequencer::ReleaseBufferIfEmpty() { } void QuicStreamSequencer::FlushBufferedFrames() { - DCHECK(ignore_read_data_); + QUICHE_DCHECK(ignore_read_data_); size_t bytes_flushed = buffered_frames_.FlushBufferedFrames(); QUIC_DVLOG(1) << "Flushing buffered data at offset " << buffered_frames_.BytesConsumed() << " length " @@ -278,7 +293,7 @@ QuicStreamOffset QuicStreamSequencer::NumBytesConsumed() const { const std::string QuicStreamSequencer::DebugString() const { // clang-format off - return quiche::QuicheStrCat("QuicStreamSequencer:", + return absl::StrCat("QuicStreamSequencer:", "\n bytes buffered: ", NumBytesBuffered(), "\n bytes consumed: ", NumBytesConsumed(), "\n has bytes to read: ", HasBytesToRead() ? "true" : "false", diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer.h b/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer.h index a74526b949e..b7ea49dac05 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer.h @@ -9,10 +9,10 @@ #include <map> #include <string> -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_stream_sequencer_buffer.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_stream_sequencer_buffer.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -42,8 +42,16 @@ class QUIC_EXPORT_PRIVATE QuicStreamSequencer { // being closed. virtual void OnUnrecoverableError(QuicErrorCode error, const std::string& details) = 0; + // Called when an error has occurred which should result in the connection + // being closed, specifying the wire error code |ietf_error| explicitly. + virtual void OnUnrecoverableError(QuicErrorCode error, + QuicIetfTransportErrorCodes ietf_error, + const std::string& details) = 0; // Returns the stream id of this stream. virtual QuicStreamId id() const = 0; + + // Returns the QUIC version being used by this stream. + virtual ParsedQuicVersion version() const = 0; }; explicit QuicStreamSequencer(StreamInterface* quic_stream); diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer_buffer.cc b/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer_buffer.cc index 6f399381a4d..5c85a6e7baa 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer_buffer.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer_buffer.cc @@ -2,21 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_stream_sequencer_buffer.h" +#include "quic/core/quic_stream_sequencer_buffer.h" #include <algorithm> #include <cstddef> #include <memory> #include <string> +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_interval.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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/common/platform/api/quiche_str_cat.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_interval.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { namespace { @@ -47,7 +47,7 @@ QuicStreamSequencerBuffer::QuicStreamSequencerBuffer(size_t max_capacity_bytes) total_bytes_read_(0), blocks_(nullptr) { if (allocate_blocks_on_demand_) { - DCHECK_GE(max_blocks_count_, kInitialBlockCount); + QUICHE_DCHECK_GE(max_blocks_count_, kInitialBlockCount); } Clear(); } @@ -82,11 +82,12 @@ bool QuicStreamSequencerBuffer::RetireBlock(size_t index) { return true; } -void QuicStreamSequencerBuffer::MaybeAddMoreBlocks(size_t next_expected_byte) { +void QuicStreamSequencerBuffer::MaybeAddMoreBlocks( + QuicStreamOffset next_expected_byte) { if (current_blocks_count_ == max_blocks_count_) { return; } - size_t last_byte = next_expected_byte - 1; + QuicStreamOffset last_byte = next_expected_byte - 1; size_t num_of_blocks_needed; // As long as last_byte does not wrap around, its index plus one blocks are // needed. Otherwise, block_count_ blocks are needed. @@ -203,7 +204,7 @@ bool QuicStreamSequencerBuffer::CopyStreamData(QuicStreamOffset offset, const size_t write_block_offset = GetInBlockOffset(offset); size_t current_blocks_count = allocate_blocks_on_demand_ ? current_blocks_count_ : max_blocks_count_; - DCHECK_GT(current_blocks_count, write_block_num); + QUICHE_DCHECK_GT(current_blocks_count, write_block_num); size_t block_capacity = GetBlockCapacity(write_block_num); size_t bytes_avail = block_capacity - write_block_offset; @@ -224,7 +225,7 @@ bool QuicStreamSequencerBuffer::CopyStreamData(QuicStreamOffset offset, } if (write_block_num >= current_blocks_count) { - *error_details = quiche::QuicheStrCat( + *error_details = absl::StrCat( "QuicStreamSequencerBuffer error: OnStreamData() exceed array bounds." "write offset = ", offset, " write_block_num = ", write_block_num, @@ -249,7 +250,7 @@ bool QuicStreamSequencerBuffer::CopyStreamData(QuicStreamOffset offset, << " length: " << bytes_to_copy; if (dest == nullptr || source == nullptr) { - *error_details = quiche::QuicheStrCat( + *error_details = absl::StrCat( "QuicStreamSequencerBuffer error: OnStreamData()" " dest == nullptr: ", (dest == nullptr), " source == nullptr: ", (source == nullptr), @@ -274,7 +275,7 @@ QuicErrorCode QuicStreamSequencerBuffer::Readv(const iovec* dest_iov, *bytes_read = 0; for (size_t i = 0; i < dest_count && ReadableBytes() > 0; ++i) { char* dest = reinterpret_cast<char*>(dest_iov[i].iov_base); - DCHECK(dest != nullptr); + QUICHE_DCHECK(dest != nullptr); size_t dest_remaining = dest_iov[i].iov_len; while (dest_remaining > 0 && ReadableBytes() > 0) { size_t block_idx = NextBlockToRead(); @@ -284,9 +285,9 @@ QuicErrorCode QuicStreamSequencerBuffer::Readv(const iovec* dest_iov, ReadableBytes(), block_capacity - start_offset_in_block); size_t bytes_to_copy = std::min<size_t>(bytes_available_in_block, dest_remaining); - DCHECK_GT(bytes_to_copy, 0u); + QUICHE_DCHECK_GT(bytes_to_copy, 0u); if (blocks_[block_idx] == nullptr || dest == nullptr) { - *error_details = quiche::QuicheStrCat( + *error_details = absl::StrCat( "QuicStreamSequencerBuffer error:" " Readv() dest == nullptr: ", (dest == nullptr), " blocks_[", block_idx, @@ -310,7 +311,7 @@ QuicErrorCode QuicStreamSequencerBuffer::Readv(const iovec* dest_iov, if (bytes_to_copy == bytes_available_in_block) { bool retire_successfully = RetireBlockIfEmpty(block_idx); if (!retire_successfully) { - *error_details = quiche::QuicheStrCat( + *error_details = absl::StrCat( "QuicStreamSequencerBuffer error: fail to retire block ", block_idx, " as the block is already released, total_bytes_read_ = ", @@ -327,8 +328,8 @@ QuicErrorCode QuicStreamSequencerBuffer::Readv(const iovec* dest_iov, int QuicStreamSequencerBuffer::GetReadableRegions(struct iovec* iov, int iov_len) const { - DCHECK(iov != nullptr); - DCHECK_GT(iov_len, 0); + QUICHE_DCHECK(iov != nullptr); + QUICHE_DCHECK_GT(iov_len, 0); if (ReadableBytes() == 0) { iov[0].iov_base = nullptr; @@ -338,7 +339,7 @@ int QuicStreamSequencerBuffer::GetReadableRegions(struct iovec* iov, size_t start_block_idx = NextBlockToRead(); QuicStreamOffset readable_offset_end = FirstMissingByte() - 1; - DCHECK_GE(readable_offset_end + 1, total_bytes_read_); + QUICHE_DCHECK_GE(readable_offset_end + 1, total_bytes_read_); size_t end_block_offset = GetInBlockOffset(readable_offset_end); size_t end_block_idx = GetBlockIndex(readable_offset_end); @@ -355,7 +356,7 @@ int QuicStreamSequencerBuffer::GetReadableRegions(struct iovec* iov, iov[0].iov_len = GetBlockCapacity(start_block_idx) - ReadOffset(); QUIC_DVLOG(1) << "Got first block " << start_block_idx << " with len " << iov[0].iov_len; - DCHECK_GT(readable_offset_end + 1, total_bytes_read_ + iov[0].iov_len) + QUICHE_DCHECK_GT(readable_offset_end + 1, total_bytes_read_ + iov[0].iov_len) << "there should be more available data"; // Get readable regions of the rest blocks till either 2nd to last block @@ -364,7 +365,7 @@ int QuicStreamSequencerBuffer::GetReadableRegions(struct iovec* iov, int iov_used = 1; size_t block_idx = (start_block_idx + iov_used) % max_blocks_count_; while (block_idx != end_block_idx && iov_used < iov_len) { - DCHECK(nullptr != blocks_[block_idx]); + QUICHE_DCHECK(nullptr != blocks_[block_idx]); iov[iov_used].iov_base = blocks_[block_idx]->buffer; iov[iov_used].iov_len = GetBlockCapacity(block_idx); QUIC_DVLOG(1) << "Got block with index: " << block_idx; @@ -374,7 +375,7 @@ int QuicStreamSequencerBuffer::GetReadableRegions(struct iovec* iov, // Deal with last block if |iov| can hold more. if (iov_used < iov_len) { - DCHECK(nullptr != blocks_[block_idx]); + QUICHE_DCHECK(nullptr != blocks_[block_idx]); iov[iov_used].iov_base = blocks_[end_block_idx]->buffer; iov[iov_used].iov_len = end_block_offset + 1; QUIC_DVLOG(1) << "Got last block with index: " << end_block_idx; @@ -389,7 +390,7 @@ bool QuicStreamSequencerBuffer::GetReadableRegion(iovec* iov) const { bool QuicStreamSequencerBuffer::PeekRegion(QuicStreamOffset offset, iovec* iov) const { - DCHECK(iov); + QUICHE_DCHECK(iov); if (offset < total_bytes_read_) { // Data at |offset| has already been consumed. @@ -490,7 +491,8 @@ size_t QuicStreamSequencerBuffer::NextBlockToRead() const { } bool QuicStreamSequencerBuffer::RetireBlockIfEmpty(size_t block_index) { - DCHECK(ReadableBytes() == 0 || GetInBlockOffset(total_bytes_read_) == 0) + QUICHE_DCHECK(ReadableBytes() == 0 || + GetInBlockOffset(total_bytes_read_) == 0) << "RetireBlockIfEmpty() should only be called when advancing to next " << "block or a gap has been reached."; // If the whole buffer becomes empty, the last piece of data has been read. diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer_buffer.h b/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer_buffer.h index 674e3d91dfb..05d41b8149c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer_buffer.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer_buffer.h @@ -65,11 +65,11 @@ #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_interval_set.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_iovec.h" +#include "quic/core/quic_interval_set.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_iovec.h" namespace quic { @@ -214,7 +214,7 @@ class QUIC_EXPORT_PRIVATE QuicStreamSequencerBuffer { // Resize blocks_ if more blocks are needed to accomodate bytes before // next_expected_byte. - void MaybeAddMoreBlocks(size_t next_expected_byte); + void MaybeAddMoreBlocks(QuicStreamOffset next_expected_byte); // The maximum total capacity of this buffer in byte, as constructed. size_t max_buffer_capacity_bytes_; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer_buffer_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer_buffer_test.cc index 0ad7244ea35..dc21a097441 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer_buffer_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer_buffer_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_stream_sequencer_buffer.h" +#include "quic/core/quic_stream_sequencer_buffer.h" #include <algorithm> #include <cstddef> @@ -11,12 +11,12 @@ #include <string> #include <utility> +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_buffer_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_stream_sequencer_buffer_peer.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { @@ -163,7 +163,7 @@ TEST_F(QuicStreamSequencerBufferTest, OnStreamDataInvalidSource) { source = absl::string_view(nullptr, 1024); EXPECT_THAT(buffer_->OnStreamData(800, source, &written_, &error_details_), IsError(QUIC_STREAM_SEQUENCER_INVALID_STATE)); - EXPECT_EQ(0u, error_details_.find(quiche::QuicheStrCat( + EXPECT_EQ(0u, error_details_.find(absl::StrCat( "QuicStreamSequencerBuffer error: OnStreamData() " "dest == nullptr: ", false, " source == nullptr: ", true))); @@ -900,7 +900,7 @@ class QuicStreamSequencerBufferRandomIOTest start_chopping_offset += chunk_size; ++iterations; } - DCHECK(start_chopping_offset == bytes_to_buffer_); + QUICHE_DCHECK(start_chopping_offset == bytes_to_buffer_); size_t chunk_num = iterations; // Randomly change the sequence of in-ordered OffsetSizePairs to make a diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer_test.cc index a996ee21d64..e8fe6f367e2 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_stream_sequencer_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_stream_sequencer.h" +#include "quic/core/quic_stream_sequencer.h" #include <algorithm> #include <cstdint> @@ -13,14 +13,14 @@ #include "absl/base/macros.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#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_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/quic_stream.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_stream_sequencer_peer.h" +#include "quic/test_tools/quic_test_utils.h" using testing::_; using testing::AnyNumber; @@ -37,10 +37,19 @@ class MockStream : public QuicStreamSequencer::StreamInterface { OnUnrecoverableError, (QuicErrorCode error, const std::string& details), (override)); + MOCK_METHOD(void, + OnUnrecoverableError, + (QuicErrorCode error, + QuicIetfTransportErrorCodes ietf_error, + const std::string& details), + (override)); MOCK_METHOD(void, Reset, (QuicRstStreamErrorCode error), (override)); MOCK_METHOD(void, AddBytesConsumed, (QuicByteCount bytes), (override)); QuicStreamId id() const override { return 1; } + ParsedQuicVersion version() const override { + return CurrentSupportedVersions()[0]; + } }; namespace { @@ -243,7 +252,11 @@ TEST_F(QuicStreamSequencerTest, BlockedThenFullFrameAndFinConsumed) { } TEST_F(QuicStreamSequencerTest, EmptyFrame) { - EXPECT_CALL(stream_, OnUnrecoverableError(QUIC_EMPTY_STREAM_FRAME_NO_FIN, _)); + if (!GetQuicReloadableFlag(quic_accept_empty_stream_frame_with_no_fin) || + !stream_.version().HasIetfQuicFrames()) { + EXPECT_CALL(stream_, + OnUnrecoverableError(QUIC_EMPTY_STREAM_FRAME_NO_FIN, _)); + } OnFrame(0, ""); EXPECT_EQ(0u, NumBufferedBytes()); EXPECT_EQ(0u, sequencer_->NumBytesConsumed()); diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_stream_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_stream_test.cc index d241dac9098..46c4b4af3f6 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_stream_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_stream_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_stream.h" +#include "quic/core/quic_stream.h" #include <memory> #include <string> @@ -11,29 +11,29 @@ #include "absl/base/macros.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_rst_stream_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/core/quic_write_blocked_list.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#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_mem_slice_storage.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test_mem_slice_vector.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_flow_controller_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/frames/quic_rst_stream_frame.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/core/quic_write_blocked_list.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_mem_slice_storage.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test_mem_slice_vector.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_flow_controller_peer.h" +#include "quic/test_tools/quic_session_peer.h" +#include "quic/test_tools/quic_stream_peer.h" +#include "quic/test_tools/quic_stream_sequencer_peer.h" +#include "quic/test_tools/quic_test_utils.h" using testing::_; using testing::AnyNumber; @@ -116,15 +116,10 @@ class QuicStreamTest : public QuicTestWithParam<ParsedQuicVersion> { // session_ now owns stream_. session_->ActivateStream(QuicWrapUnique(stream_)); // Ignore resetting when session_ is terminated. - if (!session_->split_up_send_rst()) { - EXPECT_CALL(*session_, SendRstStream(kTestStreamId, _, _, _)) - .Times(AnyNumber()); - } else { - EXPECT_CALL(*session_, MaybeSendStopSendingFrame(kTestStreamId, _)) - .Times(AnyNumber()); - EXPECT_CALL(*session_, MaybeSendRstStreamFrame(kTestStreamId, _, _)) - .Times(AnyNumber()); - } + EXPECT_CALL(*session_, MaybeSendStopSendingFrame(kTestStreamId, _)) + .Times(AnyNumber()); + EXPECT_CALL(*session_, MaybeSendRstStreamFrame(kTestStreamId, _, _)) + .Times(AnyNumber()); write_blocked_list_ = QuicSessionPeer::GetWriteBlockedStreams(session_.get()); } @@ -471,11 +466,7 @@ TEST_P(QuicStreamTest, RstAlwaysSentIfNoFinSent) { EXPECT_FALSE(rst_sent()); // Now close the stream, and expect that we send a RST. - if (!session_->split_up_send_rst()) { - EXPECT_CALL(*session_, SendRstStream(kTestStreamId, _, _, _)); - } else { - EXPECT_CALL(*session_, MaybeSendRstStreamFrame(kTestStreamId, _, _)); - } + EXPECT_CALL(*session_, MaybeSendRstStreamFrame(kTestStreamId, _, _)); QuicRstStreamFrame rst_frame(kInvalidControlFrameId, stream_->id(), QUIC_STREAM_CANCELLED, 1234); stream_->OnStreamReset(rst_frame); @@ -528,12 +519,7 @@ TEST_P(QuicStreamTest, OnlySendOneRst) { EXPECT_FALSE(rst_sent()); // Reset the stream. - if (!session_->split_up_send_rst()) { - EXPECT_CALL(*session_, SendRstStream(kTestStreamId, _, _, _)).Times(1); - } else { - EXPECT_CALL(*session_, MaybeSendRstStreamFrame(kTestStreamId, _, _)) - .Times(1); - } + EXPECT_CALL(*session_, MaybeSendRstStreamFrame(kTestStreamId, _, _)).Times(1); stream_->Reset(QUIC_STREAM_CANCELLED); EXPECT_FALSE(fin_sent()); EXPECT_TRUE(rst_sent()); @@ -747,8 +733,8 @@ TEST_P(QuicStreamTest, StreamTooLong) { QuicStreamFrame stream_frame(stream_->id(), false, kMaxStreamLength, "."); EXPECT_QUIC_PEER_BUG( stream_->OnStreamFrame(stream_frame), - quiche::QuicheStrCat("Receive stream frame on stream ", stream_->id(), - " reaches max stream length")); + absl::StrCat("Receive stream frame on stream ", stream_->id(), + " reaches max stream length")); } TEST_P(QuicStreamTest, SetDrainingIncomingOutgoing) { @@ -943,11 +929,7 @@ TEST_P(QuicStreamTest, CancelStream) { EXPECT_TRUE(session_->HasUnackedStreamData()); EXPECT_EQ(1u, QuicStreamPeer::SendBuffer(stream_).size()); // Cancel stream. - if (session_->split_up_send_rst()) { - stream_->MaybeSendStopSending(QUIC_STREAM_NO_ERROR); - } else { - stream_->Reset(QUIC_STREAM_NO_ERROR); - } + stream_->MaybeSendStopSending(QUIC_STREAM_NO_ERROR); // stream still waits for acks as the error code is QUIC_STREAM_NO_ERROR, and // data is going to be retransmitted. EXPECT_TRUE(stream_->IsWaitingForAcks()); @@ -957,21 +939,13 @@ TEST_P(QuicStreamTest, CancelStream) { EXPECT_CALL(*session_, WriteControlFrame(_, _)) .Times(AtLeast(1)) .WillRepeatedly(Invoke(&ClearControlFrameWithTransmissionType)); - if (!session_->split_up_send_rst()) { - EXPECT_CALL(*session_, - SendRstStream(stream_->id(), QUIC_STREAM_CANCELLED, 9, _)) - .WillOnce(InvokeWithoutArgs([this]() { - session_->ReallySendRstStream(stream_->id(), QUIC_STREAM_CANCELLED, - stream_->stream_bytes_written(), false); - })); - } else { - EXPECT_CALL(*session_, MaybeSendRstStreamFrame(_, _, _)) - .WillOnce(InvokeWithoutArgs([this]() { - session_->ReallyMaybeSendRstStreamFrame( - stream_->id(), QUIC_STREAM_CANCELLED, - stream_->stream_bytes_written()); - })); - } + + EXPECT_CALL(*session_, MaybeSendRstStreamFrame(_, _, _)) + .WillOnce(InvokeWithoutArgs([this]() { + session_->ReallyMaybeSendRstStreamFrame( + stream_->id(), QUIC_STREAM_CANCELLED, + stream_->stream_bytes_written()); + })); stream_->Reset(QUIC_STREAM_CANCELLED); EXPECT_EQ(1u, QuicStreamPeer::SendBuffer(stream_).size()); @@ -1003,13 +977,8 @@ TEST_P(QuicStreamTest, RstFrameReceivedStreamNotFinishSending) { QuicRstStreamFrame rst_frame(kInvalidControlFrameId, stream_->id(), QUIC_STREAM_CANCELLED, 9); - if (!session_->split_up_send_rst()) { - EXPECT_CALL(*session_, - SendRstStream(stream_->id(), QUIC_RST_ACKNOWLEDGEMENT, 9, _)); - } else { - EXPECT_CALL(*session_, MaybeSendRstStreamFrame( - stream_->id(), QUIC_RST_ACKNOWLEDGEMENT, 9)); - } + EXPECT_CALL(*session_, MaybeSendRstStreamFrame(stream_->id(), + QUIC_RST_ACKNOWLEDGEMENT, 9)); stream_->OnStreamReset(rst_frame); EXPECT_EQ(1u, QuicStreamPeer::SendBuffer(stream_).size()); // Stream stops waiting for acks as it does not finish sending and rst is @@ -1031,7 +1000,6 @@ TEST_P(QuicStreamTest, RstFrameReceivedStreamFinishSending) { EXPECT_TRUE(session_->HasUnackedStreamData()); // RST_STREAM received. - EXPECT_CALL(*session_, SendRstStream(_, _, _, _)).Times(0); QuicRstStreamFrame rst_frame(kInvalidControlFrameId, stream_->id(), QUIC_STREAM_CANCELLED, 1234); stream_->OnStreamReset(rst_frame); @@ -1052,13 +1020,8 @@ TEST_P(QuicStreamTest, ConnectionClosed) { stream_->WriteOrBufferData(kData1, false, nullptr); EXPECT_TRUE(stream_->IsWaitingForAcks()); EXPECT_TRUE(session_->HasUnackedStreamData()); - if (!session_->split_up_send_rst()) { - EXPECT_CALL(*session_, - SendRstStream(stream_->id(), QUIC_RST_ACKNOWLEDGEMENT, 9, _)); - } else { - EXPECT_CALL(*session_, MaybeSendRstStreamFrame( - stream_->id(), QUIC_RST_ACKNOWLEDGEMENT, 9)); - } + EXPECT_CALL(*session_, MaybeSendRstStreamFrame(stream_->id(), + QUIC_RST_ACKNOWLEDGEMENT, 9)); QuicConnectionPeer::SetConnectionClose(connection_); stream_->OnConnectionClosed(QUIC_INTERNAL_ERROR, ConnectionCloseSource::FROM_SELF); @@ -1583,19 +1546,13 @@ TEST_P(QuicStreamTest, ResetStreamOnTtlExpiresRetransmitLostData) { connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); // Verify stream gets reset because TTL expires. - if (!session_->split_up_send_rst()) { - EXPECT_CALL(*session_, SendRstStream(_, QUIC_STREAM_TTL_EXPIRED, _, _)) - .Times(1); - } else { - if (session_->version().UsesHttp3()) { - EXPECT_CALL(*session_, - MaybeSendStopSendingFrame(_, QUIC_STREAM_TTL_EXPIRED)) - .Times(1); - } + if (session_->version().UsesHttp3()) { EXPECT_CALL(*session_, - MaybeSendRstStreamFrame(_, QUIC_STREAM_TTL_EXPIRED, _)) + MaybeSendStopSendingFrame(_, QUIC_STREAM_TTL_EXPIRED)) .Times(1); } + EXPECT_CALL(*session_, MaybeSendRstStreamFrame(_, QUIC_STREAM_TTL_EXPIRED, _)) + .Times(1); stream_->OnCanWrite(); } @@ -1613,19 +1570,13 @@ TEST_P(QuicStreamTest, ResetStreamOnTtlExpiresEarlyRetransmitData) { connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); // Verify stream gets reset because TTL expires. - if (!session_->split_up_send_rst()) { - EXPECT_CALL(*session_, SendRstStream(_, QUIC_STREAM_TTL_EXPIRED, _, _)) - .Times(1); - } else { - if (session_->version().UsesHttp3()) { - EXPECT_CALL(*session_, - MaybeSendStopSendingFrame(_, QUIC_STREAM_TTL_EXPIRED)) - .Times(1); - } + if (session_->version().UsesHttp3()) { EXPECT_CALL(*session_, - MaybeSendRstStreamFrame(_, QUIC_STREAM_TTL_EXPIRED, _)) + MaybeSendStopSendingFrame(_, QUIC_STREAM_TTL_EXPIRED)) .Times(1); } + EXPECT_CALL(*session_, MaybeSendRstStreamFrame(_, QUIC_STREAM_TTL_EXPIRED, _)) + .Times(1); stream_->RetransmitStreamData(0, 100, false, PTO_RETRANSMISSION); } @@ -1679,6 +1630,23 @@ TEST_P(QuicStreamTest, RstStreamFrameChangesCloseOffset) { stream_->OnStreamReset(rst); } +// Regression test for b/176073284. +TEST_P(QuicStreamTest, EmptyStreamFrameWithNoFin) { + Initialize(); + QuicStreamFrame empty_stream_frame(stream_->id(), false, 0, ""); + if (GetQuicReloadableFlag(quic_accept_empty_stream_frame_with_no_fin) && + stream_->version().HasIetfQuicFrames()) { + EXPECT_CALL(*connection_, + CloseConnection(QUIC_EMPTY_STREAM_FRAME_NO_FIN, _, _)) + .Times(0); + } else { + EXPECT_CALL(*connection_, + CloseConnection(QUIC_EMPTY_STREAM_FRAME_NO_FIN, _, _)); + } + EXPECT_CALL(*stream_, OnDataAvailable()).Times(0); + stream_->OnStreamFrame(empty_stream_frame); +} + } // namespace } // namespace test } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_sustained_bandwidth_recorder.cc b/chromium/net/third_party/quiche/src/quic/core/quic_sustained_bandwidth_recorder.cc index dd94a342c51..178c4c6b239 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_sustained_bandwidth_recorder.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_sustained_bandwidth_recorder.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_sustained_bandwidth_recorder.h" +#include "quic/core/quic_sustained_bandwidth_recorder.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_logging.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_sustained_bandwidth_recorder.h b/chromium/net/third_party/quiche/src/quic/core/quic_sustained_bandwidth_recorder.h index 5d868b22ffd..f1fdfebe1f1 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_sustained_bandwidth_recorder.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_sustained_bandwidth_recorder.h @@ -7,10 +7,10 @@ #include <cstdint> -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -44,22 +44,22 @@ class QUIC_EXPORT_PRIVATE QuicSustainedBandwidthRecorder { bool HasEstimate() const { return has_estimate_; } QuicBandwidth BandwidthEstimate() const { - DCHECK(has_estimate_); + QUICHE_DCHECK(has_estimate_); return bandwidth_estimate_; } QuicBandwidth MaxBandwidthEstimate() const { - DCHECK(has_estimate_); + QUICHE_DCHECK(has_estimate_); return max_bandwidth_estimate_; } int64_t MaxBandwidthTimestamp() const { - DCHECK(has_estimate_); + QUICHE_DCHECK(has_estimate_); return max_bandwidth_timestamp_; } bool EstimateRecordedDuringSlowStart() const { - DCHECK(has_estimate_); + QUICHE_DCHECK(has_estimate_); return bandwidth_estimate_recorded_during_slow_start_; } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_sustained_bandwidth_recorder_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_sustained_bandwidth_recorder_test.cc index 28bbad8fc77..1231ee1761d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_sustained_bandwidth_recorder_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_sustained_bandwidth_recorder_test.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_sustained_bandwidth_recorder.h" +#include "quic/core/quic_sustained_bandwidth_recorder.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_syscall_wrapper.cc b/chromium/net/third_party/quiche/src/quic/core/quic_syscall_wrapper.cc index b2404c6ee97..a98331f60f9 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_syscall_wrapper.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_syscall_wrapper.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_syscall_wrapper.h" +#include "quic/core/quic_syscall_wrapper.h" #include <atomic> #include <cerrno> diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_syscall_wrapper.h b/chromium/net/third_party/quiche/src/quic/core/quic_syscall_wrapper.h index 3a80ac6f6cf..5b99d0a0345 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_syscall_wrapper.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_syscall_wrapper.h @@ -8,7 +8,7 @@ #include <sys/socket.h> #include <sys/types.h> -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" struct mmsghdr; namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_tag.cc b/chromium/net/third_party/quiche/src/quic/core/quic_tag.cc index 5b38a8b3a78..a6305b086f3 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_tag.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_tag.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_tag.h" +#include "quic/core/quic_tag.h" #include <algorithm> #include <string> @@ -10,9 +10,9 @@ #include "absl/base/macros.h" #include "absl/strings/escaping.h" #include "absl/strings/str_split.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_tag.h b/chromium/net/third_party/quiche/src/quic/core/quic_tag.h index 606d89d16ad..c77219eb321 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_tag.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_tag.h @@ -10,7 +10,7 @@ #include <vector> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_tag_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_tag_test.cc index 13c899edd41..71617f3751d 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_tag_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_tag_test.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_tag.h" +#include "quic/core/quic_tag.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_time.cc b/chromium/net/third_party/quiche/src/quic/core/quic_time.cc index b7a12fe8923..daf8e299dcd 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_time.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_time.cc @@ -2,32 +2,34 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_time.h" +#include "quic/core/quic_time.h" #include <cinttypes> #include <cstdlib> #include <limits> #include <string> -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_cat.h" namespace quic { std::string QuicTime::Delta::ToDebuggingValue() const { - const int64_t one_ms = 1000; - const int64_t one_s = 1000 * one_ms; + constexpr int64_t kMillisecondInMicroseconds = 1000; + constexpr int64_t kSecondInMicroseconds = 1000 * kMillisecondInMicroseconds; int64_t absolute_value = std::abs(time_offset_); // For debugging purposes, always display the value with the highest precision // available. - if (absolute_value > one_s && absolute_value % one_s == 0) { - return quiche::QuicheStringPrintf("%" PRId64 "s", time_offset_ / one_s); + if (absolute_value > kSecondInMicroseconds && + absolute_value % kSecondInMicroseconds == 0) { + return absl::StrCat(time_offset_ / kSecondInMicroseconds, "s"); } - if (absolute_value > one_ms && absolute_value % one_ms == 0) { - return quiche::QuicheStringPrintf("%" PRId64 "ms", time_offset_ / one_ms); + if (absolute_value > kMillisecondInMicroseconds && + absolute_value % kMillisecondInMicroseconds == 0) { + return absl::StrCat(time_offset_ / kMillisecondInMicroseconds, "ms"); } - return quiche::QuicheStringPrintf("%" PRId64 "us", time_offset_); + return absl::StrCat(time_offset_, "us"); } uint64_t QuicWallTime::ToUNIXSeconds() const { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_time.h b/chromium/net/third_party/quiche/src/quic/core/quic_time.h index 079b59a6bdc..5fe9b2e672b 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_time.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_time.h @@ -19,7 +19,7 @@ #include <ostream> #include <string> -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" // TODO(vasilvv): replace with ABSL_MUST_USE_RESULT once we're using absl. #if defined(__clang__) @@ -245,7 +245,7 @@ inline bool operator>=(QuicTime lhs, QuicTime rhs) { return !(lhs < rhs); } -// Override stream output operator for gtest or CHECK macros. +// Override stream output operator for gtest or QUICHE_CHECK macros. inline std::ostream& operator<<(std::ostream& output, const QuicTime t) { output << t.ToDebuggingValue(); return output; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_time_accumulator.h b/chromium/net/third_party/quiche/src/quic/core/quic_time_accumulator.h index 6535d74c45b..8680cb61645 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_time_accumulator.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_time_accumulator.h @@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_CORE_QUIC_TIME_ACCUMULATOR_H_ #define QUICHE_QUIC_CORE_QUIC_TIME_ACCUMULATOR_H_ -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -23,18 +23,18 @@ class QUIC_EXPORT_PRIVATE QuicTimeAccumulator { bool IsRunning() const { return last_start_time_ != NotRunningSentinel(); } void Start(QuicTime now) { - DCHECK(!IsRunning()); + QUICHE_DCHECK(!IsRunning()); last_start_time_ = now; - DCHECK(IsRunning()); + QUICHE_DCHECK(IsRunning()); } void Stop(QuicTime now) { - DCHECK(IsRunning()); + QUICHE_DCHECK(IsRunning()); if (now > last_start_time_) { total_elapsed_ = total_elapsed_ + (now - last_start_time_); } last_start_time_ = NotRunningSentinel(); - DCHECK(!IsRunning()); + QUICHE_DCHECK(!IsRunning()); } // Get total elapsed time between COMPLETED Start/Stop pairs. diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_time_accumulator_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_time_accumulator_test.cc index e7bc43a0459..35980065310 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_time_accumulator_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_time_accumulator_test.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_time_accumulator.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 "quic/core/quic_time_accumulator.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_time_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_time_test.cc index 2e2838a4b51..eaaf75568d8 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_time_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_time_test.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_time.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 "quic/core/quic_time.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_time_wait_list_manager.cc b/chromium/net/third_party/quiche/src/quic/core/quic_time_wait_list_manager.cc index 769a9c5c43f..641f5c90c03 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_time_wait_list_manager.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_time_wait_list_manager.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_time_wait_list_manager.h" +#include "quic/core/quic_time_wait_list_manager.h" #include <errno.h> @@ -10,20 +10,20 @@ #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/quic_clock.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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_map_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/quic_clock.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_map_util.h" +#include "quic/platform/api/quic_socket_address.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { @@ -49,16 +49,21 @@ class ConnectionIdCleanUpAlarm : public QuicAlarm::Delegate { TimeWaitConnectionInfo::TimeWaitConnectionInfo( bool ietf_quic, - std::vector<std::unique_ptr<QuicEncryptedPacket>>* termination_packets) + std::vector<std::unique_ptr<QuicEncryptedPacket>>* termination_packets, + std::vector<QuicConnectionId> active_connection_ids) : TimeWaitConnectionInfo(ietf_quic, termination_packets, + std::move(active_connection_ids), QuicTime::Delta::Zero()) {} TimeWaitConnectionInfo::TimeWaitConnectionInfo( bool ietf_quic, std::vector<std::unique_ptr<QuicEncryptedPacket>>* termination_packets, + std::vector<QuicConnectionId> active_connection_ids, QuicTime::Delta srtt) - : ietf_quic(ietf_quic), srtt(srtt) { + : ietf_quic(ietf_quic), + active_connection_ids(std::move(active_connection_ids)), + srtt(srtt) { if (termination_packets != nullptr) { this->termination_packets.swap(*termination_packets); } @@ -83,35 +88,91 @@ QuicTimeWaitListManager::~QuicTimeWaitListManager() { connection_id_clean_up_alarm_->Cancel(); } +QuicTimeWaitListManager::ConnectionIdMap::iterator +QuicTimeWaitListManager::FindConnectionIdDataInMap( + const QuicConnectionId& connection_id) { + if (!use_indirect_connection_id_map_) { + return connection_id_map_.find(connection_id); + } + auto it = indirect_connection_id_map_.find(connection_id); + if (it == indirect_connection_id_map_.end()) { + return connection_id_map_.end(); + } + return connection_id_map_.find(it->second); +} + +void QuicTimeWaitListManager::AddConnectionIdDataToMap( + const QuicConnectionId& canonical_connection_id, + int num_packets, + TimeWaitAction action, + TimeWaitConnectionInfo info) { + if (use_indirect_connection_id_map_) { + QUIC_RESTART_FLAG_COUNT_N(quic_time_wait_list_support_multiple_cid_v2, 1, + 3); + for (const auto& cid : info.active_connection_ids) { + indirect_connection_id_map_[cid] = canonical_connection_id; + } + } + ConnectionIdData data(num_packets, clock_->ApproximateNow(), action, + std::move(info)); + connection_id_map_.emplace( + std::make_pair(canonical_connection_id, std::move(data))); +} + +void QuicTimeWaitListManager::RemoveConnectionDataFromMap( + ConnectionIdMap::iterator it) { + if (use_indirect_connection_id_map_) { + QUIC_RESTART_FLAG_COUNT_N(quic_time_wait_list_support_multiple_cid_v2, 2, + 3); + for (const auto& cid : it->second.info.active_connection_ids) { + indirect_connection_id_map_.erase(cid); + } + } + connection_id_map_.erase(it); +} + void QuicTimeWaitListManager::AddConnectionIdToTimeWait( QuicConnectionId connection_id, TimeWaitAction action, TimeWaitConnectionInfo info) { - DCHECK(action != SEND_TERMINATION_PACKETS || - !info.termination_packets.empty()); - DCHECK(action != DO_NOTHING || info.ietf_quic); + QUICHE_DCHECK(!info.active_connection_ids.empty()); + const QuicConnectionId& canonical_connection_id = + use_indirect_connection_id_map_ ? info.active_connection_ids.front() + : connection_id; + QUICHE_DCHECK(action != SEND_TERMINATION_PACKETS || + !info.termination_packets.empty()); + QUICHE_DCHECK(action != DO_NOTHING || info.ietf_quic); int num_packets = 0; - auto it = connection_id_map_.find(connection_id); + auto it = FindConnectionIdDataInMap(canonical_connection_id); const bool new_connection_id = it == connection_id_map_.end(); if (!new_connection_id) { // Replace record if it is reinserted. num_packets = it->second.num_packets; - connection_id_map_.erase(it); + RemoveConnectionDataFromMap(it); } TrimTimeWaitListIfNeeded(); int64_t max_connections = GetQuicFlag(FLAGS_quic_time_wait_list_max_connections); - DCHECK(connection_id_map_.empty() || - num_connections() < static_cast<size_t>(max_connections)); - ConnectionIdData data(num_packets, clock_->ApproximateNow(), action, - std::move(info)); - connection_id_map_.emplace(std::make_pair(connection_id, std::move(data))); - if (new_connection_id) { - visitor_->OnConnectionAddedToTimeWaitList(connection_id); + QUICHE_DCHECK(connection_id_map_.empty() || + num_connections() < static_cast<size_t>(max_connections)); + if (use_indirect_connection_id_map_ && new_connection_id) { + QUIC_RESTART_FLAG_COUNT_N(quic_time_wait_list_support_multiple_cid_v2, 3, + 3); + for (const auto& cid : info.active_connection_ids) { + visitor_->OnConnectionAddedToTimeWaitList(cid); + } + } + AddConnectionIdDataToMap(canonical_connection_id, num_packets, action, + std::move(info)); + if (!use_indirect_connection_id_map_ && new_connection_id) { + visitor_->OnConnectionAddedToTimeWaitList(canonical_connection_id); } } bool QuicTimeWaitListManager::IsConnectionIdInTimeWait( QuicConnectionId connection_id) const { + if (use_indirect_connection_id_map_) { + return indirect_connection_id_map_.contains(connection_id); + } return QuicContainsKey(connection_id_map_, connection_id); } @@ -132,11 +193,11 @@ void QuicTimeWaitListManager::ProcessPacket( QuicConnectionId connection_id, PacketHeaderFormat header_format, std::unique_ptr<QuicPerPacketContext> packet_context) { - DCHECK(IsConnectionIdInTimeWait(connection_id)); + QUICHE_DCHECK(IsConnectionIdInTimeWait(connection_id)); // TODO(satyamshekhar): Think about handling packets from different peer // addresses. - auto it = connection_id_map_.find(connection_id); - DCHECK(it != connection_id_map_.end()); + auto it = FindConnectionIdDataInMap(connection_id); + QUICHE_DCHECK(it != connection_id_map_.end()); // Increment the received packet count. ConnectionIdData* connection_data = &it->second; ++(connection_data->num_packets); @@ -217,7 +278,7 @@ void QuicTimeWaitListManager::ProcessPacket( return; case DO_NOTHING: QUIC_CODE_COUNT(quic_time_wait_list_do_nothing); - DCHECK(connection_data->info.ietf_quic); + QUICHE_DCHECK(connection_data->info.ietf_quic); } } @@ -341,7 +402,7 @@ bool QuicTimeWaitListManager::WriteToWire(QueuedPacket* queued_packet) { if (IsWriteBlockedStatus(result.status)) { // If blocked and unbuffered, return false to retry sending. - DCHECK(writer_->IsWriteBlocked()); + QUICHE_DCHECK(writer_->IsWriteBlocked()); visitor_->OnWriteBlocked(this); return result.status == WRITE_STATUS_BLOCKED_DATA_BUFFERED; } else if (IsWriteError(result.status)) { @@ -388,7 +449,7 @@ bool QuicTimeWaitListManager::MaybeExpireOldestConnection( // This connection_id has lived its age, retire it now. QUIC_DLOG(INFO) << "Connection " << it->first << " expired from time wait list"; - connection_id_map_.erase(it); + RemoveConnectionDataFromMap(it); if (expiration_time == QuicTime::Infinite()) { QUIC_CODE_COUNT(quic_time_wait_list_trim_full); } else { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_time_wait_list_manager.h b/chromium/net/third_party/quiche/src/quic/core/quic_time_wait_list_manager.h index d1286919ed5..9b3739b958c 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_time_wait_list_manager.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_time_wait_list_manager.h @@ -11,13 +11,15 @@ #include <cstddef> #include <memory> -#include "net/third_party/quiche/src/quic/core/quic_blocked_writer_interface.h" -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "absl/container/flat_hash_map.h" +#include "quic/core/quic_blocked_writer_interface.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_packet_writer.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_session.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_flags.h" namespace quic { @@ -31,10 +33,12 @@ class QuicTimeWaitListManagerPeer; struct QUIC_NO_EXPORT TimeWaitConnectionInfo { TimeWaitConnectionInfo( bool ietf_quic, - std::vector<std::unique_ptr<QuicEncryptedPacket>>* termination_packets); + std::vector<std::unique_ptr<QuicEncryptedPacket>>* termination_packets, + std::vector<QuicConnectionId> active_connection_ids); TimeWaitConnectionInfo( bool ietf_quic, std::vector<std::unique_ptr<QuicEncryptedPacket>>* termination_packets, + std::vector<QuicConnectionId> active_connection_ids, QuicTime::Delta srtt); TimeWaitConnectionInfo(const TimeWaitConnectionInfo& other) = delete; @@ -44,6 +48,7 @@ struct QUIC_NO_EXPORT TimeWaitConnectionInfo { bool ietf_quic; std::vector<std::unique_ptr<QuicEncryptedPacket>> termination_packets; + std::vector<QuicConnectionId> active_connection_ids; QuicTime::Delta srtt; }; @@ -111,8 +116,8 @@ class QUIC_NO_EXPORT QuicTimeWaitListManager // Called when a packet is received for a connection_id that is in time wait // state. Sends a public reset packet to the peer which sent this // connection_id. Sending of the public reset packet is throttled by using - // exponential back off. DCHECKs for the connection_id to be in time wait - // state. virtual to override in tests. + // exponential back off. QUICHE_DCHECKs for the connection_id to be in time + // wait state. virtual to override in tests. virtual void ProcessPacket( const QuicSocketAddress& self_address, const QuicSocketAddress& peer_address, @@ -278,8 +283,33 @@ class QUIC_NO_EXPORT QuicTimeWaitListManager using ConnectionIdMap = QuicLinkedHashMap<QuicConnectionId, ConnectionIdData, QuicConnectionIdHash>; + // Do not use find/emplace/erase on this map directly. Use + // FindConnectionIdDataInMap, AddConnectionIdDateToMap, + // RemoveConnectionDataFromMap instead. ConnectionIdMap connection_id_map_; + // TODO(haoyuewang) Consider making connection_id_map_ a map of shared pointer + // and remove the indirect map. + // A connection can have multiple unretired ConnectionIds when it is closed. + // These Ids have the same ConnectionIdData entry in connection_id_map_. To + // find the entry, look up the cannoical ConnectionId in + // indirect_connection_id_map_ first, and look up connection_id_map_ with the + // cannoical ConnectionId. + absl::flat_hash_map<QuicConnectionId, QuicConnectionId, QuicConnectionIdHash> + indirect_connection_id_map_; + + // Find an iterator for the given connection_id. Returns + // connection_id_map_.end() if none found. + ConnectionIdMap::iterator FindConnectionIdDataInMap( + const QuicConnectionId& connection_id); + // Inserts a ConnectionIdData entry to connection_id_map_. + void AddConnectionIdDataToMap(const QuicConnectionId& canonical_connection_id, + int num_packets, + TimeWaitAction action, + TimeWaitConnectionInfo info); + // Removes a ConnectionIdData entry in connection_id_map_. + void RemoveConnectionDataFromMap(ConnectionIdMap::iterator it); + // Pending termination packets that need to be sent out to the peer when we // are given a chance to write by the dispatcher. QuicCircularDeque<std::unique_ptr<QueuedPacket>> pending_packets_queue_; @@ -299,6 +329,11 @@ class QUIC_NO_EXPORT QuicTimeWaitListManager // Interface that manages blocked writers. Visitor* visitor_; + + // When this is default true, remove the connection_id argument of + // AddConnectionIdToTimeWait. + bool use_indirect_connection_id_map_ = + GetQuicRestartFlag(quic_time_wait_list_support_multiple_cid_v2); }; } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_time_wait_list_manager_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_time_wait_list_manager_test.cc index 34c2b1e97a5..189d3f09b21 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_time_wait_list_manager_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_time_wait_list_manager_test.cc @@ -2,28 +2,29 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_time_wait_list_manager.h" +#include "quic/core/quic_time_wait_list_manager.h" #include <cerrno> #include <memory> #include <ostream> #include <utility> -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/quic_data_reader.h" -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h" -#include "net/third_party/quiche/src/quic/test_tools/mock_quic_session_visitor.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_time_wait_list_manager_peer.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_data_reader.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_packet_writer.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_uint128.h" +#include "quic/test_tools/mock_quic_session_visitor.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/quic_time_wait_list_manager_peer.h" using testing::_; using testing::Args; @@ -154,7 +155,7 @@ class QuicTimeWaitListManagerTest : public QuicTest { new QuicEncryptedPacket(nullptr, 0, false))); time_wait_list_manager_.AddConnectionIdToTimeWait( connection_id, QuicTimeWaitListManager::SEND_TERMINATION_PACKETS, - TimeWaitConnectionInfo(false, &termination_packets)); + TimeWaitConnectionInfo(false, &termination_packets, {connection_id})); } void AddConnectionId( @@ -164,8 +165,8 @@ class QuicTimeWaitListManagerTest : public QuicTest { std::vector<std::unique_ptr<QuicEncryptedPacket>>* packets) { time_wait_list_manager_.AddConnectionIdToTimeWait( connection_id, action, - TimeWaitConnectionInfo( - VersionHasIetfInvariantHeader(version.transport_version), packets)); + TimeWaitConnectionInfo(version.HasIetfInvariantHeader(), packets, + {connection_id})); } bool IsConnectionIdInTimeWait(QuicConnectionId connection_id) { @@ -444,6 +445,46 @@ TEST_F(QuicTimeWaitListManagerTest, CleanUpOldConnectionIds) { time_wait_list_manager_.num_connections()); } +TEST_F(QuicTimeWaitListManagerTest, + CleanUpOldConnectionIdsForMultipleConnectionIdsPerConnection) { + if (!GetQuicRestartFlag(quic_time_wait_list_support_multiple_cid_v2)) { + return; + } + + connection_id_ = TestConnectionId(7); + const size_t kConnectionCloseLength = 100; + EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_)); + EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(TestConnectionId(8))); + std::vector<std::unique_ptr<QuicEncryptedPacket>> termination_packets; + termination_packets.push_back( + std::unique_ptr<QuicEncryptedPacket>(new QuicEncryptedPacket( + new char[kConnectionCloseLength], kConnectionCloseLength, true))); + + // Add a CONNECTION_CLOSE termination packet. + std::vector<QuicConnectionId> active_connection_ids{connection_id_, + TestConnectionId(8)}; + time_wait_list_manager_.AddConnectionIdToTimeWait( + connection_id_, QuicTimeWaitListManager::SEND_CONNECTION_CLOSE_PACKETS, + TimeWaitConnectionInfo(/*ietf_quic=*/true, &termination_packets, + active_connection_ids, QuicTime::Delta::Zero())); + + EXPECT_TRUE( + time_wait_list_manager_.IsConnectionIdInTimeWait(TestConnectionId(7))); + EXPECT_TRUE( + time_wait_list_manager_.IsConnectionIdInTimeWait(TestConnectionId(8))); + + // Remove these IDs. + const QuicTime::Delta time_wait_period = + QuicTimeWaitListManagerPeer::time_wait_period(&time_wait_list_manager_); + clock_.AdvanceTime(time_wait_period); + time_wait_list_manager_.CleanUpOldConnectionIds(); + + EXPECT_FALSE( + time_wait_list_manager_.IsConnectionIdInTimeWait(TestConnectionId(7))); + EXPECT_FALSE( + time_wait_list_manager_.IsConnectionIdInTimeWait(TestConnectionId(8))); +} + TEST_F(QuicTimeWaitListManagerTest, SendQueuedPackets) { QuicConnectionId connection_id = TestConnectionId(1); EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id)); @@ -632,7 +673,8 @@ TEST_F(QuicTimeWaitListManagerTest, new char[kConnectionCloseLength], kConnectionCloseLength, true))); time_wait_list_manager_.AddConnectionIdToTimeWait( connection_id_, QuicTimeWaitListManager::SEND_TERMINATION_PACKETS, - TimeWaitConnectionInfo(/*ietf_quic=*/true, &termination_packets)); + TimeWaitConnectionInfo(/*ietf_quic=*/true, &termination_packets, + {connection_id_})); // Termination packet is not encrypted, instead, send stateless reset. EXPECT_CALL(writer_, @@ -656,7 +698,8 @@ TEST_F(QuicTimeWaitListManagerTest, // Add a CONNECTION_CLOSE termination packet. time_wait_list_manager_.AddConnectionIdToTimeWait( connection_id_, QuicTimeWaitListManager::SEND_CONNECTION_CLOSE_PACKETS, - TimeWaitConnectionInfo(/*ietf_quic=*/true, &termination_packets)); + TimeWaitConnectionInfo(/*ietf_quic=*/true, &termination_packets, + {connection_id_})); EXPECT_CALL(writer_, WritePacket(_, kConnectionCloseLength, self_address_.host(), peer_address_, _)) .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 1))); @@ -667,6 +710,41 @@ TEST_F(QuicTimeWaitListManagerTest, IETF_QUIC_SHORT_HEADER_PACKET, std::make_unique<QuicPerPacketContext>()); } +TEST_F(QuicTimeWaitListManagerTest, + SendConnectionClosePacketsForMultipleConnectionIds) { + if (!GetQuicRestartFlag(quic_time_wait_list_support_multiple_cid_v2)) { + return; + } + + connection_id_ = TestConnectionId(7); + const size_t kConnectionCloseLength = 100; + EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_)); + EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(TestConnectionId(8))); + std::vector<std::unique_ptr<QuicEncryptedPacket>> termination_packets; + termination_packets.push_back( + std::unique_ptr<QuicEncryptedPacket>(new QuicEncryptedPacket( + new char[kConnectionCloseLength], kConnectionCloseLength, true))); + + // Add a CONNECTION_CLOSE termination packet. + std::vector<QuicConnectionId> active_connection_ids{connection_id_, + TestConnectionId(8)}; + time_wait_list_manager_.AddConnectionIdToTimeWait( + connection_id_, QuicTimeWaitListManager::SEND_CONNECTION_CLOSE_PACKETS, + TimeWaitConnectionInfo(/*ietf_quic=*/true, &termination_packets, + active_connection_ids, QuicTime::Delta::Zero())); + + EXPECT_CALL(writer_, WritePacket(_, kConnectionCloseLength, + self_address_.host(), peer_address_, _)) + .Times(2) + .WillRepeatedly(Return(WriteResult(WRITE_STATUS_OK, 1))); + // Processes IETF short header packet. + for (auto const& cid : active_connection_ids) { + time_wait_list_manager_.ProcessPacket( + self_address_, peer_address_, cid, IETF_QUIC_SHORT_HEADER_PACKET, + std::make_unique<QuicPerPacketContext>()); + } +} + } // namespace } // namespace test } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_trace_visitor.cc b/chromium/net/third_party/quiche/src/quic/core/quic_trace_visitor.cc index 7ac7b7bd29d..381d29bd5e3 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_trace_visitor.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_trace_visitor.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_trace_visitor.h" +#include "quic/core/quic_trace_visitor.h" #include <string> -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/core/quic_types.h" +#include "common/quiche_endian.h" namespace quic { @@ -44,70 +44,6 @@ QuicTraceVisitor::QuicTraceVisitor(const QuicConnection* connection) } } -void QuicTraceVisitor::OnPacketSent(const SerializedPacket& serialized_packet, - TransmissionType /*transmission_type*/, - QuicTime sent_time) { - quic_trace::Event* event = trace_.add_events(); - event->set_event_type(quic_trace::PACKET_SENT); - event->set_time_us(ConvertTimestampToRecordedFormat(sent_time)); - event->set_packet_number(serialized_packet.packet_number.ToUint64()); - event->set_packet_size(serialized_packet.encrypted_length); - event->set_encryption_level( - EncryptionLevelToProto(serialized_packet.encryption_level)); - - for (const QuicFrame& frame : serialized_packet.retransmittable_frames) { - switch (frame.type) { - case STREAM_FRAME: - case RST_STREAM_FRAME: - case CONNECTION_CLOSE_FRAME: - case WINDOW_UPDATE_FRAME: - case BLOCKED_FRAME: - case PING_FRAME: - case HANDSHAKE_DONE_FRAME: - case ACK_FREQUENCY_FRAME: - PopulateFrameInfo(frame, event->add_frames()); - break; - - case PADDING_FRAME: - case MTU_DISCOVERY_FRAME: - case STOP_WAITING_FRAME: - case ACK_FRAME: - QUIC_BUG - << "Frames of type are not retransmittable and are not supposed " - "to be in retransmittable_frames"; - break; - - // New IETF frames, not used in current gQUIC version. - case NEW_CONNECTION_ID_FRAME: - case RETIRE_CONNECTION_ID_FRAME: - case MAX_STREAMS_FRAME: - case STREAMS_BLOCKED_FRAME: - case PATH_RESPONSE_FRAME: - case PATH_CHALLENGE_FRAME: - case STOP_SENDING_FRAME: - case MESSAGE_FRAME: - case CRYPTO_FRAME: - case NEW_TOKEN_FRAME: - break; - - // Ignore gQUIC-specific frames. - case GOAWAY_FRAME: - break; - - case NUM_FRAME_TYPES: - QUIC_BUG << "Unknown frame type encountered"; - break; - } - } - - // Output PCC DebugState on packet sent for analysis. - if (connection_->sent_packet_manager() - .GetSendAlgorithm() - ->GetCongestionControlType() == kPCC) { - PopulateTransportState(event->mutable_transport_state()); - } -} - void QuicTraceVisitor::OnPacketSent( QuicPacketNumber packet_number, QuicPacketLength packet_length, diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_trace_visitor.h b/chromium/net/third_party/quiche/src/quic/core/quic_trace_visitor.h index 889d90a06c0..47d543a0d7f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_trace_visitor.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_trace_visitor.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_CORE_QUIC_TRACE_VISITOR_H_ #define QUICHE_QUIC_CORE_QUIC_TRACE_VISITOR_H_ -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_types.h" #include "third_party/quic_trace/lib/quic_trace.pb.h" namespace quic { @@ -18,12 +18,6 @@ class QUIC_NO_EXPORT QuicTraceVisitor : public QuicConnectionDebugVisitor { public: explicit QuicTraceVisitor(const QuicConnection* connection); - // TODO(wub): Delete when deprecating - // --quic_give_sent_packet_to_debug_visitor_after_sent. - void OnPacketSent(const SerializedPacket& serialized_packet, - TransmissionType transmission_type, - QuicTime sent_time) override; - void OnPacketSent(QuicPacketNumber packet_number, QuicPacketLength packet_length, bool has_crypto_handshake, diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_trace_visitor_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_trace_visitor_test.cc index 07bc4f2ea37..4deec7cfec7 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_trace_visitor_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_trace_visitor_test.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_trace_visitor.h" +#include "quic/core/quic_trace_visitor.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/simulator.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/switch.h" +#include "quic/core/quic_constants.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/simulator/quic_endpoint.h" +#include "quic/test_tools/simulator/simulator.h" +#include "quic/test_tools/simulator/switch.h" namespace quic { namespace { @@ -48,11 +48,11 @@ class QuicTraceVisitorTest : public QuicTest { client.AddBytesToTransfer(kTransferSize); bool simulator_result = simulator.RunUntilOrTimeout( [&]() { return server.bytes_received() >= kTransferSize; }, kDeadline); - CHECK(simulator_result); + QUICHE_CHECK(simulator_result); // Save the trace and ensure some loss was observed. trace_.Swap(visitor.trace()); - CHECK_NE(0u, client.connection()->GetStats().packets_retransmitted); + QUICHE_CHECK_NE(0u, client.connection()->GetStats().packets_retransmitted); packets_sent_ = client.connection()->GetStats().packets_sent; } @@ -81,7 +81,9 @@ TEST_F(QuicTraceVisitorTest, ConnectionId) { TEST_F(QuicTraceVisitorTest, Version) { std::string version = trace_.protocol_version(); ASSERT_EQ(4u, version.size()); - EXPECT_NE(0, version[0]); + // Ensure version isn't all-zeroes. + EXPECT_TRUE(version[0] != 0 || version[1] != 0 || version[2] != 0 || + version[3] != 0); } // Check that basic metadata about sent packets is recorded. diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_transmission_info.cc b/chromium/net/third_party/quiche/src/quic/core/quic_transmission_info.cc index 3d33c998d27..9ec0f39be72 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_transmission_info.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_transmission_info.cc @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_transmission_info.h" +#include "quic/core/quic_transmission_info.h" +#include "absl/strings/str_cat.h" namespace quic { @@ -36,4 +37,19 @@ QuicTransmissionInfo::QuicTransmissionInfo(const QuicTransmissionInfo& other) = QuicTransmissionInfo::~QuicTransmissionInfo() {} +std::string QuicTransmissionInfo::DebugString() const { + return absl::StrCat( + "{sent_time: ", sent_time.ToDebuggingValue(), + ", bytes_sent: ", bytes_sent, + ", encryption_level: ", EncryptionLevelToString(encryption_level), + ", transmission_type: ", TransmissionTypeToString(transmission_type), + ", in_flight: ", in_flight, ", state: ", state, + ", has_crypto_handshake: ", has_crypto_handshake, + ", has_ack_frequency: ", has_ack_frequency, + ", first_sent_after_loss: ", first_sent_after_loss.ToString(), + ", largest_acked: ", largest_acked.ToString(), + ", retransmittable_frames: ", QuicFramesToString(retransmittable_frames), + "}"); +} + } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_transmission_info.h b/chromium/net/third_party/quiche/src/quic/core/quic_transmission_info.h index 61d1ad028cb..bc0f5f70706 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_transmission_info.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_transmission_info.h @@ -7,10 +7,10 @@ #include <list> -#include "net/third_party/quiche/src/quic/core/frames/quic_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_ack_listener_interface.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/frames/quic_frame.h" +#include "quic/core/quic_ack_listener_interface.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -32,6 +32,8 @@ struct QUIC_EXPORT_PRIVATE QuicTransmissionInfo { ~QuicTransmissionInfo(); + std::string DebugString() const; + QuicFrames retransmittable_frames; QuicTime sent_time; QuicPacketLength bytes_sent; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_types.cc b/chromium/net/third_party/quiche/src/quic/core/quic_types.cc index 9eb0a2752c8..f8182684e7f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_types.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_types.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/quic_types.h" #include <cstdint> -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_cat.h" +#include "quic/core/quic_error_codes.h" namespace quic { @@ -24,7 +24,7 @@ std::string PerspectiveToString(Perspective perspective) { if (perspective == Perspective::IS_CLIENT) { return "IS_CLIENT"; } - return quiche::QuicheStrCat("Unknown(", static_cast<int>(perspective), ")"); + return absl::StrCat("Unknown(", static_cast<int>(perspective), ")"); } std::ostream& operator<<(std::ostream& os, const Perspective& perspective) { @@ -40,8 +40,8 @@ std::string ConnectionCloseSourceToString( if (connection_close_source == ConnectionCloseSource::FROM_SELF) { return "FROM_SELF"; } - return quiche::QuicheStrCat("Unknown(", - static_cast<int>(connection_close_source), ")"); + return absl::StrCat("Unknown(", static_cast<int>(connection_close_source), + ")"); } std::ostream& operator<<(std::ostream& os, @@ -59,8 +59,8 @@ std::string ConnectionCloseBehaviorToString( ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET) { return "SEND_CONNECTION_CLOSE_PACKET"; } - return quiche::QuicheStrCat("Unknown(", - static_cast<int>(connection_close_behavior), ")"); + return absl::StrCat("Unknown(", static_cast<int>(connection_close_behavior), + ")"); } std::ostream& operator<<( @@ -155,7 +155,7 @@ std::string QuicFrameTypeToString(QuicFrameType t) { RETURN_STRING_LITERAL(ACK_FREQUENCY_FRAME) RETURN_STRING_LITERAL(NUM_FRAME_TYPES) } - return quiche::QuicheStrCat("Unknown(", static_cast<int>(t), ")"); + return absl::StrCat("Unknown(", static_cast<int>(t), ")"); } std::ostream& operator<<(std::ostream& os, const QuicFrameType& t) { @@ -196,7 +196,7 @@ std::string QuicIetfFrameTypeString(QuicIetfFrameType t) { RETURN_STRING_LITERAL(IETF_EXTENSION_MESSAGE_NO_LENGTH_V99); RETURN_STRING_LITERAL(IETF_EXTENSION_MESSAGE_V99); default: - return quiche::QuicheStrCat("Private value (", t, ")"); + return absl::StrCat("Private value (", t, ")"); } } std::ostream& operator<<(std::ostream& os, const QuicIetfFrameType& c) { @@ -214,13 +214,14 @@ std::string TransmissionTypeToString(TransmissionType transmission_type) { RETURN_STRING_LITERAL(TLP_RETRANSMISSION); RETURN_STRING_LITERAL(PTO_RETRANSMISSION); RETURN_STRING_LITERAL(PROBING_RETRANSMISSION); + RETURN_STRING_LITERAL(PATH_RETRANSMISSION); + RETURN_STRING_LITERAL(ALL_INITIAL_RETRANSMISSION); default: // Some varz rely on this behavior for statistic collection. if (transmission_type == LAST_TRANSMISSION_TYPE + 1) { return "INVALID_TRANSMISSION_TYPE"; } - return quiche::QuicheStrCat("Unknown(", - static_cast<int>(transmission_type), ")"); + return absl::StrCat("Unknown(", static_cast<int>(transmission_type), ")"); break; } } @@ -236,7 +237,7 @@ std::string PacketHeaderFormatToString(PacketHeaderFormat format) { RETURN_STRING_LITERAL(IETF_QUIC_SHORT_HEADER_PACKET); RETURN_STRING_LITERAL(GOOGLE_QUIC_PACKET); default: - return quiche::QuicheStrCat("Unknown (", static_cast<int>(format), ")"); + return absl::StrCat("Unknown (", static_cast<int>(format), ")"); } } @@ -249,7 +250,7 @@ std::string QuicLongHeaderTypeToString(QuicLongHeaderType type) { RETURN_STRING_LITERAL(RETRY); RETURN_STRING_LITERAL(INVALID_PACKET_TYPE); default: - return quiche::QuicheStrCat("Unknown (", static_cast<int>(type), ")"); + return absl::StrCat("Unknown (", static_cast<int>(type), ")"); } } @@ -262,19 +263,17 @@ std::string MessageStatusToString(MessageStatus message_status) { RETURN_STRING_LITERAL(MESSAGE_STATUS_TOO_LARGE); RETURN_STRING_LITERAL(MESSAGE_STATUS_INTERNAL_ERROR); default: - return quiche::QuicheStrCat("Unknown(", static_cast<int>(message_status), - ")"); + return absl::StrCat("Unknown(", static_cast<int>(message_status), ")"); break; } } std::string MessageResultToString(MessageResult message_result) { if (message_result.status != MESSAGE_STATUS_SUCCESS) { - return quiche::QuicheStrCat( - "{", MessageStatusToString(message_result.status), "}"); + return absl::StrCat("{", MessageStatusToString(message_result.status), "}"); } - return quiche::QuicheStrCat( - "{MESSAGE_STATUS_SUCCESS,id=", message_result.message_id, "}"); + return absl::StrCat("{MESSAGE_STATUS_SUCCESS,id=", message_result.message_id, + "}"); } std::ostream& operator<<(std::ostream& os, const MessageResult& mr) { @@ -288,8 +287,8 @@ std::string PacketNumberSpaceToString(PacketNumberSpace packet_number_space) { RETURN_STRING_LITERAL(HANDSHAKE_DATA); RETURN_STRING_LITERAL(APPLICATION_DATA); default: - return quiche::QuicheStrCat("Unknown(", - static_cast<int>(packet_number_space), ")"); + return absl::StrCat("Unknown(", static_cast<int>(packet_number_space), + ")"); break; } } @@ -301,7 +300,7 @@ std::string SerializedPacketFateToString(SerializedPacketFate fate) { RETURN_STRING_LITERAL(SEND_TO_WRITER); RETURN_STRING_LITERAL(LEGACY_VERSION_ENCAPSULATE); default: - return quiche::QuicheStrCat("Unknown(", static_cast<int>(fate), ")"); + return absl::StrCat("Unknown(", static_cast<int>(fate), ")"); } } @@ -317,7 +316,7 @@ std::string EncryptionLevelToString(EncryptionLevel level) { RETURN_STRING_LITERAL(ENCRYPTION_ZERO_RTT); RETURN_STRING_LITERAL(ENCRYPTION_FORWARD_SECURE); default: - return quiche::QuicheStrCat("Unknown(", static_cast<int>(level), ")"); + return absl::StrCat("Unknown(", static_cast<int>(level), ")"); break; } } @@ -333,7 +332,7 @@ std::string QuicConnectionCloseTypeString(QuicConnectionCloseType type) { RETURN_STRING_LITERAL(IETF_QUIC_TRANSPORT_CONNECTION_CLOSE); RETURN_STRING_LITERAL(IETF_QUIC_APPLICATION_CONNECTION_CLOSE); default: - return quiche::QuicheStrCat("Unknown(", static_cast<int>(type), ")"); + return absl::StrCat("Unknown(", static_cast<int>(type), ")"); break; } } @@ -354,7 +353,7 @@ std::string AddressChangeTypeToString(AddressChangeType type) { RETURN_STRING_LITERAL(IPV6_TO_IPV4_CHANGE); RETURN_STRING_LITERAL(IPV6_TO_IPV6_CHANGE); default: - return quiche::QuicheStrCat("Unknown(", static_cast<IntType>(type), ")"); + return absl::StrCat("Unknown(", static_cast<IntType>(type), ")"); } } @@ -375,7 +374,7 @@ std::string KeyUpdateReasonString(KeyUpdateReason reason) { RETURN_REASON_LITERAL(kLocalAeadConfidentialityLimit); RETURN_REASON_LITERAL(kLocalKeyUpdateLimitOverride); default: - return quiche::QuicheStrCat("Unknown(", static_cast<int>(reason), ")"); + return absl::StrCat("Unknown(", static_cast<int>(reason), ")"); break; } #undef RETURN_REASON_LITERAL diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_types.h b/chromium/net/third_party/quiche/src/quic/core/quic_types.h index 5152a158055..7344cea6de3 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_types.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_types.h @@ -11,13 +11,13 @@ #include <ostream> #include <vector> -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_number.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_packet_number.h" +#include "quic/core/quic_time.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_flags.h" namespace quic { @@ -173,7 +173,11 @@ enum TransmissionType : int8_t { TLP_RETRANSMISSION, // Tail loss probes. PTO_RETRANSMISSION, // Retransmission due to probe timeout. PROBING_RETRANSMISSION, // Retransmission in order to probe bandwidth. - LAST_TRANSMISSION_TYPE = PROBING_RETRANSMISSION, + PATH_RETRANSMISSION, // Retransmission proactively due to underlying + // network change. + ALL_INITIAL_RETRANSMISSION, // Retransmit all packets encrypted with INITIAL + // key. + LAST_TRANSMISSION_TYPE = ALL_INITIAL_RETRANSMISSION, }; QUIC_EXPORT_PRIVATE std::string TransmissionTypeToString( @@ -530,10 +534,11 @@ enum SentPacketState : uint8_t { PTO_RETRANSMITTED, // This packet has been retransmitted for probing purpose. PROBE_RETRANSMITTED, - // Do not collect RTT sample if this packet is the largest_acked of an - // incoming ACK. + // This packet is sent on a different path or is a PING only packet. + // Do not update RTT stats and congestion control if the packet is the + // largest_acked of an incoming ACK. NOT_CONTRIBUTING_RTT, - LAST_PACKET_STATE = PROBE_RETRANSMITTED, + LAST_PACKET_STATE = NOT_CONTRIBUTING_RTT, }; enum PacketHeaderFormat : uint8_t { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_udp_socket.h b/chromium/net/third_party/quiche/src/quic/core/quic_udp_socket.h index 258de080118..534273c1d5f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_udp_socket.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_udp_socket.h @@ -10,10 +10,10 @@ #include <type_traits> -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { @@ -66,7 +66,7 @@ class QUIC_EXPORT_PRIVATE QuicUdpPacketInfo { bool HasValue(QuicUdpPacketInfoBit bit) const { return bitmask_.IsSet(bit); } QuicPacketCount dropped_packets() const { - DCHECK(HasValue(QuicUdpPacketInfoBit::DROPPED_PACKETS)); + QUICHE_DCHECK(HasValue(QuicUdpPacketInfoBit::DROPPED_PACKETS)); return dropped_packets_; } @@ -76,7 +76,7 @@ class QUIC_EXPORT_PRIVATE QuicUdpPacketInfo { } const QuicIpAddress& self_v4_ip() const { - DCHECK(HasValue(QuicUdpPacketInfoBit::V4_SELF_IP)); + QUICHE_DCHECK(HasValue(QuicUdpPacketInfoBit::V4_SELF_IP)); return self_v4_ip_; } @@ -86,7 +86,7 @@ class QUIC_EXPORT_PRIVATE QuicUdpPacketInfo { } const QuicIpAddress& self_v6_ip() const { - DCHECK(HasValue(QuicUdpPacketInfoBit::V6_SELF_IP)); + QUICHE_DCHECK(HasValue(QuicUdpPacketInfoBit::V6_SELF_IP)); return self_v6_ip_; } @@ -104,7 +104,7 @@ class QUIC_EXPORT_PRIVATE QuicUdpPacketInfo { } const QuicSocketAddress& peer_address() const { - DCHECK(HasValue(QuicUdpPacketInfoBit::PEER_ADDRESS)); + QUICHE_DCHECK(HasValue(QuicUdpPacketInfoBit::PEER_ADDRESS)); return peer_address_; } @@ -114,7 +114,7 @@ class QUIC_EXPORT_PRIVATE QuicUdpPacketInfo { } QuicWallTime receive_timestamp() const { - DCHECK(HasValue(QuicUdpPacketInfoBit::RECV_TIMESTAMP)); + QUICHE_DCHECK(HasValue(QuicUdpPacketInfoBit::RECV_TIMESTAMP)); return receive_timestamp_; } @@ -124,7 +124,7 @@ class QUIC_EXPORT_PRIVATE QuicUdpPacketInfo { } int ttl() const { - DCHECK(HasValue(QuicUdpPacketInfoBit::TTL)); + QUICHE_DCHECK(HasValue(QuicUdpPacketInfoBit::TTL)); return ttl_; } @@ -134,7 +134,7 @@ class QUIC_EXPORT_PRIVATE QuicUdpPacketInfo { } BufferSpan google_packet_headers() const { - DCHECK(HasValue(QuicUdpPacketInfoBit::GOOGLE_PACKET_HEADER)); + QUICHE_DCHECK(HasValue(QuicUdpPacketInfoBit::GOOGLE_PACKET_HEADER)); return google_packet_headers_; } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_udp_socket_posix.cc b/chromium/net/third_party/quiche/src/quic/core/quic_udp_socket_posix.cc index ea68727211c..e410635cef5 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_udp_socket_posix.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_udp_socket_posix.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_udp_socket.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_udp_socket_platform_api.h" +#include "quic/core/quic_udp_socket.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_udp_socket_platform_api.h" #include <arpa/inet.h> #include <fcntl.h> @@ -102,7 +102,7 @@ QuicUdpSocketFd CreateNonblockingSocket(int address_family) { void SetV4SelfIpInControlMessage(const QuicIpAddress& self_address, cmsghdr* cmsg) { - DCHECK(self_address.IsIPv4()); + QUICHE_DCHECK(self_address.IsIPv4()); in_pktinfo* pktinfo = reinterpret_cast<in_pktinfo*>(CMSG_DATA(cmsg)); memset(pktinfo, 0, sizeof(in_pktinfo)); pktinfo->ipi_ifindex = 0; @@ -113,7 +113,7 @@ void SetV4SelfIpInControlMessage(const QuicIpAddress& self_address, void SetV6SelfIpInControlMessage(const QuicIpAddress& self_address, cmsghdr* cmsg) { - DCHECK(self_address.IsIPv6()); + QUICHE_DCHECK(self_address.IsIPv6()); in6_pktinfo* pktinfo = reinterpret_cast<in6_pktinfo*>(CMSG_DATA(cmsg)); memset(pktinfo, 0, sizeof(in6_pktinfo)); std::string address_string = self_address.ToPackedString(); @@ -212,12 +212,12 @@ bool NextCmsg(msghdr* hdr, } if ((*cmsg) == nullptr) { - DCHECK_EQ(nullptr, hdr->msg_control); + QUICHE_DCHECK_EQ(nullptr, hdr->msg_control); memset(control_buffer, 0, control_buffer_len); hdr->msg_control = control_buffer; (*cmsg) = CMSG_FIRSTHDR(hdr); } else { - DCHECK_NE(nullptr, hdr->msg_control); + QUICHE_DCHECK_NE(nullptr, hdr->msg_control); (*cmsg) = CMSG_NXTHDR(hdr, (*cmsg)); } @@ -237,10 +237,10 @@ QuicUdpSocketFd QuicUdpSocketApi::Create(int address_family, int receive_buffer_size, int send_buffer_size, bool ipv6_only) { - // DCHECK here so the program exits early(before reading packets) in debug - // mode. This should have been a static_assert, however it can't be done on - // ios/osx because CMSG_SPACE isn't a constant expression there. - DCHECK_GE(kDefaultUdpPacketControlBufferSize, kMinCmsgSpaceForRead); + // QUICHE_DCHECK here so the program exits early(before reading packets) in + // debug mode. This should have been a static_assert, however it can't be done + // on ios/osx because CMSG_SPACE isn't a constant expression there. + QUICHE_DCHECK_GE(kDefaultUdpPacketControlBufferSize, kMinCmsgSpaceForRead); QuicUdpSocketFd fd = CreateNonblockingSocket(address_family); if (fd == kQuicInvalidSocketFd) { @@ -383,7 +383,7 @@ void QuicUdpSocketApi::ReadPacket(QuicUdpSocketFd fd, BufferSpan& control_buffer = result->control_buffer; QuicUdpPacketInfo* packet_info = &result->packet_info; - DCHECK_GE(control_buffer.buffer_len, kMinCmsgSpaceForRead); + QUICHE_DCHECK_GE(control_buffer.buffer_len, kMinCmsgSpaceForRead); struct iovec iov = {packet_buffer.buffer, packet_buffer.buffer_len}; struct sockaddr_storage raw_peer_address; @@ -488,7 +488,7 @@ size_t QuicUdpSocketApi::ReadMultiplePackets(QuicUdpSocketFd fd, hdr->msg_control = (*results)[i].control_buffer.buffer; hdr->msg_controllen = (*results)[i].control_buffer.buffer_len; - DCHECK_GE(hdr->msg_controllen, kMinCmsgSpaceForRead); + QUICHE_DCHECK_GE(hdr->msg_controllen, kMinCmsgSpaceForRead); } // If MSG_TRUNC is set on Linux, recvmmsg will return the real packet size in // |hdrs[i].msg_len| even if packet buffer is too small to receive it. diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_udp_socket_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_udp_socket_test.cc index f54b0edd073..400c38e6fda 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_udp_socket_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_udp_socket_test.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_udp_socket.h" +#include "quic/core/quic_udp_socket.h" #include <sys/socket.h> #ifdef __APPLE__ #include <TargetConditionals.h> #endif -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/quic_constants.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_unacked_packet_map.cc b/chromium/net/third_party/quiche/src/quic/core/quic_unacked_packet_map.cc index 852a0df2dc2..eeda2159092 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_unacked_packet_map.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_unacked_packet_map.cc @@ -2,17 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_unacked_packet_map.h" +#include "quic/core/quic_unacked_packet_map.h" #include <cstddef> #include <limits> #include <type_traits> -#include "net/third_party/quiche/src/quic/core/quic_connection_stats.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_number.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" +#include "quic/core/quic_connection_stats.h" +#include "quic/core/quic_packet_number.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" namespace quic { @@ -123,20 +124,11 @@ QuicUnackedPacketMap::QuicUnackedPacketMap(Perspective perspective) last_crypto_packet_sent_time_(QuicTime::Zero()), session_notifier_(nullptr), supports_multiple_packet_number_spaces_(false) { - if (use_circular_deque_) { - QUIC_RELOADABLE_FLAG_COUNT(quic_use_circular_deque_for_unacked_packets); - } } QuicUnackedPacketMap::~QuicUnackedPacketMap() { - if (use_circular_deque_) { - for (QuicTransmissionInfo& transmission_info : unacked_packets_) { - DeleteFrames(&(transmission_info.retransmittable_frames)); - } - } else { - for (QuicTransmissionInfo& transmission_info : unacked_packets_deque_) { - DeleteFrames(&(transmission_info.retransmittable_frames)); - } + for (QuicTransmissionInfo& transmission_info : unacked_packets_) { + DeleteFrames(&(transmission_info.retransmittable_frames)); } } @@ -152,10 +144,10 @@ void QuicUnackedPacketMap::AddSentPacket(SerializedPacket* mutable_packet, largest_sent_packet_ >= packet_number) << "largest_sent_packet_: " << largest_sent_packet_ << ", packet_number: " << packet_number; - DCHECK_GE(packet_number, least_unacked_ + unacked_packets_size()); - while (least_unacked_ + unacked_packets_size() < packet_number) { - unacked_packets_push_back(QuicTransmissionInfo()); - unacked_packets_back().state = NEVER_SENT; + QUICHE_DCHECK_GE(packet_number, least_unacked_ + unacked_packets_.size()); + while (least_unacked_ + unacked_packets_.size() < packet_number) { + unacked_packets_.push_back(QuicTransmissionInfo()); + unacked_packets_.back().state = NEVER_SENT; } const bool has_crypto_handshake = packet.has_crypto_handshake == IS_HANDSHAKE; @@ -182,7 +174,7 @@ void QuicUnackedPacketMap::AddSentPacket(SerializedPacket* mutable_packet, last_inflight_packet_sent_time_ = sent_time; last_inflight_packets_sent_time_[packet_number_space] = sent_time; } - unacked_packets_push_back(info); + unacked_packets_.push_back(info); // Swap the retransmittable frames to avoid allocations. // TODO(ianswett): Could use emplace_back when Chromium can. if (has_crypto_handshake) { @@ -190,26 +182,26 @@ void QuicUnackedPacketMap::AddSentPacket(SerializedPacket* mutable_packet, } mutable_packet->retransmittable_frames.swap( - unacked_packets_back().retransmittable_frames); + unacked_packets_.back().retransmittable_frames); } void QuicUnackedPacketMap::RemoveObsoletePackets() { - while (!unacked_packets_empty()) { - if (!IsPacketUseless(least_unacked_, unacked_packets_front())) { + while (!unacked_packets_.empty()) { + if (!IsPacketUseless(least_unacked_, unacked_packets_.front())) { break; } - DeleteFrames(&unacked_packets_front().retransmittable_frames); - unacked_packets_pop_front(); + DeleteFrames(&unacked_packets_.front().retransmittable_frames); + unacked_packets_.pop_front(); ++least_unacked_; } } bool QuicUnackedPacketMap::HasRetransmittableFrames( QuicPacketNumber packet_number) const { - DCHECK_GE(packet_number, least_unacked_); - DCHECK_LT(packet_number, least_unacked_ + unacked_packets_size()); + QUICHE_DCHECK_GE(packet_number, least_unacked_); + QUICHE_DCHECK_LT(packet_number, least_unacked_ + unacked_packets_.size()); return HasRetransmittableFrames( - unacked_packets_at(packet_number - least_unacked_)); + unacked_packets_[packet_number - least_unacked_]); } bool QuicUnackedPacketMap::HasRetransmittableFrames( @@ -234,16 +226,17 @@ void QuicUnackedPacketMap::RemoveRetransmittability( void QuicUnackedPacketMap::RemoveRetransmittability( QuicPacketNumber packet_number) { - DCHECK_GE(packet_number, least_unacked_); - DCHECK_LT(packet_number, least_unacked_ + unacked_packets_size()); + QUICHE_DCHECK_GE(packet_number, least_unacked_); + QUICHE_DCHECK_LT(packet_number, least_unacked_ + unacked_packets_.size()); QuicTransmissionInfo* info = - &unacked_packets_at(packet_number - least_unacked_); + &unacked_packets_[packet_number - least_unacked_]; RemoveRetransmittability(info); } void QuicUnackedPacketMap::IncreaseLargestAcked( QuicPacketNumber largest_acked) { - DCHECK(!largest_acked_.IsInitialized() || largest_acked_ <= largest_acked); + QUICHE_DCHECK(!largest_acked_.IsInitialized() || + largest_acked_ <= largest_acked); largest_acked_ = largest_acked; } @@ -287,11 +280,11 @@ bool QuicUnackedPacketMap::IsPacketUseless( bool QuicUnackedPacketMap::IsUnacked(QuicPacketNumber packet_number) const { if (packet_number < least_unacked_ || - packet_number >= least_unacked_ + unacked_packets_size()) { + packet_number >= least_unacked_ + unacked_packets_.size()) { return false; } return !IsPacketUseless(packet_number, - unacked_packets_at(packet_number - least_unacked_)); + unacked_packets_[packet_number - least_unacked_]); } void QuicUnackedPacketMap::RemoveFromInFlight(QuicTransmissionInfo* info) { @@ -324,10 +317,10 @@ void QuicUnackedPacketMap::RemoveFromInFlight(QuicTransmissionInfo* info) { } void QuicUnackedPacketMap::RemoveFromInFlight(QuicPacketNumber packet_number) { - DCHECK_GE(packet_number, least_unacked_); - DCHECK_LT(packet_number, least_unacked_ + unacked_packets_size()); + QUICHE_DCHECK_GE(packet_number, least_unacked_); + QUICHE_DCHECK_LT(packet_number, least_unacked_ + unacked_packets_.size()); QuicTransmissionInfo* info = - &unacked_packets_at(packet_number - least_unacked_); + &unacked_packets_[packet_number - least_unacked_]; RemoveFromInFlight(info); } @@ -350,11 +343,12 @@ QuicUnackedPacketMap::NeuterUnencryptedPackets() { // send algorithm). // TODO(b/148868195): use NotifyFramesNeutered. NotifyFramesAcked(*it, QuicTime::Delta::Zero(), QuicTime::Zero()); - DCHECK(!HasRetransmittableFrames(*it)); + QUICHE_DCHECK(!HasRetransmittableFrames(*it)); } } - DCHECK(!supports_multiple_packet_number_spaces_ || - last_inflight_packets_sent_time_[INITIAL_DATA] == QuicTime::Zero()); + QUICHE_DCHECK(!supports_multiple_packet_number_spaces_ || + last_inflight_packets_sent_time_[INITIAL_DATA] == + QuicTime::Zero()); return neutered_packets; } @@ -376,8 +370,9 @@ QuicUnackedPacketMap::NeuterHandshakePackets() { NotifyFramesAcked(*it, QuicTime::Delta::Zero(), QuicTime::Zero()); } } - DCHECK(!supports_multiple_packet_number_spaces() || - last_inflight_packets_sent_time_[HANDSHAKE_DATA] == QuicTime::Zero()); + QUICHE_DCHECK(!supports_multiple_packet_number_spaces() || + last_inflight_packets_sent_time_[HANDSHAKE_DATA] == + QuicTime::Zero()); return neutered_packets; } @@ -387,12 +382,12 @@ bool QuicUnackedPacketMap::HasInFlightPackets() const { const QuicTransmissionInfo& QuicUnackedPacketMap::GetTransmissionInfo( QuicPacketNumber packet_number) const { - return unacked_packets_at(packet_number - least_unacked_); + return unacked_packets_[packet_number - least_unacked_]; } QuicTransmissionInfo* QuicUnackedPacketMap::GetMutableTransmissionInfo( QuicPacketNumber packet_number) { - return &unacked_packets_at(packet_number - least_unacked_); + return &unacked_packets_[packet_number - least_unacked_]; } QuicTime QuicUnackedPacketMap::GetLastInFlightPacketSentTime() const { @@ -474,9 +469,9 @@ void QuicUnackedPacketMap::NotifyFramesLost(const QuicTransmissionInfo& info, } } -void QuicUnackedPacketMap::RetransmitFrames(const QuicTransmissionInfo& info, +void QuicUnackedPacketMap::RetransmitFrames(const QuicFrames& frames, TransmissionType type) { - session_notifier_->RetransmitFrames(info.retransmittable_frames, type); + session_notifier_->RetransmitFrames(frames, type); } void QuicUnackedPacketMap::MaybeAggregateAckedStreamFrame( @@ -592,13 +587,13 @@ QuicUnackedPacketMap::GetLargestSentRetransmittableOfPacketNumberSpace( const QuicTransmissionInfo* QuicUnackedPacketMap::GetFirstInFlightTransmissionInfo() const { - DCHECK(HasInFlightPackets()); + QUICHE_DCHECK(HasInFlightPackets()); for (auto it = begin(); it != end(); ++it) { if (it->in_flight) { return &(*it); } } - DCHECK(false); + QUICHE_DCHECK(false); return nullptr; } @@ -637,7 +632,7 @@ int32_t QuicUnackedPacketMap::GetLastPacketContent() const { return -1; } int32_t content = 0; - const QuicTransmissionInfo& last_packet = unacked_packets_back(); + const QuicTransmissionInfo& last_packet = unacked_packets_.back(); for (const auto& frame : last_packet.retransmittable_frames) { content |= GetFrameTypeBitfield(frame.type); } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_unacked_packet_map.h b/chromium/net/third_party/quiche/src/quic/core/quic_unacked_packet_map.h index 45413510a28..75c835d6c49 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_unacked_packet_map.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_unacked_packet_map.h @@ -9,12 +9,13 @@ #include <cstdint> #include <deque> -#include "net/third_party/quiche/src/quic/core/quic_circular_deque.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_transmission_info.h" -#include "net/third_party/quiche/src/quic/core/session_notifier_interface.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "absl/strings/str_cat.h" +#include "quic/core/quic_circular_deque.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_transmission_info.h" +#include "quic/core/session_notifier_interface.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_flags.h" namespace quic { @@ -58,10 +59,8 @@ class QUIC_EXPORT_PRIVATE QuicUnackedPacketMap { void NotifyFramesLost(const QuicTransmissionInfo& info, TransmissionType type); - // Notifies session_notifier to retransmit frames in |info| with - // |transmission_type|. - void RetransmitFrames(const QuicTransmissionInfo& info, - TransmissionType type); + // Notifies session_notifier to retransmit frames with |transmission_type|. + void RetransmitFrames(const QuicFrames& frames, TransmissionType type); // Marks |info| as no longer in flight. void RemoveFromInFlight(QuicTransmissionInfo* info); @@ -93,9 +92,7 @@ class QUIC_EXPORT_PRIVATE QuicUnackedPacketMap { bool HasUnackedRetransmittableFrames() const; // Returns true if there are no packets present in the unacked packet map. - bool empty() const { return unacked_packets_empty(); } - - bool use_circular_deque() const { return use_circular_deque_; } + bool empty() const { return unacked_packets_.empty(); } // Returns the largest packet number that has been sent. QuicPacketNumber largest_sent_packet() const { return largest_sent_packet_; } @@ -115,83 +112,18 @@ class QUIC_EXPORT_PRIVATE QuicUnackedPacketMap { // been acked by the peer. If there are no unacked packets, returns 0. QuicPacketNumber GetLeastUnacked() const; - template <typename Itr1, typename Itr2> - class QUIC_EXPORT_PRIVATE IteratorWrapper { - public: - explicit IteratorWrapper(Itr1 itr1) { - itr_.template emplace<0>(std::move(itr1)); - } - explicit IteratorWrapper(Itr2 itr2) { - itr_.template emplace<1>(std::move(itr2)); - } - - auto& operator*() const { - return absl::visit( - [](const auto& itr) -> auto& { return *itr; }, itr_); - } - - auto* operator->() const { - return absl::visit([](const auto& itr) { return &*itr; }, itr_); - } - - IteratorWrapper& operator++() { - absl::visit([](auto& itr) { ++itr; }, itr_); - return *this; - } - - IteratorWrapper& operator+=(int difference) { - absl::visit([difference](auto& itr) { itr += difference; }, itr_); - return *this; - } - - IteratorWrapper operator++(int) { - return absl::visit([](auto& itr) { IteratorWrapper(itr++); }, itr_); - } - - bool operator!=(const IteratorWrapper& other) const { - return itr_ != other.itr_; - } - - private: - absl::variant<Itr1, Itr2> itr_; - }; - using const_iterator = - IteratorWrapper<std::deque<QuicTransmissionInfo>::const_iterator, - QuicCircularDeque<QuicTransmissionInfo>::const_iterator>; - using const_reverse_iterator = IteratorWrapper< - std::deque<QuicTransmissionInfo>::const_reverse_iterator, - QuicCircularDeque<QuicTransmissionInfo>::const_reverse_iterator>; - using iterator = - IteratorWrapper<std::deque<QuicTransmissionInfo>::iterator, - QuicCircularDeque<QuicTransmissionInfo>::iterator>; - - const_iterator begin() const { - return use_circular_deque_ ? const_iterator(unacked_packets_.begin()) - : const_iterator(unacked_packets_deque_.begin()); - } - const_iterator end() const { - return use_circular_deque_ ? const_iterator(unacked_packets_.end()) - : const_iterator(unacked_packets_deque_.end()); - } - const_reverse_iterator rbegin() const { - return use_circular_deque_ - ? const_reverse_iterator(unacked_packets_.rbegin()) - : const_reverse_iterator(unacked_packets_deque_.rbegin()); - } - const_reverse_iterator rend() const { - return use_circular_deque_ - ? const_reverse_iterator(unacked_packets_.rend()) - : const_reverse_iterator(unacked_packets_deque_.rend()); - } - iterator begin() { - return use_circular_deque_ ? iterator(unacked_packets_.begin()) - : iterator(unacked_packets_deque_.begin()); - } - iterator end() { - return use_circular_deque_ ? iterator(unacked_packets_.end()) - : iterator(unacked_packets_deque_.end()); - } + QuicCircularDeque<QuicTransmissionInfo>::const_iterator; + using const_reverse_iterator = + QuicCircularDeque<QuicTransmissionInfo>::const_reverse_iterator; + using iterator = QuicCircularDeque<QuicTransmissionInfo>::iterator; + + const_iterator begin() const { return unacked_packets_.begin(); } + const_iterator end() const { return unacked_packets_.end(); } + const_reverse_iterator rbegin() const { return unacked_packets_.rbegin(); } + const_reverse_iterator rend() const { return unacked_packets_.rend(); } + iterator begin() { return unacked_packets_.begin(); } + iterator end() { return unacked_packets_.end(); } // Returns true if there are unacked packets that are in flight. bool HasInFlightPackets() const; @@ -313,71 +245,21 @@ class QUIC_EXPORT_PRIVATE QuicUnackedPacketMap { } void ReserveInitialCapacity(size_t initial_capacity) { - if (use_circular_deque_) { - unacked_packets_.reserve(initial_capacity); - } - } - - private: - friend class test::QuicUnackedPacketMapPeer; - - // TODO(haoyuewang) Remove these methods when deprecate - // quic_use_circular_deque_for_unacked_packets flag. - size_t unacked_packets_size() const { - return use_circular_deque_ ? unacked_packets_.size() - : unacked_packets_deque_.size(); - } - - const QuicTransmissionInfo& unacked_packets_at(int index) const { - return use_circular_deque_ ? unacked_packets_[index] - : unacked_packets_deque_[index]; + unacked_packets_.reserve(initial_capacity); } - QuicTransmissionInfo& unacked_packets_at(int index) { - return use_circular_deque_ ? unacked_packets_[index] - : unacked_packets_deque_[index]; + std::string DebugString() const { + return absl::StrCat( + "{size: ", unacked_packets_.size(), + ", least_unacked: ", least_unacked_.ToString(), + ", largest_sent_packet: ", largest_sent_packet_.ToString(), + ", largest_acked: ", largest_acked_.ToString(), + ", bytes_in_flight: ", bytes_in_flight_, + ", packets_in_flight: ", packets_in_flight_, "}"); } - const QuicTransmissionInfo& unacked_packets_front() const { - return use_circular_deque_ ? unacked_packets_.front() - : unacked_packets_deque_.front(); - } - - QuicTransmissionInfo& unacked_packets_front() { - return use_circular_deque_ ? unacked_packets_.front() - : unacked_packets_deque_.front(); - } - - const QuicTransmissionInfo& unacked_packets_back() const { - return use_circular_deque_ ? unacked_packets_.back() - : unacked_packets_deque_.back(); - } - - QuicTransmissionInfo& unacked_packets_back() { - return use_circular_deque_ ? unacked_packets_.back() - : unacked_packets_deque_.back(); - } - - void unacked_packets_push_back(QuicTransmissionInfo info) { - if (use_circular_deque_) { - unacked_packets_.push_back(std::move(info)); - } else { - unacked_packets_deque_.push_back(std::move(info)); - } - } - - void unacked_packets_pop_front() { - if (use_circular_deque_) { - unacked_packets_.pop_front(); - } else { - unacked_packets_deque_.pop_front(); - } - } - - bool unacked_packets_empty() const { - return use_circular_deque_ ? unacked_packets_.empty() - : unacked_packets_deque_.empty(); - } + private: + friend class test::QuicUnackedPacketMapPeer; // Returns true if packet may be useful for an RTT measurement. bool IsPacketUsefulForMeasuringRtt(QuicPacketNumber packet_number, @@ -419,10 +301,6 @@ class QUIC_EXPORT_PRIVATE QuicUnackedPacketMap { // be removed from the map and the new entry's retransmittable frames will be // set to nullptr. QuicCircularDeque<QuicTransmissionInfo> unacked_packets_; - std::deque<QuicTransmissionInfo> unacked_packets_deque_; - - const bool use_circular_deque_ = - GetQuicReloadableFlag(quic_use_circular_deque_for_unacked_packets); // The packet at the 0th index of unacked_packets_. QuicPacketNumber least_unacked_; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_unacked_packet_map_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_unacked_packet_map_test.cc index 02821083e31..07efee99f27 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_unacked_packet_map_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_unacked_packet_map_test.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_unacked_packet_map.h" +#include "quic/core/quic_unacked_packet_map.h" #include <cstddef> #include <limits> #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_stream_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_number.h" -#include "net/third_party/quiche/src/quic/core/quic_transmission_info.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_unacked_packet_map_peer.h" +#include "quic/core/frames/quic_stream_frame.h" +#include "quic/core/quic_packet_number.h" +#include "quic/core/quic_transmission_info.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/quic_unacked_packet_map_peer.h" using testing::_; using testing::Return; @@ -136,7 +136,7 @@ class QuicUnackedPacketMapTest : public QuicTestWithParam<Perspective> { void RetransmitAndSendPacket(uint64_t old_packet_number, uint64_t new_packet_number, TransmissionType transmission_type) { - DCHECK(unacked_packets_.HasRetransmittableFrames( + QUICHE_DCHECK(unacked_packets_.HasRetransmittableFrames( QuicPacketNumber(old_packet_number))); QuicTransmissionInfo* info = unacked_packets_.GetMutableTransmissionInfo( QuicPacketNumber(old_packet_number)); @@ -658,7 +658,6 @@ TEST_P(QuicUnackedPacketMapTest, LargestSentPacketMultiplePacketNumberSpaces) { } TEST_P(QuicUnackedPacketMapTest, ReserveInitialCapacityTest) { - SetQuicReloadableFlag(quic_use_circular_deque_for_unacked_packets, true); QuicUnackedPacketMap unacked_packets(GetParam()); ASSERT_EQ(QuicUnackedPacketMapPeer::GetCapacity(unacked_packets), 0u); unacked_packets.ReserveInitialCapacity(16); @@ -669,6 +668,32 @@ TEST_P(QuicUnackedPacketMapTest, ReserveInitialCapacityTest) { ASSERT_EQ(QuicUnackedPacketMapPeer::GetCapacity(unacked_packets), 16u); } +TEST_P(QuicUnackedPacketMapTest, DebugString) { + EXPECT_EQ(unacked_packets_.DebugString(), + "{size: 0, least_unacked: 1, largest_sent_packet: uninitialized, " + "largest_acked: uninitialized, bytes_in_flight: 0, " + "packets_in_flight: 0}"); + + SerializedPacket packet1(CreateRetransmittablePacket(1)); + unacked_packets_.AddSentPacket(&packet1, NOT_RETRANSMISSION, now_, true, + true); + EXPECT_EQ( + unacked_packets_.DebugString(), + "{size: 1, least_unacked: 1, largest_sent_packet: 1, largest_acked: " + "uninitialized, bytes_in_flight: 1000, packets_in_flight: 1}"); + + SerializedPacket packet2(CreateRetransmittablePacket(2)); + unacked_packets_.AddSentPacket(&packet2, NOT_RETRANSMISSION, now_, true, + true); + unacked_packets_.RemoveFromInFlight(QuicPacketNumber(1)); + unacked_packets_.IncreaseLargestAcked(QuicPacketNumber(1)); + unacked_packets_.RemoveObsoletePackets(); + EXPECT_EQ( + unacked_packets_.DebugString(), + "{size: 1, least_unacked: 2, largest_sent_packet: 2, largest_acked: 1, " + "bytes_in_flight: 1000, packets_in_flight: 1}"); +} + } // namespace } // namespace test } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_utils.cc b/chromium/net/third_party/quiche/src/quic/core/quic_utils.cc index 3322fedd906..7eff759077e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_utils.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_utils.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_utils.h" +#include "quic/core/quic_utils.h" #include <algorithm> #include <cstdint> @@ -12,16 +12,16 @@ #include "absl/base/macros.h" #include "absl/base/optimization.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_prefetch.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_prefetch.h" +#include "quic/platform/api/quic_uint128.h" +#include "common/quiche_endian.h" namespace quic { namespace { @@ -170,7 +170,7 @@ const char* QuicUtils::SentPacketStateToString(SentPacketState state) { RETURN_STRING_LITERAL(RTO_RETRANSMITTED); RETURN_STRING_LITERAL(PTO_RETRANSMITTED); RETURN_STRING_LITERAL(PROBE_RETRANSMITTED); - RETURN_STRING_LITERAL(NOT_CONTRIBUTING_RTT) + RETURN_STRING_LITERAL(NOT_CONTRIBUTING_RTT); } return "INVALID_SENT_PACKET_STATE"; } @@ -244,8 +244,8 @@ void QuicUtils::CopyToBuffer(const struct iovec* iov, iov_offset -= iov[iovnum].iov_len; ++iovnum; } - DCHECK_LE(iovnum, iov_count); - DCHECK_LE(iov_offset, iov[iovnum].iov_len); + QUICHE_DCHECK_LE(iovnum, iov_count); + QUICHE_DCHECK_LE(iov_offset, iov[iovnum].iov_len); if (iovnum >= iov_count || buffer_length == 0) { return; } @@ -351,6 +351,10 @@ SentPacketState QuicUtils::RetransmissionTypeToPacketState( return PTO_RETRANSMITTED; case PROBING_RETRANSMISSION: return PROBE_RETRANSMITTED; + case PATH_RETRANSMISSION: + return NOT_CONTRIBUTING_RTT; + case ALL_INITIAL_RETRANSMISSION: + return UNACKABLE; default: QUIC_BUG << retransmission_type << " is not a retransmission_type"; return UNACKABLE; @@ -393,7 +397,7 @@ bool QuicUtils::IsCryptoStreamId(QuicTransportVersion version, // static QuicStreamId QuicUtils::GetHeadersStreamId(QuicTransportVersion version) { - DCHECK(!VersionUsesHttp3(version)); + QUICHE_DCHECK(!VersionUsesHttp3(version)); return GetFirstBidirectionalStreamId(version, Perspective::IS_CLIENT); } @@ -431,7 +435,7 @@ bool QuicUtils::IsOutgoingStreamId(ParsedQuicVersion version, // static bool QuicUtils::IsBidirectionalStreamId(QuicStreamId id, ParsedQuicVersion version) { - DCHECK(version.HasIetfQuicFrames()); + QUICHE_DCHECK(version.HasIetfQuicFrames()); return id % 4 < 2; } @@ -440,26 +444,26 @@ StreamType QuicUtils::GetStreamType(QuicStreamId id, Perspective perspective, bool peer_initiated, ParsedQuicVersion version) { - DCHECK(version.HasIetfQuicFrames()); + QUICHE_DCHECK(version.HasIetfQuicFrames()); if (IsBidirectionalStreamId(id, version)) { return BIDIRECTIONAL; } if (peer_initiated) { if (perspective == Perspective::IS_SERVER) { - DCHECK_EQ(2u, id % 4); + QUICHE_DCHECK_EQ(2u, id % 4); } else { - DCHECK_EQ(Perspective::IS_CLIENT, perspective); - DCHECK_EQ(3u, id % 4); + QUICHE_DCHECK_EQ(Perspective::IS_CLIENT, perspective); + QUICHE_DCHECK_EQ(3u, id % 4); } return READ_UNIDIRECTIONAL; } if (perspective == Perspective::IS_SERVER) { - DCHECK_EQ(3u, id % 4); + QUICHE_DCHECK_EQ(3u, id % 4); } else { - DCHECK_EQ(Perspective::IS_CLIENT, perspective); - DCHECK_EQ(2u, id % 4); + QUICHE_DCHECK_EQ(Perspective::IS_CLIENT, perspective); + QUICHE_DCHECK_EQ(2u, id % 4); } return WRITE_UNIDIRECTIONAL; } @@ -661,7 +665,7 @@ EncryptionLevel QuicUtils::GetEncryptionLevel( case APPLICATION_DATA: return ENCRYPTION_FORWARD_SECURE; default: - DCHECK(false); + QUICHE_DCHECK(false); return NUM_ENCRYPTION_LEVELS; } } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_utils.h b/chromium/net/third_party/quiche/src/quic/core/quic_utils.h index c1a19a830e4..91751175a3b 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_utils.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_utils.h @@ -12,16 +12,16 @@ #include <type_traits> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_iovec.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/frames/quic_frame.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_iovec.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_uint128.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_utils_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_utils_test.cc index efcdb7e4293..a5249d7cf48 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_utils_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_utils_test.cc @@ -2,16 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_utils.h" +#include "quic/core/quic_utils.h" #include <string> #include "absl/base/macros.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { @@ -135,8 +136,12 @@ TEST_F(QuicUtilsTest, RetransmissionTypeToPacketState) { EXPECT_EQ(PTO_RETRANSMITTED, state); } else if (i == PROBING_RETRANSMISSION) { EXPECT_EQ(PROBE_RETRANSMITTED, state); + } else if (i == PATH_RETRANSMISSION) { + EXPECT_EQ(NOT_CONTRIBUTING_RTT, state); + } else if (i == ALL_INITIAL_RETRANSMISSION) { + EXPECT_EQ(UNACKABLE, state); } else { - DCHECK(false) + QUICHE_DCHECK(false) << "No corresponding packet state according to transmission type: " << i; } diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_version_manager.cc b/chromium/net/third_party/quiche/src/quic/core/quic_version_manager.cc index 9ca86f960de..1d4dcca70e4 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_version_manager.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_version_manager.cc @@ -2,42 +2,34 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_version_manager.h" +#include "quic/core/quic_version_manager.h" #include <algorithm> #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" namespace quic { QuicVersionManager::QuicVersionManager( ParsedQuicVersionVector supported_versions) - : disable_version_draft_29_( + : enable_version_rfcv1_(GetQuicReloadableFlag(quic_enable_version_rfcv1)), + disable_version_draft_29_( GetQuicReloadableFlag(quic_disable_version_draft_29)), - disable_version_draft_27_( - GetQuicReloadableFlag(quic_disable_version_draft_27)), disable_version_t051_(GetQuicReloadableFlag(quic_disable_version_t051)), - disable_version_t050_(GetQuicReloadableFlag(quic_disable_version_t050)), disable_version_q050_(GetQuicReloadableFlag(quic_disable_version_q050)), disable_version_q046_(GetQuicReloadableFlag(quic_disable_version_q046)), disable_version_q043_(GetQuicReloadableFlag(quic_disable_version_q043)), allowed_supported_versions_(std::move(supported_versions)) { - static_assert(SupportedVersions().size() == 7u, + static_assert(SupportedVersions().size() == 6u, "Supported versions out of sync"); RefilterSupportedVersions(); } QuicVersionManager::~QuicVersionManager() {} -const QuicTransportVersionVector& -QuicVersionManager::GetSupportedTransportVersions() { - MaybeRefilterSupportedVersions(); - return filtered_transport_versions_; -} - const ParsedQuicVersionVector& QuicVersionManager::GetSupportedVersions() { MaybeRefilterSupportedVersions(); return filtered_supported_versions_; @@ -55,28 +47,24 @@ const std::vector<std::string>& QuicVersionManager::GetSupportedAlpns() { } void QuicVersionManager::MaybeRefilterSupportedVersions() { - static_assert(SupportedVersions().size() == 7u, + static_assert(SupportedVersions().size() == 6u, "Supported versions out of sync"); - if (disable_version_draft_29_ != + if (enable_version_rfcv1_ != + GetQuicReloadableFlag(quic_enable_version_rfcv1) || + disable_version_draft_29_ != GetQuicReloadableFlag(quic_disable_version_draft_29) || - disable_version_draft_27_ != - GetQuicReloadableFlag(quic_disable_version_draft_27) || disable_version_t051_ != GetQuicReloadableFlag(quic_disable_version_t051) || - disable_version_t050_ != - GetQuicReloadableFlag(quic_disable_version_t050) || disable_version_q050_ != GetQuicReloadableFlag(quic_disable_version_q050) || disable_version_q046_ != GetQuicReloadableFlag(quic_disable_version_q046) || disable_version_q043_ != GetQuicReloadableFlag(quic_disable_version_q043)) { + enable_version_rfcv1_ = GetQuicReloadableFlag(quic_enable_version_rfcv1); disable_version_draft_29_ = GetQuicReloadableFlag(quic_disable_version_draft_29); - disable_version_draft_27_ = - GetQuicReloadableFlag(quic_disable_version_draft_27); disable_version_t051_ = GetQuicReloadableFlag(quic_disable_version_t051); - disable_version_t050_ = GetQuicReloadableFlag(quic_disable_version_t050); disable_version_q050_ = GetQuicReloadableFlag(quic_disable_version_q050); disable_version_q046_ = GetQuicReloadableFlag(quic_disable_version_q046); disable_version_q043_ = GetQuicReloadableFlag(quic_disable_version_q043); diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_version_manager.h b/chromium/net/third_party/quiche/src/quic/core/quic_version_manager.h index 9c742f5eece..f443395e295 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_version_manager.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_version_manager.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_CORE_QUIC_VERSION_MANAGER_H_ #define QUICHE_QUIC_CORE_QUIC_VERSION_MANAGER_H_ -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -18,10 +18,6 @@ class QUIC_EXPORT_PRIVATE QuicVersionManager { explicit QuicVersionManager(ParsedQuicVersionVector supported_versions); virtual ~QuicVersionManager(); - // Returns currently supported QUIC versions. - // TODO(nharper): Remove this method once it is unused. - const QuicTransportVersionVector& GetSupportedTransportVersions(); - // Returns currently supported QUIC versions. This vector has the same order // as the versions passed to the constructor. const ParsedQuicVersionVector& GetSupportedVersions(); @@ -54,14 +50,12 @@ class QUIC_EXPORT_PRIVATE QuicVersionManager { private: // Cached value of reloadable flags. + // quic_enable_version_rfcv1 flag + bool enable_version_rfcv1_; // quic_disable_version_draft_29 flag bool disable_version_draft_29_; - // quic_disable_version_draft_27 flag - bool disable_version_draft_27_; // quic_disable_version_t051 flag bool disable_version_t051_; - // quic_disable_version_t050 flag - bool disable_version_t050_; // quic_disable_version_q050 flag bool disable_version_q050_; // quic_disable_version_q046 flag diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_version_manager_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_version_manager_test.cc index 487471f0e19..5776b3916c3 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_version_manager_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_version_manager_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_version_manager.h" +#include "quic/core/quic_version_manager.h" #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" using ::testing::ElementsAre; @@ -18,18 +18,17 @@ namespace { class QuicVersionManagerTest : public QuicTest {}; TEST_F(QuicVersionManagerTest, QuicVersionManager) { - static_assert(SupportedVersions().size() == 7u, + static_assert(SupportedVersions().size() == 6u, "Supported versions out of sync"); for (const ParsedQuicVersion& version : AllSupportedVersions()) { QuicEnableVersion(version); } + QuicDisableVersion(ParsedQuicVersion::RFCv1()); QuicDisableVersion(ParsedQuicVersion::Draft29()); - QuicDisableVersion(ParsedQuicVersion::Draft27()); + QuicDisableVersion(ParsedQuicVersion::T051()); QuicVersionManager manager(AllSupportedVersions()); ParsedQuicVersionVector expected_parsed_versions; - expected_parsed_versions.push_back(ParsedQuicVersion::T051()); - expected_parsed_versions.push_back(ParsedQuicVersion::T050()); expected_parsed_versions.push_back(ParsedQuicVersion::Q050()); expected_parsed_versions.push_back(ParsedQuicVersion::Q046()); expected_parsed_versions.push_back(ParsedQuicVersion::Q043()); @@ -40,39 +39,36 @@ TEST_F(QuicVersionManagerTest, QuicVersionManager) { manager.GetSupportedVersions()); EXPECT_EQ(CurrentSupportedVersionsWithQuicCrypto(), manager.GetSupportedVersionsWithQuicCrypto()); - EXPECT_THAT( - manager.GetSupportedAlpns(), - ElementsAre("h3-T051", "h3-T050", "h3-Q050", "h3-Q046", "h3-Q043")); + EXPECT_THAT(manager.GetSupportedAlpns(), + ElementsAre("h3-Q050", "h3-Q046", "h3-Q043")); int offset = 0; QuicEnableVersion(ParsedQuicVersion::Draft29()); expected_parsed_versions.insert(expected_parsed_versions.begin() + offset, ParsedQuicVersion::Draft29()); EXPECT_EQ(expected_parsed_versions, manager.GetSupportedVersions()); - EXPECT_EQ(expected_parsed_versions.size() - 3 - offset, + EXPECT_EQ(expected_parsed_versions.size() - 1 - offset, manager.GetSupportedVersionsWithQuicCrypto().size()); EXPECT_EQ(FilterSupportedVersions(AllSupportedVersions()), manager.GetSupportedVersions()); EXPECT_EQ(CurrentSupportedVersionsWithQuicCrypto(), manager.GetSupportedVersionsWithQuicCrypto()); EXPECT_THAT(manager.GetSupportedAlpns(), - ElementsAre("h3-29", "h3-T051", "h3-T050", "h3-Q050", "h3-Q046", - "h3-Q043")); + ElementsAre("h3-29", "h3-Q050", "h3-Q046", "h3-Q043")); offset++; - QuicEnableVersion(ParsedQuicVersion::Draft27()); + QuicEnableVersion(ParsedQuicVersion::T051()); expected_parsed_versions.insert(expected_parsed_versions.begin() + offset, - ParsedQuicVersion::Draft27()); + ParsedQuicVersion::T051()); EXPECT_EQ(expected_parsed_versions, manager.GetSupportedVersions()); - EXPECT_EQ(expected_parsed_versions.size() - 3 - offset, + EXPECT_EQ(expected_parsed_versions.size() - 1 - offset, manager.GetSupportedVersionsWithQuicCrypto().size()); EXPECT_EQ(FilterSupportedVersions(AllSupportedVersions()), manager.GetSupportedVersions()); EXPECT_EQ(CurrentSupportedVersionsWithQuicCrypto(), manager.GetSupportedVersionsWithQuicCrypto()); EXPECT_THAT(manager.GetSupportedAlpns(), - ElementsAre("h3-29", "h3-27", "h3-T051", "h3-T050", "h3-Q050", - "h3-Q046", "h3-Q043")); + ElementsAre("h3-29", "h3-T051", "h3-Q050", "h3-Q046", "h3-Q043")); } } // namespace diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_versions.cc b/chromium/net/third_party/quiche/src/quic/core/quic_versions.cc index 6bda82be251..a189e263b94 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_versions.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_versions.cc @@ -2,23 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_versions.h" +#include "quic/core/quic_versions.h" #include <string> #include "absl/base/macros.h" #include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/quic_tag.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#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/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/quic_tag.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/quiche_endian.h" namespace quic { namespace { @@ -42,18 +42,16 @@ QuicVersionLabel CreateRandomVersionLabelForNegotiation() { } void SetVersionFlag(const ParsedQuicVersion& version, bool should_enable) { - static_assert(SupportedVersions().size() == 7u, + static_assert(SupportedVersions().size() == 6u, "Supported versions out of sync"); const bool enable = should_enable; const bool disable = !should_enable; - if (version == ParsedQuicVersion::Draft29()) { + if (version == ParsedQuicVersion::RFCv1()) { + SetQuicReloadableFlag(quic_enable_version_rfcv1, enable); + } else if (version == ParsedQuicVersion::Draft29()) { SetQuicReloadableFlag(quic_disable_version_draft_29, disable); - } else if (version == ParsedQuicVersion::Draft27()) { - SetQuicReloadableFlag(quic_disable_version_draft_27, disable); } else if (version == ParsedQuicVersion::T051()) { SetQuicReloadableFlag(quic_disable_version_t051, disable); - } else if (version == ParsedQuicVersion::T050()) { - SetQuicReloadableFlag(quic_disable_version_t050, disable); } else if (version == ParsedQuicVersion::Q050()) { SetQuicReloadableFlag(quic_disable_version_q050, disable); } else if (version == ParsedQuicVersion::Q046()) { @@ -69,148 +67,126 @@ void SetVersionFlag(const ParsedQuicVersion& version, bool should_enable) { } // namespace bool ParsedQuicVersion::IsKnown() const { - DCHECK(ParsedQuicVersionIsValid(handshake_protocol, transport_version)) + QUICHE_DCHECK(ParsedQuicVersionIsValid(handshake_protocol, transport_version)) << QuicVersionToString(transport_version) << " " << HandshakeProtocolToString(handshake_protocol); return transport_version != QUIC_VERSION_UNSUPPORTED; } bool ParsedQuicVersion::KnowsWhichDecrypterToUse() const { - DCHECK(IsKnown()); + QUICHE_DCHECK(IsKnown()); return transport_version > QUIC_VERSION_46; } bool ParsedQuicVersion::UsesInitialObfuscators() const { - DCHECK(IsKnown()); + QUICHE_DCHECK(IsKnown()); // Initial obfuscators were added in version 50. return transport_version > QUIC_VERSION_46; } bool ParsedQuicVersion::AllowsLowFlowControlLimits() const { - DCHECK(IsKnown()); + QUICHE_DCHECK(IsKnown()); // Low flow-control limits are used for all IETF versions. return UsesHttp3(); } bool ParsedQuicVersion::HasHeaderProtection() const { - DCHECK(IsKnown()); + QUICHE_DCHECK(IsKnown()); // Header protection was added in version 50. return transport_version > QUIC_VERSION_46; } bool ParsedQuicVersion::SupportsRetry() const { - DCHECK(IsKnown()); + QUICHE_DCHECK(IsKnown()); // Retry was added in version 47. return transport_version > QUIC_VERSION_46; } -bool ParsedQuicVersion::HasRetryIntegrityTag() const { - DCHECK(IsKnown()); - return handshake_protocol == PROTOCOL_TLS1_3; -} - bool ParsedQuicVersion::SendsVariableLengthPacketNumberInLongHeader() const { - DCHECK(IsKnown()); + QUICHE_DCHECK(IsKnown()); return transport_version > QUIC_VERSION_46; } bool ParsedQuicVersion::AllowsVariableLengthConnectionIds() const { - DCHECK(IsKnown()); + QUICHE_DCHECK(IsKnown()); return VersionAllowsVariableLengthConnectionIds(transport_version); } bool ParsedQuicVersion::SupportsClientConnectionIds() const { - DCHECK(IsKnown()); + QUICHE_DCHECK(IsKnown()); // Client connection IDs were added in version 49. return transport_version > QUIC_VERSION_46; } bool ParsedQuicVersion::HasLengthPrefixedConnectionIds() const { - DCHECK(IsKnown()); + QUICHE_DCHECK(IsKnown()); return VersionHasLengthPrefixedConnectionIds(transport_version); } bool ParsedQuicVersion::SupportsAntiAmplificationLimit() const { - DCHECK(IsKnown()); + QUICHE_DCHECK(IsKnown()); // The anti-amplification limit is used for all IETF versions. return UsesHttp3(); } bool ParsedQuicVersion::CanSendCoalescedPackets() const { - DCHECK(IsKnown()); - return QuicVersionHasLongHeaderLengths(transport_version) && - handshake_protocol == PROTOCOL_TLS1_3; + QUICHE_DCHECK(IsKnown()); + return HasLongHeaderLengths() && UsesTls(); } bool ParsedQuicVersion::SupportsGoogleAltSvcFormat() const { - DCHECK(IsKnown()); + QUICHE_DCHECK(IsKnown()); return VersionSupportsGoogleAltSvcFormat(transport_version); } bool ParsedQuicVersion::HasIetfInvariantHeader() const { - DCHECK(IsKnown()); + QUICHE_DCHECK(IsKnown()); return VersionHasIetfInvariantHeader(transport_version); } bool ParsedQuicVersion::SupportsMessageFrames() const { - DCHECK(IsKnown()); + QUICHE_DCHECK(IsKnown()); return VersionSupportsMessageFrames(transport_version); } bool ParsedQuicVersion::UsesHttp3() const { - DCHECK(IsKnown()); + QUICHE_DCHECK(IsKnown()); return VersionUsesHttp3(transport_version); } bool ParsedQuicVersion::HasLongHeaderLengths() const { - DCHECK(IsKnown()); + QUICHE_DCHECK(IsKnown()); return QuicVersionHasLongHeaderLengths(transport_version); } bool ParsedQuicVersion::UsesCryptoFrames() const { - DCHECK(IsKnown()); + QUICHE_DCHECK(IsKnown()); return QuicVersionUsesCryptoFrames(transport_version); } bool ParsedQuicVersion::HasIetfQuicFrames() const { - DCHECK(IsKnown()); + QUICHE_DCHECK(IsKnown()); return VersionHasIetfQuicFrames(transport_version); } -bool ParsedQuicVersion::HasHandshakeDone() const { - DCHECK(IsKnown()); - // HANDSHAKE_DONE is supported in T051 and all IETF drafts since draft-25. - return UsesTls() && transport_version > QUIC_VERSION_50; -} - -bool ParsedQuicVersion::HasVarIntTransportParams() const { - DCHECK(IsKnown()); - // Variable-length integer transport parameters are supported in T051 and - // all IETF drafts since draft-27. - return UsesTls() && transport_version > QUIC_VERSION_50; -} - -bool ParsedQuicVersion::AuthenticatesHandshakeConnectionIds() const { - DCHECK(IsKnown()); - // Authentication of handshake connection IDs is supported in T051 and - // all IETF drafts since draft-28. - return UsesTls() && transport_version > QUIC_VERSION_50 && - transport_version != QUIC_VERSION_IETF_DRAFT_27; +bool ParsedQuicVersion::UsesLegacyTlsExtension() const { + QUICHE_DCHECK(IsKnown()); + return UsesTls() && transport_version <= QUIC_VERSION_IETF_DRAFT_29; } bool ParsedQuicVersion::UsesTls() const { - DCHECK(IsKnown()); + QUICHE_DCHECK(IsKnown()); return handshake_protocol == PROTOCOL_TLS1_3; } bool ParsedQuicVersion::UsesQuicCrypto() const { - DCHECK(IsKnown()); + QUICHE_DCHECK(IsKnown()); return handshake_protocol == PROTOCOL_QUIC_CRYPTO; } bool VersionHasLengthPrefixedConnectionIds( QuicTransportVersion transport_version) { - DCHECK(transport_version != QUIC_VERSION_UNSUPPORTED); + QUICHE_DCHECK(transport_version != QUIC_VERSION_UNSUPPORTED); // Length-prefixed connection IDs were added in version 49. return transport_version > QUIC_VERSION_46; } @@ -239,16 +215,14 @@ std::ostream& operator<<(std::ostream& os, } QuicVersionLabel CreateQuicVersionLabel(ParsedQuicVersion parsed_version) { - static_assert(SupportedVersions().size() == 7u, + static_assert(SupportedVersions().size() == 6u, "Supported versions out of sync"); - if (parsed_version == ParsedQuicVersion::Draft29()) { + if (parsed_version == ParsedQuicVersion::RFCv1()) { + return MakeVersionLabel(0x00, 0x00, 0x00, 0x01); + } else if (parsed_version == ParsedQuicVersion::Draft29()) { return MakeVersionLabel(0xff, 0x00, 0x00, 29); - } else if (parsed_version == ParsedQuicVersion::Draft27()) { - return MakeVersionLabel(0xff, 0x00, 0x00, 27); } else if (parsed_version == ParsedQuicVersion::T051()) { return MakeVersionLabel('T', '0', '5', '1'); - } else if (parsed_version == ParsedQuicVersion::T050()) { - return MakeVersionLabel('T', '0', '5', '0'); } else if (parsed_version == ParsedQuicVersion::Q050()) { return MakeVersionLabel('Q', '0', '5', '0'); } else if (parsed_version == ParsedQuicVersion::Q046()) { @@ -299,7 +273,7 @@ ParsedQuicVersionVector CurrentSupportedVersionsWithQuicCrypto() { ParsedQuicVersionVector AllSupportedVersionsWithTls() { ParsedQuicVersionVector versions; for (const ParsedQuicVersion& version : AllSupportedVersions()) { - if (version.handshake_protocol == PROTOCOL_TLS1_3) { + if (version.UsesTls()) { versions.push_back(version); } } @@ -310,7 +284,7 @@ ParsedQuicVersionVector AllSupportedVersionsWithTls() { ParsedQuicVersionVector CurrentSupportedVersionsWithTls() { ParsedQuicVersionVector versions; for (const ParsedQuicVersion& version : CurrentSupportedVersions()) { - if (version.handshake_protocol == PROTOCOL_TLS1_3) { + if (version.UsesTls()) { versions.push_back(version); } } @@ -335,24 +309,22 @@ ParsedQuicVersion ParseQuicVersionString(absl::string_view version_string) { return UnsupportedQuicVersion(); } int quic_version_number = 0; + const ParsedQuicVersionVector supported_versions = AllSupportedVersions(); if (absl::SimpleAtoi(version_string, &quic_version_number) && quic_version_number > 0) { QuicTransportVersion transport_version = static_cast<QuicTransportVersion>(quic_version_number); - bool transport_version_is_supported = false; - for (QuicTransportVersion transport_vers : SupportedTransportVersions()) { - if (transport_vers == transport_version) { - transport_version_is_supported = true; - break; - } - } - if (!transport_version_is_supported || - !ParsedQuicVersionIsValid(PROTOCOL_QUIC_CRYPTO, transport_version)) { + if (!ParsedQuicVersionIsValid(PROTOCOL_QUIC_CRYPTO, transport_version)) { return UnsupportedQuicVersion(); } - return ParsedQuicVersion(PROTOCOL_QUIC_CRYPTO, transport_version); + ParsedQuicVersion version(PROTOCOL_QUIC_CRYPTO, transport_version); + if (std::find(supported_versions.begin(), supported_versions.end(), + version) != supported_versions.end()) { + return version; + } + return UnsupportedQuicVersion(); } - for (const ParsedQuicVersion& version : AllSupportedVersions()) { + for (const ParsedQuicVersion& version : supported_versions) { if (version_string == ParsedQuicVersionToString(version) || version_string == AlpnForVersion(version) || (version.handshake_protocol == PROTOCOL_QUIC_CRYPTO && @@ -360,13 +332,13 @@ ParsedQuicVersion ParseQuicVersionString(absl::string_view version_string) { return version; } } - for (const ParsedQuicVersion& version : AllSupportedVersions()) { - if (version.UsesHttp3() && - version_string == - QuicVersionLabelToString(CreateQuicVersionLabel(version))) { - return version; - } + for (const ParsedQuicVersion& version : supported_versions) { + if (version.UsesHttp3() && + version_string == + QuicVersionLabelToString(CreateQuicVersionLabel(version))) { + return version; } + } // Reading from the client so this should not be considered an ERROR. QUIC_DLOG(INFO) << "Unsupported QUIC version string: \"" << version_string << "\"."; @@ -392,10 +364,14 @@ ParsedQuicVersionVector ParseQuicVersionVectorString( } QuicTransportVersionVector AllSupportedTransportVersions() { - constexpr auto supported_transport_versions = SupportedTransportVersions(); - QuicTransportVersionVector supported_versions( - supported_transport_versions.begin(), supported_transport_versions.end()); - return supported_versions; + QuicTransportVersionVector transport_versions; + for (const ParsedQuicVersion& version : AllSupportedVersions()) { + if (std::find(transport_versions.begin(), transport_versions.end(), + version.transport_version) == transport_versions.end()) { + transport_versions.push_back(version.transport_version); + } + } + return transport_versions; } ParsedQuicVersionVector AllSupportedVersions() { @@ -413,22 +389,18 @@ ParsedQuicVersionVector FilterSupportedVersions( ParsedQuicVersionVector filtered_versions; filtered_versions.reserve(versions.size()); for (const ParsedQuicVersion& version : versions) { - if (version == ParsedQuicVersion::Draft29()) { - if (!GetQuicReloadableFlag(quic_disable_version_draft_29)) { + if (version == ParsedQuicVersion::RFCv1()) { + if (GetQuicReloadableFlag(quic_enable_version_rfcv1)) { filtered_versions.push_back(version); } - } else if (version == ParsedQuicVersion::Draft27()) { - if (!GetQuicReloadableFlag(quic_disable_version_draft_27)) { + } else if (version == ParsedQuicVersion::Draft29()) { + if (!GetQuicReloadableFlag(quic_disable_version_draft_29)) { filtered_versions.push_back(version); } } else if (version == ParsedQuicVersion::T051()) { if (!GetQuicReloadableFlag(quic_disable_version_t051)) { filtered_versions.push_back(version); } - } else if (version == ParsedQuicVersion::T050()) { - if (!GetQuicReloadableFlag(quic_disable_version_t050)) { - filtered_versions.push_back(version); - } } else if (version == ParsedQuicVersion::Q050()) { if (!GetQuicReloadableFlag(quic_disable_version_q050)) { filtered_versions.push_back(version); @@ -449,19 +421,6 @@ ParsedQuicVersionVector FilterSupportedVersions( return filtered_versions; } -QuicTransportVersionVector VersionOfIndex( - const QuicTransportVersionVector& versions, - int index) { - QuicTransportVersionVector version; - int version_count = versions.size(); - if (index >= 0 && index < version_count) { - version.push_back(versions[index]); - } else { - version.push_back(QUIC_VERSION_UNSUPPORTED); - } - return version; -} - ParsedQuicVersionVector ParsedVersionOfIndex( const ParsedQuicVersionVector& versions, int index) { @@ -475,22 +434,6 @@ ParsedQuicVersionVector ParsedVersionOfIndex( return version; } -QuicTransportVersionVector ParsedVersionsToTransportVersions( - const ParsedQuicVersionVector& versions) { - QuicTransportVersionVector transport_versions; - transport_versions.resize(versions.size()); - for (size_t i = 0; i < versions.size(); ++i) { - transport_versions[i] = versions[i].transport_version; - } - return transport_versions; -} - -QuicVersionLabel QuicVersionToQuicVersionLabel( - QuicTransportVersion transport_version) { - return CreateQuicVersionLabel( - ParsedQuicVersion(PROTOCOL_QUIC_CRYPTO, transport_version)); -} - std::string QuicVersionLabelToString(QuicVersionLabel version_label) { return QuicTagToString(quiche::QuicheEndian::HostToNet32(version_label)); } @@ -514,35 +457,23 @@ std::string QuicVersionLabelVectorToString( return result; } -QuicTransportVersion QuicVersionLabelToQuicVersion( - QuicVersionLabel version_label) { - return ParseQuicVersionLabel(version_label).transport_version; -} - -HandshakeProtocol QuicVersionLabelToHandshakeProtocol( - QuicVersionLabel version_label) { - return ParseQuicVersionLabel(version_label).handshake_protocol; -} - #define RETURN_STRING_LITERAL(x) \ case x: \ return #x std::string QuicVersionToString(QuicTransportVersion transport_version) { - static_assert(SupportedTransportVersions().size() == 6u, - "Supported versions out of sync"); switch (transport_version) { RETURN_STRING_LITERAL(QUIC_VERSION_43); RETURN_STRING_LITERAL(QUIC_VERSION_46); RETURN_STRING_LITERAL(QUIC_VERSION_50); RETURN_STRING_LITERAL(QUIC_VERSION_51); - RETURN_STRING_LITERAL(QUIC_VERSION_IETF_DRAFT_27); RETURN_STRING_LITERAL(QUIC_VERSION_IETF_DRAFT_29); + RETURN_STRING_LITERAL(QUIC_VERSION_IETF_RFC_V1); RETURN_STRING_LITERAL(QUIC_VERSION_UNSUPPORTED); RETURN_STRING_LITERAL(QUIC_VERSION_RESERVED_FOR_NEGOTIATION); } - return quiche::QuicheStrCat("QUIC_VERSION_UNKNOWN(", - static_cast<int>(transport_version), ")"); + return absl::StrCat("QUIC_VERSION_UNKNOWN(", + static_cast<int>(transport_version), ")"); } std::string HandshakeProtocolToString(HandshakeProtocol handshake_protocol) { @@ -551,22 +482,21 @@ std::string HandshakeProtocolToString(HandshakeProtocol handshake_protocol) { RETURN_STRING_LITERAL(PROTOCOL_QUIC_CRYPTO); RETURN_STRING_LITERAL(PROTOCOL_TLS1_3); } - return quiche::QuicheStrCat("PROTOCOL_UNKNOWN(", - static_cast<int>(handshake_protocol), ")"); + return absl::StrCat("PROTOCOL_UNKNOWN(", static_cast<int>(handshake_protocol), + ")"); } std::string ParsedQuicVersionToString(ParsedQuicVersion version) { - static_assert(SupportedVersions().size() == 7u, + static_assert(SupportedVersions().size() == 6u, "Supported versions out of sync"); if (version == UnsupportedQuicVersion()) { return "0"; - } - if (version == ParsedQuicVersion::Draft29()) { - DCHECK(version.UsesHttp3()); + } else if (version == ParsedQuicVersion::RFCv1()) { + QUICHE_DCHECK(version.UsesHttp3()); + return "RFCv1"; + } else if (version == ParsedQuicVersion::Draft29()) { + QUICHE_DCHECK(version.UsesHttp3()); return "draft29"; - } else if (version == ParsedQuicVersion::Draft27()) { - DCHECK(version.UsesHttp3()); - return "draft27"; } return QuicVersionLabelToString(CreateQuicVersionLabel(version)); @@ -608,7 +538,7 @@ bool VersionSupportsGoogleAltSvcFormat(QuicTransportVersion transport_version) { bool VersionAllowsVariableLengthConnectionIds( QuicTransportVersion transport_version) { - DCHECK_NE(transport_version, QUIC_VERSION_UNSUPPORTED); + QUICHE_DCHECK_NE(transport_version, QUIC_VERSION_UNSUPPORTED); return transport_version > QUIC_VERSION_46; } @@ -653,10 +583,10 @@ ParsedQuicVersion LegacyVersionForEncapsulation() { } std::string AlpnForVersion(ParsedQuicVersion parsed_version) { - if (parsed_version == ParsedQuicVersion::Draft29()) { + if (parsed_version == ParsedQuicVersion::RFCv1()) { + return "h3"; + } else if (parsed_version == ParsedQuicVersion::Draft29()) { return "h3-29"; - } else if (parsed_version == ParsedQuicVersion::Draft27()) { - return "h3-27"; } return "h3-" + ParsedQuicVersionToString(parsed_version); } @@ -664,9 +594,6 @@ std::string AlpnForVersion(ParsedQuicVersion parsed_version) { void QuicVersionInitializeSupportForIetfDraft() { // Enable necessary flags. SetQuicRestartFlag(quic_enable_zero_rtt_for_tls_v2, true); - SetQuicReloadableFlag(quic_key_update_supported, true); - SetQuicReloadableFlag(quic_send_version_negotiation_for_short_connection_ids, - true); } void QuicEnableVersion(const ParsedQuicVersion& version) { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_versions.h b/chromium/net/third_party/quiche/src/quic/core/quic_versions.h index c29b715f288..75a6826ae81 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_versions.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_versions.h @@ -26,10 +26,11 @@ #include <string> #include <vector> +#include "absl/base/macros.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_tag.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_tag.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -119,9 +120,10 @@ enum QuicTransportVersion { QUIC_VERSION_50 = 50, // Header protection and initial obfuscators. QUIC_VERSION_51 = 51, // draft-29 features but with GoogleQUIC frames. // Number 70 used to represent draft-ietf-quic-transport-25. - QUIC_VERSION_IETF_DRAFT_27 = 71, // draft-ietf-quic-transport-27. + // Number 71 used to represent draft-ietf-quic-transport-27. // Number 72 used to represent draft-ietf-quic-transport-28. QUIC_VERSION_IETF_DRAFT_29 = 73, // draft-ietf-quic-transport-29. + QUIC_VERSION_IETF_RFC_V1 = 80, // Not-yet-published RFC. // Version 99 was a dumping ground for IETF QUIC changes which were not yet // yet ready for production between 2018-02 and 2020-02. @@ -134,23 +136,14 @@ enum QuicTransportVersion { QUIC_VERSION_RESERVED_FOR_NEGOTIATION = 999, }; -// This array contains QUIC transport versions which we currently support. -// DEPRECATED. Use SupportedVersions() instead. -constexpr std::array<QuicTransportVersion, 6> SupportedTransportVersions() { - return {QUIC_VERSION_IETF_DRAFT_29, - QUIC_VERSION_IETF_DRAFT_27, - QUIC_VERSION_51, - QUIC_VERSION_50, - QUIC_VERSION_46, - QUIC_VERSION_43}; -} - // Helper function which translates from a QuicTransportVersion to a string. // Returns strings corresponding to enum names (e.g. QUIC_VERSION_6). QUIC_EXPORT_PRIVATE std::string QuicVersionToString( QuicTransportVersion transport_version); // The crypto handshake protocols that can be used with QUIC. +// We are planning on eventually deprecating PROTOCOL_QUIC_CRYPTO in favor of +// PROTOCOL_TLS1_3. enum HandshakeProtocol { PROTOCOL_UNSUPPORTED, PROTOCOL_QUIC_CRYPTO, @@ -176,18 +169,21 @@ QUIC_EXPORT_PRIVATE constexpr bool QuicVersionUsesCryptoFrames( QUIC_EXPORT_PRIVATE constexpr bool ParsedQuicVersionIsValid( HandshakeProtocol handshake_protocol, QuicTransportVersion transport_version) { - bool transport_version_is_valid = - transport_version == QUIC_VERSION_UNSUPPORTED || - transport_version == QUIC_VERSION_RESERVED_FOR_NEGOTIATION; - if (!transport_version_is_valid) { - // Iterators are not constexpr in C++14 which Chrome uses. - constexpr auto supported_transport_versions = SupportedTransportVersions(); - for (size_t i = 0; i < supported_transport_versions.size(); ++i) { - const QuicTransportVersion& trans_vers = supported_transport_versions[i]; - if (trans_vers == transport_version) { - transport_version_is_valid = true; - break; - } + bool transport_version_is_valid = false; + constexpr QuicTransportVersion valid_transport_versions[] = { + QUIC_VERSION_IETF_RFC_V1, + QUIC_VERSION_IETF_DRAFT_29, + QUIC_VERSION_51, + QUIC_VERSION_50, + QUIC_VERSION_46, + QUIC_VERSION_43, + QUIC_VERSION_RESERVED_FOR_NEGOTIATION, + QUIC_VERSION_UNSUPPORTED, + }; + for (size_t i = 0; i < ABSL_ARRAYSIZE(valid_transport_versions); ++i) { + if (transport_version == valid_transport_versions[i]) { + transport_version_is_valid = true; + break; } } if (!transport_version_is_valid) { @@ -200,10 +196,11 @@ QUIC_EXPORT_PRIVATE constexpr bool ParsedQuicVersionIsValid( return transport_version != QUIC_VERSION_UNSUPPORTED && transport_version != QUIC_VERSION_RESERVED_FOR_NEGOTIATION && transport_version != QUIC_VERSION_51 && - transport_version != QUIC_VERSION_IETF_DRAFT_27 && - transport_version != QUIC_VERSION_IETF_DRAFT_29; + transport_version != QUIC_VERSION_IETF_DRAFT_29 && + transport_version != QUIC_VERSION_IETF_RFC_V1; case PROTOCOL_TLS1_3: return transport_version != QUIC_VERSION_UNSUPPORTED && + transport_version != QUIC_VERSION_50 && QuicVersionUsesCryptoFrames(transport_version); } return false; @@ -219,7 +216,8 @@ struct QUIC_EXPORT_PRIVATE ParsedQuicVersion { QuicTransportVersion transport_version) : handshake_protocol(handshake_protocol), transport_version(transport_version) { - DCHECK(ParsedQuicVersionIsValid(handshake_protocol, transport_version)) + QUICHE_DCHECK( + ParsedQuicVersionIsValid(handshake_protocol, transport_version)) << QuicVersionToString(transport_version) << " " << HandshakeProtocolToString(handshake_protocol); } @@ -228,8 +226,8 @@ struct QUIC_EXPORT_PRIVATE ParsedQuicVersion { : ParsedQuicVersion(other.handshake_protocol, other.transport_version) {} ParsedQuicVersion& operator=(const ParsedQuicVersion& other) { - DCHECK(ParsedQuicVersionIsValid(other.handshake_protocol, - other.transport_version)) + QUICHE_DCHECK(ParsedQuicVersionIsValid(other.handshake_protocol, + other.transport_version)) << QuicVersionToString(other.transport_version) << " " << HandshakeProtocolToString(other.handshake_protocol); if (this != &other) { @@ -249,22 +247,18 @@ struct QUIC_EXPORT_PRIVATE ParsedQuicVersion { transport_version != other.transport_version; } - static constexpr ParsedQuicVersion Draft29() { - return ParsedQuicVersion(PROTOCOL_TLS1_3, QUIC_VERSION_IETF_DRAFT_29); + static constexpr ParsedQuicVersion RFCv1() { + return ParsedQuicVersion(PROTOCOL_TLS1_3, QUIC_VERSION_IETF_RFC_V1); } - static constexpr ParsedQuicVersion Draft27() { - return ParsedQuicVersion(PROTOCOL_TLS1_3, QUIC_VERSION_IETF_DRAFT_27); + static constexpr ParsedQuicVersion Draft29() { + return ParsedQuicVersion(PROTOCOL_TLS1_3, QUIC_VERSION_IETF_DRAFT_29); } static constexpr ParsedQuicVersion T051() { return ParsedQuicVersion(PROTOCOL_TLS1_3, QUIC_VERSION_51); } - static constexpr ParsedQuicVersion T050() { - return ParsedQuicVersion(PROTOCOL_TLS1_3, QUIC_VERSION_50); - } - static constexpr ParsedQuicVersion Q050() { return ParsedQuicVersion(PROTOCOL_QUIC_CRYPTO, QUIC_VERSION_50); } @@ -308,9 +302,6 @@ struct QUIC_EXPORT_PRIVATE ParsedQuicVersion { // Returns whether this version supports IETF RETRY packets. bool SupportsRetry() const; - // Returns whether RETRY packets carry the Retry Integrity Tag field. - bool HasRetryIntegrityTag() const; - // Returns true if this version sends variable length packet number in long // header. bool SendsVariableLengthPacketNumberInLongHeader() const; @@ -368,16 +359,8 @@ struct QUIC_EXPORT_PRIVATE ParsedQuicVersion { // frames or not. bool HasIetfQuicFrames() const; - // Returns true if this parsed version supports handshake done. - bool HasHandshakeDone() const; - - // Returns true if this version uses variable-length integers when - // encoding transport parameter types and lengths. - bool HasVarIntTransportParams() const; - - // Returns true if this version uses transport parameters to authenticate all - // the connection IDs used during the handshake. - bool AuthenticatesHandshakeConnectionIds() const; + // Returns whether this version uses the legacy TLS extension codepoint. + bool UsesLegacyTlsExtension() const; // Returns whether this version uses PROTOCOL_TLS1_3. bool UsesTls() const; @@ -417,12 +400,11 @@ constexpr std::array<HandshakeProtocol, 2> SupportedHandshakeProtocols() { return {PROTOCOL_TLS1_3, PROTOCOL_QUIC_CRYPTO}; } -constexpr std::array<ParsedQuicVersion, 7> SupportedVersions() { +constexpr std::array<ParsedQuicVersion, 6> SupportedVersions() { return { - ParsedQuicVersion::Draft29(), ParsedQuicVersion::Draft27(), - ParsedQuicVersion::T051(), ParsedQuicVersion::T050(), - ParsedQuicVersion::Q050(), ParsedQuicVersion::Q046(), - ParsedQuicVersion::Q043(), + ParsedQuicVersion::RFCv1(), ParsedQuicVersion::Draft29(), + ParsedQuicVersion::T051(), ParsedQuicVersion::Q050(), + ParsedQuicVersion::Q046(), ParsedQuicVersion::Q043(), }; } @@ -432,16 +414,11 @@ QUIC_EXPORT_PRIVATE std::ostream& operator<<( std::ostream& os, const QuicTransportVersionVector& transport_versions); -// Returns a vector of QUIC versions in kSupportedTransportVersions. -QUIC_EXPORT_PRIVATE QuicTransportVersionVector AllSupportedTransportVersions(); - -// Returns a vector of QUIC versions that is the cartesian product of -// kSupportedTransportVersions and kSupportedHandshakeProtocols. +// Returns a vector of supported QUIC versions. QUIC_EXPORT_PRIVATE ParsedQuicVersionVector AllSupportedVersions(); -// Returns a vector of QUIC versions that is the cartesian product of -// kSupportedTransportVersions and kSupportedHandshakeProtocols, with any -// versions disabled by flags excluded. +// Returns a vector of supported QUIC versions, with any versions disabled by +// flags excluded. QUIC_EXPORT_PRIVATE ParsedQuicVersionVector CurrentSupportedVersions(); // Returns a vector of QUIC versions from |versions| which exclude any versions @@ -470,22 +447,10 @@ QUIC_EXPORT_PRIVATE ParsedQuicVersionVector AllSupportedVersionsWithTls(); QUIC_EXPORT_PRIVATE ParsedQuicVersionVector CurrentSupportedVersionsWithTls(); // Returns QUIC version of |index| in result of |versions|. Returns -// QUIC_VERSION_UNSUPPORTED if |index| is out of bounds. -QUIC_EXPORT_PRIVATE QuicTransportVersionVector -VersionOfIndex(const QuicTransportVersionVector& versions, int index); - -// Returns QUIC version of |index| in result of |versions|. Returns // UnsupportedQuicVersion() if |index| is out of bounds. QUIC_EXPORT_PRIVATE ParsedQuicVersionVector ParsedVersionOfIndex(const ParsedQuicVersionVector& versions, int index); -// Returns a vector of QuicTransportVersions corresponding to just the transport -// versions in |versions|. If the input vector contains multiple parsed versions -// with different handshake protocols (but the same transport version), that -// transport version will appear in the resulting vector multiple times. -QUIC_EXPORT_PRIVATE QuicTransportVersionVector -ParsedVersionsToTransportVersions(const ParsedQuicVersionVector& versions); - // QuicVersionLabel is written to and read from the wire, but we prefer to use // the more readable ParsedQuicVersion at other levels. // Helper function which translates from a QuicVersionLabel to a @@ -493,7 +458,7 @@ ParsedVersionsToTransportVersions(const ParsedQuicVersionVector& versions); QUIC_EXPORT_PRIVATE ParsedQuicVersion ParseQuicVersionLabel(QuicVersionLabel version_label); -// Parses a QUIC version string such as "Q043" or "T050". Also supports parsing +// Parses a QUIC version string such as "Q043" or "T051". Also supports parsing // ALPN such as "h3-29" or "h3-Q050". For PROTOCOL_QUIC_CRYPTO versions, also // supports parsing numbers such as "46". QUIC_EXPORT_PRIVATE ParsedQuicVersion @@ -506,6 +471,10 @@ QUIC_EXPORT_PRIVATE ParsedQuicVersionVector ParseQuicVersionVectorString(absl::string_view versions_string); // Constructs a QuicVersionLabel from the provided ParsedQuicVersion. +// QuicVersionLabel is written to and read from the wire, but we prefer to use +// the more readable ParsedQuicVersion at other levels. +// Helper function which translates from a ParsedQuicVersion to a +// QuicVersionLabel. Returns 0 if |parsed_version| is unsupported. QUIC_EXPORT_PRIVATE QuicVersionLabel CreateQuicVersionLabel(ParsedQuicVersion parsed_version); @@ -514,13 +483,6 @@ CreateQuicVersionLabel(ParsedQuicVersion parsed_version); QUIC_EXPORT_PRIVATE QuicVersionLabelVector CreateQuicVersionLabelVector(const ParsedQuicVersionVector& versions); -// QuicVersionLabel is written to and read from the wire, but we prefer to use -// the more readable QuicTransportVersion at other levels. -// Helper function which translates from a QuicTransportVersion to a -// QuicVersionLabel. Returns 0 if |version| is unsupported. -QUIC_EXPORT_PRIVATE QuicVersionLabel -QuicVersionToQuicVersionLabel(QuicTransportVersion transport_version); - // Helper function which translates from a QuicVersionLabel to a string. QUIC_EXPORT_PRIVATE std::string QuicVersionLabelToString( QuicVersionLabel version_label); @@ -541,21 +503,15 @@ QUIC_EXPORT_PRIVATE inline std::string QuicVersionLabelVectorToString( std::numeric_limits<size_t>::max()); } -// Returns appropriate QuicTransportVersion from a QuicVersionLabel. -// Returns QUIC_VERSION_UNSUPPORTED if |version_label| cannot be understood. -QUIC_EXPORT_PRIVATE QuicTransportVersion -QuicVersionLabelToQuicVersion(QuicVersionLabel version_label); - -// Returns the HandshakeProtocol used with the given |version_label|, returning -// PROTOCOL_UNSUPPORTED if it is unknown. -QUIC_EXPORT_PRIVATE HandshakeProtocol -QuicVersionLabelToHandshakeProtocol(QuicVersionLabel version_label); - // Helper function which translates from a ParsedQuicVersion to a string. // Returns strings corresponding to the on-the-wire tag. QUIC_EXPORT_PRIVATE std::string ParsedQuicVersionToString( ParsedQuicVersion version); +// Returns a vector of supported QUIC transport versions. DEPRECATED, use +// AllSupportedVersions instead. +QUIC_EXPORT_PRIVATE QuicTransportVersionVector AllSupportedTransportVersions(); + // Returns comma separated list of string representations of // QuicTransportVersion enum values in the supplied |versions| vector. QUIC_EXPORT_PRIVATE std::string QuicTransportVersionVectorToString( diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_versions_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_versions_test.cc index 452f3f8e345..c9bc8b311ed 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_versions_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_versions_test.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_versions.h" +#include "quic/core/quic_versions.h" #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#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_mock_log.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_mock_log.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { @@ -26,32 +26,7 @@ class QuicVersionsTest : public QuicTest { } }; -TEST_F(QuicVersionsTest, QuicVersionToQuicVersionLabel) { - // If you add a new version to the QuicTransportVersion enum you will need to - // add a new case to QuicVersionToQuicVersionLabel, otherwise this test will - // fail. - - // Any logs would indicate an unsupported version which we don't expect. - CREATE_QUIC_MOCK_LOG(log); - EXPECT_QUIC_LOG_CALL(log).Times(0); - log.StartCapturingLogs(); - - // Explicitly test a specific version. - EXPECT_EQ(MakeQuicTag('3', '4', '0', 'Q'), - QuicVersionToQuicVersionLabel(QUIC_VERSION_43)); - - // Loop over all supported versions and make sure that we never hit the - // default case (i.e. all supported versions should be successfully converted - // to valid QuicVersionLabels). - for (QuicTransportVersion transport_version : SupportedTransportVersions()) { - if (!ParsedQuicVersionIsValid(PROTOCOL_QUIC_CRYPTO, transport_version)) { - continue; - } - EXPECT_LT(0u, QuicVersionToQuicVersionLabel(transport_version)); - } -} - -TEST_F(QuicVersionsTest, QuicVersionToQuicVersionLabelUnsupported) { +TEST_F(QuicVersionsTest, CreateQuicVersionLabelUnsupported) { EXPECT_QUIC_BUG( CreateQuicVersionLabel(UnsupportedQuicVersion()), "Unsupported version QUIC_VERSION_UNSUPPORTED PROTOCOL_UNSUPPORTED"); @@ -74,7 +49,7 @@ TEST_F(QuicVersionsTest, KnownAndValid) { // Check that invalid combinations are not valid. EXPECT_FALSE(ParsedQuicVersionIsValid(PROTOCOL_TLS1_3, QUIC_VERSION_43)); EXPECT_FALSE(ParsedQuicVersionIsValid(PROTOCOL_QUIC_CRYPTO, - QUIC_VERSION_IETF_DRAFT_27)); + QUIC_VERSION_IETF_DRAFT_29)); // Check that deprecated versions are not valid. EXPECT_FALSE(ParsedQuicVersionIsValid(PROTOCOL_QUIC_CRYPTO, static_cast<QuicTransportVersion>(33))); @@ -86,7 +61,7 @@ TEST_F(QuicVersionsTest, KnownAndValid) { TEST_F(QuicVersionsTest, Features) { ParsedQuicVersion parsed_version_q043 = ParsedQuicVersion::Q043(); - ParsedQuicVersion parsed_version_draft_27 = ParsedQuicVersion::Draft27(); + ParsedQuicVersion parsed_version_draft_29 = ParsedQuicVersion::Draft29(); EXPECT_TRUE(parsed_version_q043.IsKnown()); EXPECT_FALSE(parsed_version_q043.KnowsWhichDecrypterToUse()); @@ -94,7 +69,6 @@ TEST_F(QuicVersionsTest, Features) { EXPECT_FALSE(parsed_version_q043.AllowsLowFlowControlLimits()); EXPECT_FALSE(parsed_version_q043.HasHeaderProtection()); EXPECT_FALSE(parsed_version_q043.SupportsRetry()); - EXPECT_FALSE(parsed_version_q043.HasRetryIntegrityTag()); EXPECT_FALSE( parsed_version_q043.SendsVariableLengthPacketNumberInLongHeader()); EXPECT_FALSE(parsed_version_q043.AllowsVariableLengthConnectionIds()); @@ -109,101 +83,31 @@ TEST_F(QuicVersionsTest, Features) { EXPECT_FALSE(parsed_version_q043.HasLongHeaderLengths()); EXPECT_FALSE(parsed_version_q043.UsesCryptoFrames()); EXPECT_FALSE(parsed_version_q043.HasIetfQuicFrames()); - EXPECT_FALSE(parsed_version_q043.HasHandshakeDone()); - EXPECT_FALSE(parsed_version_q043.HasVarIntTransportParams()); EXPECT_FALSE(parsed_version_q043.UsesTls()); EXPECT_TRUE(parsed_version_q043.UsesQuicCrypto()); - EXPECT_TRUE(parsed_version_draft_27.IsKnown()); - EXPECT_TRUE(parsed_version_draft_27.KnowsWhichDecrypterToUse()); - EXPECT_TRUE(parsed_version_draft_27.UsesInitialObfuscators()); - EXPECT_TRUE(parsed_version_draft_27.AllowsLowFlowControlLimits()); - EXPECT_TRUE(parsed_version_draft_27.HasHeaderProtection()); - EXPECT_TRUE(parsed_version_draft_27.SupportsRetry()); - EXPECT_TRUE(parsed_version_draft_27.HasRetryIntegrityTag()); + EXPECT_TRUE(parsed_version_draft_29.IsKnown()); + EXPECT_TRUE(parsed_version_draft_29.KnowsWhichDecrypterToUse()); + EXPECT_TRUE(parsed_version_draft_29.UsesInitialObfuscators()); + EXPECT_TRUE(parsed_version_draft_29.AllowsLowFlowControlLimits()); + EXPECT_TRUE(parsed_version_draft_29.HasHeaderProtection()); + EXPECT_TRUE(parsed_version_draft_29.SupportsRetry()); EXPECT_TRUE( - parsed_version_draft_27.SendsVariableLengthPacketNumberInLongHeader()); - EXPECT_TRUE(parsed_version_draft_27.AllowsVariableLengthConnectionIds()); - EXPECT_TRUE(parsed_version_draft_27.SupportsClientConnectionIds()); - EXPECT_TRUE(parsed_version_draft_27.HasLengthPrefixedConnectionIds()); - EXPECT_TRUE(parsed_version_draft_27.SupportsAntiAmplificationLimit()); - EXPECT_TRUE(parsed_version_draft_27.CanSendCoalescedPackets()); - EXPECT_FALSE(parsed_version_draft_27.SupportsGoogleAltSvcFormat()); - EXPECT_TRUE(parsed_version_draft_27.HasIetfInvariantHeader()); - EXPECT_TRUE(parsed_version_draft_27.SupportsMessageFrames()); - EXPECT_TRUE(parsed_version_draft_27.UsesHttp3()); - EXPECT_TRUE(parsed_version_draft_27.HasLongHeaderLengths()); - EXPECT_TRUE(parsed_version_draft_27.UsesCryptoFrames()); - EXPECT_TRUE(parsed_version_draft_27.HasIetfQuicFrames()); - EXPECT_TRUE(parsed_version_draft_27.HasHandshakeDone()); - EXPECT_TRUE(parsed_version_draft_27.HasVarIntTransportParams()); - EXPECT_TRUE(parsed_version_draft_27.UsesTls()); - EXPECT_FALSE(parsed_version_draft_27.UsesQuicCrypto()); -} - -TEST_F(QuicVersionsTest, QuicVersionLabelToQuicTransportVersion) { - // If you add a new version to the QuicTransportVersion enum you will need to - // add a new case to QuicVersionLabelToQuicTransportVersion, otherwise this - // test will fail. - - // Any logs would indicate an unsupported version which we don't expect. - CREATE_QUIC_MOCK_LOG(log); - EXPECT_QUIC_LOG_CALL(log).Times(0); - log.StartCapturingLogs(); - - // Explicitly test specific versions. - EXPECT_EQ(QUIC_VERSION_43, - QuicVersionLabelToQuicVersion(MakeQuicTag('3', '4', '0', 'Q'))); - - for (QuicTransportVersion transport_version : SupportedTransportVersions()) { - if (!ParsedQuicVersionIsValid(PROTOCOL_QUIC_CRYPTO, transport_version)) { - continue; - } - - // Get the label from the version (we can loop over QuicVersions easily). - QuicVersionLabel version_label = - QuicVersionToQuicVersionLabel(transport_version); - EXPECT_LT(0u, version_label); - - // Now try converting back. - QuicTransportVersion label_to_transport_version = - QuicVersionLabelToQuicVersion(version_label); - EXPECT_EQ(transport_version, label_to_transport_version); - EXPECT_NE(QUIC_VERSION_UNSUPPORTED, label_to_transport_version); - } -} - -TEST_F(QuicVersionsTest, QuicVersionLabelToQuicVersionUnsupported) { - CREATE_QUIC_MOCK_LOG(log); - if (QUIC_DLOG_INFO_IS_ON()) { - EXPECT_QUIC_LOG_CALL_CONTAINS(log, INFO, - "Unsupported QuicVersionLabel version: EKAF") - .Times(1); - } - log.StartCapturingLogs(); - - EXPECT_EQ(QUIC_VERSION_UNSUPPORTED, - QuicVersionLabelToQuicVersion(MakeQuicTag('F', 'A', 'K', 'E'))); -} - -TEST_F(QuicVersionsTest, QuicVersionLabelToHandshakeProtocol) { - CREATE_QUIC_MOCK_LOG(log); - EXPECT_QUIC_LOG_CALL(log).Times(0); - log.StartCapturingLogs(); - - for (const ParsedQuicVersion& version : AllSupportedVersions()) { - if (version.handshake_protocol != PROTOCOL_QUIC_CRYPTO) { - continue; - } - QuicVersionLabel version_label = - QuicVersionToQuicVersionLabel(version.transport_version); - EXPECT_EQ(PROTOCOL_QUIC_CRYPTO, - QuicVersionLabelToHandshakeProtocol(version_label)); - } - - // Test a TLS version: - QuicTag tls_tag = MakeQuicTag('0', '5', '0', 'T'); - EXPECT_EQ(PROTOCOL_TLS1_3, QuicVersionLabelToHandshakeProtocol(tls_tag)); + parsed_version_draft_29.SendsVariableLengthPacketNumberInLongHeader()); + EXPECT_TRUE(parsed_version_draft_29.AllowsVariableLengthConnectionIds()); + EXPECT_TRUE(parsed_version_draft_29.SupportsClientConnectionIds()); + EXPECT_TRUE(parsed_version_draft_29.HasLengthPrefixedConnectionIds()); + EXPECT_TRUE(parsed_version_draft_29.SupportsAntiAmplificationLimit()); + EXPECT_TRUE(parsed_version_draft_29.CanSendCoalescedPackets()); + EXPECT_FALSE(parsed_version_draft_29.SupportsGoogleAltSvcFormat()); + EXPECT_TRUE(parsed_version_draft_29.HasIetfInvariantHeader()); + EXPECT_TRUE(parsed_version_draft_29.SupportsMessageFrames()); + EXPECT_TRUE(parsed_version_draft_29.UsesHttp3()); + EXPECT_TRUE(parsed_version_draft_29.HasLongHeaderLengths()); + EXPECT_TRUE(parsed_version_draft_29.UsesCryptoFrames()); + EXPECT_TRUE(parsed_version_draft_29.HasIetfQuicFrames()); + EXPECT_TRUE(parsed_version_draft_29.UsesTls()); + EXPECT_FALSE(parsed_version_draft_29.UsesQuicCrypto()); } TEST_F(QuicVersionsTest, ParseQuicVersionLabel) { @@ -213,8 +117,10 @@ TEST_F(QuicVersionsTest, ParseQuicVersionLabel) { ParseQuicVersionLabel(MakeVersionLabel('Q', '0', '4', '6'))); EXPECT_EQ(ParsedQuicVersion::Q050(), ParseQuicVersionLabel(MakeVersionLabel('Q', '0', '5', '0'))); - EXPECT_EQ(ParsedQuicVersion::T050(), - ParseQuicVersionLabel(MakeVersionLabel('T', '0', '5', '0'))); + EXPECT_EQ(ParsedQuicVersion::T051(), + ParseQuicVersionLabel(MakeVersionLabel('T', '0', '5', '1'))); + EXPECT_EQ(ParsedQuicVersion::Draft29(), + ParseQuicVersionLabel(MakeVersionLabel(0xff, 0x00, 0x00, 0x1d))); } TEST_F(QuicVersionsTest, ParseQuicVersionString) { @@ -226,6 +132,8 @@ TEST_F(QuicVersionsTest, ParseQuicVersionString) { EXPECT_EQ(ParsedQuicVersion::Q050(), ParseQuicVersionString("Q050")); EXPECT_EQ(ParsedQuicVersion::Q050(), ParseQuicVersionString("50")); EXPECT_EQ(ParsedQuicVersion::Q050(), ParseQuicVersionString("h3-Q050")); + EXPECT_EQ(ParsedQuicVersion::T051(), ParseQuicVersionString("T051")); + EXPECT_EQ(ParsedQuicVersion::T051(), ParseQuicVersionString("h3-T051")); EXPECT_EQ(UnsupportedQuicVersion(), ParseQuicVersionString("")); EXPECT_EQ(UnsupportedQuicVersion(), ParseQuicVersionString("Q 46")); @@ -233,14 +141,9 @@ TEST_F(QuicVersionsTest, ParseQuicVersionString) { EXPECT_EQ(UnsupportedQuicVersion(), ParseQuicVersionString("99")); EXPECT_EQ(UnsupportedQuicVersion(), ParseQuicVersionString("70")); - EXPECT_EQ(ParsedQuicVersion::T050(), ParseQuicVersionString("T050")); - EXPECT_EQ(ParsedQuicVersion::T050(), ParseQuicVersionString("h3-T050")); EXPECT_EQ(ParsedQuicVersion::Draft29(), ParseQuicVersionString("ff00001d")); EXPECT_EQ(ParsedQuicVersion::Draft29(), ParseQuicVersionString("draft29")); EXPECT_EQ(ParsedQuicVersion::Draft29(), ParseQuicVersionString("h3-29")); - EXPECT_EQ(ParsedQuicVersion::Draft27(), ParseQuicVersionString("ff00001b")); - EXPECT_EQ(ParsedQuicVersion::Draft27(), ParseQuicVersionString("draft27")); - EXPECT_EQ(ParsedQuicVersion::Draft27(), ParseQuicVersionString("h3-27")); for (const ParsedQuicVersion& version : AllSupportedVersions()) { EXPECT_EQ(version, @@ -249,11 +152,9 @@ TEST_F(QuicVersionsTest, ParseQuicVersionString) { } TEST_F(QuicVersionsTest, ParseQuicVersionVectorString) { - ParsedQuicVersion version_q046(PROTOCOL_QUIC_CRYPTO, QUIC_VERSION_46); - ParsedQuicVersion version_q050(PROTOCOL_QUIC_CRYPTO, QUIC_VERSION_50); - ParsedQuicVersion version_t050(PROTOCOL_TLS1_3, QUIC_VERSION_50); - ParsedQuicVersion version_draft_27(PROTOCOL_TLS1_3, - QUIC_VERSION_IETF_DRAFT_27); + ParsedQuicVersion version_q046 = ParsedQuicVersion::Q046(); + ParsedQuicVersion version_q050 = ParsedQuicVersion::Q050(); + ParsedQuicVersion version_t051 = ParsedQuicVersion::T051(); ParsedQuicVersion version_draft_29 = ParsedQuicVersion::Draft29(); EXPECT_THAT(ParseQuicVersionVectorString(""), IsEmpty()); @@ -262,35 +163,35 @@ TEST_F(QuicVersionsTest, ParseQuicVersionVectorString) { ElementsAre(version_q050)); EXPECT_THAT(ParseQuicVersionVectorString("h3-Q050"), ElementsAre(version_q050)); - EXPECT_THAT(ParseQuicVersionVectorString("h3-T050"), - ElementsAre(version_t050)); - - EXPECT_THAT(ParseQuicVersionVectorString("h3-27, h3-29"), - ElementsAre(version_draft_27, version_draft_29)); - EXPECT_THAT(ParseQuicVersionVectorString("h3-29,h3-27,h3-29"), - ElementsAre(version_draft_29, version_draft_27)); - EXPECT_THAT(ParseQuicVersionVectorString("h3-29,h3-27, h3-29"), - ElementsAre(version_draft_29, version_draft_27)); - EXPECT_THAT(ParseQuicVersionVectorString("h3-27,h3-29"), - ElementsAre(version_draft_27, version_draft_29)); - EXPECT_THAT(ParseQuicVersionVectorString("h3-29,h3-27"), - ElementsAre(version_draft_29, version_draft_27)); - - EXPECT_THAT(ParseQuicVersionVectorString("h3-27,50"), - ElementsAre(version_draft_27, version_q050)); - - EXPECT_THAT(ParseQuicVersionVectorString("h3-Q050, h3-T050"), - ElementsAre(version_q050, version_t050)); - EXPECT_THAT(ParseQuicVersionVectorString("h3-T050, h3-Q050"), - ElementsAre(version_t050, version_q050)); - EXPECT_THAT(ParseQuicVersionVectorString("QUIC_VERSION_50,h3-T050"), - ElementsAre(version_q050, version_t050)); - EXPECT_THAT(ParseQuicVersionVectorString("h3-T050,QUIC_VERSION_50"), - ElementsAre(version_t050, version_q050)); - EXPECT_THAT(ParseQuicVersionVectorString("QUIC_VERSION_50, h3-T050"), - ElementsAre(version_q050, version_t050)); - EXPECT_THAT(ParseQuicVersionVectorString("h3-T050, QUIC_VERSION_50"), - ElementsAre(version_t050, version_q050)); + EXPECT_THAT(ParseQuicVersionVectorString("h3-T051"), + ElementsAre(version_t051)); + + EXPECT_THAT(ParseQuicVersionVectorString("h3-T051, h3-29"), + ElementsAre(version_t051, version_draft_29)); + EXPECT_THAT(ParseQuicVersionVectorString("h3-29,h3-T051,h3-29"), + ElementsAre(version_draft_29, version_t051)); + EXPECT_THAT(ParseQuicVersionVectorString("h3-29,h3-T051, h3-29"), + ElementsAre(version_draft_29, version_t051)); + EXPECT_THAT(ParseQuicVersionVectorString("h3-T051,h3-29"), + ElementsAre(version_t051, version_draft_29)); + EXPECT_THAT(ParseQuicVersionVectorString("h3-29,h3-T051"), + ElementsAre(version_draft_29, version_t051)); + + EXPECT_THAT(ParseQuicVersionVectorString("h3-T051,50"), + ElementsAre(version_t051, version_q050)); + + EXPECT_THAT(ParseQuicVersionVectorString("h3-Q050, h3-T051"), + ElementsAre(version_q050, version_t051)); + EXPECT_THAT(ParseQuicVersionVectorString("h3-T051, h3-Q050"), + ElementsAre(version_t051, version_q050)); + EXPECT_THAT(ParseQuicVersionVectorString("QUIC_VERSION_50,h3-T051"), + ElementsAre(version_q050, version_t051)); + EXPECT_THAT(ParseQuicVersionVectorString("h3-T051,QUIC_VERSION_50"), + ElementsAre(version_t051, version_q050)); + EXPECT_THAT(ParseQuicVersionVectorString("QUIC_VERSION_50, h3-T051"), + ElementsAre(version_q050, version_t051)); + EXPECT_THAT(ParseQuicVersionVectorString("h3-T051, QUIC_VERSION_50"), + ElementsAre(version_t051, version_q050)); EXPECT_THAT(ParseQuicVersionVectorString("QUIC_VERSION_50,QUIC_VERSION_46"), ElementsAre(version_q050, version_q046)); @@ -302,15 +203,15 @@ TEST_F(QuicVersionsTest, ParseQuicVersionVectorString) { ElementsAre(version_q050)); EXPECT_THAT(ParseQuicVersionVectorString("h3-Q050, h3-Q050"), ElementsAre(version_q050)); - EXPECT_THAT(ParseQuicVersionVectorString("h3-T050, h3-T050"), - ElementsAre(version_t050)); + EXPECT_THAT(ParseQuicVersionVectorString("h3-T051, h3-T051"), + ElementsAre(version_t051)); EXPECT_THAT(ParseQuicVersionVectorString("h3-Q050, QUIC_VERSION_50"), ElementsAre(version_q050)); EXPECT_THAT(ParseQuicVersionVectorString( "QUIC_VERSION_50, h3-Q050, QUIC_VERSION_50, h3-Q050"), ElementsAre(version_q050)); - EXPECT_THAT(ParseQuicVersionVectorString("QUIC_VERSION_50, h3-T050, h3-Q050"), - ElementsAre(version_q050, version_t050)); + EXPECT_THAT(ParseQuicVersionVectorString("QUIC_VERSION_50, h3-T051, h3-Q050"), + ElementsAre(version_q050, version_t051)); EXPECT_THAT(ParseQuicVersionVectorString("99"), IsEmpty()); EXPECT_THAT(ParseQuicVersionVectorString("70"), IsEmpty()); @@ -328,8 +229,8 @@ TEST_F(QuicVersionsTest, CreateQuicVersionLabel) { CreateQuicVersionLabel(ParsedQuicVersion::Q050())); // Test a TLS version: - EXPECT_EQ(MakeVersionLabel('T', '0', '5', '0'), - CreateQuicVersionLabel(ParsedQuicVersion::T050())); + EXPECT_EQ(MakeVersionLabel('T', '0', '5', '1'), + CreateQuicVersionLabel(ParsedQuicVersion::T051())); // Make sure the negotiation reserved version is in the IETF reserved space. EXPECT_EQ( @@ -387,9 +288,9 @@ TEST_F(QuicVersionsTest, QuicVersionToString) { QuicTransportVersionVectorToString(versions_vector)); // Make sure that all supported versions are present in QuicVersionToString. - for (QuicTransportVersion transport_version : SupportedTransportVersions()) { + for (const ParsedQuicVersion& version : AllSupportedVersions()) { EXPECT_NE("QUIC_VERSION_UNSUPPORTED", - QuicVersionToString(transport_version)); + QuicVersionToString(version.transport_version)); } std::ostringstream os; @@ -402,8 +303,7 @@ TEST_F(QuicVersionsTest, ParsedQuicVersionToString) { EXPECT_EQ("Q043", ParsedQuicVersionToString(ParsedQuicVersion::Q043())); EXPECT_EQ("Q046", ParsedQuicVersionToString(ParsedQuicVersion::Q046())); EXPECT_EQ("Q050", ParsedQuicVersionToString(ParsedQuicVersion::Q050())); - EXPECT_EQ("T050", ParsedQuicVersionToString(ParsedQuicVersion::T050())); - EXPECT_EQ("draft27", ParsedQuicVersionToString(ParsedQuicVersion::Draft27())); + EXPECT_EQ("T051", ParsedQuicVersionToString(ParsedQuicVersion::T051())); EXPECT_EQ("draft29", ParsedQuicVersionToString(ParsedQuicVersion::Draft29())); ParsedQuicVersionVector versions_vector = {ParsedQuicVersion::Q043()}; @@ -454,19 +354,6 @@ TEST_F(QuicVersionsTest, FilterSupportedVersionsWithoutFirstVersion) { FilterSupportedVersions(AllSupportedVersions())); } -TEST_F(QuicVersionsTest, LookUpVersionByIndex) { - QuicTransportVersionVector all_versions = {QUIC_VERSION_43}; - int version_count = all_versions.size(); - for (int i = -5; i <= version_count + 1; ++i) { - QuicTransportVersionVector index = VersionOfIndex(all_versions, i); - if (i >= 0 && i < version_count) { - EXPECT_EQ(all_versions[i], index[0]); - } else { - EXPECT_EQ(QUIC_VERSION_UNSUPPORTED, index[0]); - } - } -} - TEST_F(QuicVersionsTest, LookUpParsedVersionByIndex) { ParsedQuicVersionVector all_versions = AllSupportedVersions(); int version_count = all_versions.size(); @@ -480,40 +367,29 @@ TEST_F(QuicVersionsTest, LookUpParsedVersionByIndex) { } } -TEST_F(QuicVersionsTest, ParsedVersionsToTransportVersions) { - ParsedQuicVersionVector all_versions = AllSupportedVersions(); - QuicTransportVersionVector transport_versions = - ParsedVersionsToTransportVersions(all_versions); - ASSERT_EQ(all_versions.size(), transport_versions.size()); - for (size_t i = 0; i < all_versions.size(); ++i) { - EXPECT_EQ(transport_versions[i], all_versions[i].transport_version); - } -} - // This test may appear to be so simplistic as to be unnecessary, // yet a typo was made in doing the #defines and it was caught // only in some test far removed from here... Better safe than sorry. TEST_F(QuicVersionsTest, CheckTransportVersionNumbersForTypos) { - static_assert(SupportedTransportVersions().size() == 6u, + static_assert(SupportedVersions().size() == 6u, "Supported versions out of sync"); EXPECT_EQ(QUIC_VERSION_43, 43); EXPECT_EQ(QUIC_VERSION_46, 46); EXPECT_EQ(QUIC_VERSION_50, 50); EXPECT_EQ(QUIC_VERSION_51, 51); - EXPECT_EQ(QUIC_VERSION_IETF_DRAFT_27, 71); EXPECT_EQ(QUIC_VERSION_IETF_DRAFT_29, 73); + EXPECT_EQ(QUIC_VERSION_IETF_RFC_V1, 80); } TEST_F(QuicVersionsTest, AlpnForVersion) { - static_assert(SupportedVersions().size() == 7u, + static_assert(SupportedVersions().size() == 6u, "Supported versions out of sync"); EXPECT_EQ("h3-Q043", AlpnForVersion(ParsedQuicVersion::Q043())); EXPECT_EQ("h3-Q046", AlpnForVersion(ParsedQuicVersion::Q046())); EXPECT_EQ("h3-Q050", AlpnForVersion(ParsedQuicVersion::Q050())); - EXPECT_EQ("h3-T050", AlpnForVersion(ParsedQuicVersion::T050())); EXPECT_EQ("h3-T051", AlpnForVersion(ParsedQuicVersion::T051())); - EXPECT_EQ("h3-27", AlpnForVersion(ParsedQuicVersion::Draft27())); EXPECT_EQ("h3-29", AlpnForVersion(ParsedQuicVersion::Draft29())); + EXPECT_EQ("h3", AlpnForVersion(ParsedQuicVersion::RFCv1())); } TEST_F(QuicVersionsTest, QuicVersionEnabling) { @@ -529,18 +405,18 @@ TEST_F(QuicVersionsTest, QuicVersionEnabling) { TEST_F(QuicVersionsTest, ReservedForNegotiation) { EXPECT_EQ(QUIC_VERSION_RESERVED_FOR_NEGOTIATION, QuicVersionReservedForNegotiation().transport_version); - // QUIC_VERSION_RESERVED_FOR_NEGOTIATION MUST NOT be added to - // kSupportedTransportVersions. - for (QuicTransportVersion transport_version : SupportedTransportVersions()) { - EXPECT_NE(QUIC_VERSION_RESERVED_FOR_NEGOTIATION, transport_version); + // QUIC_VERSION_RESERVED_FOR_NEGOTIATION MUST NOT be supported. + for (const ParsedQuicVersion& version : AllSupportedVersions()) { + EXPECT_NE(QUIC_VERSION_RESERVED_FOR_NEGOTIATION, version.transport_version); } } TEST_F(QuicVersionsTest, SupportedVersionsHasCorrectList) { size_t index = 0; for (HandshakeProtocol handshake_protocol : SupportedHandshakeProtocols()) { - for (QuicTransportVersion transport_version : - SupportedTransportVersions()) { + for (int trans_vers = 255; trans_vers > 0; trans_vers--) { + QuicTransportVersion transport_version = + static_cast<QuicTransportVersion>(trans_vers); SCOPED_TRACE(index); if (ParsedQuicVersionIsValid(handshake_protocol, transport_version)) { ParsedQuicVersion version = SupportedVersions()[index]; diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_write_blocked_list.cc b/chromium/net/third_party/quiche/src/quic/core/quic_write_blocked_list.cc index eba6a2936b3..084241db1e3 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_write_blocked_list.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_write_blocked_list.cc @@ -2,21 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_write_blocked_list.h" +#include "quic/core/quic_write_blocked_list.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" namespace quic { QuicWriteBlockedList::QuicWriteBlockedList(QuicTransportVersion version) - : priority_write_scheduler_( - std::make_unique<spdy::PriorityWriteScheduler<QuicStreamId>>( - QuicVersionUsesCryptoFrames(version) - ? std::numeric_limits<QuicStreamId>::max() - : 0)), - last_priority_popped_(0), - scheduler_type_(spdy::WriteSchedulerType::SPDY) { + : priority_write_scheduler_(QuicVersionUsesCryptoFrames(version) + ? std::numeric_limits<QuicStreamId>::max() + : 0), + last_priority_popped_(0) { memset(batch_write_stream_id_, 0, sizeof(batch_write_stream_id_)); memset(bytes_left_for_batch_write_, 0, sizeof(bytes_left_for_batch_write_)); } @@ -35,47 +32,7 @@ bool QuicWriteBlockedList::ShouldYield(QuicStreamId id) const { } } - return priority_write_scheduler_->ShouldYield(id); -} - -bool QuicWriteBlockedList::SwitchWriteScheduler(spdy::WriteSchedulerType type, - QuicTransportVersion version) { - if (scheduler_type_ == type) { - return true; - } - if (priority_write_scheduler_->NumRegisteredStreams() != 0) { - QUIC_BUG << "Cannot switch scheduler with registered streams"; - return false; - } - QUIC_DVLOG(1) << "Switching to scheduler type: " - << spdy::WriteSchedulerTypeToString(type); - switch (type) { - case spdy::WriteSchedulerType::LIFO: - priority_write_scheduler_ = - std::make_unique<spdy::LifoWriteScheduler<QuicStreamId>>(); - break; - case spdy::WriteSchedulerType::SPDY: - priority_write_scheduler_ = - std::make_unique<spdy::PriorityWriteScheduler<QuicStreamId>>( - QuicVersionUsesCryptoFrames(version) - ? std::numeric_limits<QuicStreamId>::max() - : 0); - break; - case spdy::WriteSchedulerType::HTTP2: - priority_write_scheduler_ = - std::make_unique<spdy::Http2PriorityWriteScheduler<QuicStreamId>>(); - break; - case spdy::WriteSchedulerType::FIFO: - priority_write_scheduler_ = - std::make_unique<spdy::FifoWriteScheduler<QuicStreamId>>(); - break; - default: - QUIC_BUG << "Scheduler is not supported for type: " - << spdy::WriteSchedulerTypeToString(type); - return false; - } - scheduler_type_ = type; - return true; + return priority_write_scheduler_.ShouldYield(id); } QuicStreamId QuicWriteBlockedList::PopFront() { @@ -85,16 +42,12 @@ QuicStreamId QuicWriteBlockedList::PopFront() { } const auto id_and_precedence = - priority_write_scheduler_->PopNextReadyStreamAndPrecedence(); + priority_write_scheduler_.PopNextReadyStreamAndPrecedence(); const QuicStreamId id = std::get<0>(id_and_precedence); - if (scheduler_type_ != spdy::WriteSchedulerType::SPDY) { - // No batch writing logic for non-SPDY priority write scheduler. - return id; - } const spdy::SpdyPriority priority = std::get<1>(id_and_precedence).spdy3_priority(); - if (!priority_write_scheduler_->HasReadyStreams()) { + if (!priority_write_scheduler_.HasReadyStreams()) { // If no streams are blocked, don't bother latching. This stream will be // the first popped for its priority anyway. batch_write_stream_id_[priority] = 0; @@ -113,15 +66,15 @@ void QuicWriteBlockedList::RegisterStream( QuicStreamId stream_id, bool is_static_stream, const spdy::SpdyStreamPrecedence& precedence) { - DCHECK(!priority_write_scheduler_->StreamRegistered(stream_id)) + QUICHE_DCHECK(!priority_write_scheduler_.StreamRegistered(stream_id)) << "stream " << stream_id << " already registered"; - DCHECK(PrecedenceMatchesSchedulerType(precedence)); + QUICHE_DCHECK(precedence.is_spdy3_priority()); if (is_static_stream) { static_stream_collection_.Register(stream_id); return; } - priority_write_scheduler_->RegisterStream(stream_id, precedence); + priority_write_scheduler_.RegisterStream(stream_id, precedence); } void QuicWriteBlockedList::UnregisterStream(QuicStreamId stream_id, @@ -130,22 +83,19 @@ void QuicWriteBlockedList::UnregisterStream(QuicStreamId stream_id, static_stream_collection_.Unregister(stream_id); return; } - priority_write_scheduler_->UnregisterStream(stream_id); + priority_write_scheduler_.UnregisterStream(stream_id); } void QuicWriteBlockedList::UpdateStreamPriority( QuicStreamId stream_id, const spdy::SpdyStreamPrecedence& new_precedence) { - DCHECK(!static_stream_collection_.IsRegistered(stream_id)); - DCHECK(PrecedenceMatchesSchedulerType(new_precedence)); - priority_write_scheduler_->UpdateStreamPrecedence(stream_id, new_precedence); + QUICHE_DCHECK(!static_stream_collection_.IsRegistered(stream_id)); + QUICHE_DCHECK(new_precedence.is_spdy3_priority()); + priority_write_scheduler_.UpdateStreamPrecedence(stream_id, new_precedence); } void QuicWriteBlockedList::UpdateBytesForStream(QuicStreamId stream_id, size_t bytes) { - if (scheduler_type_ != spdy::WriteSchedulerType::SPDY) { - return; - } if (batch_write_stream_id_[last_priority_popped_] == stream_id) { // If this was the last data stream popped by PopFront, update the // bytes remaining in its batch write. @@ -160,10 +110,9 @@ void QuicWriteBlockedList::AddStream(QuicStreamId stream_id) { } bool push_front = - scheduler_type_ == spdy::WriteSchedulerType::SPDY && stream_id == batch_write_stream_id_[last_priority_popped_] && bytes_left_for_batch_write_[last_priority_popped_] > 0; - priority_write_scheduler_->MarkStreamReady(stream_id, push_front); + priority_write_scheduler_.MarkStreamReady(stream_id, push_front); } bool QuicWriteBlockedList::IsStreamBlocked(QuicStreamId stream_id) const { @@ -173,29 +122,11 @@ bool QuicWriteBlockedList::IsStreamBlocked(QuicStreamId stream_id) const { } } - return priority_write_scheduler_->IsStreamReady(stream_id); -} - -bool QuicWriteBlockedList::PrecedenceMatchesSchedulerType( - const spdy::SpdyStreamPrecedence& precedence) { - switch (scheduler_type_) { - case spdy::WriteSchedulerType::LIFO: - break; - case spdy::WriteSchedulerType::SPDY: - return precedence.is_spdy3_priority(); - case spdy::WriteSchedulerType::HTTP2: - return !precedence.is_spdy3_priority(); - case spdy::WriteSchedulerType::FIFO: - break; - default: - DCHECK(false); - return false; - } - return true; + return priority_write_scheduler_.IsStreamReady(stream_id); } void QuicWriteBlockedList::StaticStreamCollection::Register(QuicStreamId id) { - DCHECK(!IsRegistered(id)); + QUICHE_DCHECK(!IsRegistered(id)); streams_.push_back({id, false}); } @@ -219,7 +150,7 @@ void QuicWriteBlockedList::StaticStreamCollection::Unregister(QuicStreamId id) { return; } } - DCHECK(false) << "Erasing a non-exist stream with id " << id; + QUICHE_DCHECK(false) << "Erasing a non-exist stream with id " << id; } bool QuicWriteBlockedList::StaticStreamCollection::SetBlocked(QuicStreamId id) { diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_write_blocked_list.h b/chromium/net/third_party/quiche/src/quic/core/quic_write_blocked_list.h index 930157b5197..3379fcb39df 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_write_blocked_list.h +++ b/chromium/net/third_party/quiche/src/quic/core/quic_write_blocked_list.h @@ -9,16 +9,13 @@ #include <cstdint> #include <utility> -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" -#include "net/third_party/quiche/src/spdy/core/fifo_write_scheduler.h" -#include "net/third_party/quiche/src/spdy/core/http2_priority_write_scheduler.h" -#include "net/third_party/quiche/src/spdy/core/lifo_write_scheduler.h" -#include "net/third_party/quiche/src/spdy/core/priority_write_scheduler.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_map_util.h" +#include "spdy/core/priority_write_scheduler.h" namespace quic { @@ -26,9 +23,6 @@ namespace quic { // priority. QUIC stream priority order is: // Crypto stream > Headers stream > Data streams by requested priority. class QUIC_EXPORT_PRIVATE QuicWriteBlockedList { - private: - using QuicPriorityWriteScheduler = spdy::WriteScheduler<QuicStreamId>; - public: explicit QuicWriteBlockedList(QuicTransportVersion version); QuicWriteBlockedList(const QuicWriteBlockedList&) = delete; @@ -36,7 +30,7 @@ class QUIC_EXPORT_PRIVATE QuicWriteBlockedList { ~QuicWriteBlockedList(); bool HasWriteBlockedDataStreams() const { - return priority_write_scheduler_->HasReadyStreams(); + return priority_write_scheduler_.HasReadyStreams(); } bool HasWriteBlockedSpecialStream() const { @@ -49,20 +43,15 @@ class QUIC_EXPORT_PRIVATE QuicWriteBlockedList { size_t NumBlockedStreams() const { return NumBlockedSpecialStreams() + - priority_write_scheduler_->NumReadyStreams(); + priority_write_scheduler_.NumReadyStreams(); } bool ShouldYield(QuicStreamId id) const; spdy::SpdyPriority GetSpdyPriorityofStream(QuicStreamId id) const { - return priority_write_scheduler_->GetStreamPrecedence(id).spdy3_priority(); + return priority_write_scheduler_.GetStreamPrecedence(id).spdy3_priority(); } - // Switches write scheduler. This can only be called before any stream is - // registered. - bool SwitchWriteScheduler(spdy::WriteSchedulerType type, - QuicTransportVersion version); - // Pops the highest priority stream, special casing crypto and headers // streams. Latches the most recently popped data stream for batch writing // purposes. @@ -88,13 +77,8 @@ class QUIC_EXPORT_PRIVATE QuicWriteBlockedList { // Returns true if stream with |stream_id| is write blocked. bool IsStreamBlocked(QuicStreamId stream_id) const; - spdy::WriteSchedulerType scheduler_type() const { return scheduler_type_; } - private: - bool PrecedenceMatchesSchedulerType( - const spdy::SpdyStreamPrecedence& precedence); - - std::unique_ptr<QuicPriorityWriteScheduler> priority_write_scheduler_; + spdy::PriorityWriteScheduler<QuicStreamId> priority_write_scheduler_; // If performing batch writes, this will be the stream ID of the stream doing // batch writes for this priority level. We will allow this stream to write @@ -152,8 +136,6 @@ class QUIC_EXPORT_PRIVATE QuicWriteBlockedList { }; StaticStreamCollection static_stream_collection_; - - spdy::WriteSchedulerType scheduler_type_; }; } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/quic_write_blocked_list_test.cc b/chromium/net/third_party/quiche/src/quic/core/quic_write_blocked_list_test.cc index 15494e21ffb..7cf77972f66 100644 --- a/chromium/net/third_party/quiche/src/quic/core/quic_write_blocked_list_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/quic_write_blocked_list_test.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/quic_write_blocked_list.h" +#include "quic/core/quic_write_blocked_list.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" using spdy::kHttp2DefaultStreamWeight; using spdy::kV3HighestPriority; @@ -15,73 +15,37 @@ namespace quic { namespace test { namespace { -const bool kExclusiveBit = true; - class QuicWriteBlockedListTest : public QuicTestWithParam<bool> { public: QuicWriteBlockedListTest() - : write_blocked_list_(AllSupportedVersions()[0].transport_version) { - if (GetParam()) { - write_blocked_list_.SwitchWriteScheduler( - spdy::WriteSchedulerType::HTTP2, - AllSupportedVersions()[0].transport_version); - } - } + : write_blocked_list_(AllSupportedVersions()[0].transport_version) {} protected: QuicWriteBlockedList write_blocked_list_; }; -INSTANTIATE_TEST_SUITE_P(Tests, - QuicWriteBlockedListTest, - ::testing::Bool(), - ::testing::PrintToStringParamName()); - -TEST_P(QuicWriteBlockedListTest, PriorityOrder) { - if (GetParam()) { - /* - 0 - | - 23 - | - 17 - | - 40 - */ - write_blocked_list_.RegisterStream( - 17, false, - spdy::SpdyStreamPrecedence(0, kHttp2DefaultStreamWeight, - kExclusiveBit)); - write_blocked_list_.RegisterStream( - 40, false, - spdy::SpdyStreamPrecedence(17, kHttp2DefaultStreamWeight, - kExclusiveBit)); - write_blocked_list_.RegisterStream( - 23, false, - spdy::SpdyStreamPrecedence(0, kHttp2DefaultStreamWeight, - kExclusiveBit)); - write_blocked_list_.RegisterStream( - 1, true, - spdy::SpdyStreamPrecedence(0, kHttp2DefaultStreamWeight, - kExclusiveBit)); - write_blocked_list_.RegisterStream( - 3, true, - spdy::SpdyStreamPrecedence(0, kHttp2DefaultStreamWeight, - kExclusiveBit)); - } else { - // Mark streams blocked in roughly reverse priority order, and - // verify that streams are sorted. - write_blocked_list_.RegisterStream( - 40, false, spdy::SpdyStreamPrecedence(kV3LowestPriority)); - write_blocked_list_.RegisterStream( - 23, false, spdy::SpdyStreamPrecedence(kV3HighestPriority)); - write_blocked_list_.RegisterStream( - 17, false, spdy::SpdyStreamPrecedence(kV3HighestPriority)); - write_blocked_list_.RegisterStream( - 1, true, spdy::SpdyStreamPrecedence(kV3HighestPriority)); - write_blocked_list_.RegisterStream( - 3, true, spdy::SpdyStreamPrecedence(kV3HighestPriority)); - } +TEST_F(QuicWriteBlockedListTest, PriorityOrder) { + /* + 0 + | + 23 + | + 17 + | + 40 + */ + // Mark streams blocked in roughly reverse priority order, and + // verify that streams are sorted. + write_blocked_list_.RegisterStream( + 40, false, spdy::SpdyStreamPrecedence(kV3LowestPriority)); + write_blocked_list_.RegisterStream( + 23, false, spdy::SpdyStreamPrecedence(kV3HighestPriority)); + write_blocked_list_.RegisterStream( + 17, false, spdy::SpdyStreamPrecedence(kV3HighestPriority)); + write_blocked_list_.RegisterStream( + 1, true, spdy::SpdyStreamPrecedence(kV3HighestPriority)); + write_blocked_list_.RegisterStream( + 3, true, spdy::SpdyStreamPrecedence(kV3HighestPriority)); write_blocked_list_.AddStream(40); EXPECT_TRUE(write_blocked_list_.IsStreamBlocked(40)); @@ -120,16 +84,9 @@ TEST_P(QuicWriteBlockedListTest, PriorityOrder) { EXPECT_FALSE(write_blocked_list_.HasWriteBlockedDataStreams()); } -TEST_P(QuicWriteBlockedListTest, CryptoStream) { - if (GetParam()) { - write_blocked_list_.RegisterStream( - 1, true, - spdy::SpdyStreamPrecedence(0, kHttp2DefaultStreamWeight, - kExclusiveBit)); - } else { - write_blocked_list_.RegisterStream( - 1, true, spdy::SpdyStreamPrecedence(kV3HighestPriority)); - } +TEST_F(QuicWriteBlockedListTest, CryptoStream) { + write_blocked_list_.RegisterStream( + 1, true, spdy::SpdyStreamPrecedence(kV3HighestPriority)); write_blocked_list_.AddStream(1); EXPECT_EQ(1u, write_blocked_list_.NumBlockedStreams()); @@ -139,16 +96,9 @@ TEST_P(QuicWriteBlockedListTest, CryptoStream) { EXPECT_FALSE(write_blocked_list_.HasWriteBlockedSpecialStream()); } -TEST_P(QuicWriteBlockedListTest, HeadersStream) { - if (GetParam()) { - write_blocked_list_.RegisterStream( - 3, true, - spdy::SpdyStreamPrecedence(0, kHttp2DefaultStreamWeight, - kExclusiveBit)); - } else { - write_blocked_list_.RegisterStream( - 3, true, spdy::SpdyStreamPrecedence(kV3HighestPriority)); - } +TEST_F(QuicWriteBlockedListTest, HeadersStream) { + write_blocked_list_.RegisterStream( + 3, true, spdy::SpdyStreamPrecedence(kV3HighestPriority)); write_blocked_list_.AddStream(3); EXPECT_EQ(1u, write_blocked_list_.NumBlockedStreams()); @@ -158,22 +108,11 @@ TEST_P(QuicWriteBlockedListTest, HeadersStream) { EXPECT_FALSE(write_blocked_list_.HasWriteBlockedSpecialStream()); } -TEST_P(QuicWriteBlockedListTest, VerifyHeadersStream) { - if (GetParam()) { - write_blocked_list_.RegisterStream( - 5, false, - spdy::SpdyStreamPrecedence(0, kHttp2DefaultStreamWeight, - kExclusiveBit)); - write_blocked_list_.RegisterStream( - 3, true, - spdy::SpdyStreamPrecedence(0, kHttp2DefaultStreamWeight, - kExclusiveBit)); - } else { - write_blocked_list_.RegisterStream( - 5, false, spdy::SpdyStreamPrecedence(kV3HighestPriority)); - write_blocked_list_.RegisterStream( - 3, true, spdy::SpdyStreamPrecedence(kV3HighestPriority)); - } +TEST_F(QuicWriteBlockedListTest, VerifyHeadersStream) { + write_blocked_list_.RegisterStream( + 5, false, spdy::SpdyStreamPrecedence(kV3HighestPriority)); + write_blocked_list_.RegisterStream( + 3, true, spdy::SpdyStreamPrecedence(kV3HighestPriority)); write_blocked_list_.AddStream(5); write_blocked_list_.AddStream(3); @@ -189,20 +128,13 @@ TEST_P(QuicWriteBlockedListTest, VerifyHeadersStream) { EXPECT_FALSE(write_blocked_list_.HasWriteBlockedDataStreams()); } -TEST_P(QuicWriteBlockedListTest, NoDuplicateEntries) { +TEST_F(QuicWriteBlockedListTest, NoDuplicateEntries) { // Test that QuicWriteBlockedList doesn't allow duplicate entries. // Try to add a stream to the write blocked list multiple times at the same // priority. const QuicStreamId kBlockedId = 3 + 2; - if (GetParam()) { - write_blocked_list_.RegisterStream( - kBlockedId, false, - spdy::SpdyStreamPrecedence(0, kHttp2DefaultStreamWeight, - kExclusiveBit)); - } else { write_blocked_list_.RegisterStream( kBlockedId, false, spdy::SpdyStreamPrecedence(kV3HighestPriority)); - } write_blocked_list_.AddStream(kBlockedId); write_blocked_list_.AddStream(kBlockedId); write_blocked_list_.AddStream(kBlockedId); @@ -217,10 +149,7 @@ TEST_P(QuicWriteBlockedListTest, NoDuplicateEntries) { EXPECT_FALSE(write_blocked_list_.HasWriteBlockedDataStreams()); } -TEST_P(QuicWriteBlockedListTest, BatchingWrites) { - if (GetParam()) { - return; - } +TEST_F(QuicWriteBlockedListTest, BatchingWrites) { const QuicStreamId id1 = 3 + 2; const QuicStreamId id2 = id1 + 2; const QuicStreamId id3 = id2 + 2; @@ -273,62 +202,31 @@ TEST_P(QuicWriteBlockedListTest, BatchingWrites) { EXPECT_EQ(id1, write_blocked_list_.PopFront()); } -TEST_P(QuicWriteBlockedListTest, Ceding) { - if (GetParam()) { - /* - 0 - | - 15 - | - 16 - | - 5 - | - 4 - | - 7 - */ - write_blocked_list_.RegisterStream( - 15, false, - spdy::SpdyStreamPrecedence(0, kHttp2DefaultStreamWeight, - kExclusiveBit)); - write_blocked_list_.RegisterStream( - 16, false, - spdy::SpdyStreamPrecedence(15, kHttp2DefaultStreamWeight, - kExclusiveBit)); - write_blocked_list_.RegisterStream( - 4, false, - spdy::SpdyStreamPrecedence(16, kHttp2DefaultStreamWeight, - kExclusiveBit)); - write_blocked_list_.RegisterStream( - 5, false, - spdy::SpdyStreamPrecedence(16, kHttp2DefaultStreamWeight, - kExclusiveBit)); - write_blocked_list_.RegisterStream( - 7, false, - spdy::SpdyStreamPrecedence(4, kHttp2DefaultStreamWeight, - kExclusiveBit)); - write_blocked_list_.RegisterStream( - 1, true, - spdy::SpdyStreamPrecedence(0, kHttp2DefaultStreamWeight, - kExclusiveBit)); - write_blocked_list_.RegisterStream( - 3, true, - spdy::SpdyStreamPrecedence(0, kHttp2DefaultStreamWeight, - kExclusiveBit)); - } else { - write_blocked_list_.RegisterStream( - 15, false, spdy::SpdyStreamPrecedence(kV3HighestPriority)); - write_blocked_list_.RegisterStream( - 16, false, spdy::SpdyStreamPrecedence(kV3HighestPriority)); - write_blocked_list_.RegisterStream(5, false, spdy::SpdyStreamPrecedence(5)); - write_blocked_list_.RegisterStream(4, false, spdy::SpdyStreamPrecedence(5)); - write_blocked_list_.RegisterStream(7, false, spdy::SpdyStreamPrecedence(7)); - write_blocked_list_.RegisterStream( - 1, true, spdy::SpdyStreamPrecedence(kV3HighestPriority)); - write_blocked_list_.RegisterStream( - 3, true, spdy::SpdyStreamPrecedence(kV3HighestPriority)); - } +TEST_F(QuicWriteBlockedListTest, Ceding) { + /* + 0 + | + 15 + | + 16 + | + 5 + | + 4 + | + 7 + */ + write_blocked_list_.RegisterStream( + 15, false, spdy::SpdyStreamPrecedence(kV3HighestPriority)); + write_blocked_list_.RegisterStream( + 16, false, spdy::SpdyStreamPrecedence(kV3HighestPriority)); + write_blocked_list_.RegisterStream(5, false, spdy::SpdyStreamPrecedence(5)); + write_blocked_list_.RegisterStream(4, false, spdy::SpdyStreamPrecedence(5)); + write_blocked_list_.RegisterStream(7, false, spdy::SpdyStreamPrecedence(7)); + write_blocked_list_.RegisterStream( + 1, true, spdy::SpdyStreamPrecedence(kV3HighestPriority)); + write_blocked_list_.RegisterStream( + 3, true, spdy::SpdyStreamPrecedence(kV3HighestPriority)); // When nothing is on the list, nothing yields. EXPECT_FALSE(write_blocked_list_.ShouldYield(5)); @@ -366,66 +264,6 @@ TEST_P(QuicWriteBlockedListTest, Ceding) { EXPECT_FALSE(write_blocked_list_.ShouldYield(1)); } -TEST_P(QuicWriteBlockedListTest, UpdateStreamPriority) { - if (!GetParam()) { - return; - } - /* - 0 - | - 5 - | - 7 - | - 9 - | - 11 - */ - write_blocked_list_.RegisterStream( - 5, false, - spdy::SpdyStreamPrecedence(0, kHttp2DefaultStreamWeight, kExclusiveBit)); - write_blocked_list_.RegisterStream( - 7, false, - spdy::SpdyStreamPrecedence(5, kHttp2DefaultStreamWeight, kExclusiveBit)); - write_blocked_list_.RegisterStream( - 9, false, - spdy::SpdyStreamPrecedence(7, kHttp2DefaultStreamWeight, kExclusiveBit)); - write_blocked_list_.RegisterStream( - 11, false, - spdy::SpdyStreamPrecedence(9, kHttp2DefaultStreamWeight, kExclusiveBit)); - - write_blocked_list_.AddStream(7); - EXPECT_FALSE(write_blocked_list_.ShouldYield(5)); - EXPECT_TRUE(write_blocked_list_.ShouldYield(9)); - EXPECT_TRUE(write_blocked_list_.ShouldYield(11)); - - // Update 9's priority. - if (GetParam()) { - /* - 0 - | - 5 - / \ - 7 9 - | - 11 - */ - write_blocked_list_.UpdateStreamPriority( - 9, spdy::SpdyStreamPrecedence(5, kHttp2DefaultStreamWeight, - kExclusiveBit)); - } else { - write_blocked_list_.UpdateStreamPriority(9, spdy::SpdyStreamPrecedence(1)); - } - EXPECT_FALSE(write_blocked_list_.ShouldYield(5)); - // Verify 9 now does not yield to 7. - EXPECT_FALSE(write_blocked_list_.ShouldYield(9)); - EXPECT_FALSE(write_blocked_list_.ShouldYield(11)); - - write_blocked_list_.AddStream(9); - // Verify 11 yield to 9. - EXPECT_TRUE(write_blocked_list_.ShouldYield(11)); -} - } // namespace } // namespace test } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/session_notifier_interface.h b/chromium/net/third_party/quiche/src/quic/core/session_notifier_interface.h index 89b4a9c28f1..fc16b63407b 100644 --- a/chromium/net/third_party/quiche/src/quic/core/session_notifier_interface.h +++ b/chromium/net/third_party/quiche/src/quic/core/session_notifier_interface.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_CORE_SESSION_NOTIFIER_INTERFACE_H_ #define QUICHE_QUIC_CORE_SESSION_NOTIFIER_INTERFACE_H_ -#include "net/third_party/quiche/src/quic/core/frames/quic_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" +#include "quic/core/frames/quic_frame.h" +#include "quic/core/quic_time.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/stream_delegate_interface.h b/chromium/net/third_party/quiche/src/quic/core/stream_delegate_interface.h index dc932999f2c..38b8e5326e7 100644 --- a/chromium/net/third_party/quiche/src/quic/core/stream_delegate_interface.h +++ b/chromium/net/third_party/quiche/src/quic/core/stream_delegate_interface.h @@ -7,8 +7,8 @@ #include <cstddef> #include "absl/types/optional.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" +#include "quic/core/quic_types.h" +#include "spdy/core/spdy_protocol.h" namespace quic { @@ -23,6 +23,11 @@ class QUIC_EXPORT_PRIVATE StreamDelegateInterface { // Called when the stream has encountered errors that it can't handle. virtual void OnStreamError(QuicErrorCode error_code, std::string error_details) = 0; + // Called when the stream has encountered errors that it can't handle, + // specifying the wire error code |ietf_error| explicitly. + virtual void OnStreamError(QuicErrorCode error_code, + QuicIetfTransportErrorCodes ietf_error, + std::string error_details) = 0; // Called when the stream needs to write data. If |level| is present, the data // will be written at the specified |level|. The data will be written // at specified transmission |type|. diff --git a/chromium/net/third_party/quiche/src/quic/core/tls_chlo_extractor.cc b/chromium/net/third_party/quiche/src/quic/core/tls_chlo_extractor.cc index 06ed1c8a4da..ca9eb5b9865 100644 --- a/chromium/net/third_party/quiche/src/quic/core/tls_chlo_extractor.cc +++ b/chromium/net/third_party/quiche/src/quic/core/tls_chlo_extractor.cc @@ -2,22 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/tls_chlo_extractor.h" +#include "quic/core/tls_chlo_extractor.h" #include <cstring> #include <memory> +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_crypto_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_data_reader.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/frames/quic_crypto_frame.h" +#include "quic/core/quic_data_reader.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { @@ -43,7 +43,7 @@ TlsChloExtractor& TlsChloExtractor::operator=(TlsChloExtractor&& other) { std::pair<SSL_CTX*, int> shared_handles = GetSharedSslHandles(); int ex_data_index = shared_handles.second; const int rv = SSL_set_ex_data(ssl_.get(), ex_data_index, this); - CHECK_EQ(rv, 1) << "Internal allocation failure in SSL_set_ex_data"; + QUICHE_CHECK_EQ(rv, 1) << "Internal allocation failure in SSL_set_ex_data"; } state_ = other.state_; error_details_ = std::move(other.error_details_); @@ -138,10 +138,19 @@ bool TlsChloExtractor::OnProtocolVersionMismatch(ParsedQuicVersion version) { // error that will prevent it from reassembling the crypto stream data. void TlsChloExtractor::OnUnrecoverableError(QuicErrorCode error, const std::string& details) { - HandleUnrecoverableError(quiche::QuicheStrCat( + HandleUnrecoverableError(absl::StrCat( "Crypto stream error ", QuicErrorCodeToString(error), ": ", details)); } +void TlsChloExtractor::OnUnrecoverableError( + QuicErrorCode error, + QuicIetfTransportErrorCodes ietf_error, + const std::string& details) { + HandleUnrecoverableError(absl::StrCat( + "Crypto stream error ", QuicErrorCodeToString(error), "(", + QuicIetfTransportErrorCodeString(ietf_error), "): ", details)); +} + // This is called by the framer if it sees a CRYPTO frame during parsing. bool TlsChloExtractor::OnCryptoFrame(const QuicCryptoFrame& frame) { if (frame.level != ENCRYPTION_INITIAL) { @@ -232,7 +241,7 @@ int TlsChloExtractor::FlushFlightCallback(SSL* ssl) { void TlsChloExtractor::HandleUnexpectedCallback( const std::string& callback_name) { std::string error_details = - quiche::QuicheStrCat("Unexpected callback ", callback_name); + absl::StrCat("Unexpected callback ", callback_name); QUIC_BUG << error_details; HandleUnrecoverableError(error_details); } @@ -252,7 +261,7 @@ void TlsChloExtractor::SendAlert(uint8_t tls_alert_value) { // try to send this alert to tell the client that the handshake failed. return; } - HandleUnrecoverableError(quiche::QuicheStrCat( + HandleUnrecoverableError(absl::StrCat( "BoringSSL attempted to send alert ", static_cast<int>(tls_alert_value), " ", SSL_alert_desc_string_long(tls_alert_value))); } @@ -346,8 +355,15 @@ void TlsChloExtractor::SetupSslHandle() { ssl_ = bssl::UniquePtr<SSL>(SSL_new(ssl_ctx)); const int rv = SSL_set_ex_data(ssl_.get(), ex_data_index, this); - CHECK_EQ(rv, 1) << "Internal allocation failure in SSL_set_ex_data"; + QUICHE_CHECK_EQ(rv, 1) << "Internal allocation failure in SSL_set_ex_data"; SSL_set_accept_state(ssl_.get()); + + // Make sure we use the right TLS extension codepoint. + int use_legacy_extension = 0; + if (framer_->version().UsesLegacyTlsExtension()) { + use_legacy_extension = 1; + } + SSL_set_quic_use_legacy_codepoint(ssl_.get(), use_legacy_extension); } // Called by other methods to record any unrecoverable failures they experience. @@ -365,7 +381,7 @@ void TlsChloExtractor::HandleUnrecoverableError( if (error_details_.empty()) { error_details_ = error_details; } else { - error_details_ = quiche::QuicheStrCat(error_details_, "; ", error_details); + error_details_ = absl::StrCat(error_details_, "; ", error_details); } } @@ -383,7 +399,7 @@ std::string TlsChloExtractor::StateToString(State state) { case State::kUnrecoverableFailure: return "UnrecoverableFailure"; } - return quiche::QuicheStrCat("Unknown(", static_cast<int>(state), ")"); + return absl::StrCat("Unknown(", static_cast<int>(state), ")"); } std::ostream& operator<<(std::ostream& os, diff --git a/chromium/net/third_party/quiche/src/quic/core/tls_chlo_extractor.h b/chromium/net/third_party/quiche/src/quic/core/tls_chlo_extractor.h index 718e5fa09eb..f7392a5817f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/tls_chlo_extractor.h +++ b/chromium/net/third_party/quiche/src/quic/core/tls_chlo_extractor.h @@ -9,11 +9,11 @@ #include <string> #include <vector> #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_stream_sequencer.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/frames/quic_ack_frequency_frame.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_stream_sequencer.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -74,7 +74,8 @@ class QUIC_NO_EXPORT TlsChloExtractor bool OnUnauthenticatedHeader(const QuicPacketHeader& /*header*/) override { return true; } - void OnDecryptedPacket(EncryptionLevel /*level*/) override {} + void OnDecryptedPacket(size_t /*packet_length*/, + EncryptionLevel /*level*/) override {} bool OnPacketHeader(const QuicPacketHeader& /*header*/) override { return true; } @@ -177,7 +178,11 @@ class QUIC_NO_EXPORT TlsChloExtractor void Reset(QuicRstStreamErrorCode /*error*/) override {} void OnUnrecoverableError(QuicErrorCode error, const std::string& details) override; + void OnUnrecoverableError(QuicErrorCode error, + QuicIetfTransportErrorCodes ietf_error, + const std::string& details) override; QuicStreamId id() const override { return 0; } + ParsedQuicVersion version() const override { return framer_->version(); } private: // Parses the length of the CHLO message by looking at the first four bytes. diff --git a/chromium/net/third_party/quiche/src/quic/core/tls_chlo_extractor_test.cc b/chromium/net/third_party/quiche/src/quic/core/tls_chlo_extractor_test.cc index db926b422c2..f5a6e85f96b 100644 --- a/chromium/net/third_party/quiche/src/quic/core/tls_chlo_extractor_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/tls_chlo_extractor_test.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/tls_chlo_extractor.h" +#include "quic/core/tls_chlo_extractor.h" #include <memory> -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/first_flight.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/http/quic_spdy_client_session.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_packet_writer_wrapper.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/first_flight.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/core/tls_client_handshaker.cc b/chromium/net/third_party/quiche/src/quic/core/tls_client_handshaker.cc index 6ea06b83b3c..448136f8013 100644 --- a/chromium/net/third_party/quiche/src/quic/core/tls_client_handshaker.cc +++ b/chromium/net/third_party/quiche/src/quic/core/tls_client_handshaker.cc @@ -2,21 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/tls_client_handshaker.h" +#include "quic/core/tls_client_handshaker.h" #include <cstring> #include <string> +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/transport_parameters.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_hostname_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/quic_crypto_client_config.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/crypto/transport_parameters.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_hostname_utils.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { @@ -39,7 +40,16 @@ TlsClientHandshaker::TlsClientHandshaker( pre_shared_key_(crypto_config->pre_shared_key()), crypto_negotiated_params_(new QuicCryptoNegotiatedParameters), has_application_state_(has_application_state), - tls_connection_(crypto_config->ssl_ctx(), this) {} + crypto_config_(crypto_config), + tls_connection_(crypto_config->ssl_ctx(), this) { + if (GetQuicReloadableFlag(quic_enable_token_based_address_validation)) { + std::string token = + crypto_config->LookupOrCreate(server_id)->source_address_token(); + if (!token.empty()) { + session->SetSourceAddressTokenToSend(token); + } + } +} TlsClientHandshaker::~TlsClientHandshaker() {} @@ -53,6 +63,13 @@ bool TlsClientHandshaker::CryptoConnect() { return false; } + // Make sure we use the right TLS extension codepoint. + int use_legacy_extension = 0; + if (session()->version().UsesLegacyTlsExtension()) { + use_legacy_extension = 1; + } + SSL_set_quic_use_legacy_codepoint(ssl(), use_legacy_extension); + // Set the SNI to send, if any. SSL_set_connect_state(ssl()); if (QUIC_DLOG_INFO_IS_ON() && @@ -158,6 +175,19 @@ bool TlsClientHandshaker::SetAlpn() { alpn_writer.data(), alpn_writer.length())); return false; } + + // Enable ALPS. + if (enable_alps_) { + for (const std::string& alpn_string : alpns) { + if (SSL_add_application_settings( + ssl(), reinterpret_cast<const uint8_t*>(alpn_string.data()), + alpn_string.size(), nullptr, /* settings_len = */ 0) != 1) { + QUIC_BUG << "Failed to enable ALPS."; + return false; + } + } + } + QUIC_DLOG(INFO) << "Client using ALPN: '" << alpns[0] << "'"; return true; } @@ -200,7 +230,7 @@ bool TlsClientHandshaker::ProcessTransportParameters( session()->connection()->version(), Perspective::IS_SERVER, param_bytes, param_bytes_len, received_transport_params_.get(), &parse_error_details)) { - DCHECK(!parse_error_details.empty()); + QUICHE_DCHECK(!parse_error_details.empty()); *error_details = "Unable to parse server's transport parameters: " + parse_error_details; return false; @@ -233,7 +263,7 @@ bool TlsClientHandshaker::ProcessTransportParameters( handshaker_delegate()->ProcessTransportParameters( *received_transport_params_, /* is_resumption = */ false, error_details) != QUIC_NO_ERROR) { - DCHECK(!error_details->empty()); + QUICHE_DCHECK(!error_details->empty()); return false; } @@ -346,6 +376,15 @@ void TlsClientHandshaker::OnHandshakeDoneReceived() { OnHandshakeConfirmed(); } +void TlsClientHandshaker::OnNewTokenReceived(absl::string_view token) { + if (token.empty()) { + return; + } + QuicCryptoClientConfig::CachedState* cached = + crypto_config_->LookupOrCreate(server_id_); + cached->set_source_address_token(token); +} + void TlsClientHandshaker::SetWriteSecret( EncryptionLevel level, const SSL_CIPHER* cipher, @@ -363,7 +402,7 @@ void TlsClientHandshaker::SetWriteSecret( } void TlsClientHandshaker::OnHandshakeConfirmed() { - DCHECK(one_rtt_keys_available()); + QUICHE_DCHECK(one_rtt_keys_available()); if (state_ >= HANDSHAKE_CONFIRMED) { return; } @@ -425,7 +464,7 @@ void TlsClientHandshaker::FinishHandshake() { std::string error_details; if (!ProcessTransportParameters(&error_details)) { - DCHECK(!error_details.empty()); + QUICHE_DCHECK(!error_details.empty()); CloseConnection(QUIC_HANDSHAKE_FAILED, error_details); return; } @@ -457,6 +496,23 @@ void TlsClientHandshaker::FinishHandshake() { session()->OnAlpnSelected(received_alpn_string); QUIC_DLOG(INFO) << "Client: server selected ALPN: '" << received_alpn_string << "'"; + + // Parse ALPS extension. + if (enable_alps_) { + const uint8_t* alps_data; + size_t alps_length; + SSL_get0_peer_application_settings(ssl(), &alps_data, &alps_length); + if (alps_length > 0) { + auto error = session()->OnAlpsData(alps_data, alps_length); + if (error) { + CloseConnection( + QUIC_HANDSHAKE_FAILED, + absl::StrCat("Error processing ALPS data: ", error.value())); + return; + } + } + } + state_ = HANDSHAKE_COMPLETE; handshaker_delegate()->OnTlsHandshakeComplete(); } @@ -479,7 +535,7 @@ bool TlsClientHandshaker::ShouldCloseConnectionOnUnexpectedError( void TlsClientHandshaker::HandleZeroRttReject() { QUIC_LOG(INFO) << "0-RTT handshake attempted but was rejected by the server"; - DCHECK(session_cache_); + QUICHE_DCHECK(session_cache_); // Disable encrytion to block outgoing data until 1-RTT keys are available. encryption_established_ = false; handshaker_delegate()->OnZeroRttRejected(EarlyDataReason()); @@ -520,7 +576,7 @@ void TlsClientHandshaker::WriteMessage(EncryptionLevel level, void TlsClientHandshaker::SetServerApplicationStateForResumption( std::unique_ptr<ApplicationState> application_state) { - DCHECK(one_rtt_keys_available()); + QUICHE_DCHECK(one_rtt_keys_available()); received_application_state_ = std::move(application_state); // At least one tls session is cached before application state is received. So // insert now. diff --git a/chromium/net/third_party/quiche/src/quic/core/tls_client_handshaker.h b/chromium/net/third_party/quiche/src/quic/core/tls_client_handshaker.h index aadfa0bf541..42d587fdbcc 100644 --- a/chromium/net/third_party/quiche/src/quic/core/tls_client_handshaker.h +++ b/chromium/net/third_party/quiche/src/quic/core/tls_client_handshaker.h @@ -11,13 +11,13 @@ #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.h" -#include "net/third_party/quiche/src/quic/core/crypto/tls_client_connection.h" -#include "net/third_party/quiche/src/quic/core/crypto/transport_parameters.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_client_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h" -#include "net/third_party/quiche/src/quic/core/tls_handshaker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/quic_crypto_client_config.h" +#include "quic/core/crypto/tls_client_connection.h" +#include "quic/core/crypto/transport_parameters.h" +#include "quic/core/quic_crypto_client_stream.h" +#include "quic/core/quic_crypto_stream.h" +#include "quic/core/tls_handshaker.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -28,6 +28,7 @@ class QUIC_EXPORT_PRIVATE TlsClientHandshaker public QuicCryptoClientStream::HandshakerInterface, public TlsClientConnection::Delegate { public: + // |crypto_config| must outlive TlsClientHandshaker. TlsClientHandshaker(const QuicServerId& server_id, QuicCryptoStream* stream, QuicSession* session, @@ -67,6 +68,7 @@ class QUIC_EXPORT_PRIVATE TlsClientHandshaker void OnConnectionClosed(QuicErrorCode error, ConnectionCloseSource source) override; void OnHandshakeDoneReceived() override; + void OnNewTokenReceived(absl::string_view token) override; void SetWriteSecret(EncryptionLevel level, const SSL_CIPHER* cipher, const std::vector<uint8_t>& write_secret) override; @@ -79,6 +81,8 @@ class QUIC_EXPORT_PRIVATE TlsClientHandshaker void AllowEmptyAlpnForTests() { allow_empty_alpn_for_tests_ = true; } void AllowInvalidSNIForTests() { allow_invalid_sni_for_tests_ = true; } + SSL* GetSslForTests() { return tls_connection_.ssl(); } + const SSL* GetSslForTests() const { return tls_connection_.ssl(); } protected: const TlsConnection* tls_connection() const override { @@ -152,6 +156,8 @@ class QUIC_EXPORT_PRIVATE TlsClientHandshaker // will always be non-null if a 0-RTT resumption is attempted. std::unique_ptr<QuicResumptionState> cached_state_; + QuicCryptoClientConfig* crypto_config_; // Not owned. + TlsClientConnection tls_connection_; // If |has_application_state_|, stores the tls session tickets before @@ -160,6 +166,9 @@ class QUIC_EXPORT_PRIVATE TlsClientHandshaker std::unique_ptr<TransportParameters> received_transport_params_ = nullptr; std::unique_ptr<ApplicationState> received_application_state_ = nullptr; + + // Latched value of reloadable flag quic_enable_alps_client. + const bool enable_alps_ = GetQuicReloadableFlag(quic_enable_alps_client); }; } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/tls_client_handshaker_test.cc b/chromium/net/third_party/quiche/src/quic/core/tls_client_handshaker_test.cc index 2488426167f..19fdab5db04 100644 --- a/chromium/net/third_party/quiche/src/quic/core/tls_client_handshaker_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/tls_client_handshaker_test.cc @@ -7,25 +7,25 @@ #include <utility> #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_framer_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/simple_session_cache.h" -#include "net/third_party/quiche/src/quic/tools/fake_proof_verifier.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_server_id.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_framer_peer.h" +#include "quic/test_tools/quic_session_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/simple_session_cache.h" +#include "quic/tools/fake_proof_verifier.h" +#include "common/test_tools/quiche_test_utils.h" using testing::_; @@ -280,7 +280,11 @@ TEST_P(TlsClientHandshakerTest, ConnectedAfterHandshake) { TEST_P(TlsClientHandshakerTest, ConnectionClosedOnTlsError) { // Have client send ClientHello. stream()->CryptoConnect(); - EXPECT_CALL(*connection_, CloseConnection(QUIC_HANDSHAKE_FAILED, _, _)); + if (GetQuicReloadableFlag(quic_send_tls_crypto_error_code)) { + EXPECT_CALL(*connection_, CloseConnection(QUIC_HANDSHAKE_FAILED, _, _, _)); + } else { + EXPECT_CALL(*connection_, CloseConnection(QUIC_HANDSHAKE_FAILED, _, _)); + } // Send a zero-length ServerHello from server to client. char bogus_handshake_message[] = { @@ -562,11 +566,23 @@ TEST_P(TlsClientHandshakerTest, ServerRequiresCustomALPN) { .WillOnce([kTestAlpn](const std::vector<absl::string_view>& alpns) { return std::find(alpns.cbegin(), alpns.cend(), kTestAlpn); }); - EXPECT_CALL(*server_connection_, - CloseConnection(QUIC_HANDSHAKE_FAILED, - "TLS handshake failure (ENCRYPTION_INITIAL) 120: " - "no application protocol", - _)); + if (GetQuicReloadableFlag(quic_send_tls_crypto_error_code)) { + EXPECT_CALL( + *server_connection_, + CloseConnection( + QUIC_HANDSHAKE_FAILED, + static_cast<QuicIetfTransportErrorCodes>(CRYPTO_ERROR_FIRST + 120), + "TLS handshake failure (ENCRYPTION_INITIAL) 120: " + "no application protocol", + _)); + } else { + EXPECT_CALL( + *server_connection_, + CloseConnection(QUIC_HANDSHAKE_FAILED, + "TLS handshake failure (ENCRYPTION_INITIAL) 120: " + "no application protocol", + _)); + } stream()->CryptoConnect(); crypto_test_utils::AdvanceHandshake(connection_, stream(), 0, diff --git a/chromium/net/third_party/quiche/src/quic/core/tls_handshaker.cc b/chromium/net/third_party/quiche/src/quic/core/tls_handshaker.cc index bfe35455f2e..133c85c4a27 100644 --- a/chromium/net/third_party/quiche/src/quic/core/tls_handshaker.cc +++ b/chromium/net/third_party/quiche/src/quic/core/tls_handshaker.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/tls_handshaker.h" +#include "quic/core/tls_handshaker.h" #include "absl/base/macros.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/crypto.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h" -#include "net/third_party/quiche/src/quic/core/tls_client_handshaker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "quic/core/quic_crypto_stream.h" +#include "quic/core/tls_client_handshaker.h" +#include "quic/platform/api/quic_bug_tracker.h" namespace quic { @@ -114,11 +114,19 @@ void TlsHandshaker::AdvanceHandshake() { void TlsHandshaker::CloseConnection(QuicErrorCode error, const std::string& reason_phrase) { - DCHECK(!reason_phrase.empty()); + QUICHE_DCHECK(!reason_phrase.empty()); stream()->OnUnrecoverableError(error, reason_phrase); is_connection_closed_ = true; } +void TlsHandshaker::CloseConnection(QuicErrorCode error, + QuicIetfTransportErrorCodes ietf_error, + const std::string& reason_phrase) { + QUICHE_DCHECK(!reason_phrase.empty()); + stream()->OnUnrecoverableError(error, ietf_error, reason_phrase); + is_connection_closed_ = true; +} + void TlsHandshaker::OnConnectionClosed(QuicErrorCode /*error*/, ConnectionCloseSource /*source*/) { is_connection_closed_ = true; @@ -204,7 +212,7 @@ void TlsHandshaker::SetWriteSecret(EncryptionLevel level, absl::string_view(reinterpret_cast<char*>(header_protection_key.data()), header_protection_key.size())); if (level == ENCRYPTION_FORWARD_SECURE) { - DCHECK(latest_write_secret_.empty()); + QUICHE_DCHECK(latest_write_secret_.empty()); latest_write_secret_ = write_secret; one_rtt_write_header_protection_key_ = header_protection_key; } @@ -227,7 +235,7 @@ bool TlsHandshaker::SetReadSecret(EncryptionLevel level, absl::string_view(reinterpret_cast<char*>(header_protection_key.data()), header_protection_key.size())); if (level == ENCRYPTION_FORWARD_SECURE) { - DCHECK(latest_read_secret_.empty()); + QUICHE_DCHECK(latest_read_secret_.empty()); latest_read_secret_ = read_secret; one_rtt_read_header_protection_key_ = header_protection_key; } @@ -290,17 +298,19 @@ void TlsHandshaker::WriteMessage(EncryptionLevel level, void TlsHandshaker::FlushFlight() {} void TlsHandshaker::SendAlert(EncryptionLevel level, uint8_t desc) { - // TODO(b/151676147): Alerts should be sent on the wire as a varint QUIC error - // code computed to be 0x100 | desc (draft-ietf-quic-tls-27, section 4.9). - // This puts it in the range reserved for CRYPTO_ERROR - // (draft-ietf-quic-transport-27, section 20). However, according to - // quic_error_codes.h, this QUIC implementation only sends 1-byte error codes - // right now. - std::string error_details = quiche::QuicheStrCat( + std::string error_details = absl::StrCat( "TLS handshake failure (", EncryptionLevelToString(level), ") ", static_cast<int>(desc), ": ", SSL_alert_desc_string_long(desc)); QUIC_DLOG(ERROR) << error_details; - CloseConnection(QUIC_HANDSHAKE_FAILED, error_details); + if (GetQuicReloadableFlag(quic_send_tls_crypto_error_code)) { + QUIC_RELOADABLE_FLAG_COUNT(quic_send_tls_crypto_error_code); + CloseConnection( + TlsAlertToQuicErrorCode(desc), + static_cast<QuicIetfTransportErrorCodes>(CRYPTO_ERROR_FIRST + desc), + error_details); + } else { + CloseConnection(QUIC_HANDSHAKE_FAILED, error_details); + } } } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/tls_handshaker.h b/chromium/net/third_party/quiche/src/quic/core/tls_handshaker.h index 12b27f1b00f..4f8bf47d20f 100644 --- a/chromium/net/third_party/quiche/src/quic/core/tls_handshaker.h +++ b/chromium/net/third_party/quiche/src/quic/core/tls_handshaker.h @@ -8,14 +8,14 @@ #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/base.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_message_parser.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_verifier.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/tls_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/crypto_message_parser.h" +#include "quic/core/crypto/proof_verifier.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/crypto/tls_connection.h" +#include "quic/core/quic_session.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -59,6 +59,11 @@ class QUIC_EXPORT_PRIVATE TlsHandshaker : public TlsConnection::Delegate, void AdvanceHandshake(); void CloseConnection(QuicErrorCode error, const std::string& reason_phrase); + // Closes the connection, specifying the wire error code |ietf_error| + // explicitly. + void CloseConnection(QuicErrorCode error, + QuicIetfTransportErrorCodes ietf_error, + const std::string& reason_phrase); void OnConnectionClosed(QuicErrorCode error, ConnectionCloseSource source); diff --git a/chromium/net/third_party/quiche/src/quic/core/tls_server_handshaker.cc b/chromium/net/third_party/quiche/src/quic/core/tls_server_handshaker.cc index e0fe84d9c52..81c7559489b 100644 --- a/chromium/net/third_party/quiche/src/quic/core/tls_server_handshaker.cc +++ b/chromium/net/third_party/quiche/src/quic/core/tls_server_handshaker.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/tls_server_handshaker.h" +#include "quic/core/tls_server_handshaker.h" #include <memory> #include <string> @@ -11,19 +11,108 @@ #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/pool.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" -#include "net/third_party/quiche/src/quic/core/crypto/transport_parameters.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_hostname_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/quic_crypto_server_config.h" +#include "quic/core/crypto/transport_parameters.h" +#include "quic/core/http/http_encoder.h" +#include "quic/core/http/http_frames.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_flag_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_hostname_utils.h" +#include "quic/platform/api/quic_logging.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { +TlsServerHandshaker::DefaultProofSourceHandle::DefaultProofSourceHandle( + TlsServerHandshaker* handshaker, + ProofSource* proof_source) + : handshaker_(handshaker), proof_source_(proof_source) {} + +TlsServerHandshaker::DefaultProofSourceHandle::~DefaultProofSourceHandle() { + CancelPendingOperation(); +} + +void TlsServerHandshaker::DefaultProofSourceHandle::CancelPendingOperation() { + QUIC_DVLOG(1) << "CancelPendingOperation. is_signature_pending=" + << (signature_callback_ != nullptr); + if (signature_callback_) { + QUIC_RELOADABLE_FLAG_COUNT_N(quic_tls_use_per_handshaker_proof_source, 3, + 3); + signature_callback_->Cancel(); + signature_callback_ = nullptr; + } +} + +QuicAsyncStatus +TlsServerHandshaker::DefaultProofSourceHandle::SelectCertificate( + const QuicSocketAddress& server_address, + const QuicSocketAddress& client_address, + const std::string& hostname, + absl::string_view /*client_hello*/, + const std::string& /*alpn*/, + const std::vector<uint8_t>& /*quic_transport_params*/, + const absl::optional<std::vector<uint8_t>>& /*early_data_context*/) { + if (!handshaker_ || !proof_source_) { + QUIC_BUG << "SelectCertificate called on a detached handle"; + return QUIC_FAILURE; + } + + QuicReferenceCountedPointer<ProofSource::Chain> chain = + proof_source_->GetCertChain(server_address, client_address, hostname); + + handshaker_->OnSelectCertificateDone( + /*ok=*/true, /*is_sync=*/true, chain.get()); + if (!handshaker_->select_cert_status().has_value()) { + QUIC_BUG + << "select_cert_status() has no value after a synchronous select cert"; + // Return success to continue the handshake. + return QUIC_SUCCESS; + } + return handshaker_->select_cert_status().value(); +} + +QuicAsyncStatus TlsServerHandshaker::DefaultProofSourceHandle::ComputeSignature( + const QuicSocketAddress& server_address, + const QuicSocketAddress& client_address, + const std::string& hostname, + uint16_t signature_algorithm, + absl::string_view in, + size_t max_signature_size) { + if (!handshaker_ || !proof_source_) { + QUIC_BUG << "ComputeSignature called on a detached handle"; + return QUIC_FAILURE; + } + + if (signature_callback_) { + QUIC_BUG << "ComputeSignature called while pending"; + return QUIC_FAILURE; + } + + signature_callback_ = new DefaultSignatureCallback(this); + proof_source_->ComputeTlsSignature( + server_address, client_address, hostname, signature_algorithm, in, + std::unique_ptr<DefaultSignatureCallback>(signature_callback_)); + + if (signature_callback_) { + QUIC_DVLOG(1) << "ComputeTlsSignature is pending"; + signature_callback_->set_is_sync(false); + return QUIC_PENDING; + } + + bool success = handshaker_->HasValidSignature(max_signature_size); + QUIC_DVLOG(1) << "ComputeTlsSignature completed synchronously. success:" + << success; + // OnComputeSignatureDone should have been called by signature_callback_->Run. + return success ? QUIC_SUCCESS : QUIC_FAILURE; +} + TlsServerHandshaker::SignatureCallback::SignatureCallback( TlsServerHandshaker* handshaker) - : handshaker_(handshaker) {} + : handshaker_(handshaker) { + QUICHE_DCHECK(!handshaker_->use_proof_source_handle_); +} void TlsServerHandshaker::SignatureCallback::Run( bool ok, @@ -80,25 +169,33 @@ void TlsServerHandshaker::DecryptCallback::Run(std::vector<uint8_t> plaintext) { } void TlsServerHandshaker::DecryptCallback::Cancel() { - DCHECK(handshaker_); + QUICHE_DCHECK(handshaker_); handshaker_ = nullptr; } TlsServerHandshaker::TlsServerHandshaker( QuicSession* session, - const QuicCryptoServerConfig& crypto_config) + const QuicCryptoServerConfig* crypto_config) : TlsHandshaker(this, session), QuicCryptoServerStreamBase(session), - proof_source_(crypto_config.proof_source()), - pre_shared_key_(crypto_config.pre_shared_key()), + proof_source_(crypto_config->proof_source()), + pre_shared_key_(crypto_config->pre_shared_key()), crypto_negotiated_params_(new QuicCryptoNegotiatedParameters), - tls_connection_(crypto_config.ssl_ctx(), this) { - DCHECK_EQ(PROTOCOL_TLS1_3, - session->connection()->version().handshake_protocol); + tls_connection_(crypto_config->ssl_ctx(), this), + crypto_config_(crypto_config) { + QUICHE_DCHECK_EQ(PROTOCOL_TLS1_3, + session->connection()->version().handshake_protocol); // Configure the SSL to be a server. SSL_set_accept_state(ssl()); + // Make sure we use the right TLS extension codepoint. + int use_legacy_extension = 0; + if (session->version().UsesLegacyTlsExtension()) { + use_legacy_extension = 1; + } + SSL_set_quic_use_legacy_codepoint(ssl(), use_legacy_extension); + if (GetQuicFlag(FLAGS_quic_disable_server_tls_resumption)) { SSL_set_options(ssl(), SSL_OP_NO_TICKET); } @@ -109,6 +206,9 @@ TlsServerHandshaker::~TlsServerHandshaker() { } void TlsServerHandshaker::CancelOutstandingCallbacks() { + if (use_proof_source_handle_ && proof_source_handle_) { + proof_source_handle_->CancelPendingOperation(); + } if (signature_callback_) { signature_callback_->Cancel(); signature_callback_ = nullptr; @@ -119,6 +219,12 @@ void TlsServerHandshaker::CancelOutstandingCallbacks() { } } +std::unique_ptr<ProofSourceHandle> +TlsServerHandshaker::MaybeCreateProofSourceHandle() { + QUICHE_DCHECK(use_proof_source_handle_); + return std::make_unique<DefaultProofSourceHandle>(this, proof_source_); +} + bool TlsServerHandshaker::GetBase64SHA256ClientChannelID( std::string* /*output*/) const { // Channel ID is not supported when TLS is used in QUIC. @@ -164,7 +270,42 @@ void TlsServerHandshaker::OnPacketDecrypted(EncryptionLevel level) { } void TlsServerHandshaker::OnHandshakeDoneReceived() { - DCHECK(false); + QUICHE_DCHECK(false); +} + +void TlsServerHandshaker::OnNewTokenReceived(absl::string_view /*token*/) { + QUICHE_DCHECK(false); +} + +std::string TlsServerHandshaker::GetAddressToken() const { + SourceAddressTokens empty_previous_tokens; + const QuicConnection* connection = session()->connection(); + return crypto_config_->NewSourceAddressToken( + crypto_config_->source_address_token_boxer(), empty_previous_tokens, + connection->effective_peer_address().host(), + connection->random_generator(), connection->clock()->WallNow(), + /*cached_network_params=*/nullptr); +} + +bool TlsServerHandshaker::ValidateAddressToken(absl::string_view token) const { + SourceAddressTokens tokens; + HandshakeFailureReason reason = crypto_config_->ParseSourceAddressToken( + crypto_config_->source_address_token_boxer(), token, &tokens); + if (reason != HANDSHAKE_OK) { + QUIC_DLOG(WARNING) << "Failed to parse source address token: " + << CryptoUtils::HandshakeFailureReasonToString(reason); + return false; + } + reason = crypto_config_->ValidateSourceAddressTokens( + tokens, session()->connection()->effective_peer_address().host(), + session()->connection()->clock()->WallNow(), + /*cached_network_params=*/nullptr); + if (reason != HANDSHAKE_OK) { + QUIC_DLOG(WARNING) << "Failed to validate source address token: " + << CryptoUtils::HandshakeFailureReasonToString(reason); + return false; + } + return true; } bool TlsServerHandshaker::ShouldSendExpectCTHeader() const { @@ -233,22 +374,32 @@ void TlsServerHandshaker::OverrideQuicConfigDefaults(QuicConfig* /*config*/) {} void TlsServerHandshaker::AdvanceHandshakeFromCallback() { AdvanceHandshake(); - if (GetQuicReloadableFlag( - quic_process_undecryptable_packets_after_async_decrypt_callback) && - !is_connection_closed()) { - QUIC_RELOADABLE_FLAG_COUNT( - quic_process_undecryptable_packets_after_async_decrypt_callback); + if (!is_connection_closed()) { handshaker_delegate()->OnHandshakeCallbackDone(); } } bool TlsServerHandshaker::ProcessTransportParameters( + const SSL_CLIENT_HELLO* client_hello, std::string* error_details) { TransportParameters client_params; const uint8_t* client_params_bytes; size_t params_bytes_len; - SSL_get_peer_quic_transport_params(ssl(), &client_params_bytes, - ¶ms_bytes_len); + + // Make sure we use the right TLS extension codepoint. + uint16_t extension_type = TLSEXT_TYPE_quic_transport_parameters_standard; + if (session()->version().UsesLegacyTlsExtension()) { + extension_type = TLSEXT_TYPE_quic_transport_parameters_legacy; + } + // When using early select cert callback, SSL_get_peer_quic_transport_params + // can not be used to retrieve the client's transport parameters, but we can + // use SSL_early_callback_ctx_extension_get to do that. + if (!SSL_early_callback_ctx_extension_get(client_hello, extension_type, + &client_params_bytes, + ¶ms_bytes_len)) { + params_bytes_len = 0; + } + if (params_bytes_len == 0) { *error_details = "Client's transport parameters are missing"; return false; @@ -258,7 +409,7 @@ bool TlsServerHandshaker::ProcessTransportParameters( Perspective::IS_CLIENT, client_params_bytes, params_bytes_len, &client_params, &parse_error_details)) { - DCHECK(!parse_error_details.empty()); + QUICHE_DCHECK(!parse_error_details.empty()); *error_details = "Unable to parse client's transport parameters: " + parse_error_details; return false; @@ -304,7 +455,11 @@ bool TlsServerHandshaker::ProcessTransportParameters( return true; } -bool TlsServerHandshaker::SetTransportParameters() { +TlsServerHandshaker::SetTransportParametersResult +TlsServerHandshaker::SetTransportParameters() { + SetTransportParametersResult result; + QUICHE_DCHECK(!result.success); + TransportParameters server_params; server_params.perspective = Perspective::IS_SERVER; server_params.supported_versions = @@ -313,31 +468,38 @@ bool TlsServerHandshaker::SetTransportParameters() { CreateQuicVersionLabel(session()->connection()->version()); if (!handshaker_delegate()->FillTransportParameters(&server_params)) { - return false; + return result; } // Notify QuicConnectionDebugVisitor. session()->connection()->OnTransportParametersSent(server_params); - std::vector<uint8_t> server_params_bytes; - if (!SerializeTransportParameters(session()->connection()->version(), - server_params, &server_params_bytes) || - SSL_set_quic_transport_params(ssl(), server_params_bytes.data(), - server_params_bytes.size()) != 1) { - return false; + { // Ensure |server_params_bytes| is not accessed out of the scope. + std::vector<uint8_t> server_params_bytes; + if (!SerializeTransportParameters(session()->connection()->version(), + server_params, &server_params_bytes) || + SSL_set_quic_transport_params(ssl(), server_params_bytes.data(), + server_params_bytes.size()) != 1) { + return result; + } + result.quic_transport_params = std::move(server_params_bytes); } + if (application_state_) { std::vector<uint8_t> early_data_context; if (!SerializeTransportParametersForTicket( server_params, *application_state_, &early_data_context)) { QUIC_BUG << "Failed to serialize Transport Parameters for ticket."; - return false; + result.early_data_context = std::vector<uint8_t>(); + return result; } SSL_set_quic_early_data_context(ssl(), early_data_context.data(), early_data_context.size()); + result.early_data_context = std::move(early_data_context); application_state_.reset(nullptr); } - return true; + result.success = true; + return result; } void TlsServerHandshaker::SetWriteSecret( @@ -359,6 +521,11 @@ void TlsServerHandshaker::SetWriteSecret( TlsHandshaker::SetWriteSecret(level, cipher, write_secret); } +std::string TlsServerHandshaker::GetAcceptChValueForOrigin( + const std::string& /*origin*/) const { + return {}; +} + void TlsServerHandshaker::FinishHandshake() { if (SSL_in_early_data(ssl())) { // If the server accepts early data, SSL_do_handshake returns success twice: @@ -390,7 +557,11 @@ void TlsServerHandshaker::FinishHandshake() { handshaker_delegate()->OnTlsHandshakeComplete(); handshaker_delegate()->DiscardOldEncryptionKey(ENCRYPTION_HANDSHAKE); handshaker_delegate()->DiscardOldDecryptionKey(ENCRYPTION_HANDSHAKE); - handshaker_delegate()->DiscardOldDecryptionKey(ENCRYPTION_ZERO_RTT); + // ENCRYPTION_ZERO_RTT decryption key is not discarded here as "Servers MAY + // temporarily retain 0-RTT keys to allow decrypting reordered packets + // without requiring their contents to be retransmitted with 1-RTT keys." + // It is expected that QuicConnection will discard the key at an + // appropriate time. } QuicAsyncStatus TlsServerHandshaker::VerifyCertChain( @@ -412,11 +583,25 @@ ssl_private_key_result_t TlsServerHandshaker::PrivateKeySign( size_t max_out, uint16_t sig_alg, absl::string_view in) { + QUICHE_DCHECK_EQ(expected_ssl_error(), SSL_ERROR_WANT_READ); + if (use_proof_source_handle_) { + QUIC_RELOADABLE_FLAG_COUNT_N(quic_tls_use_per_handshaker_proof_source, 2, + 3); + QuicAsyncStatus status = proof_source_handle_->ComputeSignature( + session()->connection()->self_address(), + session()->connection()->peer_address(), cert_selection_hostname(), + sig_alg, in, max_out); + if (status == QUIC_PENDING) { + set_expected_ssl_error(SSL_ERROR_WANT_PRIVATE_KEY_OPERATION); + } + return PrivateKeyComplete(out, out_len, max_out); + } + signature_callback_ = new SignatureCallback(this); proof_source_->ComputeTlsSignature( session()->connection()->self_address(), - session()->connection()->peer_address(), hostname_, sig_alg, in, - std::unique_ptr<SignatureCallback>(signature_callback_)); + session()->connection()->peer_address(), cert_selection_hostname(), + sig_alg, in, std::unique_ptr<SignatureCallback>(signature_callback_)); if (signature_callback_) { set_expected_ssl_error(SSL_ERROR_WANT_PRIVATE_KEY_OPERATION); return ssl_private_key_retry; @@ -431,7 +616,7 @@ ssl_private_key_result_t TlsServerHandshaker::PrivateKeyComplete( if (expected_ssl_error() == SSL_ERROR_WANT_PRIVATE_KEY_OPERATION) { return ssl_private_key_retry; } - if (cert_verify_sig_.size() > max_out || cert_verify_sig_.empty()) { + if (!HasValidSignature(max_out)) { return ssl_private_key_failure; } *out_len = cert_verify_sig_.size(); @@ -441,8 +626,35 @@ ssl_private_key_result_t TlsServerHandshaker::PrivateKeyComplete( return ssl_private_key_success; } +void TlsServerHandshaker::OnComputeSignatureDone( + bool ok, + bool is_sync, + std::string signature, + std::unique_ptr<ProofSource::Details> details) { + QUIC_DVLOG(1) << "OnComputeSignatureDone. ok:" << ok + << ", is_sync:" << is_sync + << ", len(signature):" << signature.size(); + QUICHE_DCHECK(use_proof_source_handle_); + if (ok) { + cert_verify_sig_ = std::move(signature); + proof_source_details_ = std::move(details); + } + const int last_expected_ssl_error = expected_ssl_error(); + set_expected_ssl_error(SSL_ERROR_WANT_READ); + if (!is_sync) { + QUICHE_DCHECK_EQ(last_expected_ssl_error, + SSL_ERROR_WANT_PRIVATE_KEY_OPERATION); + AdvanceHandshakeFromCallback(); + } +} + +bool TlsServerHandshaker::HasValidSignature(size_t max_signature_size) const { + return !cert_verify_sig_.empty() && + cert_verify_sig_.size() <= max_signature_size; +} + size_t TlsServerHandshaker::SessionTicketMaxOverhead() { - DCHECK(proof_source_->GetTicketCrypter()); + QUICHE_DCHECK(proof_source_->GetTicketCrypter()); return proof_source_->GetTicketCrypter()->MaxOverhead(); } @@ -450,7 +662,7 @@ int TlsServerHandshaker::SessionTicketSeal(uint8_t* out, size_t* out_len, size_t max_out_len, absl::string_view in) { - DCHECK(proof_source_->GetTicketCrypter()); + QUICHE_DCHECK(proof_source_->GetTicketCrypter()); std::vector<uint8_t> ticket = proof_source_->GetTicketCrypter()->Encrypt(in); if (max_out_len < ticket.size()) { QUIC_BUG @@ -469,7 +681,7 @@ ssl_ticket_aead_result_t TlsServerHandshaker::SessionTicketOpen( size_t* out_len, size_t max_out_len, absl::string_view in) { - DCHECK(proof_source_->GetTicketCrypter()); + QUICHE_DCHECK(proof_source_->GetTicketCrypter()); if (!ticket_decryption_callback_) { ticket_received_ = true; @@ -506,56 +718,166 @@ ssl_ticket_aead_result_t TlsServerHandshaker::SessionTicketOpen( return ssl_ticket_aead_success; } -int TlsServerHandshaker::SelectCertificate(int* out_alert) { +ssl_select_cert_result_t TlsServerHandshaker::EarlySelectCertCallback( + const SSL_CLIENT_HELLO* client_hello) { + // EarlySelectCertCallback can be called twice from BoringSSL: If the first + // call returns ssl_select_cert_retry, when cert selection completes, + // SSL_do_handshake will call it again. + if (use_proof_source_handle_) { + QUIC_RELOADABLE_FLAG_COUNT_N(quic_tls_use_per_handshaker_proof_source, 1, + 3); + if (select_cert_status_.has_value()) { + // This is the second call, return the result directly. + QUIC_DVLOG(1) << "EarlySelectCertCallback called to continue handshake, " + "returning directly. success:" + << (select_cert_status_.value() == QUIC_SUCCESS); + return (select_cert_status_.value() == QUIC_SUCCESS) + ? ssl_select_cert_success + : ssl_select_cert_error; + } + + // This is the first call. + select_cert_status_ = QUIC_PENDING; + proof_source_handle_ = MaybeCreateProofSourceHandle(); + } + + if (!pre_shared_key_.empty()) { + // TODO(b/154162689) add PSK support to QUIC+TLS. + QUIC_BUG << "QUIC server pre-shared keys not yet supported with TLS"; + return ssl_select_cert_error; + } + + // This callback is called very early by Boring SSL, most of the SSL_get_foo + // function do not work at this point, but SSL_get_servername does. const char* hostname = SSL_get_servername(ssl(), TLSEXT_NAMETYPE_host_name); if (hostname) { hostname_ = hostname; crypto_negotiated_params_->sni = QuicHostnameUtils::NormalizeHostname(hostname_); - if (!QuicHostnameUtils::IsValidSNI(hostname_)) { - // TODO(b/151676147): Include this error string in the CONNECTION_CLOSE - // frame. - QUIC_LOG(ERROR) << "Invalid SNI provided: \"" << hostname_ << "\""; - return SSL_TLSEXT_ERR_ALERT_FATAL; + if (!ValidateHostname(hostname_)) { + return ssl_select_cert_error; + } + if (hostname_ != crypto_negotiated_params_->sni) { + QUIC_CODE_COUNT(quic_tls_server_hostname_diff); + QUIC_LOG_EVERY_N_SEC(WARNING, 300) + << "Raw and normalized hostnames differ, but both are valid SNIs. " + "raw hostname:" + << hostname_ << ", normalized:" << crypto_negotiated_params_->sni; + } else { + QUIC_CODE_COUNT(quic_tls_server_hostname_same); } } else { QUIC_LOG(INFO) << "No hostname indicated in SNI"; } + if (use_proof_source_handle_) { + std::string error_details; + if (!ProcessTransportParameters(client_hello, &error_details)) { + CloseConnection(QUIC_HANDSHAKE_FAILED, error_details); + return ssl_select_cert_error; + } + OverrideQuicConfigDefaults(session()->config()); + session()->OnConfigNegotiated(); + + auto set_transport_params_result = SetTransportParameters(); + if (!set_transport_params_result.success) { + QUIC_LOG(ERROR) << "Failed to set transport parameters"; + return ssl_select_cert_error; + } + + const QuicAsyncStatus status = proof_source_handle_->SelectCertificate( + session()->connection()->self_address(), + session()->connection()->peer_address(), cert_selection_hostname(), + absl::string_view( + reinterpret_cast<const char*>(client_hello->client_hello), + client_hello->client_hello_len), + AlpnForVersion(session()->version()), + set_transport_params_result.quic_transport_params, + set_transport_params_result.early_data_context); + + QUICHE_DCHECK_EQ(status, select_cert_status().value()); + + if (status == QUIC_PENDING) { + set_expected_ssl_error(SSL_ERROR_PENDING_CERTIFICATE); + return ssl_select_cert_retry; + } + + if (status == QUIC_FAILURE) { + return ssl_select_cert_error; + } + + return ssl_select_cert_success; + } + QuicReferenceCountedPointer<ProofSource::Chain> chain = proof_source_->GetCertChain(session()->connection()->self_address(), session()->connection()->peer_address(), - hostname_); + cert_selection_hostname()); if (!chain || chain->certs.empty()) { - QUIC_LOG(ERROR) << "No certs provided for host '" << hostname_ << "'"; - return SSL_TLSEXT_ERR_ALERT_FATAL; - } - - if (!pre_shared_key_.empty()) { - // TODO(b/154162689) add PSK support to QUIC+TLS. - QUIC_BUG << "QUIC server pre-shared keys not yet supported with TLS"; - return SSL_TLSEXT_ERR_ALERT_FATAL; + QUIC_LOG(ERROR) << "No certs provided for host. raw:" << hostname_ + << ", normalized:" << crypto_negotiated_params_->sni; + return ssl_select_cert_error; } CryptoBuffers cert_buffers = chain->ToCryptoBuffers(); tls_connection_.SetCertChain(cert_buffers.value); std::string error_details; - if (!ProcessTransportParameters(&error_details)) { + if (!ProcessTransportParameters(client_hello, &error_details)) { CloseConnection(QUIC_HANDSHAKE_FAILED, error_details); - *out_alert = SSL_AD_INTERNAL_ERROR; - return SSL_TLSEXT_ERR_ALERT_FATAL; + return ssl_select_cert_error; } OverrideQuicConfigDefaults(session()->config()); session()->OnConfigNegotiated(); - if (!SetTransportParameters()) { + if (!SetTransportParameters().success) { QUIC_LOG(ERROR) << "Failed to set transport parameters"; - return SSL_TLSEXT_ERR_ALERT_FATAL; + return ssl_select_cert_error; } QUIC_DLOG(INFO) << "Set " << chain->certs.size() << " certs for server " << "with hostname " << hostname_; + return ssl_select_cert_success; +} + +void TlsServerHandshaker::OnSelectCertificateDone( + bool ok, + bool is_sync, + const ProofSource::Chain* chain) { + QUIC_DVLOG(1) << "OnSelectCertificateDone. ok:" << ok + << ", is_sync:" << is_sync; + QUICHE_DCHECK(use_proof_source_handle_); + + select_cert_status_ = QUIC_FAILURE; + if (ok) { + if (chain && !chain->certs.empty()) { + tls_connection_.SetCertChain(chain->ToCryptoBuffers().value); + select_cert_status_ = QUIC_SUCCESS; + } else { + QUIC_LOG(ERROR) << "No certs provided for host '" << hostname_ << "'"; + } + } + const int last_expected_ssl_error = expected_ssl_error(); + set_expected_ssl_error(SSL_ERROR_WANT_READ); + if (!is_sync) { + QUICHE_DCHECK_EQ(last_expected_ssl_error, SSL_ERROR_PENDING_CERTIFICATE); + AdvanceHandshakeFromCallback(); + } +} + +bool TlsServerHandshaker::ValidateHostname(const std::string& hostname) const { + if (!QuicHostnameUtils::IsValidSNI(hostname)) { + // TODO(b/151676147): Include this error string in the CONNECTION_CLOSE + // frame. + QUIC_LOG(ERROR) << "Invalid SNI provided: \"" << hostname << "\""; + return false; + } + return true; +} + +int TlsServerHandshaker::TlsExtServernameCallback(int* /*out_alert*/) { + // SSL_TLSEXT_ERR_OK causes the server_name extension to be acked in + // ServerHello. return SSL_TLSEXT_ERR_OK; } @@ -598,6 +920,30 @@ int TlsServerHandshaker::SelectAlpn(const uint8_t** out, return SSL_TLSEXT_ERR_NOACK; } + // Enable ALPS for the selected ALPN protocol. + if (GetQuicReloadableFlag(quic_enable_alps_server)) { + QUIC_RELOADABLE_FLAG_COUNT(quic_enable_alps_server); + + const uint8_t* alps_data = nullptr; + size_t alps_length = 0; + std::unique_ptr<char[]> buffer; + + const std::string& origin = crypto_negotiated_params_->sni; + std::string accept_ch_value = GetAcceptChValueForOrigin(origin); + if (!accept_ch_value.empty()) { + AcceptChFrame frame{{{origin, std::move(accept_ch_value)}}}; + alps_length = HttpEncoder::SerializeAcceptChFrame(frame, &buffer); + alps_data = reinterpret_cast<const uint8_t*>(buffer.get()); + } + + if (SSL_add_application_settings( + ssl(), reinterpret_cast<const uint8_t*>(selected_alpn->data()), + selected_alpn->size(), alps_data, alps_length) != 1) { + QUIC_DLOG(ERROR) << "Failed to enable ALPS"; + return SSL_TLSEXT_ERR_NOACK; + } + } + session()->OnAlpnSelected(*selected_alpn); valid_alpn_received_ = true; *out_len = selected_alpn->size(); diff --git a/chromium/net/third_party/quiche/src/quic/core/tls_server_handshaker.h b/chromium/net/third_party/quiche/src/quic/core/tls_server_handshaker.h index 4d12bf3ce27..16707cd2938 100644 --- a/chromium/net/third_party/quiche/src/quic/core/tls_server_handshaker.h +++ b/chromium/net/third_party/quiche/src/quic/core/tls_server_handshaker.h @@ -10,13 +10,14 @@ #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/pool.h" #include "third_party/boringssl/src/include/openssl/ssl.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" -#include "net/third_party/quiche/src/quic/core/crypto/tls_server_connection.h" -#include "net/third_party/quiche/src/quic/core/proto/cached_network_parameters_proto.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h" -#include "net/third_party/quiche/src/quic/core/tls_handshaker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/crypto/quic_crypto_server_config.h" +#include "quic/core/crypto/tls_server_connection.h" +#include "quic/core/proto/cached_network_parameters_proto.h" +#include "quic/core/quic_crypto_server_stream_base.h" +#include "quic/core/quic_crypto_stream.h" +#include "quic/core/quic_types.h" +#include "quic/core/tls_handshaker.h" +#include "quic/platform/api/quic_export.h" namespace quic { @@ -25,10 +26,12 @@ namespace quic { class QUIC_EXPORT_PRIVATE TlsServerHandshaker : public TlsHandshaker, public TlsServerConnection::Delegate, + public ProofSourceHandleCallback, public QuicCryptoServerStreamBase { public: + // |crypto_config| must outlive TlsServerHandshaker. TlsServerHandshaker(QuicSession* session, - const QuicCryptoServerConfig& crypto_config); + const QuicCryptoServerConfig* crypto_config); TlsServerHandshaker(const TlsServerHandshaker&) = delete; TlsServerHandshaker& operator=(const TlsServerHandshaker&) = delete; @@ -52,6 +55,9 @@ class QUIC_EXPORT_PRIVATE TlsServerHandshaker void OnConnectionClosed(QuicErrorCode error, ConnectionCloseSource source) override; void OnHandshakeDoneReceived() override; + std::string GetAddressToken() const override; + bool ValidateAddressToken(absl::string_view token) const override; + void OnNewTokenReceived(absl::string_view token) override; bool ShouldSendExpectCTHeader() const override; const ProofSource::Details* ProofSourceDetails() const override; @@ -74,11 +80,32 @@ class QUIC_EXPORT_PRIVATE TlsServerHandshaker const SSL_CIPHER* cipher, const std::vector<uint8_t>& write_secret) override; + // Called with normalized SNI hostname as |origin|. Return value will be sent + // in an ACCEPT_CH frame in the TLS ALPS extension, unless empty. + virtual std::string GetAcceptChValueForOrigin( + const std::string& origin) const; + protected: + // Creates a proof source handle for selecting cert and computing signature. + // Only called when |use_proof_source_handle_| is true. + virtual std::unique_ptr<ProofSourceHandle> MaybeCreateProofSourceHandle(); + + bool use_proof_source_handle() const { return use_proof_source_handle_; } + // Hook to allow the server to override parts of the QuicConfig based on SNI // before we generate transport parameters. virtual void OverrideQuicConfigDefaults(QuicConfig* config); + virtual bool ValidateHostname(const std::string& hostname) const; + + // The hostname to be used to select certificates and compute signatures. + // The function should only be called after a successful ValidateHostname(). + const std::string& cert_selection_hostname() const { + return use_normalized_sni_for_cert_selection_ + ? crypto_negotiated_params_->sni + : hostname_; + } + const TlsConnection* tls_connection() const override { return &tls_connection_; } @@ -103,7 +130,10 @@ class QUIC_EXPORT_PRIVATE TlsServerHandshaker const ProofVerifyDetails& verify_details) override; // TlsServerConnection::Delegate implementation: - int SelectCertificate(int* out_alert) override; + // Used to select certificates and process transport parameters. + ssl_select_cert_result_t EarlySelectCertCallback( + const SSL_CLIENT_HELLO* client_hello) override; + int TlsExtServernameCallback(int* out_alert) override; int SelectAlpn(const uint8_t** out, uint8_t* out_len, const uint8_t* in, @@ -127,6 +157,28 @@ class QUIC_EXPORT_PRIVATE TlsServerHandshaker absl::string_view in) override; TlsConnection::Delegate* ConnectionDelegate() override { return this; } + // The status of cert selection. nullopt means it hasn't started. + const absl::optional<QuicAsyncStatus>& select_cert_status() const { + return select_cert_status_; + } + // Whether |cert_verify_sig_| contains a valid signature. + // NOTE: BoringSSL queries the result of a async signature operation using + // PrivateKeyComplete(), a successful PrivateKeyComplete() will clear the + // content of |cert_verify_sig_|, this function should not be called after + // that. + bool HasValidSignature(size_t max_signature_size) const; + + // ProofSourceHandleCallback implementation: + void OnSelectCertificateDone(bool ok, + bool is_sync, + const ProofSource::Chain* chain) override; + + void OnComputeSignatureDone( + bool ok, + bool is_sync, + std::string signature, + std::unique_ptr<ProofSource::Details> details) override; + private: class QUIC_EXPORT_PRIVATE SignatureCallback : public ProofSource::SignatureCallback { @@ -156,9 +208,95 @@ class QUIC_EXPORT_PRIVATE TlsServerHandshaker TlsServerHandshaker* handshaker_; }; - bool SetTransportParameters(); - bool ProcessTransportParameters(std::string* error_details); + // DefaultProofSourceHandle delegates all operations to the shared proof + // source. + class QUIC_EXPORT_PRIVATE DefaultProofSourceHandle + : public ProofSourceHandle { + public: + DefaultProofSourceHandle(TlsServerHandshaker* handshaker, + ProofSource* proof_source); + + ~DefaultProofSourceHandle() override; + + // Cancel the pending signature operation, if any. + void CancelPendingOperation() override; + + // Delegates to proof_source_->GetCertChain. + // Returns QUIC_SUCCESS or QUIC_FAILURE. Never returns QUIC_PENDING. + QuicAsyncStatus SelectCertificate( + const QuicSocketAddress& server_address, + const QuicSocketAddress& client_address, + const std::string& hostname, + absl::string_view client_hello, + const std::string& alpn, + const std::vector<uint8_t>& quic_transport_params, + const absl::optional<std::vector<uint8_t>>& early_data_context) + override; + + // Delegates to proof_source_->ComputeTlsSignature. + // Returns QUIC_SUCCESS, QUIC_FAILURE or QUIC_PENDING. + QuicAsyncStatus ComputeSignature(const QuicSocketAddress& server_address, + const QuicSocketAddress& client_address, + const std::string& hostname, + uint16_t signature_algorithm, + absl::string_view in, + size_t max_signature_size) override; + + protected: + ProofSourceHandleCallback* callback() override { return handshaker_; } + + private: + class QUIC_EXPORT_PRIVATE DefaultSignatureCallback + : public ProofSource::SignatureCallback { + public: + explicit DefaultSignatureCallback(DefaultProofSourceHandle* handle) + : handle_(handle) {} + + void Run(bool ok, + std::string signature, + std::unique_ptr<ProofSource::Details> details) override { + if (handle_ == nullptr) { + // Operation has been canceled, or Run has been called. + return; + } + handle_->signature_callback_ = nullptr; + if (handle_->handshaker_ != nullptr) { + handle_->handshaker_->OnComputeSignatureDone( + ok, is_sync_, std::move(signature), std::move(details)); + } + } + + // If called, Cancel causes the pending callback to be a no-op. + void Cancel() { handle_ = nullptr; } + + void set_is_sync(bool is_sync) { is_sync_ = is_sync; } + + private: + DefaultProofSourceHandle* handle_; + // Set to false if handle_->ComputeSignature returns QUIC_PENDING. + bool is_sync_ = true; + }; + + // Not nullptr on construction. Set to nullptr when cancelled. + TlsServerHandshaker* handshaker_; // Not owned. + ProofSource* proof_source_; // Not owned. + DefaultSignatureCallback* signature_callback_ = nullptr; + }; + + struct QUIC_NO_EXPORT SetTransportParametersResult { + bool success = false; + // Empty vector if QUIC transport params are not set successfully. + std::vector<uint8_t> quic_transport_params; + // absl::nullopt if there is no application state to begin with. + // Empty vector if application state is not set successfully. + absl::optional<std::vector<uint8_t>> early_data_context; + }; + + SetTransportParametersResult SetTransportParameters(); + bool ProcessTransportParameters(const SSL_CLIENT_HELLO* client_hello, + std::string* error_details); + std::unique_ptr<ProofSourceHandle> proof_source_handle_; ProofSource* proof_source_; SignatureCallback* signature_callback_ = nullptr; @@ -176,6 +314,9 @@ class QUIC_EXPORT_PRIVATE TlsServerHandshaker // indicates that the client attempted a resumption. bool ticket_received_ = false; + // nullopt means select cert hasn't started. + absl::optional<QuicAsyncStatus> select_cert_status_; + std::string hostname_; std::string cert_verify_sig_; std::unique_ptr<ProofSource::Details> proof_source_details_; @@ -191,6 +332,11 @@ class QUIC_EXPORT_PRIVATE TlsServerHandshaker QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> crypto_negotiated_params_; TlsServerConnection tls_connection_; + const bool use_proof_source_handle_ = + GetQuicReloadableFlag(quic_tls_use_per_handshaker_proof_source); + const bool use_normalized_sni_for_cert_selection_ = + GetQuicReloadableFlag(quic_tls_use_normalized_sni_for_cert_selectioon); + const QuicCryptoServerConfig* crypto_config_; // Unowned. }; } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/core/tls_server_handshaker_test.cc b/chromium/net/third_party/quiche/src/quic/core/tls_server_handshaker_test.cc index 7411ba2027f..66cdd7984d3 100644 --- a/chromium/net/third_party/quiche/src/quic/core/tls_server_handshaker_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/tls_server_handshaker_test.cc @@ -8,22 +8,24 @@ #include "absl/base/macros.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_client_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/core/tls_client_handshaker.h" -#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_test.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/failing_proof_source.h" -#include "net/third_party/quiche/src/quic/test_tools/fake_proof_source.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/simple_session_cache.h" -#include "net/third_party/quiche/src/quic/test_tools/test_ticket_crypter.h" +#include "quic/core/crypto/proof_source.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/quic_crypto_client_stream.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/core/tls_client_handshaker.h" +#include "quic/core/tls_server_handshaker.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/failing_proof_source.h" +#include "quic/test_tools/fake_proof_source.h" +#include "quic/test_tools/fake_proof_source_handle.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/simple_session_cache.h" +#include "quic/test_tools/test_ticket_crypter.h" namespace quic { class QuicConnection; @@ -49,7 +51,7 @@ struct TestParams { // Used by ::testing::PrintToStringParamName(). std::string PrintToString(const TestParams& p) { - return quiche::QuicheStrCat( + return absl::StrCat( ParsedQuicVersionToString(p.version), "_", (p.disable_resumption ? "ResumptionDisabled" : "ResumptionEnabled")); } @@ -65,6 +67,70 @@ std::vector<TestParams> GetTestParams() { return params; } +class TestTlsServerHandshaker : public TlsServerHandshaker { + public: + TestTlsServerHandshaker(QuicSession* session, + const QuicCryptoServerConfig* crypto_config) + : TlsServerHandshaker(session, crypto_config), + proof_source_(crypto_config->proof_source()) { + ON_CALL(*this, MaybeCreateProofSourceHandle()) + .WillByDefault(testing::Invoke( + this, &TestTlsServerHandshaker::RealMaybeCreateProofSourceHandle)); + } + + MOCK_METHOD(std::unique_ptr<ProofSourceHandle>, + MaybeCreateProofSourceHandle, + (), + (override)); + + void SetupProofSourceHandle( + FakeProofSourceHandle::Action select_cert_action, + FakeProofSourceHandle::Action compute_signature_action) { + EXPECT_CALL(*this, MaybeCreateProofSourceHandle()) + .WillOnce(testing::Invoke( + [this, select_cert_action, compute_signature_action]() { + auto handle = std::make_unique<FakeProofSourceHandle>( + proof_source_, this, select_cert_action, + compute_signature_action); + fake_proof_source_handle_ = handle.get(); + return handle; + })); + } + + FakeProofSourceHandle* fake_proof_source_handle() { + return fake_proof_source_handle_; + } + + using TlsServerHandshaker::expected_ssl_error; + + private: + std::unique_ptr<ProofSourceHandle> RealMaybeCreateProofSourceHandle() { + return TlsServerHandshaker::MaybeCreateProofSourceHandle(); + } + + // Owned by TlsServerHandshaker. + FakeProofSourceHandle* fake_proof_source_handle_ = nullptr; + ProofSource* proof_source_ = nullptr; +}; + +class TlsServerHandshakerTestSession : public TestQuicSpdyServerSession { + public: + using TestQuicSpdyServerSession::TestQuicSpdyServerSession; + + std::unique_ptr<QuicCryptoServerStreamBase> CreateQuicCryptoServerStream( + const QuicCryptoServerConfig* crypto_config, + QuicCompressedCertsCache* /*compressed_certs_cache*/) override { + if (connection()->version().handshake_protocol == PROTOCOL_TLS1_3) { + return std::make_unique<NiceMock<TestTlsServerHandshaker>>(this, + crypto_config); + } + + QUICHE_CHECK(false) << "Unsupported handshake protocol: " + << connection()->version().handshake_protocol; + return nullptr; + } +}; + class TlsServerHandshakerTest : public QuicTestWithParam<TestParams> { public: TlsServerHandshakerTest() @@ -109,6 +175,46 @@ class TlsServerHandshakerTest : public QuicTestWithParam<TestParams> { std::make_unique<FailingProofSource>(), KeyExchangeSource::Default()); } + void CreateTlsServerHandshakerTestSession(MockQuicConnectionHelper* helper, + MockAlarmFactory* alarm_factory) { + server_connection_ = new PacketSavingConnection( + helper, alarm_factory, Perspective::IS_SERVER, + ParsedVersionOfIndex(supported_versions_, 0)); + + TlsServerHandshakerTestSession* server_session = + new TlsServerHandshakerTestSession( + server_connection_, DefaultQuicConfig(), supported_versions_, + server_crypto_config_.get(), &server_compressed_certs_cache_); + server_session->Initialize(); + + // We advance the clock initially because the default time is zero and the + // strike register worries that we've just overflowed a uint32_t time. + server_connection_->AdvanceTime(QuicTime::Delta::FromSeconds(100000)); + + QUICHE_CHECK(server_session); + server_session_.reset(server_session); + } + + void InitializeServerWithFakeProofSourceHandle() { + helpers_.push_back(std::make_unique<NiceMock<MockQuicConnectionHelper>>()); + alarm_factories_.push_back(std::make_unique<MockAlarmFactory>()); + CreateTlsServerHandshakerTestSession(helpers_.back().get(), + alarm_factories_.back().get()); + server_handshaker_ = static_cast<NiceMock<TestTlsServerHandshaker>*>( + server_session_->GetMutableCryptoStream()); + EXPECT_CALL(*server_session_->helper(), CanAcceptClientHello(_, _, _, _, _)) + .Times(testing::AnyNumber()); + EXPECT_CALL(*server_session_, SelectAlpn(_)) + .WillRepeatedly([this](const std::vector<absl::string_view>& alpns) { + return std::find( + alpns.cbegin(), alpns.cend(), + AlpnForVersion(server_session_->connection()->version())); + }); + crypto_test_utils::SetupCryptoServerConfigForTest( + server_connection_->clock(), server_connection_->random_generator(), + server_crypto_config_.get()); + } + // Initializes the crypto server stream state for testing. May be // called multiple times. void InitializeServer() { @@ -120,17 +226,17 @@ class TlsServerHandshakerTest : public QuicTestWithParam<TestParams> { helpers_.back().get(), alarm_factories_.back().get(), server_crypto_config_.get(), &server_compressed_certs_cache_, &server_connection_, &server_session); - CHECK(server_session); + QUICHE_CHECK(server_session); server_session_.reset(server_session); + server_handshaker_ = nullptr; EXPECT_CALL(*server_session_->helper(), CanAcceptClientHello(_, _, _, _, _)) .Times(testing::AnyNumber()); EXPECT_CALL(*server_session_, SelectAlpn(_)) - .WillRepeatedly( - [this](const std::vector<absl::string_view>& alpns) { - return std::find( - alpns.cbegin(), alpns.cend(), - AlpnForVersion(server_session_->connection()->version())); - }); + .WillRepeatedly([this](const std::vector<absl::string_view>& alpns) { + return std::find( + alpns.cbegin(), alpns.cend(), + AlpnForVersion(server_session_->connection()->version())); + }); crypto_test_utils::SetupCryptoServerConfigForTest( server_connection_->clock(), server_connection_->random_generator(), server_crypto_config_.get()); @@ -158,7 +264,7 @@ class TlsServerHandshakerTest : public QuicTestWithParam<TestParams> { AlpnForVersion(client_connection_->version()); ON_CALL(*client_session, GetAlpnsToOffer()) .WillByDefault(Return(std::vector<std::string>({default_alpn}))); - CHECK(client_session); + QUICHE_CHECK(client_session); client_session_.reset(client_session); moved_messages_counts_ = {0, 0}; } @@ -176,8 +282,8 @@ class TlsServerHandshakerTest : public QuicTestWithParam<TestParams> { // Performs a single round of handshake message-exchange between the // client and server. void AdvanceHandshakeWithFakeClient() { - CHECK(server_connection_); - CHECK(client_session_ != nullptr); + QUICHE_CHECK(server_connection_); + QUICHE_CHECK(client_session_ != nullptr); EXPECT_CALL(*client_session_, OnProofValid(_)).Times(testing::AnyNumber()); EXPECT_CALL(*client_session_, OnProofVerifyDetailsAvailable(_)) @@ -221,6 +327,31 @@ class TlsServerHandshakerTest : public QuicTestWithParam<TestParams> { EXPECT_EQ(0, server_crypto_params.peer_signature_algorithm); } + // Should only be called when using FakeProofSourceHandle. + FakeProofSourceHandle::SelectCertArgs last_select_cert_args() const { + QUICHE_CHECK(server_handshaker_ && + server_handshaker_->fake_proof_source_handle()); + QUICHE_CHECK(!server_handshaker_->fake_proof_source_handle() + ->all_select_cert_args() + .empty()); + return server_handshaker_->fake_proof_source_handle() + ->all_select_cert_args() + .back(); + } + + // Should only be called when using FakeProofSourceHandle. + FakeProofSourceHandle::ComputeSignatureArgs last_compute_signature_args() + const { + QUICHE_CHECK(server_handshaker_ && + server_handshaker_->fake_proof_source_handle()); + QUICHE_CHECK(!server_handshaker_->fake_proof_source_handle() + ->all_compute_signature_args() + .empty()); + return server_handshaker_->fake_proof_source_handle() + ->all_compute_signature_args() + .back(); + } + protected: // Every connection gets its own MockQuicConnectionHelper and // MockAlarmFactory, tracked separately from the server and client state so @@ -231,8 +362,10 @@ class TlsServerHandshakerTest : public QuicTestWithParam<TestParams> { // Server state. PacketSavingConnection* server_connection_; std::unique_ptr<TestQuicSpdyServerSession> server_session_; + // Only set when initialized with InitializeServerWithFakeProofSourceHandle. + NiceMock<TestTlsServerHandshaker>* server_handshaker_ = nullptr; TestTicketCrypter* ticket_crypter_; // owned by proof_source_ - FakeProofSource* proof_source_; // owned by server_crypto_config_ + FakeProofSource* proof_source_; // owned by server_crypto_config_ std::unique_ptr<QuicCryptoServerConfig> server_crypto_config_; QuicCompressedCertsCache server_compressed_certs_cache_; QuicServerId server_id_; @@ -267,7 +400,96 @@ TEST_P(TlsServerHandshakerTest, ConnectedAfterTlsHandshake) { ExpectHandshakeSuccessful(); } -TEST_P(TlsServerHandshakerTest, HandshakeWithAsyncProofSource) { +TEST_P(TlsServerHandshakerTest, HandshakeWithAsyncSelectCertSuccess) { + if (!GetQuicReloadableFlag(quic_tls_use_per_handshaker_proof_source)) { + return; + } + + InitializeServerWithFakeProofSourceHandle(); + server_handshaker_->SetupProofSourceHandle( + /*select_cert_action=*/FakeProofSourceHandle::Action::DELEGATE_ASYNC, + /*compute_signature_action=*/FakeProofSourceHandle::Action:: + DELEGATE_SYNC); + + EXPECT_CALL(*client_connection_, CloseConnection(_, _, _)).Times(0); + EXPECT_CALL(*server_connection_, CloseConnection(_, _, _)).Times(0); + + // Start handshake. + AdvanceHandshakeWithFakeClient(); + + ASSERT_TRUE( + server_handshaker_->fake_proof_source_handle()->HasPendingOperation()); + server_handshaker_->fake_proof_source_handle()->CompletePendingOperation(); + + CompleteCryptoHandshake(); + + ExpectHandshakeSuccessful(); +} + +TEST_P(TlsServerHandshakerTest, HandshakeWithAsyncSelectCertFailure) { + if (!GetQuicReloadableFlag(quic_tls_use_per_handshaker_proof_source)) { + return; + } + + InitializeServerWithFakeProofSourceHandle(); + server_handshaker_->SetupProofSourceHandle( + /*select_cert_action=*/FakeProofSourceHandle::Action::FAIL_ASYNC, + /*compute_signature_action=*/FakeProofSourceHandle::Action:: + DELEGATE_SYNC); + + // Start handshake. + AdvanceHandshakeWithFakeClient(); + + ASSERT_TRUE( + server_handshaker_->fake_proof_source_handle()->HasPendingOperation()); + server_handshaker_->fake_proof_source_handle()->CompletePendingOperation(); + + // Check that the server didn't send any handshake messages, because it failed + // to handshake. + EXPECT_EQ(moved_messages_counts_.second, 0u); +} + +TEST_P(TlsServerHandshakerTest, HandshakeWithAsyncSelectCertAndSignature) { + if (!GetQuicReloadableFlag(quic_tls_use_per_handshaker_proof_source)) { + return; + } + + InitializeServerWithFakeProofSourceHandle(); + server_handshaker_->SetupProofSourceHandle( + /*select_cert_action=*/FakeProofSourceHandle::Action::DELEGATE_ASYNC, + /*compute_signature_action=*/FakeProofSourceHandle::Action:: + DELEGATE_ASYNC); + + EXPECT_CALL(*client_connection_, CloseConnection(_, _, _)).Times(0); + EXPECT_CALL(*server_connection_, CloseConnection(_, _, _)).Times(0); + + // Start handshake. + AdvanceHandshakeWithFakeClient(); + + // A select cert operation is now pending. + ASSERT_TRUE( + server_handshaker_->fake_proof_source_handle()->HasPendingOperation()); + EXPECT_EQ(server_handshaker_->expected_ssl_error(), + SSL_ERROR_PENDING_CERTIFICATE); + + // Complete the pending select cert. It should advance the handshake to + // compute a signature, which will also be saved as a pending operation. + server_handshaker_->fake_proof_source_handle()->CompletePendingOperation(); + + // A compute signature operation is now pending. + ASSERT_TRUE( + server_handshaker_->fake_proof_source_handle()->HasPendingOperation()); + EXPECT_EQ(server_handshaker_->expected_ssl_error(), + SSL_ERROR_WANT_PRIVATE_KEY_OPERATION); + + server_handshaker_->fake_proof_source_handle()->CompletePendingOperation(); + + CompleteCryptoHandshake(); + + ExpectHandshakeSuccessful(); +} + +TEST_P(TlsServerHandshakerTest, HandshakeWithAsyncSignature) { EXPECT_CALL(*client_connection_, CloseConnection(_, _, _)).Times(0); EXPECT_CALL(*server_connection_, CloseConnection(_, _, _)).Times(0); // Enable FakeProofSource to capture call to ComputeTlsSignature and run it @@ -285,7 +507,33 @@ TEST_P(TlsServerHandshakerTest, HandshakeWithAsyncProofSource) { ExpectHandshakeSuccessful(); } -TEST_P(TlsServerHandshakerTest, CancelPendingProofSource) { +TEST_P(TlsServerHandshakerTest, CancelPendingSelectCert) { + if (!GetQuicReloadableFlag(quic_tls_use_per_handshaker_proof_source)) { + return; + } + + InitializeServerWithFakeProofSourceHandle(); + server_handshaker_->SetupProofSourceHandle( + /*select_cert_action=*/FakeProofSourceHandle::Action::DELEGATE_ASYNC, + /*compute_signature_action=*/FakeProofSourceHandle::Action:: + DELEGATE_SYNC); + + EXPECT_CALL(*client_connection_, CloseConnection(_, _, _)).Times(0); + EXPECT_CALL(*server_connection_, CloseConnection(_, _, _)).Times(0); + + // Start handshake. + AdvanceHandshakeWithFakeClient(); + + ASSERT_TRUE( + server_handshaker_->fake_proof_source_handle()->HasPendingOperation()); + server_handshaker_->CancelOutstandingCallbacks(); + ASSERT_FALSE( + server_handshaker_->fake_proof_source_handle()->HasPendingOperation()); + // CompletePendingOperation should be noop. + server_handshaker_->fake_proof_source_handle()->CompletePendingOperation(); +} + +TEST_P(TlsServerHandshakerTest, CancelPendingSignature) { EXPECT_CALL(*client_connection_, CloseConnection(_, _, _)).Times(0); EXPECT_CALL(*server_connection_, CloseConnection(_, _, _)).Times(0); // Enable FakeProofSource to capture call to ComputeTlsSignature and run it @@ -309,9 +557,44 @@ TEST_P(TlsServerHandshakerTest, ExtractSNI) { "test.example.com"); } +TEST_P(TlsServerHandshakerTest, HostnameForCertSelectionAndComputeSignature) { + if (!GetQuicReloadableFlag(quic_tls_use_per_handshaker_proof_source)) { + return; + } + + // Client uses upper case letters in hostname. It is considered valid by + // QuicHostnameUtils::IsValidSNI, but it should be normalized for cert + // selection. + server_id_ = QuicServerId("tEsT.EXAMPLE.CoM", kServerPort, false); + InitializeServerWithFakeProofSourceHandle(); + server_handshaker_->SetupProofSourceHandle( + /*select_cert_action=*/FakeProofSourceHandle::Action::DELEGATE_SYNC, + /*compute_signature_action=*/FakeProofSourceHandle::Action:: + DELEGATE_SYNC); + InitializeFakeClient(); + CompleteCryptoHandshake(); + ExpectHandshakeSuccessful(); + + EXPECT_EQ(server_stream()->crypto_negotiated_params().sni, + "test.example.com"); + + if (GetQuicReloadableFlag(quic_tls_use_normalized_sni_for_cert_selectioon)) { + EXPECT_EQ(last_select_cert_args().hostname, "test.example.com"); + EXPECT_EQ(last_compute_signature_args().hostname, "test.example.com"); + } else { + EXPECT_EQ(last_select_cert_args().hostname, "tEsT.EXAMPLE.CoM"); + EXPECT_EQ(last_compute_signature_args().hostname, "tEsT.EXAMPLE.CoM"); + } +} + TEST_P(TlsServerHandshakerTest, ConnectionClosedOnTlsError) { - EXPECT_CALL(*server_connection_, - CloseConnection(QUIC_HANDSHAKE_FAILED, _, _)); + if (GetQuicReloadableFlag(quic_send_tls_crypto_error_code)) { + EXPECT_CALL(*server_connection_, + CloseConnection(QUIC_HANDSHAKE_FAILED, _, _, _)); + } else { + EXPECT_CALL(*server_connection_, + CloseConnection(QUIC_HANDSHAKE_FAILED, _, _)); + } // Send a zero-length ClientHello from client to server. char bogus_handshake_message[] = { @@ -331,11 +614,23 @@ TEST_P(TlsServerHandshakerTest, ClientSendingBadALPN) { const std::string kTestBadClientAlpn = "bad-client-alpn"; EXPECT_CALL(*client_session_, GetAlpnsToOffer()) .WillOnce(Return(std::vector<std::string>({kTestBadClientAlpn}))); - EXPECT_CALL(*server_connection_, - CloseConnection(QUIC_HANDSHAKE_FAILED, - "TLS handshake failure (ENCRYPTION_INITIAL) 120: " - "no application protocol", - _)); + if (GetQuicReloadableFlag(quic_send_tls_crypto_error_code)) { + EXPECT_CALL( + *server_connection_, + CloseConnection( + QUIC_HANDSHAKE_FAILED, + static_cast<QuicIetfTransportErrorCodes>(CRYPTO_ERROR_FIRST + 120), + "TLS handshake failure (ENCRYPTION_INITIAL) 120: " + "no application protocol", + _)); + } else { + EXPECT_CALL( + *server_connection_, + CloseConnection(QUIC_HANDSHAKE_FAILED, + "TLS handshake failure (ENCRYPTION_INITIAL) 120: " + "no application protocol", + _)); + } AdvanceHandshakeWithFakeClient(); diff --git a/chromium/net/third_party/quiche/src/quic/core/uber_quic_stream_id_manager.cc b/chromium/net/third_party/quiche/src/quic/core/uber_quic_stream_id_manager.cc index 2f33594e042..4cf55bcd9db 100644 --- a/chromium/net/third_party/quiche/src/quic/core/uber_quic_stream_id_manager.cc +++ b/chromium/net/third_party/quiche/src/quic/core/uber_quic_stream_id_manager.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/uber_quic_stream_id_manager.h" +#include "quic/core/uber_quic_stream_id_manager.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_utils.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/uber_quic_stream_id_manager.h b/chromium/net/third_party/quiche/src/quic/core/uber_quic_stream_id_manager.h index 0e03b42c8d6..67ab7a05509 100644 --- a/chromium/net/third_party/quiche/src/quic/core/uber_quic_stream_id_manager.h +++ b/chromium/net/third_party/quiche/src/quic/core/uber_quic_stream_id_manager.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_CORE_UBER_QUIC_STREAM_ID_MANAGER_H_ #define QUICHE_QUIC_CORE_UBER_QUIC_STREAM_ID_MANAGER_H_ -#include "net/third_party/quiche/src/quic/core/quic_stream_id_manager.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/quic_stream_id_manager.h" +#include "quic/core/quic_types.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/uber_quic_stream_id_manager_test.cc b/chromium/net/third_party/quiche/src/quic/core/uber_quic_stream_id_manager_test.cc index 705a3953272..8f2b59093df 100644 --- a/chromium/net/third_party/quiche/src/quic/core/uber_quic_stream_id_manager_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/uber_quic_stream_id_manager_test.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/uber_quic_stream_id_manager.h" +#include "quic/core/uber_quic_stream_id_manager.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_id_manager_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_stream_id_manager_peer.h" +#include "quic/test_tools/quic_test_utils.h" using testing::_; using testing::StrictMock; @@ -27,7 +27,7 @@ struct TestParams { // Used by ::testing::PrintToStringParamName(). std::string PrintToString(const TestParams& p) { - return quiche::QuicheStrCat( + return absl::StrCat( ParsedQuicVersionToString(p.version), "_", (p.perspective == Perspective::IS_CLIENT ? "client" : "server")); } @@ -203,16 +203,16 @@ TEST_P(UberQuicStreamIdManagerTest, SetMaxOpenIncomingStreams) { EXPECT_FALSE(manager_.MaybeIncreaseLargestPeerStreamId( GetNthPeerInitiatedUnidirectionalStreamId(i), &error_details)); EXPECT_EQ(error_details, - quiche::QuicheStrCat( + absl::StrCat( "Stream id ", GetNthPeerInitiatedUnidirectionalStreamId(i), " would exceed stream count limit ", kNumMaxIncomingStreams)); EXPECT_FALSE(manager_.MaybeIncreaseLargestPeerStreamId( GetNthPeerInitiatedBidirectionalStreamId(i + 1), &error_details)); - EXPECT_EQ( - error_details, - quiche::QuicheStrCat( - "Stream id ", GetNthPeerInitiatedBidirectionalStreamId(i + 1), - " would exceed stream count limit ", kNumMaxIncomingStreams + 1)); + EXPECT_EQ(error_details, + absl::StrCat("Stream id ", + GetNthPeerInitiatedBidirectionalStreamId(i + 1), + " would exceed stream count limit ", + kNumMaxIncomingStreams + 1)); } TEST_P(UberQuicStreamIdManagerTest, GetNextOutgoingStreamId) { diff --git a/chromium/net/third_party/quiche/src/quic/core/uber_received_packet_manager.cc b/chromium/net/third_party/quiche/src/quic/core/uber_received_packet_manager.cc index 025da645341..7235edf192e 100644 --- a/chromium/net/third_party/quiche/src/quic/core/uber_received_packet_manager.cc +++ b/chromium/net/third_party/quiche/src/quic/core/uber_received_packet_manager.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/uber_received_packet_manager.h" +#include "quic/core/uber_received_packet_manager.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" namespace quic { @@ -189,7 +189,7 @@ bool UberReceivedPacketManager::IsAckFrameEmpty( QuicPacketNumber UberReceivedPacketManager::peer_least_packet_awaiting_ack() const { - DCHECK(!supports_multiple_packet_number_spaces_); + QUICHE_DCHECK(!supports_multiple_packet_number_spaces_); return received_packet_managers_[0].peer_least_packet_awaiting_ack(); } @@ -211,13 +211,13 @@ void UberReceivedPacketManager::set_ack_frequency(size_t new_value) { } const QuicAckFrame& UberReceivedPacketManager::ack_frame() const { - DCHECK(!supports_multiple_packet_number_spaces_); + QUICHE_DCHECK(!supports_multiple_packet_number_spaces_); return received_packet_managers_[0].ack_frame(); } const QuicAckFrame& UberReceivedPacketManager::GetAckFrame( PacketNumberSpace packet_number_space) const { - DCHECK(supports_multiple_packet_number_spaces_); + QUICHE_DCHECK(supports_multiple_packet_number_spaces_); return received_packet_managers_[packet_number_space].ack_frame(); } diff --git a/chromium/net/third_party/quiche/src/quic/core/uber_received_packet_manager.h b/chromium/net/third_party/quiche/src/quic/core/uber_received_packet_manager.h index a9f177592b6..3dddbdaa575 100644 --- a/chromium/net/third_party/quiche/src/quic/core/uber_received_packet_manager.h +++ b/chromium/net/third_party/quiche/src/quic/core/uber_received_packet_manager.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_CORE_UBER_RECEIVED_PACKET_MANAGER_H_ #define QUICHE_QUIC_CORE_UBER_RECEIVED_PACKET_MANAGER_H_ -#include "net/third_party/quiche/src/quic/core/frames/quic_ack_frequency_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_received_packet_manager.h" +#include "quic/core/frames/quic_ack_frequency_frame.h" +#include "quic/core/quic_received_packet_manager.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/core/uber_received_packet_manager_test.cc b/chromium/net/third_party/quiche/src/quic/core/uber_received_packet_manager_test.cc index 3a1531bcfa8..05e4a33aedf 100644 --- a/chromium/net/third_party/quiche/src/quic/core/uber_received_packet_manager_test.cc +++ b/chromium/net/third_party/quiche/src/quic/core/uber_received_packet_manager_test.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/core/uber_received_packet_manager.h" +#include "quic/core/uber_received_packet_manager.h" #include <utility> -#include "net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_stats.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.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 "quic/core/congestion_control/rtt_stats.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/quic_connection_stats.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" namespace quic { namespace test { @@ -89,17 +89,17 @@ class UberReceivedPacketManagerTest : public QuicTest { } void CheckAckTimeout(QuicTime time) { - DCHECK(HasPendingAck()); + QUICHE_DCHECK(HasPendingAck()); if (!manager_->supports_multiple_packet_number_spaces()) { - DCHECK(manager_->GetAckTimeout(APPLICATION_DATA) == time); + QUICHE_DCHECK(manager_->GetAckTimeout(APPLICATION_DATA) == time); if (time <= clock_.ApproximateNow()) { // ACK timeout expires, send an ACK. manager_->ResetAckStates(ENCRYPTION_FORWARD_SECURE); - DCHECK(!HasPendingAck()); + QUICHE_DCHECK(!HasPendingAck()); } return; } - DCHECK(manager_->GetEarliestAckTimeout() == time); + QUICHE_DCHECK(manager_->GetEarliestAckTimeout() == time); // Send all expired ACKs. for (int8_t i = INITIAL_DATA; i < NUM_PACKET_NUMBER_SPACES; ++i) { const QuicTime ack_timeout = diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_client_bin.cc b/chromium/net/third_party/quiche/src/quic/masque/masque_client_bin.cc index 0e44092876b..8e09a12b27c 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_client_bin.cc +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_client_bin.cc @@ -9,20 +9,20 @@ #include <memory> +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" -#include "net/third_party/quiche/src/quic/masque/masque_client_tools.h" -#include "net/third_party/quiche/src/quic/masque/masque_encapsulated_epoll_client.h" -#include "net/third_party/quiche/src/quic/masque/masque_epoll_client.h" -#include "net/third_party/quiche/src/quic/masque/masque_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_default_proof_providers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_system_event_loop.h" -#include "net/third_party/quiche/src/quic/tools/fake_proof_verifier.h" -#include "net/third_party/quiche/src/quic/tools/quic_url.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/quic_server_id.h" +#include "quic/masque/masque_client_tools.h" +#include "quic/masque/masque_encapsulated_epoll_client.h" +#include "quic/masque/masque_epoll_client.h" +#include "quic/masque/masque_utils.h" +#include "quic/platform/api/quic_default_proof_providers.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_system_event_loop.h" +#include "quic/tools/fake_proof_verifier.h" +#include "quic/tools/quic_url.h" +#include "common/platform/api/quiche_text_utils.h" DEFINE_QUIC_COMMAND_LINE_FLAG(bool, disable_certificate_verification, @@ -51,7 +51,7 @@ int RunMasqueClient(int argc, char* argv[]) { QuicUrl masque_url(urls[0], "https"); if (masque_url.host().empty()) { - masque_url = QuicUrl(quiche::QuicheStrCat("https://", urls[0]), "https"); + masque_url = QuicUrl(absl::StrCat("https://", urls[0]), "https"); } if (masque_url.host().empty()) { QUIC_LOG(ERROR) << "Failed to parse MASQUE server address " << urls[0]; diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_client_session.cc b/chromium/net/third_party/quiche/src/quic/masque/masque_client_session.cc index 4baf4ad26f0..eeedccfd0d5 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_client_session.cc +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_client_session.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/masque/masque_client_session.h" +#include "quic/masque/masque_client_session.h" namespace quic { @@ -74,10 +74,11 @@ void MasqueClientSession::RegisterConnectionId( EncapsulatedClientSession* encapsulated_client_session) { QUIC_DLOG(INFO) << "Registering " << client_connection_id << " to encapsulated client"; - DCHECK(client_connection_id_registrations_.find(client_connection_id) == - client_connection_id_registrations_.end() || - client_connection_id_registrations_[client_connection_id] == - encapsulated_client_session); + QUICHE_DCHECK( + client_connection_id_registrations_.find(client_connection_id) == + client_connection_id_registrations_.end() || + client_connection_id_registrations_[client_connection_id] == + encapsulated_client_session); client_connection_id_registrations_[client_connection_id] = encapsulated_client_session; } diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_client_session.h b/chromium/net/third_party/quiche/src/quic/masque/masque_client_session.h index 38fa929a591..0eab5b22c20 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_client_session.h +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_client_session.h @@ -5,11 +5,12 @@ #ifndef QUICHE_QUIC_MASQUE_MASQUE_CLIENT_SESSION_H_ #define QUICHE_QUIC_MASQUE_MASQUE_CLIENT_SESSION_H_ +#include "absl/container/flat_hash_map.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h" -#include "net/third_party/quiche/src/quic/masque/masque_compression_engine.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/http/quic_spdy_client_session.h" +#include "quic/masque/masque_compression_engine.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { @@ -86,9 +87,9 @@ class QUIC_NO_EXPORT MasqueClientSession : public QuicSpdyClientSession { void UnregisterConnectionId(QuicConnectionId client_connection_id); private: - QuicHashMap<QuicConnectionId, - EncapsulatedClientSession*, - QuicConnectionIdHash> + absl::flat_hash_map<QuicConnectionId, + EncapsulatedClientSession*, + QuicConnectionIdHash> client_connection_id_registrations_; Owner* owner_; // Unowned; MasqueCompressionEngine compression_engine_; diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_client_tools.cc b/chromium/net/third_party/quiche/src/quic/masque/masque_client_tools.cc index e59204a9344..7ab9bd41d7d 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_client_tools.cc +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_client_tools.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/masque/masque_client_tools.h" -#include "net/third_party/quiche/src/quic/masque/masque_encapsulated_epoll_client.h" -#include "net/third_party/quiche/src/quic/masque/masque_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_default_proof_providers.h" -#include "net/third_party/quiche/src/quic/tools/fake_proof_verifier.h" -#include "net/third_party/quiche/src/quic/tools/quic_url.h" +#include "quic/masque/masque_client_tools.h" +#include "quic/masque/masque_encapsulated_epoll_client.h" +#include "quic/masque/masque_utils.h" +#include "quic/platform/api/quic_default_proof_providers.h" +#include "quic/tools/fake_proof_verifier.h" +#include "quic/tools/quic_url.h" namespace quic { namespace tools { @@ -26,7 +26,7 @@ bool SendEncapsulatedMasqueRequest(MasqueEpollClient* masque_client, // Build the client, and try to connect. const QuicSocketAddress addr = - LookupAddress(url.host(), quiche::QuicheStrCat(url.port())); + LookupAddress(url.host(), absl::StrCat(url.port())); if (!addr.IsInitialized()) { QUIC_LOG(ERROR) << "Unable to resolve address: " << url.host(); return false; diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_client_tools.h b/chromium/net/third_party/quiche/src/quic/masque/masque_client_tools.h index 4ddc2d70846..30727df2d3f 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_client_tools.h +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_client_tools.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_MASQUE_MASQUE_CLIENT_TOOLS_H_ #define QUICHE_QUIC_MASQUE_MASQUE_CLIENT_TOOLS_H_ -#include "net/third_party/quiche/src/quic/masque/masque_epoll_client.h" +#include "quic/masque/masque_epoll_client.h" namespace quic { namespace tools { diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_compression_engine.cc b/chromium/net/third_party/quiche/src/quic/masque/masque_compression_engine.cc index 008e2b8bf01..af6758af58a 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_compression_engine.cc +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_compression_engine.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/masque/masque_compression_engine.h" +#include "quic/masque/masque_compression_engine.h" #include <cstdint> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_data_reader.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/quic_buffer_allocator.h" +#include "quic/core/quic_data_reader.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_containers.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { @@ -63,7 +63,7 @@ QuicDatagramFlowId MasqueCompressionEngine::FindOrCreateCompressionContext( } flow_id = kv.first; - DCHECK_NE(flow_id, kFlowId0); + QUICHE_DCHECK_NE(flow_id, kFlowId0); *validated = context.validated; QUIC_DVLOG(1) << "Compressing using " << (*validated ? "" : "un") << "validated flow_id " << flow_id << " to " @@ -133,9 +133,9 @@ bool MasqueCompressionEngine::WriteCompressedPacketToSlice( return false; } QuicIpAddress peer_ip = server_address.host(); - DCHECK(peer_ip.IsInitialized()); + QUICHE_DCHECK(peer_ip.IsInitialized()); std::string peer_ip_bytes = peer_ip.ToPackedString(); - DCHECK(!peer_ip_bytes.empty()); + QUICHE_DCHECK(!peer_ip_bytes.empty()); uint8_t address_id; if (peer_ip.address_family() == IpAddressFamily::IP_V6) { address_id = MasqueAddressFamilyIPv6; @@ -229,7 +229,7 @@ void MasqueCompressionEngine::CompressAndSendPacket( QUIC_DVLOG(2) << "Compressing client " << client_connection_id << " server " << server_connection_id << "\n" << quiche::QuicheTextUtils::HexDump(packet); - DCHECK(server_address.IsInitialized()); + QUICHE_DCHECK(server_address.IsInitialized()); if (packet.empty()) { QUIC_BUG << "Tried to send empty packet"; return; diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_compression_engine.h b/chromium/net/third_party/quiche/src/quic/masque/masque_compression_engine.h index 6eb7a444f64..96c59482b52 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_compression_engine.h +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_compression_engine.h @@ -5,13 +5,14 @@ #ifndef QUICHE_QUIC_MASQUE_MASQUE_PROTOCOL_H_ #define QUICHE_QUIC_MASQUE_MASQUE_PROTOCOL_H_ +#include "absl/container/flat_hash_map.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { @@ -117,7 +118,7 @@ class QUIC_NO_EXPORT MasqueCompressionEngine { bool* version_present); QuicSession* masque_session_; // Unowned. - QuicHashMap<QuicDatagramFlowId, MasqueCompressionContext> contexts_; + absl::flat_hash_map<QuicDatagramFlowId, MasqueCompressionContext> contexts_; QuicDatagramFlowId next_flow_id_; }; diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_dispatcher.cc b/chromium/net/third_party/quiche/src/quic/masque/masque_dispatcher.cc index bc3b3beef7f..6edca628f4f 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_dispatcher.cc +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_dispatcher.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/masque/masque_dispatcher.h" -#include "net/third_party/quiche/src/quic/masque/masque_server_session.h" +#include "quic/masque/masque_dispatcher.h" +#include "quic/masque/masque_server_session.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_dispatcher.h b/chromium/net/third_party/quiche/src/quic/masque/masque_dispatcher.h index 9ba52ef913d..2e0186c9a3d 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_dispatcher.h +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_dispatcher.h @@ -5,10 +5,11 @@ #ifndef QUICHE_QUIC_MASQUE_MASQUE_DISPATCHER_H_ #define QUICHE_QUIC_MASQUE_MASQUE_DISPATCHER_H_ -#include "net/third_party/quiche/src/quic/masque/masque_server_backend.h" -#include "net/third_party/quiche/src/quic/masque/masque_server_session.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.h" +#include "absl/container/flat_hash_map.h" +#include "quic/masque/masque_server_backend.h" +#include "quic/masque/masque_server_session.h" +#include "quic/platform/api/quic_export.h" +#include "quic/tools/quic_simple_dispatcher.h" namespace quic { @@ -53,7 +54,9 @@ class QUIC_NO_EXPORT MasqueDispatcher : public QuicSimpleDispatcher, MasqueServerBackend* masque_server_backend_; // Unowned. // Mapping from client connection IDs to server sessions, allows routing // incoming packets to the right MASQUE connection. - QuicHashMap<QuicConnectionId, MasqueServerSession*, QuicConnectionIdHash> + absl::flat_hash_map<QuicConnectionId, + MasqueServerSession*, + QuicConnectionIdHash> client_connection_id_registrations_; }; diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_encapsulated_client_session.cc b/chromium/net/third_party/quiche/src/quic/masque/masque_encapsulated_client_session.cc index 628e7c83b36..983a094f30a 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_encapsulated_client_session.cc +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_encapsulated_client_session.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/masque/masque_encapsulated_client_session.h" +#include "quic/masque/masque_encapsulated_client_session.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_encapsulated_client_session.h b/chromium/net/third_party/quiche/src/quic/masque/masque_encapsulated_client_session.h index 11e96011d96..570ccdb84d3 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_encapsulated_client_session.h +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_encapsulated_client_session.h @@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_MASQUE_MASQUE_ENCAPSULATED_CLIENT_SESSION_H_ #define QUICHE_QUIC_MASQUE_MASQUE_ENCAPSULATED_CLIENT_SESSION_H_ -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h" -#include "net/third_party/quiche/src/quic/masque/masque_client_session.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/http/quic_spdy_client_session.h" +#include "quic/masque/masque_client_session.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_encapsulated_epoll_client.cc b/chromium/net/third_party/quiche/src/quic/masque/masque_encapsulated_epoll_client.cc index 934a8e53ae3..8fb938dbdc7 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_encapsulated_epoll_client.cc +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_encapsulated_epoll_client.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/masque/masque_encapsulated_epoll_client.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/masque/masque_client_session.h" -#include "net/third_party/quiche/src/quic/masque/masque_encapsulated_client_session.h" -#include "net/third_party/quiche/src/quic/masque/masque_epoll_client.h" -#include "net/third_party/quiche/src/quic/masque/masque_utils.h" +#include "quic/masque/masque_encapsulated_epoll_client.h" +#include "quic/core/quic_utils.h" +#include "quic/masque/masque_client_session.h" +#include "quic/masque/masque_encapsulated_client_session.h" +#include "quic/masque/masque_epoll_client.h" +#include "quic/masque/masque_utils.h" namespace quic { @@ -24,7 +24,7 @@ class MasquePacketWriter : public QuicPacketWriter { const QuicIpAddress& /*self_address*/, const QuicSocketAddress& peer_address, PerPacketOptions* /*options*/) override { - DCHECK(peer_address.IsInitialized()); + QUICHE_DCHECK(peer_address.IsInitialized()); QUIC_DVLOG(1) << "MasquePacketWriter trying to write " << buf_len << " bytes to " << peer_address; absl::string_view packet(buffer, buf_len); diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_encapsulated_epoll_client.h b/chromium/net/third_party/quiche/src/quic/masque/masque_encapsulated_epoll_client.h index c8bff2154c4..70f0732f993 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_encapsulated_epoll_client.h +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_encapsulated_epoll_client.h @@ -5,10 +5,10 @@ #ifndef QUICHE_QUIC_MASQUE_MASQUE_ENCAPSULATED_EPOLL_CLIENT_H_ #define QUICHE_QUIC_MASQUE_MASQUE_ENCAPSULATED_EPOLL_CLIENT_H_ -#include "net/third_party/quiche/src/quic/masque/masque_encapsulated_client_session.h" -#include "net/third_party/quiche/src/quic/masque/masque_epoll_client.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/tools/quic_client.h" +#include "quic/masque/masque_encapsulated_client_session.h" +#include "quic/masque/masque_epoll_client.h" +#include "quic/platform/api/quic_export.h" +#include "quic/tools/quic_client.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_epoll_client.cc b/chromium/net/third_party/quiche/src/quic/masque/masque_epoll_client.cc index 3b7c2011331..1d77e557a64 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_epoll_client.cc +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_epoll_client.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/masque/masque_epoll_client.h" -#include "net/third_party/quiche/src/quic/masque/masque_client_session.h" -#include "net/third_party/quiche/src/quic/masque/masque_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" +#include "quic/masque/masque_epoll_client.h" +#include "quic/masque/masque_client_session.h" +#include "quic/masque/masque_utils.h" +#include "quic/platform/api/quic_ptr_util.h" namespace quic { @@ -47,8 +47,7 @@ std::unique_ptr<MasqueEpollClient> MasqueEpollClient::Create( QuicEpollServer* epoll_server, std::unique_ptr<ProofVerifier> proof_verifier) { // Build the masque_client, and try to connect. - QuicSocketAddress addr = - tools::LookupAddress(host, quiche::QuicheStrCat(port)); + QuicSocketAddress addr = tools::LookupAddress(host, absl::StrCat(port)); if (!addr.IsInitialized()) { QUIC_LOG(ERROR) << "Unable to resolve address: " << host; return nullptr; @@ -59,7 +58,7 @@ std::unique_ptr<MasqueEpollClient> MasqueEpollClient::Create( // MasqueEpollClient is private and therefore not accessible from make_unique. auto masque_client = QuicWrapUnique(new MasqueEpollClient( addr, server_id, epoll_server, std::move(proof_verifier), - quiche::QuicheStrCat(host, ":", port))); + absl::StrCat(host, ":", port))); if (masque_client == nullptr) { QUIC_LOG(ERROR) << "Failed to create masque_client"; diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_epoll_client.h b/chromium/net/third_party/quiche/src/quic/masque/masque_epoll_client.h index 403216bc9a5..345c18c7dee 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_epoll_client.h +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_epoll_client.h @@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_MASQUE_MASQUE_EPOLL_CLIENT_H_ #define QUICHE_QUIC_MASQUE_MASQUE_EPOLL_CLIENT_H_ -#include "net/third_party/quiche/src/quic/masque/masque_client_session.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/tools/quic_client.h" +#include "quic/masque/masque_client_session.h" +#include "quic/platform/api/quic_export.h" +#include "quic/tools/quic_client.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_epoll_server.cc b/chromium/net/third_party/quiche/src/quic/masque/masque_epoll_server.cc index 60adecab108..34769a37bf7 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_epoll_server.cc +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_epoll_server.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/masque/masque_epoll_server.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.h" -#include "net/third_party/quiche/src/quic/masque/masque_dispatcher.h" -#include "net/third_party/quiche/src/quic/masque/masque_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_default_proof_providers.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_crypto_server_stream_helper.h" +#include "quic/masque/masque_epoll_server.h" +#include "quic/core/quic_epoll_alarm_factory.h" +#include "quic/masque/masque_dispatcher.h" +#include "quic/masque/masque_utils.h" +#include "quic/platform/api/quic_default_proof_providers.h" +#include "quic/tools/quic_simple_crypto_server_stream_helper.h" namespace quic { @@ -18,7 +18,6 @@ MasqueEpollServer::MasqueEpollServer(MasqueServerBackend* masque_server_backend) masque_server_backend_(masque_server_backend) {} QuicDispatcher* MasqueEpollServer::CreateQuicDispatcher() { - QuicEpollAlarmFactory alarm_factory(epoll_server()); return new MasqueDispatcher( &config(), &crypto_config(), version_manager(), std::make_unique<QuicEpollConnectionHelper>(epoll_server(), diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_epoll_server.h b/chromium/net/third_party/quiche/src/quic/masque/masque_epoll_server.h index 8d462e80b67..57eab6a1f84 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_epoll_server.h +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_epoll_server.h @@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_MASQUE_MASQUE_EPOLL_SERVER_H_ #define QUICHE_QUIC_MASQUE_MASQUE_EPOLL_SERVER_H_ -#include "net/third_party/quiche/src/quic/masque/masque_server_backend.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/tools/quic_server.h" +#include "quic/masque/masque_server_backend.h" +#include "quic/platform/api/quic_export.h" +#include "quic/tools/quic_server.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_server_backend.cc b/chromium/net/third_party/quiche/src/quic/masque/masque_server_backend.cc index fc2fdc08c41..19948198f33 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_server_backend.cc +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_server_backend.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/masque/masque_server_backend.h" +#include "quic/masque/masque_server_backend.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" namespace quic { @@ -12,9 +12,9 @@ namespace { std::string GetRequestHandlerKey( const QuicSimpleServerBackend::RequestHandler* request_handler) { - return quiche::QuicheStrCat(request_handler->connection_id().ToString(), "_", - request_handler->stream_id(), "_", - request_handler->peer_host()); + return absl::StrCat(request_handler->connection_id().ToString(), "_", + request_handler->stream_id(), "_", + request_handler->peer_host()); } } // namespace diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_server_backend.h b/chromium/net/third_party/quiche/src/quic/masque/masque_server_backend.h index 52260b72fbd..180935917e5 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_server_backend.h +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_server_backend.h @@ -5,8 +5,9 @@ #ifndef QUICHE_QUIC_MASQUE_MASQUE_SERVER_BACKEND_H_ #define QUICHE_QUIC_MASQUE_MASQUE_SERVER_BACKEND_H_ -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h" +#include "absl/container/flat_hash_map.h" +#include "quic/platform/api/quic_export.h" +#include "quic/tools/quic_memory_cache_backend.h" namespace quic { @@ -57,9 +58,9 @@ class QUIC_NO_EXPORT MasqueServerBackend : public QuicMemoryCacheBackend { QuicSimpleServerBackend::RequestHandler* request_handler); std::string server_authority_; - QuicHashMap<std::string, std::unique_ptr<QuicBackendResponse>> + absl::flat_hash_map<std::string, std::unique_ptr<QuicBackendResponse>> active_response_map_; - QuicHashMap<QuicConnectionId, BackendClient*, QuicConnectionIdHash> + absl::flat_hash_map<QuicConnectionId, BackendClient*, QuicConnectionIdHash> backend_clients_; }; diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_server_bin.cc b/chromium/net/third_party/quiche/src/quic/masque/masque_server_bin.cc index 08ead0c6f2c..b25bf834ed3 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_server_bin.cc +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_server_bin.cc @@ -9,11 +9,11 @@ #include <memory> -#include "net/third_party/quiche/src/quic/masque/masque_epoll_server.h" -#include "net/third_party/quiche/src/quic/masque/masque_server_backend.h" -#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_socket_address.h" +#include "quic/masque/masque_epoll_server.h" +#include "quic/masque/masque_server_backend.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_socket_address.h" DEFINE_QUIC_COMMAND_LINE_FLAG(int32_t, port, diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_server_session.cc b/chromium/net/third_party/quiche/src/quic/masque/masque_server_session.cc index e6ca1f3c6d5..228444aacbb 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_server_session.cc +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_server_session.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/masque/masque_server_session.h" +#include "quic/masque/masque_server_session.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_server_session.h b/chromium/net/third_party/quiche/src/quic/masque/masque_server_session.h index 63cadcd0aca..9e43b63ccbc 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_server_session.h +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_server_session.h @@ -5,10 +5,10 @@ #ifndef QUICHE_QUIC_MASQUE_MASQUE_SERVER_SESSION_H_ #define QUICHE_QUIC_MASQUE_MASQUE_SERVER_SESSION_H_ -#include "net/third_party/quiche/src/quic/masque/masque_compression_engine.h" -#include "net/third_party/quiche/src/quic/masque/masque_server_backend.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_session.h" +#include "quic/masque/masque_compression_engine.h" +#include "quic/masque/masque_server_backend.h" +#include "quic/platform/api/quic_export.h" +#include "quic/tools/quic_simple_server_session.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_utils.cc b/chromium/net/third_party/quiche/src/quic/masque/masque_utils.cc index 80c467560d1..f4f77f5faa2 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_utils.cc +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_utils.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/masque/masque_utils.h" +#include "quic/masque/masque_utils.h" namespace quic { @@ -16,7 +16,7 @@ ParsedQuicVersionVector MasqueSupportedVersions() { break; } } - CHECK(version.IsKnown()); + QUICHE_CHECK(version.IsKnown()); QuicEnableVersion(version); return {version}; } diff --git a/chromium/net/third_party/quiche/src/quic/masque/masque_utils.h b/chromium/net/third_party/quiche/src/quic/masque/masque_utils.h index d8f9d0fcdb2..f151f5508cd 100644 --- a/chromium/net/third_party/quiche/src/quic/masque/masque_utils.h +++ b/chromium/net/third_party/quiche/src/quic/masque/masque_utils.h @@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_MASQUE_MASQUE_UTILS_H_ #define QUICHE_QUIC_MASQUE_MASQUE_UTILS_H_ -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_cert_utils.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_cert_utils.h deleted file mode 100644 index b2a5bc22b62..00000000000 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_cert_utils.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file._ - -#ifndef QUICHE_QUIC_PLATFORM_API_QUIC_CERT_UTILS_H_ -#define QUICHE_QUIC_PLATFORM_API_QUIC_CERT_UTILS_H_ - -#include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/quic/platform/impl/quic_cert_utils_impl.h" - -namespace quic { - -class QUIC_EXPORT_PRIVATE QuicCertUtils { - public: - static bool ExtractSubjectNameFromDERCert(absl::string_view cert, - absl::string_view* subject_out) { - return QuicCertUtilsImpl::ExtractSubjectNameFromDERCert(cert, subject_out); - } -}; - -} // namespace quic - -#endif // QUICHE_QUIC_PLATFORM_API_QUIC_CERT_UTILS_H_ diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_containers.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_containers.h index d0c63a53b50..fa4610be27b 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_containers.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_containers.h @@ -52,6 +52,14 @@ using QuicQueue = QuicQueueImpl<T>; template <typename T, size_t N, typename A = std::allocator<T>> using QuicInlinedVector = QuicInlinedVectorImpl<T, N, A>; +// An ordered set of values. +// +// DOES NOT GUARANTEE POINTER OR ITERATOR STABILITY! +template <typename Key, + typename Compare = std::less<Key>, + typename Rep = std::vector<Key>> +using QuicOrderedSet = QuicOrderedSetImpl<Key, Compare, Rep>; + } // namespace quic #endif // QUICHE_QUIC_PLATFORM_API_QUIC_CONTAINERS_H_ diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_containers_test.cc b/chromium/net/third_party/quiche/src/quic/platform/api/quic_containers_test.cc index b272b09efca..bc255d36dcf 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_containers_test.cc +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_containers_test.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" using ::testing::ElementsAre; diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_default_proof_providers.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_default_proof_providers.h index 98907096137..c6ace4162d5 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_default_proof_providers.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_default_proof_providers.h @@ -7,8 +7,8 @@ #include <memory> -#include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_verifier.h" +#include "quic/core/crypto/proof_source.h" +#include "quic/core/crypto/proof_verifier.h" #include "net/quic/platform/impl/quic_default_proof_providers_impl.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_estimate_memory_usage.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_estimate_memory_usage.h index dd844856bc3..a5a093b9f1c 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_estimate_memory_usage.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_estimate_memory_usage.h @@ -7,13 +7,13 @@ #include <cstddef> -#include "net/quic/platform/impl/quic_estimate_memory_usage_impl.h" +#include "quiche_platform_impl/quiche_estimate_memory_usage_impl.h" namespace quic { template <class T> size_t QuicEstimateMemoryUsage(const T& object) { - return QuicEstimateMemoryUsageImpl(object); + return quiche::QuicheEstimateMemoryUsageImpl(object); } } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_export.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_export.h index 90696a6fba6..b4f82aa15f4 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_export.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_export.h @@ -5,13 +5,17 @@ #ifndef QUICHE_QUIC_PLATFORM_API_QUIC_EXPORT_H_ #define QUICHE_QUIC_PLATFORM_API_QUIC_EXPORT_H_ -#include "net/quic/platform/impl/quic_export_impl.h" +#include "quiche_platform_impl/quiche_export_impl.h" -// quic_export_impl.h defines the following macros: -// - QUIC_EXPORT is not meant to be used. -// - QUIC_EXPORT_PRIVATE is meant for QUIC functionality that is built in -// Chromium as part of //net, and not fully contained in headers. -// - QUIC_NO_EXPORT is meant for QUIC functionality that is either fully defined -// in a header, or is built in Chromium as part of tests or tools. +// QUIC_EXPORT is not meant to be used. +#define QUIC_EXPORT QUICHE_EXPORT_IMPL + +// QUIC_EXPORT_PRIVATE is meant for QUIC functionality that is built in Chromium +// as part of //net, and not fully contained in headers. +#define QUIC_EXPORT_PRIVATE QUICHE_EXPORT_PRIVATE_IMPL + +// QUIC_NO_EXPORT is meant for QUIC functionality that is either fully defined +// in a header, or is built in Chromium as part of tests or tools. +#define QUIC_NO_EXPORT QUICHE_NO_EXPORT_IMPL #endif // QUICHE_QUIC_PLATFORM_API_QUIC_EXPORT_H_ diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_file_utils.cc b/chromium/net/third_party/quiche/src/quic/platform/api/quic_file_utils.cc index a9901e14d86..5cb310baf9f 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_file_utils.cc +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_file_utils.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/platform/api/quic_file_utils.h" +#include "quic/platform/api/quic_file_utils.h" #include "absl/strings/string_view.h" #include "net/quic/platform/impl/quic_file_utils_impl.h" diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_file_utils.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_file_utils.h index 6142feb3f95..a1f881f63a6 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_file_utils.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_file_utils.h @@ -9,7 +9,7 @@ #include <vector> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h index bec9b39c653..63cbb91dd4f 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h @@ -5,15 +5,15 @@ #ifndef QUICHE_QUIC_PLATFORM_API_QUIC_FLAG_UTILS_H_ #define QUICHE_QUIC_PLATFORM_API_QUIC_FLAG_UTILS_H_ -#include "net/quic/platform/impl/quic_flag_utils_impl.h" +#include "common/platform/api/quiche_flag_utils.h" -#define QUIC_RELOADABLE_FLAG_COUNT QUIC_RELOADABLE_FLAG_COUNT_IMPL -#define QUIC_RELOADABLE_FLAG_COUNT_N QUIC_RELOADABLE_FLAG_COUNT_N_IMPL +#define QUIC_RELOADABLE_FLAG_COUNT QUICHE_RELOADABLE_FLAG_COUNT +#define QUIC_RELOADABLE_FLAG_COUNT_N QUICHE_RELOADABLE_FLAG_COUNT_N -#define QUIC_RESTART_FLAG_COUNT QUIC_RESTART_FLAG_COUNT_IMPL -#define QUIC_RESTART_FLAG_COUNT_N QUIC_RESTART_FLAG_COUNT_N_IMPL +#define QUIC_RESTART_FLAG_COUNT QUICHE_RESTART_FLAG_COUNT +#define QUIC_RESTART_FLAG_COUNT_N QUICHE_RESTART_FLAG_COUNT_N -#define QUIC_CODE_COUNT QUIC_CODE_COUNT_IMPL -#define QUIC_CODE_COUNT_N QUIC_CODE_COUNT_N_IMPL +#define QUIC_CODE_COUNT QUICHE_CODE_COUNT +#define QUIC_CODE_COUNT_N QUICHE_CODE_COUNT_N #endif // QUICHE_QUIC_PLATFORM_API_QUIC_FLAG_UTILS_H_ diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_flags.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_flags.h index bf6fc3c306a..1a9f2d99fa2 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_flags.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_flags.h @@ -8,22 +8,23 @@ #include <string> #include <vector> -#include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" #include "net/quic/platform/impl/quic_flags_impl.h" +#include "common/platform/api/quiche_flags.h" + +#define GetQuicReloadableFlag(flag) GetQuicheReloadableFlag(quic, flag) +#define SetQuicReloadableFlag(flag, value) \ + SetQuicheReloadableFlag(quic, flag, value) +#define GetQuicRestartFlag(flag) GetQuicheRestartFlag(quic, flag) +#define SetQuicRestartFlag(flag, value) SetQuicheRestartFlag(quic, flag, value) +#define GetQuicFlag(flag) GetQuicheFlag(flag) +#define SetQuicFlag(flag, value) SetQuicheFlag(flag, value) + // Define a command-line flag that can be automatically set via // QuicParseCommandLineFlags(). #define DEFINE_QUIC_COMMAND_LINE_FLAG(type, name, default_value, help) \ DEFINE_QUIC_COMMAND_LINE_FLAG_IMPL(type, name, default_value, help) -#define GetQuicReloadableFlag(flag) GetQuicReloadableFlagImpl(flag) -#define SetQuicReloadableFlag(flag, value) \ - SetQuicReloadableFlagImpl(flag, value) -#define GetQuicRestartFlag(flag) GetQuicRestartFlagImpl(flag) -#define SetQuicRestartFlag(flag, value) SetQuicRestartFlagImpl(flag, value) -#define GetQuicFlag(flag) GetQuicFlagImpl(flag) -#define SetQuicFlag(flag, value) SetQuicFlagImpl(flag, value) - namespace quic { // Parses command-line flags, setting flag variables defined using diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_hostname_utils.cc b/chromium/net/third_party/quiche/src/quic/platform/api/quic_hostname_utils.cc index d13339c4ca8..d8d63fa17d6 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_hostname_utils.cc +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_hostname_utils.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/platform/api/quic_hostname_utils.h" +#include "quic/platform/api/quic_hostname_utils.h" #include "absl/strings/string_view.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_hostname_utils.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_hostname_utils.h index a3c902ef55b..79158b97eb3 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_hostname_utils.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_hostname_utils.h @@ -8,7 +8,7 @@ #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" #include "net/quic/platform/impl/quic_hostname_utils_impl.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_hostname_utils_test.cc b/chromium/net/third_party/quiche/src/quic/platform/api/quic_hostname_utils_test.cc index d1808fb0b3c..7049715f74e 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_hostname_utils_test.cc +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_hostname_utils_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/platform/api/quic_hostname_utils.h" +#include "quic/platform/api/quic_hostname_utils.h" #include <string> #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_ip_address.cc b/chromium/net/third_party/quiche/src/quic/platform/api/quic_ip_address.cc index 6db0838dfd4..95877f4c8e7 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_ip_address.cc +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_ip_address.cc @@ -2,14 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_ip_address.h" #include <algorithm> #include <cstdint> #include <cstring> #include <string> -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_logging.h" namespace quic { @@ -217,18 +218,18 @@ bool QuicIpAddress::InSameSubnet(const QuicIpAddress& other, if (bits_to_check == 0) { return true; } - DCHECK_LT(static_cast<size_t>(bytes_to_check), sizeof(address_.bytes)); + QUICHE_DCHECK_LT(static_cast<size_t>(bytes_to_check), sizeof(address_.bytes)); int mask = (~0u) << (8u - bits_to_check); return (lhs[bytes_to_check] & mask) == (rhs[bytes_to_check] & mask); } in_addr QuicIpAddress::GetIPv4() const { - DCHECK(IsIPv4()); + QUICHE_DCHECK(IsIPv4()); return address_.v4; } in6_addr QuicIpAddress::GetIPv6() const { - DCHECK(IsIPv6()); + QUICHE_DCHECK(IsIPv6()); return address_.v6; } diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_ip_address.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_ip_address.h index 3585970d9d5..26be870b11e 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_ip_address.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_ip_address.h @@ -18,8 +18,8 @@ #include <ostream> #include <string> -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address_family.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_ip_address_family.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_ip_address_test.cc b/chromium/net/third_party/quiche/src/quic/platform/api/quic_ip_address_test.cc index 7dfe243068c..f0f196ff579 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_ip_address_test.cc +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_ip_address_test.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_ip_address.h" #include <cstdint> -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_logging.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_logging.h index 06a3a6156c0..770d4081c20 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_logging.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_logging.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_PLATFORM_API_QUIC_LOGGING_H_ #define QUICHE_QUIC_PLATFORM_API_QUIC_LOGGING_H_ -#include "net/third_party/quiche/src/common/platform/api/quiche_logging.h" +#include "common/platform/api/quiche_logging.h" // Please note following QUIC_LOG are platform dependent: // INFO severity can be degraded (to VLOG(1) or DVLOG(1)). diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice.h index 2d44085588b..32e64575b25 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice.h @@ -5,7 +5,8 @@ #ifndef QUICHE_QUIC_PLATFORM_API_QUIC_MEM_SLICE_H_ #define QUICHE_QUIC_PLATFORM_API_QUIC_MEM_SLICE_H_ -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include <memory> +#include "quic/platform/api/quic_export.h" #include "net/quic/platform/impl/quic_mem_slice_impl.h" /* API_DESCRIPTION @@ -33,6 +34,11 @@ class QUIC_EXPORT_PRIVATE QuicMemSlice { QuicMemSlice(QuicUniqueBufferPtr buffer, size_t length) : impl_(std::move(buffer), length) {} + // Constructs a QuicMemSlice that takes ownership of |buffer| allocated on + // heap. |length| must not be zero. + QuicMemSlice(std::unique_ptr<char[]> buffer, size_t length) + : impl_(std::move(buffer), length) {} + // Constructs QuicMemSlice from |impl|. It takes the reference away from // |impl|. explicit QuicMemSlice(QuicMemSliceImpl impl) : impl_(std::move(impl)) {} diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_span.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_span.h index 741ecb19411..c33707a1763 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_span.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_span.h @@ -6,7 +6,7 @@ #define QUICHE_QUIC_PLATFORM_API_QUIC_MEM_SLICE_SPAN_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" #include "net/quic/platform/impl/quic_mem_slice_span_impl.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_span_test.cc b/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_span_test.cc index 8230a1ba482..99a11df5a2e 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_span_test.cc +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_span_test.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/platform/api/quic_mem_slice_span.h" +#include "quic/platform/api/quic_mem_slice_span.h" -#include "net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test_mem_slice_vector.h" +#include "quic/core/quic_simple_buffer_allocator.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test_mem_slice_vector.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_storage.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_storage.h index 9164e9af74b..3ec1fc4503c 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_storage.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_storage.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_PLATFORM_API_QUIC_MEM_SLICE_STORAGE_H_ #define QUICHE_QUIC_PLATFORM_API_QUIC_MEM_SLICE_STORAGE_H_ -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" #include "net/quic/platform/impl/quic_mem_slice_storage_impl.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_storage_test.cc b/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_storage_test.cc index a13899d443e..086e218d312 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_storage_test.cc +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_storage_test.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/platform/api/quic_mem_slice_storage.h" +#include "quic/platform/api/quic_mem_slice_storage.h" -#include "net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test_mem_slice_vector.h" +#include "quic/core/quic_simple_buffer_allocator.h" +#include "quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test_mem_slice_vector.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_test.cc b/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_test.cc index d441aface45..380c462f880 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_test.cc +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_mem_slice_test.cc @@ -2,10 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/platform/api/quic_mem_slice.h" +#include "quic/platform/api/quic_mem_slice.h" -#include "net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include <memory> +#include "quic/core/quic_simple_buffer_allocator.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { @@ -45,6 +46,16 @@ TEST_F(QuicMemSliceTest, MoveAssign) { EXPECT_TRUE(slice_.empty()); } +TEST_F(QuicMemSliceTest, SliceAllocatedOnHeap) { + auto buffer = std::make_unique<char[]>(128); + char* orig_data = buffer.get(); + size_t used_length = 105; + QuicMemSlice slice = QuicMemSlice(std::move(buffer), used_length); + QuicMemSlice moved = std::move(slice); + EXPECT_EQ(moved.data(), orig_data); + EXPECT_EQ(moved.length(), used_length); +} + } // namespace } // namespace test } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_mutex.cc b/chromium/net/third_party/quiche/src/quic/platform/api/quic_mutex.cc index fc0c9b562e9..401feb37f36 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_mutex.cc +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_mutex.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/platform/api/quic_mutex.h" +#include "quic/platform/api/quic_mutex.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_mutex.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_mutex.h index d35c6602aeb..33f01e48fb2 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_mutex.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_mutex.h @@ -5,7 +5,8 @@ #ifndef QUICHE_QUIC_PLATFORM_API_QUIC_MUTEX_H_ #define QUICHE_QUIC_PLATFORM_API_QUIC_MUTEX_H_ -#include "net/quic/platform/impl/quic_mutex_impl.h" +// TODO(b/178613777): move into the common QUICHE platform. +#include "quiche_platform_impl/quic_mutex_impl.h" #define QUIC_EXCLUSIVE_LOCKS_REQUIRED QUIC_EXCLUSIVE_LOCKS_REQUIRED_IMPL #define QUIC_GUARDED_BY QUIC_GUARDED_BY_IMPL diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_pcc_sender.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_pcc_sender.h deleted file mode 100644 index 03db5b3645c..00000000000 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_pcc_sender.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef QUICHE_QUIC_PLATFORM_API_QUIC_PCC_SENDER_H_ -#define QUICHE_QUIC_PLATFORM_API_QUIC_PCC_SENDER_H_ - -#include "net/quic/platform/impl/quic_pcc_sender_impl.h" - -namespace quic { - -class SendAlgorithmInterface; -// Interface for creating a PCC SendAlgorithmInterface -inline SendAlgorithmInterface* CreatePccSender( - const QuicClock* clock, - const RttStats* rtt_stats, - const QuicUnackedPacketMap* unacked_packets, - QuicRandom* random, - QuicConnectionStats* stats, - QuicPacketCount initial_congestion_window, - QuicPacketCount max_congestion_window) { - return CreatePccSenderImpl(clock, rtt_stats, unacked_packets, random, stats, - initial_congestion_window, max_congestion_window); -} - -} // namespace quic - -#endif // QUICHE_QUIC_PLATFORM_API_QUIC_PCC_SENDER_H_ diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_reference_counted_test.cc b/chromium/net/third_party/quiche/src/quic/platform/api/quic_reference_counted_test.cc index a1932ed55d2..e2ea9816dee 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_reference_counted_test.cc +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_reference_counted_test.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/platform/api/quic_reference_counted.h" +#include "quic/platform/api/quic_reference_counted.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_sleep.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_sleep.h index 12c20df536c..8067d458330 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_sleep.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_sleep.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_PLATFORM_API_QUIC_SLEEP_H_ #define QUICHE_QUIC_PLATFORM_API_QUIC_SLEEP_H_ -#include "net/third_party/quiche/src/quic/core/quic_time.h" +#include "quic/core/quic_time.h" #include "net/quic/platform/impl/quic_sleep_impl.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_socket_address.cc b/chromium/net/third_party/quiche/src/quic/platform/api/quic_socket_address.cc index ee3c3beb57e..38179e9fcf6 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_socket_address.cc +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_socket_address.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_socket_address.h" #include <cstring> #include <limits> #include <string> -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address_family.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_cat.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_ip_address_family.h" namespace quic { @@ -70,9 +70,9 @@ bool QuicSocketAddress::IsInitialized() const { std::string QuicSocketAddress::ToString() const { switch (host_.address_family()) { case IpAddressFamily::IP_V4: - return quiche::QuicheStrCat(host_.ToString(), ":", port_); + return absl::StrCat(host_.ToString(), ":", port_); case IpAddressFamily::IP_V6: - return quiche::QuicheStrCat("[", host_.ToString(), "]:", port_); + return absl::StrCat("[", host_.ToString(), "]:", port_); default: return ""; } diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_socket_address.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_socket_address.h index c91b1f205ea..0831985e6a4 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_socket_address.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_socket_address.h @@ -7,8 +7,8 @@ #include <string> -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_ip_address.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_socket_address_test.cc b/chromium/net/third_party/quiche/src/quic/platform/api/quic_socket_address_test.cc index 3c7010d89a5..2282a8a5158 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_socket_address_test.cc +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_socket_address_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_socket_address.h" #include <memory> #include <sstream> -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_string_utils.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_string_utils.h deleted file mode 100644 index e069948902c..00000000000 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_string_utils.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef QUICHE_QUIC_PLATFORM_API_QUIC_STRING_UTILS_H_ -#define QUICHE_QUIC_PLATFORM_API_QUIC_STRING_UTILS_H_ - -#include <string> -#include <utility> - -#include "net/quic/platform/impl/quic_string_utils_impl.h" - -namespace quic { - -template <typename... Args> -inline void QuicStrAppend(std::string* output, const Args&... args) { - QuicStrAppendImpl(output, std::forward<const Args&>(args)...); -} - -} // namespace quic - -#endif // QUICHE_QUIC_PLATFORM_API_QUIC_STRING_UTILS_H_ diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_string_utils_test.cc b/chromium/net/third_party/quiche/src/quic/platform/api/quic_string_utils_test.cc deleted file mode 100644 index e23b6ff4697..00000000000 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_string_utils_test.cc +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "net/third_party/quiche/src/quic/platform/api/quic_string_utils.h" - -#include <cstdint> - -#include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" - -namespace quic { -namespace test { -namespace { - -TEST(QuicStringUtilsTest, QuicheStrCat) { - // No arguments. - EXPECT_EQ("", quiche::QuicheStrCat()); - - // Single string-like argument. - const char kFoo[] = "foo"; - const std::string string_foo(kFoo); - const absl::string_view stringpiece_foo(string_foo); - EXPECT_EQ("foo", quiche::QuicheStrCat(kFoo)); - EXPECT_EQ("foo", quiche::QuicheStrCat(string_foo)); - EXPECT_EQ("foo", quiche::QuicheStrCat(stringpiece_foo)); - - // Two string-like arguments. - const char kBar[] = "bar"; - const absl::string_view stringpiece_bar(kBar); - const std::string string_bar(kBar); - EXPECT_EQ("foobar", quiche::QuicheStrCat(kFoo, kBar)); - EXPECT_EQ("foobar", quiche::QuicheStrCat(kFoo, string_bar)); - EXPECT_EQ("foobar", quiche::QuicheStrCat(kFoo, stringpiece_bar)); - EXPECT_EQ("foobar", quiche::QuicheStrCat(string_foo, kBar)); - EXPECT_EQ("foobar", quiche::QuicheStrCat(string_foo, string_bar)); - EXPECT_EQ("foobar", quiche::QuicheStrCat(string_foo, stringpiece_bar)); - EXPECT_EQ("foobar", quiche::QuicheStrCat(stringpiece_foo, kBar)); - EXPECT_EQ("foobar", quiche::QuicheStrCat(stringpiece_foo, string_bar)); - EXPECT_EQ("foobar", quiche::QuicheStrCat(stringpiece_foo, stringpiece_bar)); - - // Many-many arguments. - EXPECT_EQ("foobarbazquxquuxquuzcorgegraultgarplywaldofredplughxyzzythud", - quiche::QuicheStrCat("foo", "bar", "baz", "qux", "quux", "quuz", - "corge", "grault", "garply", "waldo", "fred", - "plugh", "xyzzy", "thud")); - - // Numerical arguments. - const int16_t i = 1; - const uint64_t u = 8; - const double d = 3.1415; - - EXPECT_EQ("1 8", quiche::QuicheStrCat(i, " ", u)); - EXPECT_EQ("3.14151181", quiche::QuicheStrCat(d, i, i, u, i)); - EXPECT_EQ("i: 1, u: 8, d: 3.1415", - quiche::QuicheStrCat("i: ", i, ", u: ", u, ", d: ", d)); - - // Boolean arguments. - const bool t = true; - const bool f = false; - - EXPECT_EQ("1", quiche::QuicheStrCat(t)); - EXPECT_EQ("0", quiche::QuicheStrCat(f)); - EXPECT_EQ("0110", quiche::QuicheStrCat(f, t, t, f)); - - // Mixed string-like, numerical, and Boolean arguments. - EXPECT_EQ("foo1foo081bar3.14151", - quiche::QuicheStrCat(kFoo, i, string_foo, f, u, t, stringpiece_bar, - d, t)); - EXPECT_EQ("3.141511bar18bar13.14150", - quiche::QuicheStrCat(d, t, t, string_bar, i, u, kBar, t, d, f)); -} - -TEST(QuicStringUtilsTest, QuicStrAppend) { - // No arguments on empty string. - std::string output; - QuicStrAppend(&output); - EXPECT_TRUE(output.empty()); - - // Single string-like argument. - const char kFoo[] = "foo"; - const std::string string_foo(kFoo); - const absl::string_view stringpiece_foo(string_foo); - QuicStrAppend(&output, kFoo); - EXPECT_EQ("foo", output); - QuicStrAppend(&output, string_foo); - EXPECT_EQ("foofoo", output); - QuicStrAppend(&output, stringpiece_foo); - EXPECT_EQ("foofoofoo", output); - - // No arguments on non-empty string. - QuicStrAppend(&output); - EXPECT_EQ("foofoofoo", output); - - output.clear(); - - // Two string-like arguments. - const char kBar[] = "bar"; - const absl::string_view stringpiece_bar(kBar); - const std::string string_bar(kBar); - QuicStrAppend(&output, kFoo, kBar); - EXPECT_EQ("foobar", output); - QuicStrAppend(&output, kFoo, string_bar); - EXPECT_EQ("foobarfoobar", output); - QuicStrAppend(&output, kFoo, stringpiece_bar); - EXPECT_EQ("foobarfoobarfoobar", output); - QuicStrAppend(&output, string_foo, kBar); - EXPECT_EQ("foobarfoobarfoobarfoobar", output); - - output.clear(); - - QuicStrAppend(&output, string_foo, string_bar); - EXPECT_EQ("foobar", output); - QuicStrAppend(&output, string_foo, stringpiece_bar); - EXPECT_EQ("foobarfoobar", output); - QuicStrAppend(&output, stringpiece_foo, kBar); - EXPECT_EQ("foobarfoobarfoobar", output); - QuicStrAppend(&output, stringpiece_foo, string_bar); - EXPECT_EQ("foobarfoobarfoobarfoobar", output); - - output.clear(); - - QuicStrAppend(&output, stringpiece_foo, stringpiece_bar); - EXPECT_EQ("foobar", output); - - // Many-many arguments. - QuicStrAppend(&output, "foo", "bar", "baz", "qux", "quux", "quuz", "corge", - "grault", "garply", "waldo", "fred", "plugh", "xyzzy", "thud"); - EXPECT_EQ( - "foobarfoobarbazquxquuxquuzcorgegraultgarplywaldofredplughxyzzythud", - output); - - output.clear(); - - // Numerical arguments. - const int16_t i = 1; - const uint64_t u = 8; - const double d = 3.1415; - - QuicStrAppend(&output, i, " ", u); - EXPECT_EQ("1 8", output); - QuicStrAppend(&output, d, i, i, u, i); - EXPECT_EQ("1 83.14151181", output); - QuicStrAppend(&output, "i: ", i, ", u: ", u, ", d: ", d); - EXPECT_EQ("1 83.14151181i: 1, u: 8, d: 3.1415", output); - - output.clear(); - - // Boolean arguments. - const bool t = true; - const bool f = false; - - QuicStrAppend(&output, t); - EXPECT_EQ("1", output); - QuicStrAppend(&output, f); - EXPECT_EQ("10", output); - QuicStrAppend(&output, f, t, t, f); - EXPECT_EQ("100110", output); - - output.clear(); - - // Mixed string-like, numerical, and Boolean arguments. - QuicStrAppend(&output, kFoo, i, string_foo, f, u, t, stringpiece_bar, d, t); - EXPECT_EQ("foo1foo081bar3.14151", output); - QuicStrAppend(&output, d, t, t, string_bar, i, u, kBar, t, d, f); - EXPECT_EQ("foo1foo081bar3.141513.141511bar18bar13.14150", output); -} - -TEST(QuicStringUtilsTest, QuicStringPrintf) { - EXPECT_EQ("", quiche::QuicheStringPrintf("%s", "")); - EXPECT_EQ("foobar", quiche::QuicheStringPrintf("%sbar", "foo")); - EXPECT_EQ("foobar", quiche::QuicheStringPrintf("%s%s", "foo", "bar")); - EXPECT_EQ("foo: 1, bar: 2.0", - quiche::QuicheStringPrintf("foo: %d, bar: %.1f", 1, 2.0)); -} - -} // namespace -} // namespace test -} // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_test.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_test.h index ffd9bb0571c..69995c35ff8 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_test.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_test.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_PLATFORM_API_QUIC_TEST_H_ #define QUICHE_QUIC_PLATFORM_API_QUIC_TEST_H_ -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_logging.h" #include "net/quic/platform/impl/quic_test_impl.h" using QuicFlagSaver = QuicFlagSaverImpl; diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_test_loopback.cc b/chromium/net/third_party/quiche/src/quic/platform/api/quic_test_loopback.cc index febcf3731de..070a68fa436 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_test_loopback.cc +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_test_loopback.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/platform/api/quic_test_loopback.h" +#include "quic/platform/api/quic_test_loopback.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_test_mem_slice_vector.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_test_mem_slice_vector.h index 734db63684b..17d5853523c 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_test_mem_slice_vector.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_test_mem_slice_vector.h @@ -7,7 +7,7 @@ #include <utility> -#include "net/third_party/quiche/src/quic/platform/api/quic_mem_slice_span.h" +#include "quic/platform/api/quic_mem_slice_span.h" #include "net/quic/platform/impl/quic_test_mem_slice_vector_impl.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_testvalue.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_testvalue.h index 96ce96864a2..58bc4f4544c 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_testvalue.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_testvalue.h @@ -6,7 +6,9 @@ #define QUICHE_QUIC_PLATFORM_API_QUIC_TESTVALUE_H_ #include "absl/strings/string_view.h" -#include "net/quic/platform/impl/quic_testvalue_impl.h" + +// TODO(b/178613777): move into the common QUICHE platform. +#include "quiche_platform_impl/quic_testvalue_impl.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/platform/api/quic_thread.h b/chromium/net/third_party/quiche/src/quic/platform/api/quic_thread.h index 4b1e5642c58..e18263284c0 100644 --- a/chromium/net/third_party/quiche/src/quic/platform/api/quic_thread.h +++ b/chromium/net/third_party/quiche/src/quic/platform/api/quic_thread.h @@ -7,7 +7,7 @@ #include <string> -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" #include "net/quic/platform/impl/quic_thread_impl.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable.cc b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable.cc index a16b2fa61ca..b5d9c47f3b8 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable.h" +#include "quic/qbone/bonnet/icmp_reachable.h" #include <netinet/ip6.h> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_mutex.h" -#include "net/third_party/quiche/src/quic/qbone/platform/icmp_packet.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_mutex.h" +#include "quic/qbone/platform/icmp_packet.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/quiche_endian.h" namespace quic { namespace { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable.h b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable.h index a3bc0900ead..7faf873f87a 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable.h @@ -8,10 +8,10 @@ #include <netinet/icmp6.h> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_mutex.h" -#include "net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable_interface.h" -#include "net/third_party/quiche/src/quic/qbone/platform/kernel_interface.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_mutex.h" +#include "quic/qbone/bonnet/icmp_reachable_interface.h" +#include "quic/qbone/platform/kernel_interface.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable_interface.h b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable_interface.h index e766a89ba3f..f082bb67f58 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable_interface.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable_interface.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_QBONE_BONNET_ICMP_REACHABLE_INTERFACE_H_ #define QUICHE_QUIC_QBONE_BONNET_ICMP_REACHABLE_INTERFACE_H_ -#include "net/third_party/quiche/src/quic/platform/api/quic_epoll.h" +#include "quic/platform/api/quic_epoll.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable_test.cc b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable_test.cc index fdadeff1ce3..221e5f665d5 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable_test.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable_test.cc @@ -2,15 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable.h" +#include "quic/qbone/bonnet/icmp_reachable.h" #include <netinet/ip6.h> -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_epoll.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/qbone/platform/mock_kernel.h" +#include "absl/container/node_hash_map.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_epoll.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/qbone/platform/mock_kernel.h" namespace quic { namespace { @@ -27,7 +28,7 @@ constexpr char kDestinationAddress[] = "fe80:4:3:2:1::1"; constexpr int kFakeWriteFd = 0; icmp6_hdr GetHeaderFromPacket(const void* buf, size_t len) { - CHECK_GE(len, sizeof(ip6_hdr) + sizeof(icmp6_hdr)); + QUICHE_CHECK_GE(len, sizeof(ip6_hdr) + sizeof(icmp6_hdr)); auto* buffer = reinterpret_cast<const char*>(buf); return *reinterpret_cast<const icmp6_hdr*>(&buffer[sizeof(ip6_hdr)]); @@ -73,18 +74,18 @@ class StatsInterface : public IcmpReachable::StatsInterface { std::string current_source_{}; - QuicUnorderedMap<int, int> read_errors_; - QuicUnorderedMap<int, int> write_errors_; + absl::node_hash_map<int, int> read_errors_; + absl::node_hash_map<int, int> write_errors_; }; class IcmpReachableTest : public QuicTest { public: IcmpReachableTest() { - CHECK(source_.FromString(kSourceAddress)); - CHECK(destination_.FromString(kDestinationAddress)); + QUICHE_CHECK(source_.FromString(kSourceAddress)); + QUICHE_CHECK(destination_.FromString(kDestinationAddress)); int pipe_fds[2]; - CHECK(pipe(pipe_fds) >= 0) << "pipe() failed"; + QUICHE_CHECK(pipe(pipe_fds) >= 0) << "pipe() failed"; read_fd_ = pipe_fds[0]; read_src_fd_ = pipe_fds[1]; diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/mock_icmp_reachable.h b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/mock_icmp_reachable.h index b717a604a7f..02f364c1376 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/mock_icmp_reachable.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/mock_icmp_reachable.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_QBONE_BONNET_MOCK_ICMP_REACHABLE_H_ #define QUICHE_QUIC_QBONE_BONNET_MOCK_ICMP_REACHABLE_H_ -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/qbone/bonnet/icmp_reachable_interface.h" +#include "quic/platform/api/quic_test.h" +#include "quic/qbone/bonnet/icmp_reachable_interface.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/mock_packet_exchanger_stats_interface.h b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/mock_packet_exchanger_stats_interface.h index f1f8e87cad3..c38f24de4c1 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/mock_packet_exchanger_stats_interface.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/mock_packet_exchanger_stats_interface.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_QBONE_BONNET_MOCK_PACKET_EXCHANGER_STATS_INTERFACE_H_ #define QUICHE_QUIC_QBONE_BONNET_MOCK_PACKET_EXCHANGER_STATS_INTERFACE_H_ -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/qbone/bonnet/tun_device_packet_exchanger.h" +#include "quic/platform/api/quic_test.h" +#include "quic/qbone/bonnet/tun_device_packet_exchanger.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/mock_qbone_tunnel.h b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/mock_qbone_tunnel.h new file mode 100644 index 00000000000..9fc74349e6d --- /dev/null +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/mock_qbone_tunnel.h @@ -0,0 +1,43 @@ +// Copyright (c) 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef QUICHE_QUIC_QBONE_BONNET_MOCK_QBONE_TUNNEL_H_ +#define QUICHE_QUIC_QBONE_BONNET_MOCK_QBONE_TUNNEL_H_ + +#include "quic/platform/api/quic_test.h" +#include "quic/qbone/bonnet/qbone_tunnel_interface.h" + +namespace quic { + +class MockQboneTunnel : public QboneTunnelInterface { + public: + MockQboneTunnel() = default; + + MOCK_METHOD(bool, WaitForEvents, (), (override)); + + MOCK_METHOD(void, Wake, (), (override)); + + MOCK_METHOD(void, ResetTunnel, (), (override)); + + MOCK_METHOD(State, Disconnect, (), (override)); + + MOCK_METHOD(void, OnControlRequest, (const quic::QboneClientRequest&), + (override)); + + MOCK_METHOD(void, OnControlError, (), (override)); + + MOCK_METHOD(bool, AwaitConnection, ()); + + MOCK_METHOD(std::string, StateToString, (State), (override)); + + MOCK_METHOD(quic::QboneClient*, client, (), (override)); + + MOCK_METHOD(State, state, ()); + + MOCK_METHOD(std::string, HealthString, ()); +}; + +} // namespace quic + +#endif // QUICHE_QUIC_QBONE_BONNET_MOCK_QBONE_TUNNEL_H_ diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/mock_tun_device.h b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/mock_tun_device.h index 14879de24cc..d593913d3ae 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/mock_tun_device.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/mock_tun_device.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_QBONE_BONNET_MOCK_TUN_DEVICE_H_ #define QUICHE_QUIC_QBONE_BONNET_MOCK_TUN_DEVICE_H_ -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/qbone/bonnet/tun_device_interface.h" +#include "quic/platform/api/quic_test.h" +#include "quic/qbone/bonnet/tun_device_interface.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/mock_tun_device_controller.h b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/mock_tun_device_controller.h new file mode 100644 index 00000000000..7773111b18c --- /dev/null +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/mock_tun_device_controller.h @@ -0,0 +1,27 @@ +// Copyright (c) 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef QUICHE_QUIC_QBONE_BONNET_MOCK_TUN_DEVICE_CONTROLLER_H_ +#define QUICHE_QUIC_QBONE_BONNET_MOCK_TUN_DEVICE_CONTROLLER_H_ + +#include "quic/platform/api/quic_test.h" +#include "quic/qbone/bonnet/tun_device_controller.h" + +namespace quic { + +class MockTunDeviceController : public TunDeviceController { + public: + MockTunDeviceController() : TunDeviceController("", true, nullptr) {} + + MOCK_METHOD(bool, UpdateAddress, (const IpRange&), (override)); + + MOCK_METHOD(bool, UpdateRoutes, (const IpRange&, const std::vector<IpRange>&), + (override)); + + MOCK_METHOD(QuicIpAddress, current_address, (), (override)); +}; + +} // namespace quic + +#endif // QUICHE_QUIC_QBONE_BONNET_MOCK_TUN_DEVICE_CONTROLLER_H_ diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/qbone_tunnel_interface.h b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/qbone_tunnel_interface.h new file mode 100644 index 00000000000..ae19519cd9a --- /dev/null +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/qbone_tunnel_interface.h @@ -0,0 +1,68 @@ +// Copyright (c) 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef QUICHE_QUIC_QBONE_BONNET_QBONE_TUNNEL_INTERFACE_H_ +#define QUICHE_QUIC_QBONE_BONNET_QBONE_TUNNEL_INTERFACE_H_ + +#include "quic/qbone/qbone_client.h" + +namespace quic { + +// Interface for establishing bidirectional communication between a network +// device and a QboneClient. +class QboneTunnelInterface : public quic::QboneClientControlStream::Handler { + public: + QboneTunnelInterface() = default; + + QboneTunnelInterface(const QboneTunnelInterface&) = delete; + QboneTunnelInterface& operator=(const QboneTunnelInterface&) = delete; + + QboneTunnelInterface(QboneTunnelInterface&&) = delete; + QboneTunnelInterface& operator=(QboneTunnelInterface&&) = delete; + + enum State { + UNINITIALIZED, + IP_RANGE_REQUESTED, + START_REQUESTED, + STARTED, + LAME_DUCK_REQUESTED, + END_REQUESTED, + ENDED, + FAILED, + }; + + // Wait and handle any events which occur. + // Returns true if there are any outstanding requests. + virtual bool WaitForEvents() = 0; + + // Wakes the tunnel if it is currently in WaitForEvents. + virtual void Wake() = 0; + + // Disconnect the tunnel, resetting it to an uninitialized state. This will + // force ConnectIfNeeded to reconnect on the next epoll cycle. + virtual void ResetTunnel() = 0; + + // Disconnect from the QBONE server. + virtual State Disconnect() = 0; + + // Callback handling responses from the QBONE server. + void OnControlRequest(const QboneClientRequest& request) override = 0; + + // Callback handling bad responses from the QBONE server. Currently, this is + // only called when the response is unparsable. + void OnControlError() override = 0; + + // Returns a string value of the given state. + virtual std::string StateToString(State state) = 0; + + virtual QboneClient* client() = 0; + + virtual State state() = 0; + + virtual std::string HealthString() = 0; +}; + +} // namespace quic + +#endif // QUICHE_QUIC_QBONE_BONNET_QBONE_TUNNEL_INTERFACE_H_ diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/qbone_tunnel_silo.cc b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/qbone_tunnel_silo.cc new file mode 100644 index 00000000000..736829ad0b5 --- /dev/null +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/qbone_tunnel_silo.cc @@ -0,0 +1,31 @@ +// Copyright (c) 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "quic/qbone/bonnet/qbone_tunnel_silo.h" + +namespace quic { + +void QboneTunnelSilo::Run() { + while (ShouldRun()) { + tunnel_->WaitForEvents(); + } + + QUIC_LOG(INFO) << "Tunnel has disconnected in state: " + << tunnel_->StateToString(tunnel_->Disconnect()); +} + +void QboneTunnelSilo::Quit() { + QUIC_LOG(INFO) << "Quit called on QboneTunnelSilo"; + quitting_.Notify(); + tunnel_->Wake(); +} + +bool QboneTunnelSilo::ShouldRun() { + bool post_init_shutdown_ready = + only_setup_tun_ && + tunnel_->state() == quic::QboneTunnelInterface::STARTED; + return !quitting_.HasBeenNotified() && !post_init_shutdown_ready; +} + +} // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/qbone_tunnel_silo.h b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/qbone_tunnel_silo.h new file mode 100644 index 00000000000..cf8ce38f131 --- /dev/null +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/qbone_tunnel_silo.h @@ -0,0 +1,48 @@ +// Copyright (c) 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef QUICHE_QUIC_QBONE_BONNET_QBONE_TUNNEL_SILO_H_ +#define QUICHE_QUIC_QBONE_BONNET_QBONE_TUNNEL_SILO_H_ + +#include "absl/synchronization/notification.h" +#include "quic/platform/api/quic_thread.h" +#include "quic/qbone/bonnet/qbone_tunnel_interface.h" + +namespace quic { + +// QboneTunnelSilo is a thread that initializes and evaluates a QboneTunnel's +// event loop. +class QboneTunnelSilo : public QuicThread { + public: + // Does not take ownership of |tunnel| + explicit QboneTunnelSilo(QboneTunnelInterface* tunnel, bool only_setup_tun) + : QuicThread("QboneTunnelSilo"), + tunnel_(tunnel), + only_setup_tun_(only_setup_tun) {} + + QboneTunnelSilo(const QboneTunnelSilo&) = delete; + QboneTunnelSilo& operator=(const QboneTunnelSilo&) = delete; + + QboneTunnelSilo(QboneTunnelSilo&&) = delete; + QboneTunnelSilo& operator=(QboneTunnelSilo&&) = delete; + + // Terminates the tunnel's event loop. This silo must still be joined. + void Quit(); + + protected: + void Run() override; + + private: + bool ShouldRun(); + + QboneTunnelInterface* tunnel_; + + absl::Notification quitting_; + + const bool only_setup_tun_; +}; + +} // namespace quic + +#endif // QUICHE_QUIC_QBONE_BONNET_QBONE_TUNNEL_SILO_H_ diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/qbone_tunnel_silo_test.cc b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/qbone_tunnel_silo_test.cc new file mode 100644 index 00000000000..8327a53eacc --- /dev/null +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/qbone_tunnel_silo_test.cc @@ -0,0 +1,78 @@ +// Copyright (c) 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "quic/qbone/bonnet/qbone_tunnel_silo.h" + +#include "absl/synchronization/notification.h" +#include "quic/platform/api/quic_test.h" +#include "quic/qbone/bonnet/mock_qbone_tunnel.h" + +namespace quic { +namespace { + +using ::testing::Eq; +using ::testing::Invoke; +using ::testing::Return; + +TEST(QboneTunnelSiloTest, SiloRunsEventLoop) { + MockQboneTunnel mock_tunnel; + + absl::Notification event_loop_run; + EXPECT_CALL(mock_tunnel, WaitForEvents) + .WillRepeatedly(Invoke([&event_loop_run]() { + if (!event_loop_run.HasBeenNotified()) { + event_loop_run.Notify(); + } + return false; + })); + + QboneTunnelSilo silo(&mock_tunnel, false); + silo.Start(); + + event_loop_run.WaitForNotification(); + + absl::Notification client_disconnected; + EXPECT_CALL(mock_tunnel, Disconnect) + .WillOnce(Invoke([&client_disconnected]() { + client_disconnected.Notify(); + return QboneTunnelInterface::ENDED; + })); + + silo.Quit(); + client_disconnected.WaitForNotification(); + + silo.Join(); +} + +TEST(QboneTunnelSiloTest, SiloCanShutDownAfterInit) { + MockQboneTunnel mock_tunnel; + + int iteration_count = 0; + EXPECT_CALL(mock_tunnel, WaitForEvents) + .WillRepeatedly(Invoke([&iteration_count]() { + iteration_count++; + return false; + })); + + EXPECT_CALL(mock_tunnel, state) + .WillOnce(Return(QboneTunnelInterface::START_REQUESTED)) + .WillOnce(Return(QboneTunnelInterface::STARTED)); + + absl::Notification client_disconnected; + EXPECT_CALL(mock_tunnel, Disconnect) + .WillOnce(Invoke([&client_disconnected]() { + client_disconnected.Notify(); + return QboneTunnelInterface::ENDED; + })); + + QboneTunnelSilo silo(&mock_tunnel, true); + silo.Start(); + + client_disconnected.WaitForNotification(); + silo.Join(); + EXPECT_THAT(iteration_count, Eq(1)); +} + +} // namespace +} // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device.cc b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device.cc index c64e5b9e61f..3ee066a1b7b 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/bonnet/tun_device.h" +#include "quic/qbone/bonnet/tun_device.h" #include <fcntl.h> #include <linux/if_tun.h> @@ -10,9 +10,9 @@ #include <sys/ioctl.h> #include <sys/socket.h> -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/qbone/platform/kernel_interface.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/qbone/platform/kernel_interface.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device.h b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device.h index 9f76fa60796..bff85f5943a 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device.h @@ -8,8 +8,8 @@ #include <string> #include <vector> -#include "net/third_party/quiche/src/quic/qbone/bonnet/tun_device_interface.h" -#include "net/third_party/quiche/src/quic/qbone/platform/kernel_interface.h" +#include "quic/qbone/bonnet/tun_device_interface.h" +#include "quic/qbone/platform/kernel_interface.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_controller.cc b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_controller.cc new file mode 100644 index 00000000000..c8a6517a4c3 --- /dev/null +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_controller.cc @@ -0,0 +1,151 @@ +// Copyright (c) 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "quic/qbone/bonnet/tun_device_controller.h" + +#include <linux/rtnetlink.h> + +#include "absl/time/clock.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/qbone/qbone_constants.h" + +ABSL_FLAG(bool, qbone_tun_device_replace_default_routing_rules, true, + "If true, will define a rule that points packets sourced from the " + "qbone interface to the qbone table. This is unnecessary in " + "environments with no other ipv6 route."); + +namespace quic { + +bool TunDeviceController::UpdateAddress(const IpRange& desired_range) { + if (!setup_tun_) { + return true; + } + + NetlinkInterface::LinkInfo link_info{}; + if (!netlink_->GetLinkInfo(ifname_, &link_info)) { + return false; + } + + std::vector<NetlinkInterface::AddressInfo> addresses; + if (!netlink_->GetAddresses(link_info.index, 0, &addresses, nullptr)) { + return false; + } + + QuicIpAddress desired_address = desired_range.FirstAddressInRange(); + + for (const auto& address : addresses) { + if (!netlink_->ChangeLocalAddress( + link_info.index, NetlinkInterface::Verb::kRemove, + address.interface_address, address.prefix_length, 0, 0, {})) { + return false; + } + } + + bool address_updated = netlink_->ChangeLocalAddress( + link_info.index, NetlinkInterface::Verb::kAdd, desired_address, + desired_range.prefix_length(), IFA_F_PERMANENT | IFA_F_NODAD, + RT_SCOPE_LINK, {}); + + if (address_updated) { + current_address_ = desired_address; + } + + return address_updated; +} + +bool TunDeviceController::UpdateRoutes( + const IpRange& desired_range, + const std::vector<IpRange>& desired_routes) { + if (!setup_tun_) { + return true; + } + + NetlinkInterface::LinkInfo link_info{}; + if (!netlink_->GetLinkInfo(ifname_, &link_info)) { + QUIC_LOG(ERROR) << "Could not get link info for interface <" << ifname_ + << ">"; + return false; + } + + std::vector<NetlinkInterface::RoutingRule> routing_rules; + if (!netlink_->GetRouteInfo(&routing_rules)) { + QUIC_LOG(ERROR) << "Unable to get route info"; + return false; + } + + for (const auto& rule : routing_rules) { + if (rule.out_interface == link_info.index && + rule.table == QboneConstants::kQboneRouteTableId) { + if (!netlink_->ChangeRoute(NetlinkInterface::Verb::kRemove, + rule.table, rule.destination_subnet, + rule.scope, rule.preferred_source, + rule.out_interface)) { + QUIC_LOG(ERROR) << "Unable to remove old route to <" + << rule.destination_subnet.ToString() << ">"; + return false; + } + } + } + + if (!UpdateRules(desired_range)) { + return false; + } + + QuicIpAddress desired_address = desired_range.FirstAddressInRange(); + + std::vector<IpRange> routes(desired_routes.begin(), desired_routes.end()); + routes.emplace_back(*QboneConstants::TerminatorLocalAddressRange()); + + for (const auto& route : routes) { + if (!netlink_->ChangeRoute(NetlinkInterface::Verb::kReplace, + QboneConstants::kQboneRouteTableId, route, + RT_SCOPE_LINK, desired_address, + link_info.index)) { + QUIC_LOG(ERROR) << "Unable to add route <" << route.ToString() << ">"; + return false; + } + } + + return true; +} + +bool TunDeviceController::UpdateRules(IpRange desired_range) { + if (!absl::GetFlag(FLAGS_qbone_tun_device_replace_default_routing_rules)) { + return true; + } + + std::vector<NetlinkInterface::IpRule> ip_rules; + if (!netlink_->GetRuleInfo(&ip_rules)) { + QUIC_LOG(ERROR) << "Unable to get rule info"; + return false; + } + + for (const auto& rule : ip_rules) { + if (rule.table == QboneConstants::kQboneRouteTableId) { + if (!netlink_->ChangeRule(NetlinkInterface::Verb::kRemove, + rule.table, rule.source_range)) { + QUIC_LOG(ERROR) << "Unable to remove old rule for table <" << rule.table + << "> from source <" << rule.source_range.ToString() + << ">"; + return false; + } + } + } + + if (!netlink_->ChangeRule(NetlinkInterface::Verb::kAdd, + QboneConstants::kQboneRouteTableId, + desired_range)) { + QUIC_LOG(ERROR) << "Unable to add rule for <" << desired_range.ToString() + << ">"; + return false; + } + + return true; +} + +QuicIpAddress TunDeviceController::current_address() { + return current_address_; +} + +} // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_controller.h b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_controller.h new file mode 100644 index 00000000000..6854521014f --- /dev/null +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_controller.h @@ -0,0 +1,58 @@ +// Copyright (c) 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef QUICHE_QUIC_QBONE_BONNET_TUN_DEVICE_CONTROLLER_H_ +#define QUICHE_QUIC_QBONE_BONNET_TUN_DEVICE_CONTROLLER_H_ + +#include "quic/qbone/bonnet/tun_device.h" +#include "quic/qbone/platform/netlink_interface.h" +#include "quic/qbone/qbone_control.pb.h" +#include "quic/qbone/qbone_control_stream.h" + +namespace quic { + +// TunDeviceController consumes control stream messages from a Qbone server +// and applies the given updates to the TUN device. +class TunDeviceController { + public: + // |ifname| is the interface name of the TUN device to be managed. This does + // not take ownership of |netlink|. + TunDeviceController(std::string ifname, bool setup_tun, + NetlinkInterface* netlink) + : ifname_(std::move(ifname)), setup_tun_(setup_tun), netlink_(netlink) {} + + TunDeviceController(const TunDeviceController&) = delete; + TunDeviceController& operator=(const TunDeviceController&) = delete; + + TunDeviceController(TunDeviceController&&) = delete; + TunDeviceController& operator=(TunDeviceController&&) = delete; + + virtual ~TunDeviceController() = default; + + // Updates the local address of the TUN device to be the first address in the + // given |response.ip_range()|. + virtual bool UpdateAddress(const IpRange& desired_range); + + // Updates the set of routes that the TUN device will provide. All current + // routes for the tunnel that do not exist in the |response| will be removed. + virtual bool UpdateRoutes(const IpRange& desired_range, + const std::vector<IpRange>& desired_routes); + + virtual QuicIpAddress current_address(); + + private: + // Update the IP Rules, this should only be used by UpdateRoutes. + bool UpdateRules(IpRange desired_range); + + const std::string ifname_; + const bool setup_tun_; + + NetlinkInterface* netlink_; + + QuicIpAddress current_address_; +}; + +} // namespace quic + +#endif // QUICHE_QUIC_QBONE_BONNET_TUN_DEVICE_CONTROLLER_H_ diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_controller_test.cc b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_controller_test.cc new file mode 100644 index 00000000000..73a7abc2864 --- /dev/null +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_controller_test.cc @@ -0,0 +1,257 @@ +// Copyright (c) 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "quic/qbone/bonnet/tun_device_controller.h" + +#include <linux/if_addr.h> +#include <linux/rtnetlink.h> + +#include "absl/strings/string_view.h" +#include "quic/platform/api/quic_test.h" +#include "quic/qbone/platform/mock_netlink.h" +#include "quic/qbone/qbone_constants.h" + +ABSL_DECLARE_FLAG(bool, qbone_tun_device_replace_default_routing_rules); + +namespace quic { +namespace { +using ::testing::Eq; + +constexpr int kIfindex = 42; +constexpr char kIfname[] = "qbone0"; + +const IpRange kIpRange = []() { + IpRange range; + QCHECK(range.FromString("2604:31c0:2::/64")); + return range; +}(); + +constexpr char kOldAddress[] = "1.2.3.4"; +constexpr int kOldPrefixLen = 24; + +using ::testing::_; +using ::testing::Invoke; +using ::testing::Return; +using ::testing::StrictMock; + +MATCHER_P(IpRangeEq, range, + absl::StrCat("expected IpRange to equal ", range.ToString())) { + return arg == range; +} + +class TunDeviceControllerTest : public QuicTest { + public: + TunDeviceControllerTest() + : controller_(kIfname, true, &netlink_), + link_local_range_( + *QboneConstants::TerminatorLocalAddressRange()) {} + + protected: + void ExpectLinkInfo(const std::string& interface_name, int ifindex) { + EXPECT_CALL(netlink_, GetLinkInfo(interface_name, _)) + .WillOnce( + Invoke([ifindex](absl::string_view ifname, + NetlinkInterface::LinkInfo* link_info) { + link_info->index = ifindex; + return true; + })); + } + + MockNetlink netlink_; + TunDeviceController controller_; + + IpRange link_local_range_; +}; + +TEST_F(TunDeviceControllerTest, AddressAppliedWhenNoneExisted) { + ExpectLinkInfo(kIfname, kIfindex); + + EXPECT_CALL(netlink_, GetAddresses(kIfindex, _, _, _)).WillOnce(Return(true)); + + EXPECT_CALL(netlink_, + ChangeLocalAddress( + kIfindex, NetlinkInterface::Verb::kAdd, + kIpRange.FirstAddressInRange(), kIpRange.prefix_length(), + IFA_F_PERMANENT | IFA_F_NODAD, RT_SCOPE_LINK, _)) + .WillOnce(Return(true)); + + EXPECT_TRUE(controller_.UpdateAddress(kIpRange)); +} + +TEST_F(TunDeviceControllerTest, OldAddressesAreRemoved) { + ExpectLinkInfo(kIfname, kIfindex); + + EXPECT_CALL(netlink_, GetAddresses(kIfindex, _, _, _)) + .WillOnce( + Invoke([](int interface_index, uint8_t unwanted_flags, + std::vector<NetlinkInterface::AddressInfo>* addresses, + int* num_ipv6_nodad_dadfailed_addresses) { + NetlinkInterface::AddressInfo info{}; + info.interface_address.FromString(kOldAddress); + info.prefix_length = kOldPrefixLen; + addresses->emplace_back(info); + return true; + })); + + QuicIpAddress old_address; + old_address.FromString(kOldAddress); + + EXPECT_CALL(netlink_, ChangeLocalAddress( + kIfindex, NetlinkInterface::Verb::kRemove, + old_address, kOldPrefixLen, _, _, _)) + .WillOnce(Return(true)); + + EXPECT_CALL(netlink_, + ChangeLocalAddress( + kIfindex, NetlinkInterface::Verb::kAdd, + kIpRange.FirstAddressInRange(), kIpRange.prefix_length(), + IFA_F_PERMANENT | IFA_F_NODAD, RT_SCOPE_LINK, _)) + .WillOnce(Return(true)); + + EXPECT_TRUE(controller_.UpdateAddress(kIpRange)); +} + +TEST_F(TunDeviceControllerTest, UpdateRoutesRemovedOldRoutes) { + ExpectLinkInfo(kIfname, kIfindex); + + const int num_matching_routes = 3; + EXPECT_CALL(netlink_, GetRouteInfo(_)) + .WillOnce(Invoke( + [](std::vector<NetlinkInterface::RoutingRule>* routing_rules) { + NetlinkInterface::RoutingRule non_matching_route; + non_matching_route.table = QboneConstants::kQboneRouteTableId; + non_matching_route.out_interface = kIfindex + 1; + routing_rules->push_back(non_matching_route); + + NetlinkInterface::RoutingRule matching_route; + matching_route.table = QboneConstants::kQboneRouteTableId; + matching_route.out_interface = kIfindex; + for (int i = 0; i < num_matching_routes; i++) { + routing_rules->push_back(matching_route); + } + + NetlinkInterface::RoutingRule non_matching_table; + non_matching_table.table = + QboneConstants::kQboneRouteTableId + 1; + non_matching_table.out_interface = kIfindex; + routing_rules->push_back(non_matching_table); + return true; + })); + + EXPECT_CALL(netlink_, ChangeRoute(NetlinkInterface::Verb::kRemove, + QboneConstants::kQboneRouteTableId, _, + _, _, kIfindex)) + .Times(num_matching_routes) + .WillRepeatedly(Return(true)); + + EXPECT_CALL(netlink_, GetRuleInfo(_)).WillOnce(Return(true)); + + EXPECT_CALL(netlink_, ChangeRule(NetlinkInterface::Verb::kAdd, + QboneConstants::kQboneRouteTableId, + IpRangeEq(kIpRange))) + .WillOnce(Return(true)); + + EXPECT_CALL(netlink_, + ChangeRoute(NetlinkInterface::Verb::kReplace, + QboneConstants::kQboneRouteTableId, + IpRangeEq(link_local_range_), _, _, kIfindex)) + .WillOnce(Return(true)); + + EXPECT_TRUE(controller_.UpdateRoutes(kIpRange, {})); +} + +TEST_F(TunDeviceControllerTest, UpdateRoutesAddsNewRoutes) { + ExpectLinkInfo(kIfname, kIfindex); + + EXPECT_CALL(netlink_, GetRouteInfo(_)).WillOnce(Return(true)); + + EXPECT_CALL(netlink_, GetRuleInfo(_)).WillOnce(Return(true)); + + EXPECT_CALL(netlink_, ChangeRoute(NetlinkInterface::Verb::kReplace, + QboneConstants::kQboneRouteTableId, + IpRangeEq(kIpRange), _, _, kIfindex)) + .Times(2) + .WillRepeatedly(Return(true)) + .RetiresOnSaturation(); + + EXPECT_CALL(netlink_, ChangeRule(NetlinkInterface::Verb::kAdd, + QboneConstants::kQboneRouteTableId, + IpRangeEq(kIpRange))) + .WillOnce(Return(true)); + + EXPECT_CALL(netlink_, + ChangeRoute(NetlinkInterface::Verb::kReplace, + QboneConstants::kQboneRouteTableId, + IpRangeEq(link_local_range_), _, _, kIfindex)) + .WillOnce(Return(true)); + + EXPECT_TRUE(controller_.UpdateRoutes(kIpRange, {kIpRange, kIpRange})); +} + +TEST_F(TunDeviceControllerTest, EmptyUpdateRouteKeepsLinkLocalRoute) { + ExpectLinkInfo(kIfname, kIfindex); + + EXPECT_CALL(netlink_, GetRouteInfo(_)).WillOnce(Return(true)); + + EXPECT_CALL(netlink_, GetRuleInfo(_)).WillOnce(Return(true)); + + EXPECT_CALL(netlink_, ChangeRule(NetlinkInterface::Verb::kAdd, + QboneConstants::kQboneRouteTableId, + IpRangeEq(kIpRange))) + .WillOnce(Return(true)); + + EXPECT_CALL(netlink_, + ChangeRoute(NetlinkInterface::Verb::kReplace, + QboneConstants::kQboneRouteTableId, + IpRangeEq(link_local_range_), _, _, kIfindex)) + .WillOnce(Return(true)); + + EXPECT_TRUE(controller_.UpdateRoutes(kIpRange, {})); +} + +TEST_F(TunDeviceControllerTest, DisablingRoutingRulesSkipsRuleCreation) { + absl::SetFlag(&FLAGS_qbone_tun_device_replace_default_routing_rules, false); + ExpectLinkInfo(kIfname, kIfindex); + + EXPECT_CALL(netlink_, GetRouteInfo(_)).WillOnce(Return(true)); + + EXPECT_CALL(netlink_, ChangeRoute(NetlinkInterface::Verb::kReplace, + QboneConstants::kQboneRouteTableId, + IpRangeEq(kIpRange), _, _, kIfindex)) + .Times(2) + .WillRepeatedly(Return(true)) + .RetiresOnSaturation(); + + EXPECT_CALL(netlink_, + ChangeRoute(NetlinkInterface::Verb::kReplace, + QboneConstants::kQboneRouteTableId, + IpRangeEq(link_local_range_), _, _, kIfindex)) + .WillOnce(Return(true)); + + EXPECT_TRUE(controller_.UpdateRoutes(kIpRange, {kIpRange, kIpRange})); +} + +class DisabledTunDeviceControllerTest : public QuicTest { + public: + DisabledTunDeviceControllerTest() + : controller_(kIfname, false, &netlink_), + link_local_range_( + *QboneConstants::TerminatorLocalAddressRange()) {} + + StrictMock<MockNetlink> netlink_; + TunDeviceController controller_; + + IpRange link_local_range_; +}; + +TEST_F(DisabledTunDeviceControllerTest, UpdateRoutesIsNop) { + EXPECT_THAT(controller_.UpdateRoutes(kIpRange, {}), Eq(true)); +} + +TEST_F(DisabledTunDeviceControllerTest, UpdateAddressIsNop) { + EXPECT_THAT(controller_.UpdateAddress(kIpRange), Eq(true)); +} + +} // namespace +} // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_packet_exchanger.cc b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_packet_exchanger.cc index 4e7c93b1fe7..21196716760 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_packet_exchanger.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_packet_exchanger.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/bonnet/tun_device_packet_exchanger.h" +#include "quic/qbone/bonnet/tun_device_packet_exchanger.h" #include <utility> -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_cat.h" namespace quic { @@ -29,8 +29,7 @@ bool TunDevicePacketExchanger::WritePacket(const char* packet, std::string* error) { *blocked = false; if (fd_ < 0) { - *error = quiche::QuicheStrCat("Invalid file descriptor of the TUN device: ", - fd_); + *error = absl::StrCat("Invalid file descriptor of the TUN device: ", fd_); stats_->OnWriteError(error); return false; } @@ -41,8 +40,7 @@ bool TunDevicePacketExchanger::WritePacket(const char* packet, // The tunnel is blocked. Note that this does not mean the receive buffer // of a TCP connection is filled. This simply means the TUN device itself // is blocked on handing packets to the rest part of the kernel. - *error = - quiche::QuicheStrCat("Write to the TUN device was blocked: ", errno); + *error = absl::StrCat("Write to the TUN device was blocked: ", errno); *blocked = true; stats_->OnWriteError(error); } @@ -58,8 +56,7 @@ std::unique_ptr<QuicData> TunDevicePacketExchanger::ReadPacket( std::string* error) { *blocked = false; if (fd_ < 0) { - *error = quiche::QuicheStrCat("Invalid file descriptor of the TUN device: ", - fd_); + *error = absl::StrCat("Invalid file descriptor of the TUN device: ", fd_); stats_->OnReadError(error); return nullptr; } @@ -71,8 +68,7 @@ std::unique_ptr<QuicData> TunDevicePacketExchanger::ReadPacket( // is no end of file. Therefore 0 also indicates error. if (result <= 0) { if (errno == EAGAIN || errno == EWOULDBLOCK) { - *error = - quiche::QuicheStrCat("Read from the TUN device was blocked: ", errno); + *error = absl::StrCat("Read from the TUN device was blocked: ", errno); *blocked = true; stats_->OnReadError(error); } diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_packet_exchanger.h b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_packet_exchanger.h index fe7c900c002..1d28fee1dbc 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_packet_exchanger.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_packet_exchanger.h @@ -5,10 +5,10 @@ #ifndef QUICHE_QUIC_QBONE_BONNET_TUN_DEVICE_PACKET_EXCHANGER_H_ #define QUICHE_QUIC_QBONE_BONNET_TUN_DEVICE_PACKET_EXCHANGER_H_ -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/qbone/platform/kernel_interface.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_client_interface.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_packet_exchanger.h" +#include "quic/core/quic_packets.h" +#include "quic/qbone/platform/kernel_interface.h" +#include "quic/qbone/qbone_client_interface.h" +#include "quic/qbone/qbone_packet_exchanger.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_packet_exchanger_test.cc b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_packet_exchanger_test.cc index f61407d8057..4a00c60eb78 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_packet_exchanger_test.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_packet_exchanger_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/bonnet/tun_device_packet_exchanger.h" +#include "quic/qbone/bonnet/tun_device_packet_exchanger.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/qbone/bonnet/mock_packet_exchanger_stats_interface.h" -#include "net/third_party/quiche/src/quic/qbone/mock_qbone_client.h" -#include "net/third_party/quiche/src/quic/qbone/platform/mock_kernel.h" +#include "quic/platform/api/quic_test.h" +#include "quic/qbone/bonnet/mock_packet_exchanger_stats_interface.h" +#include "quic/qbone/mock_qbone_client.h" +#include "quic/qbone/platform/mock_kernel.h" namespace quic { namespace { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_test.cc b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_test.cc index e44f499e707..9c216afe258 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_test.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/bonnet/tun_device_test.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/bonnet/tun_device.h" +#include "quic/qbone/bonnet/tun_device.h" #include <linux/if.h> #include <linux/if_tun.h> #include <sys/ioctl.h> -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/qbone/platform/mock_kernel.h" +#include "quic/platform/api/quic_test.h" +#include "quic/qbone/platform/mock_kernel.h" namespace quic { namespace { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/mock_qbone_client.h b/chromium/net/third_party/quiche/src/quic/qbone/mock_qbone_client.h index c5ec95bd2c7..3b84d556324 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/mock_qbone_client.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/mock_qbone_client.h @@ -6,8 +6,8 @@ #define QUICHE_QUIC_QBONE_MOCK_QBONE_CLIENT_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_client_interface.h" +#include "quic/platform/api/quic_test.h" +#include "quic/qbone/qbone_client_interface.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/mock_qbone_server_session.h b/chromium/net/third_party/quiche/src/quic/qbone/mock_qbone_server_session.h index d398ba57d6c..8d4f64eda24 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/mock_qbone_server_session.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/mock_qbone_server_session.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_QBONE_MOCK_QBONE_SERVER_SESSION_H_ #define QUICHE_QUIC_QBONE_MOCK_QBONE_SERVER_SESSION_H_ -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_server_session.h" +#include "quic/platform/api/quic_test.h" +#include "quic/qbone/qbone_server_session.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/icmp_packet.cc b/chromium/net/third_party/quiche/src/quic/qbone/platform/icmp_packet.cc index 68d15010675..50e3f2b6d78 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/icmp_packet.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/icmp_packet.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/platform/icmp_packet.h" +#include "quic/qbone/platform/icmp_packet.h" #include <netinet/ip6.h> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/qbone/platform/internet_checksum.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/qbone/platform/internet_checksum.h" +#include "common/quiche_endian.h" namespace quic { namespace { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/icmp_packet.h b/chromium/net/third_party/quiche/src/quic/qbone/platform/icmp_packet.h index ca3fc436832..f03f78b05bd 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/icmp_packet.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/icmp_packet.h @@ -11,7 +11,7 @@ #include <functional> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_ip_address.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/icmp_packet_test.cc b/chromium/net/third_party/quiche/src/quic/qbone/platform/icmp_packet_test.cc index 08623e1ce5d..857cada50a6 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/icmp_packet_test.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/icmp_packet_test.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/platform/icmp_packet.h" +#include "quic/qbone/platform/icmp_packet.h" #include <netinet/ip6.h> #include <cstdint> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/platform/api/quic_test.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { namespace { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/internet_checksum.cc b/chromium/net/third_party/quiche/src/quic/qbone/platform/internet_checksum.cc index b98c85767b4..3290764082a 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/internet_checksum.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/internet_checksum.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/platform/internet_checksum.h" +#include "quic/qbone/platform/internet_checksum.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/internet_checksum_test.cc b/chromium/net/third_party/quiche/src/quic/qbone/platform/internet_checksum_test.cc index a4736e2c183..7da04bdcbeb 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/internet_checksum_test.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/internet_checksum_test.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/platform/internet_checksum.h" +#include "quic/qbone/platform/internet_checksum.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/ip_range.cc b/chromium/net/third_party/quiche/src/quic/qbone/platform/ip_range.cc index cb9f4a1ab04..97df5cff052 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/ip_range.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/ip_range.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/platform/ip_range.h" +#include "quic/qbone/platform/ip_range.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "common/quiche_endian.h" namespace quic { @@ -94,7 +94,7 @@ bool IpRange::FromString(const std::string& range) { return true; } -QuicIpAddress IpRange::FirstAddressInRange() { +QuicIpAddress IpRange::FirstAddressInRange() const { return prefix(); } diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/ip_range.h b/chromium/net/third_party/quiche/src/quic/qbone/platform/ip_range.h index c9f1f34e6cf..e3df295967d 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/ip_range.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/ip_range.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_QBONE_PLATFORM_IP_RANGE_H_ #define QUICHE_QUIC_QBONE_PLATFORM_IP_RANGE_H_ -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_cat.h" +#include "quic/platform/api/quic_ip_address.h" namespace quic { @@ -29,7 +29,7 @@ class IpRange { // Returns the string representation of this object. std::string ToString() const { if (IsInitialized()) { - return quiche::QuicheStrCat(prefix_.ToString(), "/", prefix_length_); + return absl::StrCat(prefix_.ToString(), "/", prefix_length_); } return "(uninitialized)"; } @@ -39,7 +39,7 @@ class IpRange { // Returns the first available IP address in this IpRange. The resulting // address will be uninitialized if there is no available address. - QuicIpAddress FirstAddressInRange(); + QuicIpAddress FirstAddressInRange() const; // The address family of this IpRange. IpAddressFamily address_family() const { return prefix_.address_family(); } diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/ip_range_test.cc b/chromium/net/third_party/quiche/src/quic/qbone/platform/ip_range_test.cc index bac5c963af8..1e1b00117dc 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/ip_range_test.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/ip_range_test.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/platform/ip_range.h" +#include "quic/qbone/platform/ip_range.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/mock_kernel.h b/chromium/net/third_party/quiche/src/quic/qbone/platform/mock_kernel.h index e30bfa1bad9..f014b573347 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/mock_kernel.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/mock_kernel.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_QBONE_PLATFORM_MOCK_KERNEL_H_ #define QUICHE_QUIC_QBONE_PLATFORM_MOCK_KERNEL_H_ -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/qbone/platform/kernel_interface.h" +#include "quic/platform/api/quic_test.h" +#include "quic/qbone/platform/kernel_interface.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/mock_netlink.h b/chromium/net/third_party/quiche/src/quic/qbone/platform/mock_netlink.h index ea5d62e9f61..83077a0404f 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/mock_netlink.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/mock_netlink.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_QBONE_PLATFORM_MOCK_NETLINK_H_ #define QUICHE_QUIC_QBONE_PLATFORM_MOCK_NETLINK_H_ -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/qbone/platform/netlink_interface.h" +#include "quic/platform/api/quic_test.h" +#include "quic/qbone/platform/netlink_interface.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/netlink.cc b/chromium/net/third_party/quiche/src/quic/qbone/platform/netlink.cc index d19c28b5fda..52196239d13 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/netlink.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/netlink.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/platform/netlink.h" +#include "quic/qbone/platform/netlink.h" #include <linux/fib_rules.h> #include <utility> #include "absl/base/attributes.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "absl/strings/str_cat.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_logging.h" #include "net/quic/platform/impl/quic_ip_address_impl.h" -#include "net/third_party/quiche/src/quic/qbone/platform/rtnetlink_message.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "quic/qbone/platform/rtnetlink_message.h" namespace quic { @@ -80,7 +80,7 @@ class LinkInfoParser : public NetlinkParserInterface { void Run(struct nlmsghdr* netlink_message) override { if (netlink_message->nlmsg_type != RTM_NEWLINK) { - QUIC_LOG(INFO) << quiche::QuicheStrCat( + QUIC_LOG(INFO) << absl::StrCat( "Unexpected nlmsg_type: ", netlink_message->nlmsg_type, " expected: ", RTM_NEWLINK); return; @@ -91,7 +91,7 @@ class LinkInfoParser : public NetlinkParserInterface { // make sure interface_info is what we asked for. if (interface_info->ifi_family != AF_UNSPEC) { - QUIC_LOG(INFO) << quiche::QuicheStrCat( + QUIC_LOG(INFO) << absl::StrCat( "Unexpected ifi_family: ", interface_info->ifi_family, " expected: ", AF_UNSPEC); return; @@ -221,8 +221,8 @@ class LocalAddressParser : public NetlinkParserInterface { // Make sure this is for an address family we're interested in. if (interface_address->ifa_family != AF_INET && interface_address->ifa_family != AF_INET6) { - QUIC_VLOG(2) << quiche::QuicheStrCat("uninteresting ifa family: ", - interface_address->ifa_family); + QUIC_VLOG(2) << absl::StrCat("uninteresting ifa family: ", + interface_address->ifa_family); return; } @@ -236,8 +236,7 @@ class LocalAddressParser : public NetlinkParserInterface { uint8_t unwanted_flags = interface_address->ifa_flags & unwanted_flags_; if (unwanted_flags != 0) { - QUIC_VLOG(2) << quiche::QuicheStrCat("unwanted ifa flags: ", - unwanted_flags); + QUIC_VLOG(2) << absl::StrCat("unwanted ifa flags: ", unwanted_flags); return; } @@ -276,8 +275,8 @@ class LocalAddressParser : public NetlinkParserInterface { } break; default: - QUIC_LOG(ERROR) << quiche::QuicheStrCat( - "Unknown address family: ", interface_address->ifa_family); + QUIC_LOG(ERROR) << absl::StrCat("Unknown address family: ", + interface_address->ifa_family); } } @@ -413,7 +412,7 @@ class RoutingRuleParser : public NetlinkParserInterface { void Run(struct nlmsghdr* netlink_message) override { if (netlink_message->nlmsg_type != RTM_NEWROUTE) { - QUIC_LOG(WARNING) << quiche::QuicheStrCat( + QUIC_LOG(WARNING) << absl::StrCat( "Unexpected nlmsg_type: ", netlink_message->nlmsg_type, " expected: ", RTM_NEWROUTE); return; @@ -423,8 +422,7 @@ class RoutingRuleParser : public NetlinkParserInterface { int payload_length = RTM_PAYLOAD(netlink_message); if (route->rtm_family != AF_INET && route->rtm_family != AF_INET6) { - QUIC_VLOG(2) << quiche::QuicheStrCat("Uninteresting family: ", - route->rtm_family); + QUIC_VLOG(2) << absl::StrCat("Uninteresting family: ", route->rtm_family); return; } @@ -458,8 +456,8 @@ class RoutingRuleParser : public NetlinkParserInterface { break; } default: { - QUIC_VLOG(2) << quiche::QuicheStrCat("Uninteresting attribute: ", - rta->rta_type); + QUIC_VLOG(2) << absl::StrCat("Uninteresting attribute: ", + rta->rta_type); } } } @@ -601,7 +599,7 @@ class IpRuleParser : public NetlinkParserInterface { void Run(struct nlmsghdr* netlink_message) override { if (netlink_message->nlmsg_type != RTM_NEWRULE) { - QUIC_LOG(WARNING) << quiche::QuicheStrCat( + QUIC_LOG(WARNING) << absl::StrCat( "Unexpected nlmsg_type: ", netlink_message->nlmsg_type, " expected: ", RTM_NEWRULE); return; @@ -611,8 +609,7 @@ class IpRuleParser : public NetlinkParserInterface { int payload_length = RTM_PAYLOAD(netlink_message); if (rule->rtm_family != AF_INET6) { - QUIC_LOG(ERROR) << quiche::QuicheStrCat("Unexpected family: ", - rule->rtm_family); + QUIC_LOG(ERROR) << absl::StrCat("Unexpected family: ", rule->rtm_family); return; } @@ -636,8 +633,8 @@ class IpRuleParser : public NetlinkParserInterface { break; } default: { - QUIC_VLOG(2) << quiche::QuicheStrCat("Uninteresting attribute: ", - rta->rta_type); + QUIC_VLOG(2) << absl::StrCat("Uninteresting attribute: ", + rta->rta_type); } } } diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/netlink.h b/chromium/net/third_party/quiche/src/quic/qbone/platform/netlink.h index 6c856584068..9a5b7d9fac1 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/netlink.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/netlink.h @@ -14,10 +14,10 @@ #include <string> #include <vector> -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/qbone/platform/ip_range.h" -#include "net/third_party/quiche/src/quic/qbone/platform/kernel_interface.h" -#include "net/third_party/quiche/src/quic/qbone/platform/netlink_interface.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/qbone/platform/ip_range.h" +#include "quic/qbone/platform/kernel_interface.h" +#include "quic/qbone/platform/netlink_interface.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/netlink_interface.h b/chromium/net/third_party/quiche/src/quic/qbone/platform/netlink_interface.h index 1b1ba111ac7..eabfe078665 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/netlink_interface.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/netlink_interface.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_QBONE_PLATFORM_NETLINK_INTERFACE_H_ #define QUICHE_QUIC_QBONE_PLATFORM_NETLINK_INTERFACE_H_ -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/qbone/platform/ip_range.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/qbone/platform/ip_range.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/netlink_test.cc b/chromium/net/third_party/quiche/src/quic/qbone/platform/netlink_test.cc index f8d0f193225..58b03d38838 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/netlink_test.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/netlink_test.cc @@ -2,15 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/platform/netlink.h" +#include "quic/qbone/platform/netlink.h" #include <utility> -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/qbone/platform/mock_kernel.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_constants.h" +#include "absl/container/node_hash_set.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_test.h" +#include "quic/qbone/platform/mock_kernel.h" +#include "quic/qbone/qbone_constants.h" namespace quic { namespace { @@ -74,7 +75,7 @@ class NetlinkTest : public QuicTest { send_callback(buf.c_str(), buf.size()); } - CHECK_EQ(seq, -1); + QUICHE_CHECK_EQ(seq, -1); seq = netlink_message->nlmsg_seq; return buf.size(); })); @@ -90,7 +91,7 @@ class NetlinkTest : public QuicTest { nl_addr->nl_groups = 0; // no multicast int ret = recv_callback(reply_packet_, sizeof(reply_packet_), seq); - CHECK_LE(ret, sizeof(reply_packet_)); + QUICHE_CHECK_LE(ret, sizeof(reply_packet_)); return ret; })); @@ -185,7 +186,7 @@ void CreateIfaddrmsg(struct nlmsghdr* nlm, unsigned char flags, unsigned char scope, QuicIpAddress ip) { - CHECK(ip.IsInitialized()); + QUICHE_CHECK(ip.IsInitialized()); unsigned char family; switch (ip.address_family()) { case IpAddressFamily::IP_V4: @@ -195,8 +196,8 @@ void CreateIfaddrmsg(struct nlmsghdr* nlm, family = AF_INET6; break; default: - QUIC_BUG << quiche::QuicheStrCat("unexpected address family: ", - ip.address_family()); + QUIC_BUG << absl::StrCat("unexpected address family: ", + ip.address_family()); family = AF_UNSPEC; } auto* msg = reinterpret_cast<struct ifaddrmsg*>(NLMSG_DATA(nlm)); @@ -287,8 +288,8 @@ TEST_F(NetlinkTest, GetLinkInfoWorks) { TEST_F(NetlinkTest, GetAddressesWorks) { auto netlink = std::make_unique<Netlink>(&mock_kernel_); - QuicUnorderedSet<std::string> addresses = {QuicIpAddress::Any4().ToString(), - QuicIpAddress::Any6().ToString()}; + absl::node_hash_set<std::string> addresses = { + QuicIpAddress::Any4().ToString(), QuicIpAddress::Any6().ToString()}; ExpectNetlinkPacket( RTM_GETADDR, NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST, diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/rtnetlink_message.cc b/chromium/net/third_party/quiche/src/quic/qbone/platform/rtnetlink_message.cc index d52e72538b1..24709e7d1c3 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/rtnetlink_message.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/rtnetlink_message.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/platform/rtnetlink_message.h" +#include "quic/qbone/platform/rtnetlink_message.h" #include <utility> diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/rtnetlink_message.h b/chromium/net/third_party/quiche/src/quic/qbone/platform/rtnetlink_message.h index f36cd4c505f..e67da1bcaa2 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/rtnetlink_message.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/rtnetlink_message.h @@ -14,7 +14,7 @@ #include <memory> #include <vector> -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_logging.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/rtnetlink_message_test.cc b/chromium/net/third_party/quiche/src/quic/qbone/platform/rtnetlink_message_test.cc index 64931c79fbd..f2d9d929dae 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/rtnetlink_message_test.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/rtnetlink_message_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/platform/rtnetlink_message.h" +#include "quic/qbone/platform/rtnetlink_message.h" #include <net/if_arp.h> -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace { @@ -124,7 +124,7 @@ TEST(RtnetlinkMessageTest, AddressMessageCanBeCreatedForNewOperation) { seq, pid, &interface_address_header); QuicIpAddress ip; - CHECK(ip.FromString("10.0.100.3")); + QUICHE_CHECK(ip.FromString("10.0.100.3")); message.AppendAttribute(IFA_ADDRESS, ip.ToPackedString().c_str(), ip.ToPackedString().size()); @@ -181,7 +181,7 @@ TEST(RtnetlinkMessageTest, RouteMessageCanBeCreatedFromNewOperation) { pid, &route_message_header); QuicIpAddress preferred_source; - CHECK(preferred_source.FromString("ff80::1")); + QUICHE_CHECK(preferred_source.FromString("ff80::1")); message.AppendAttribute(RTA_PREFSRC, preferred_source.ToPackedString().c_str(), preferred_source.ToPackedString().size()); diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/tcp_packet.cc b/chromium/net/third_party/quiche/src/quic/qbone/platform/tcp_packet.cc index 1b0103e3336..f4752f25973 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/tcp_packet.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/tcp_packet.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/platform/tcp_packet.h" +#include "quic/qbone/platform/tcp_packet.h" #include <netinet/ip6.h> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/qbone/platform/internet_checksum.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/qbone/platform/internet_checksum.h" +#include "common/quiche_endian.h" namespace quic { namespace { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/tcp_packet.h b/chromium/net/third_party/quiche/src/quic/qbone/platform/tcp_packet.h index 2038fab09ec..5fd7a76436e 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/tcp_packet.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/tcp_packet.h @@ -11,7 +11,7 @@ #include <functional> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_ip_address.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/platform/tcp_packet_test.cc b/chromium/net/third_party/quiche/src/quic/qbone/platform/tcp_packet_test.cc index a1431952199..df107d63c2f 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/platform/tcp_packet_test.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/platform/tcp_packet_test.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/platform/tcp_packet.h" +#include "quic/qbone/platform/tcp_packet.h" #include <netinet/ip6.h> #include <cstdint> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/platform/api/quic_test.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { namespace { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_client.cc b/chromium/net/third_party/quiche/src/quic/qbone/qbone_client.cc index 44aec9c27f0..464c0532589 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_client.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_client.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/qbone_client.h" +#include "quic/qbone/qbone_client.h" #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_epoll.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_exported_stats.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_stream.h" +#include "quic/core/quic_epoll_alarm_factory.h" +#include "quic/core/quic_epoll_connection_helper.h" +#include "quic/platform/api/quic_epoll.h" +#include "quic/platform/api/quic_exported_stats.h" +#include "quic/qbone/qbone_stream.h" namespace quic { namespace { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_client.h b/chromium/net/third_party/quiche/src/quic/qbone/qbone_client.h index 7fbba4b7b44..7aefb25bf63 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_client.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_client.h @@ -6,11 +6,11 @@ #define QUICHE_QUIC_QBONE_QBONE_CLIENT_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_client_interface.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_client_session.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_packet_writer.h" -#include "net/third_party/quiche/src/quic/tools/quic_client_base.h" -#include "net/third_party/quiche/src/quic/tools/quic_client_epoll_network_helper.h" +#include "quic/qbone/qbone_client_interface.h" +#include "quic/qbone/qbone_client_session.h" +#include "quic/qbone/qbone_packet_writer.h" +#include "quic/tools/quic_client_base.h" +#include "quic/tools/quic_client_epoll_network_helper.h" namespace quic { // A QboneClient encapsulates connecting to a server via an epoll server diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_client_session.cc b/chromium/net/third_party/quiche/src/quic/qbone/qbone_client_session.cc index 4697fcccc52..f3b62904d6b 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_client_session.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_client_session.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/qbone_client_session.h" +#include "quic/qbone/qbone_client_session.h" #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_constants.h" +#include "quic/core/quic_types.h" +#include "quic/qbone/qbone_constants.h" namespace quic { @@ -42,7 +42,8 @@ void QboneClientSession::Initialize() { ->CryptoConnect(); // Register the reserved control stream. QuicStreamId next_id = GetNextOutgoingBidirectionalStreamId(); - DCHECK_EQ(next_id, QboneConstants::GetControlStreamId(transport_version())); + QUICHE_DCHECK_EQ(next_id, + QboneConstants::GetControlStreamId(transport_version())); auto control_stream = std::make_unique<QboneClientControlStream>(this, handler_); control_stream_ = control_stream.get(); diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_client_session.h b/chromium/net/third_party/quiche/src/quic/qbone/qbone_client_session.h index f3cd0202ba2..442b859d1f7 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_client_session.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_client_session.h @@ -6,12 +6,12 @@ #define QUICHE_QUIC_QBONE_QBONE_CLIENT_SESSION_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_client_stream.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_control.pb.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_control_stream.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_packet_writer.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_session_base.h" +#include "quic/core/quic_crypto_client_stream.h" +#include "quic/platform/api/quic_export.h" +#include "quic/qbone/qbone_control.pb.h" +#include "quic/qbone/qbone_control_stream.h" +#include "quic/qbone/qbone_packet_writer.h" +#include "quic/qbone/qbone_session_base.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_client_test.cc b/chromium/net/third_party/quiche/src/quic/qbone/qbone_client_test.cc index 98b1a2e59ba..75a3a1e9216 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_client_test.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_client_test.cc @@ -4,29 +4,30 @@ // Sets up a dispatcher and sends requests via the QboneClient. -#include "net/third_party/quiche/src/quic/qbone/qbone_client.h" +#include "quic/qbone/qbone_client.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_alarm_factory.h" -#include "net/third_party/quiche/src/quic/core/quic_default_packet_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_dispatcher.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_reader.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_mutex.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_port_utils.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/platform/api/quic_test_loopback.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_constants.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_packet_processor_test_tools.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_server_session.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_server_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/server_thread.h" -#include "net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h" -#include "net/third_party/quiche/src/quic/tools/quic_server.h" +#include "quic/core/quic_alarm_factory.h" +#include "quic/core/quic_default_packet_writer.h" +#include "quic/core/quic_dispatcher.h" +#include "quic/core/quic_epoll_alarm_factory.h" +#include "quic/core/quic_epoll_connection_helper.h" +#include "quic/core/quic_packet_reader.h" +#include "quic/platform/api/quic_mutex.h" +#include "quic/platform/api/quic_port_utils.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test_loopback.h" +#include "quic/qbone/qbone_constants.h" +#include "quic/qbone/qbone_packet_processor_test_tools.h" +#include "quic/qbone/qbone_server_session.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_dispatcher_peer.h" +#include "quic/test_tools/quic_server_peer.h" +#include "quic/test_tools/server_thread.h" +#include "quic/tools/quic_memory_cache_backend.h" +#include "quic/tools/quic_server.h" namespace quic { namespace test { @@ -127,7 +128,7 @@ class QuicQboneDispatcher : public QuicDispatcher { const QuicSocketAddress& peer_address, absl::string_view alpn, const quic::ParsedQuicVersion& version) override { - CHECK_EQ(alpn, "qbone"); + QUICHE_CHECK_EQ(alpn, "qbone"); QuicConnection* connection = new QuicConnection( id, self_address, peer_address, helper(), alarm_factory(), writer(), /* owns_writer= */ false, Perspective::IS_SERVER, @@ -261,11 +262,9 @@ TEST_P(QboneClientTest, SendDataFromClient) { server_thread.Schedule([&server, &long_data]() { EXPECT_THAT(server->data()[0], testing::Eq(TestPacketOut("hello"))); EXPECT_THAT(server->data()[1], testing::Eq(TestPacketOut("world"))); - auto server_session = - static_cast<QboneServerSession*>(QuicServerPeer::GetDispatcher(server) - ->session_map() - .begin() - ->second.get()); + auto server_session = static_cast<QboneServerSession*>( + QuicDispatcherPeer::GetFirstSessionIfAny( + QuicServerPeer::GetDispatcher(server))); server_session->ProcessPacketFromNetwork( TestPacketIn("Somethingsomething")); server_session->ProcessPacketFromNetwork(TestPacketIn(long_data)); diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_constants.cc b/chromium/net/third_party/quiche/src/quic/qbone/qbone_constants.cc index a83f74e4d1d..fb92af7319f 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_constants.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_constants.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/qbone_constants.h" +#include "quic/qbone/qbone_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" +#include "quic/core/quic_utils.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_constants.h b/chromium/net/third_party/quiche/src/quic/qbone/qbone_constants.h index eeb617148b7..8053013abf9 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_constants.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_constants.h @@ -5,10 +5,10 @@ #ifndef QUICHE_QUIC_QBONE_QBONE_CONSTANTS_H_ #define QUICHE_QUIC_QBONE_QBONE_CONSTANTS_H_ -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/qbone/platform/ip_range.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/qbone/platform/ip_range.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_control_placeholder.proto b/chromium/net/third_party/quiche/src/quic/qbone/qbone_control_placeholder.proto index 375b015df02..d9b1a6ae035 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_control_placeholder.proto +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_control_placeholder.proto @@ -4,7 +4,7 @@ option optimize_for = LITE_RUNTIME; package quic; -import "net/third_party/quiche/src/quic/qbone/qbone_control.proto"; +import "quic/qbone/qbone_control.proto"; // These provide fields for QboneServerRequest and QboneClientRequest that are // used to test the control channel. Once the control channel actually has real diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_control_stream.cc b/chromium/net/third_party/quiche/src/quic/qbone/qbone_control_stream.cc index 04f074c30a7..132ecb7a232 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_control_stream.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_control_stream.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/qbone_control_stream.h" +#include "quic/qbone/qbone_control_stream.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_constants.h" +#include "quic/core/quic_session.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/qbone/qbone_constants.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_control_stream.h b/chromium/net/third_party/quiche/src/quic/qbone/qbone_control_stream.h index 10da82cfcf1..d0c2b1a1ed4 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_control_stream.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_control_stream.h @@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_QBONE_QBONE_CONTROL_STREAM_H_ #define QUICHE_QUIC_QBONE_QBONE_CONTROL_STREAM_H_ -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_control.pb.h" +#include "quic/core/quic_stream.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/qbone/qbone_control.pb.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_exchanger.cc b/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_exchanger.cc index ded41a24a6f..5ee52e1e065 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_exchanger.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_exchanger.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/qbone_packet_exchanger.h" +#include "quic/qbone/qbone_packet_exchanger.h" #include <utility> diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_exchanger.h b/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_exchanger.h index 1b3577a24f8..ad393b866b8 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_exchanger.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_exchanger.h @@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_QBONE_QBONE_PACKET_EXCHANGER_H_ #define QUICHE_QUIC_QBONE_QBONE_PACKET_EXCHANGER_H_ -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_client_interface.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_packet_writer.h" +#include "quic/core/quic_packets.h" +#include "quic/qbone/qbone_client_interface.h" +#include "quic/qbone/qbone_packet_writer.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_exchanger_test.cc b/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_exchanger_test.cc index 9ec9e209a60..a2b502fa26f 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_exchanger_test.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_exchanger_test.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/qbone_packet_exchanger.h" +#include "quic/qbone/qbone_packet_exchanger.h" #include <utility> -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/qbone/mock_qbone_client.h" +#include "quic/platform/api/quic_test.h" +#include "quic/qbone/mock_qbone_client.h" namespace quic { namespace { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor.cc b/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor.cc index 5fbf63dfc2d..c9935577a86 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/qbone_packet_processor.h" +#include "quic/qbone/qbone_packet_processor.h" #include <cstring> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/qbone/platform/icmp_packet.h" -#include "net/third_party/quiche/src/quic/qbone/platform/internet_checksum.h" -#include "net/third_party/quiche/src/quic/qbone/platform/tcp_packet.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/qbone/platform/icmp_packet.h" +#include "quic/qbone/platform/internet_checksum.h" +#include "quic/qbone/platform/tcp_packet.h" +#include "common/quiche_endian.h" namespace { @@ -38,12 +38,12 @@ QbonePacketProcessor::QbonePacketProcessor(QuicIpAddress self_ip, stats_(stats), filter_(new Filter) { memcpy(self_ip_.s6_addr, self_ip.ToPackedString().data(), kIPv6AddressSize); - DCHECK_LE(client_ip_subnet_length, kIPv6AddressSize * 8); + QUICHE_DCHECK_LE(client_ip_subnet_length, kIPv6AddressSize * 8); client_ip_subnet_length_ = client_ip_subnet_length; - DCHECK(IpAddressFamily::IP_V6 == self_ip.address_family()); - DCHECK(IpAddressFamily::IP_V6 == client_ip.address_family()); - DCHECK(self_ip != kInvalidIpAddress); + QUICHE_DCHECK(IpAddressFamily::IP_V6 == self_ip.address_family()); + QUICHE_DCHECK(IpAddressFamily::IP_V6 == client_ip.address_family()); + QUICHE_DCHECK(self_ip != kInvalidIpAddress); } QbonePacketProcessor::OutputInterface::~OutputInterface() {} @@ -201,7 +201,7 @@ QbonePacketProcessor::ProcessingResult QbonePacketProcessor::ProcessIPv6Header( address_reject_code = ICMP6_DST_UNREACH_NOROUTE; break; } - DCHECK(ip_parse_result); + QUICHE_DCHECK(ip_parse_result); if (!client_ip_.InSameSubnet(address_to_check, client_ip_subnet_length_)) { QUIC_DVLOG(1) << "Dropped packet: source/destination address is not client's"; diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor.h b/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor.h index bb5e8163f04..c85280fe18f 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor.h @@ -9,8 +9,8 @@ #include <netinet/ip6.h> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_ip_address.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor_test.cc b/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor_test.cc index 569df911229..d79400c0418 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor_test.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor_test.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/qbone_packet_processor.h" +#include "quic/qbone/qbone_packet_processor.h" #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_packet_processor_test_tools.h" +#include "quic/platform/api/quic_test.h" +#include "quic/qbone/qbone_packet_processor_test_tools.h" namespace quic { namespace { @@ -138,9 +138,9 @@ class MockPacketFilter : public QbonePacketProcessor::Filter { class QbonePacketProcessorTest : public QuicTest { protected: QbonePacketProcessorTest() { - CHECK(client_ip_.FromString("fd00:0:0:1::1")); - CHECK(self_ip_.FromString("fd00:0:0:4::1")); - CHECK(network_ip_.FromString("fd00:0:0:5::1")); + QUICHE_CHECK(client_ip_.FromString("fd00:0:0:1::1")); + QUICHE_CHECK(self_ip_.FromString("fd00:0:0:4::1")); + QUICHE_CHECK(network_ip_.FromString("fd00:0:0:5::1")); processor_ = std::make_unique<QbonePacketProcessor>( self_ip_, client_ip_, /*client_ip_subnet_length=*/62, &output_, diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor_test_tools.cc b/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor_test_tools.cc index 97655e08fc2..5df158d87f9 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor_test_tools.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor_test_tools.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/qbone_packet_processor_test_tools.h" +#include "quic/qbone/qbone_packet_processor_test_tools.h" #include <netinet/ip6.h> diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor_test_tools.h b/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor_test_tools.h index 8384821882d..e26313b4f1b 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor_test_tools.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_packet_processor_test_tools.h @@ -6,8 +6,8 @@ #define QUICHE_QUIC_QBONE_QBONE_PACKET_PROCESSOR_TEST_TOOLS_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_packet_processor.h" +#include "quic/platform/api/quic_test.h" +#include "quic/qbone/qbone_packet_processor.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_server_session.cc b/chromium/net/third_party/quiche/src/quic/qbone/qbone_server_session.cc index 7f83381c875..76a460c99d1 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_server_session.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_server_session.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/qbone_server_session.h" +#include "quic/qbone/qbone_server_session.h" #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_constants.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/qbone/qbone_constants.h" namespace quic { @@ -89,7 +89,7 @@ void QboneServerSession::SendPacketToClient(absl::string_view packet) { } void QboneServerSession::SendPacketToNetwork(absl::string_view packet) { - DCHECK(writer_ != nullptr); + QUICHE_DCHECK(writer_ != nullptr); writer_->WritePacketToNetwork(packet.data(), packet.size()); } diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_server_session.h b/chromium/net/third_party/quiche/src/quic/qbone/qbone_server_session.h index 63a0d8d954c..76b7333ad05 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_server_session.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_server_session.h @@ -6,14 +6,14 @@ #define QUICHE_QUIC_QBONE_QBONE_SERVER_SESSION_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_control.pb.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_control_stream.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_packet_processor.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_packet_writer.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_session_base.h" +#include "quic/core/quic_crypto_server_stream_base.h" +#include "quic/core/quic_crypto_stream.h" +#include "quic/platform/api/quic_export.h" +#include "quic/qbone/qbone_control.pb.h" +#include "quic/qbone/qbone_control_stream.h" +#include "quic/qbone/qbone_packet_processor.h" +#include "quic/qbone/qbone_packet_writer.h" +#include "quic/qbone/qbone_session_base.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_session_base.cc b/chromium/net/third_party/quiche/src/quic/qbone/qbone_session_base.cc index d2d2ab4a24b..607c542591f 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_session_base.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_session_base.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/qbone_session_base.h" +#include "quic/qbone/qbone_session_base.h" #include <netinet/icmp6.h> #include <netinet/ip6.h> @@ -10,13 +10,13 @@ #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_data_reader.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_exported_stats.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/qbone/platform/icmp_packet.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_constants.h" +#include "quic/core/quic_buffer_allocator.h" +#include "quic/core/quic_data_reader.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_exported_stats.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/qbone/platform/icmp_packet.h" +#include "quic/qbone/qbone_constants.h" ABSL_FLAG( bool, @@ -50,12 +50,7 @@ QboneSessionBase::QboneSessionBase( } } -QboneSessionBase::~QboneSessionBase() { - // Clear out the streams before leaving this destructor to avoid calling - // QuicSession::UnregisterStreamPriority - stream_map().clear(); - closed_streams()->clear(); -} +QboneSessionBase::~QboneSessionBase() {} void QboneSessionBase::Initialize() { crypto_stream_ = CreateCryptoStream(); diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_session_base.h b/chromium/net/third_party/quiche/src/quic/qbone/qbone_session_base.h index 222999b4868..6d2c1b213ac 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_session_base.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_session_base.h @@ -6,14 +6,14 @@ #define QUICHE_QUIC_QBONE_QBONE_SESSION_BASE_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_packet_writer.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_stream.h" +#include "quic/core/quic_crypto_server_stream_base.h" +#include "quic/core/quic_crypto_stream.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_session.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_export.h" +#include "quic/qbone/qbone_packet_writer.h" +#include "quic/qbone/qbone_stream.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_session_test.cc b/chromium/net/third_party/quiche/src/quic/qbone/qbone_session_test.cc index 505927421bd..f0d9d16059e 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_session_test.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_session_test.cc @@ -5,25 +5,25 @@ #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/proto/crypto_server_config_proto.h" -#include "net/third_party/quiche/src/quic/core/quic_alarm_factory.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_port_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test_loopback.h" -#include "net/third_party/quiche/src/quic/qbone/platform/icmp_packet.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_client_session.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_constants.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_control_placeholder.pb.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_packet_processor_test_tools.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_server_session.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/mock_clock.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/proto/crypto_server_config_proto.h" +#include "quic/core/quic_alarm_factory.h" +#include "quic/core/quic_epoll_alarm_factory.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_port_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test_loopback.h" +#include "quic/qbone/platform/icmp_packet.h" +#include "quic/qbone/qbone_client_session.h" +#include "quic/qbone/qbone_constants.h" +#include "quic/qbone/qbone_control_placeholder.pb.h" +#include "quic/qbone/qbone_packet_processor_test_tools.h" +#include "quic/qbone/qbone_server_session.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/mock_clock.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_session_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_stream.cc b/chromium/net/third_party/quiche/src/quic/qbone/qbone_stream.cc index db499bab55a..43aab4d001b 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_stream.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_stream.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/qbone_stream.h" +#include "quic/qbone/qbone_stream.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_data_reader.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_constants.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_session_base.h" +#include "quic/core/quic_data_reader.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_types.h" +#include "quic/qbone/qbone_constants.h" +#include "quic/qbone/qbone_session_base.h" ABSL_FLAG(int, qbone_stream_ttl_secs, 3, "The QBONE Stream TTL in seconds."); diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_stream.h b/chromium/net/third_party/quiche/src/quic/qbone/qbone_stream.h index c27a91ab702..e7ea045cf48 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_stream.h +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_stream.h @@ -6,9 +6,9 @@ #define QUICHE_QUIC_QBONE_QBONE_STREAM_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_stream.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/qbone/qbone_stream_test.cc b/chromium/net/third_party/quiche/src/quic/qbone/qbone_stream_test.cc index 18f48f7331b..bcbc5a514e8 100644 --- a/chromium/net/third_party/quiche/src/quic/qbone/qbone_stream_test.cc +++ b/chromium/net/third_party/quiche/src/quic/qbone/qbone_stream_test.cc @@ -2,22 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/qbone/qbone_stream.h" +#include "quic/qbone/qbone_stream.h" #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test_loopback.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_constants.h" -#include "net/third_party/quiche/src/quic/qbone/qbone_session_base.h" -#include "net/third_party/quiche/src/quic/test_tools/mock_clock.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_simple_buffer_allocator.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test_loopback.h" +#include "quic/qbone/qbone_constants.h" +#include "quic/qbone/qbone_session_base.h" +#include "quic/test_tools/mock_clock.h" +#include "quic/test_tools/quic_test_utils.h" +#include "spdy/core/spdy_protocol.h" namespace quic { @@ -59,10 +59,6 @@ class MockQuicSession : public QboneSessionBase { // Called by QuicStream when they want to close stream. MOCK_METHOD(void, - SendRstStream, - (QuicStreamId, QuicRstStreamErrorCode, QuicStreamOffset, bool), - (override)); - MOCK_METHOD(void, MaybeSendRstStreamFrame, (QuicStreamId stream_id, QuicRstStreamErrorCode error, @@ -245,15 +241,10 @@ TEST_F(QboneReadOnlyStreamTest, ReadBufferedTooLarge) { CreateReliableQuicStream(); std::string packet = "0123456789"; int iterations = (QboneConstants::kMaxQbonePacketBytes / packet.size()) + 2; - if (!session_->split_up_send_rst()) { - EXPECT_CALL(*session_, - SendRstStream(kStreamId, QUIC_BAD_APPLICATION_PAYLOAD, _, _)); - } else { - EXPECT_CALL(*session_, MaybeSendStopSendingFrame( - kStreamId, QUIC_BAD_APPLICATION_PAYLOAD)); - EXPECT_CALL(*session_, MaybeSendRstStreamFrame( - kStreamId, QUIC_BAD_APPLICATION_PAYLOAD, _)); - } + EXPECT_CALL(*session_, MaybeSendStopSendingFrame( + kStreamId, QUIC_BAD_APPLICATION_PAYLOAD)); + EXPECT_CALL(*session_, MaybeSendRstStreamFrame( + kStreamId, QUIC_BAD_APPLICATION_PAYLOAD, _)); for (int i = 0; i < iterations; ++i) { QuicStreamFrame frame(kStreamId, i == (iterations - 1), i * packet.size(), packet); diff --git a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_client_session.cc b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_client_session.cc index f38d6b3462b..cf7032103b9 100644 --- a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_client_session.cc +++ b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_client_session.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_client_session.h" +#include "quic/quic_transport/quic_transport_client_session.h" #include <cstdint> #include <limits> @@ -12,17 +12,17 @@ #include "absl/strings/string_view.h" #include "url/gurl.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_client_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_protocol.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_stream.h" +#include "quic/core/quic_constants.h" +#include "quic/core/quic_crypto_client_stream.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/quic_transport/quic_transport_protocol.h" +#include "quic/quic_transport/quic_transport_stream.h" namespace quic { @@ -34,12 +34,14 @@ QuicTransportClientSession::QuicTransportClientSession( const GURL& url, QuicCryptoClientConfig* crypto_config, url::Origin origin, - ClientVisitor* visitor) + ClientVisitor* visitor, + std::unique_ptr<QuicDatagramQueue::Observer> datagram_observer) : QuicSession(connection, owner, config, supported_versions, - /*num_expected_unidirectional_static_streams*/ 0), + /*num_expected_unidirectional_static_streams*/ 0, + std::move(datagram_observer)), url_(url), origin_(origin), visitor_(visitor) { diff --git a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_client_session.h b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_client_session.h index c4f417fcbb8..d01903c388d 100644 --- a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_client_session.h +++ b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_client_session.h @@ -11,20 +11,21 @@ #include "absl/strings/string_view.h" #include "url/gurl.h" #include "url/origin.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_client_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_protocol.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_session_interface.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_stream.h" +#include "quic/core/crypto/quic_crypto_client_config.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_crypto_client_stream.h" +#include "quic/core/quic_crypto_stream.h" +#include "quic/core/quic_datagram_queue.h" +#include "quic/core/quic_server_id.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_stream.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/quic_transport/quic_transport_protocol.h" +#include "quic/quic_transport/quic_transport_session_interface.h" +#include "quic/quic_transport/quic_transport_stream.h" namespace quic { @@ -56,14 +57,16 @@ class QUIC_EXPORT_PRIVATE QuicTransportClientSession virtual void OnCanCreateNewOutgoingUnidirectionalStream() = 0; }; - QuicTransportClientSession(QuicConnection* connection, - Visitor* owner, - const QuicConfig& config, - const ParsedQuicVersionVector& supported_versions, - const GURL& url, - QuicCryptoClientConfig* crypto_config, - url::Origin origin, - ClientVisitor* visitor); + QuicTransportClientSession( + QuicConnection* connection, + Visitor* owner, + const QuicConfig& config, + const ParsedQuicVersionVector& supported_versions, + const GURL& url, + QuicCryptoClientConfig* crypto_config, + url::Origin origin, + ClientVisitor* visitor, + std::unique_ptr<QuicDatagramQueue::Observer> datagram_observer); std::vector<std::string> GetAlpnsToOffer() const override { return std::vector<std::string>({QuicTransportAlpn()}); diff --git a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_client_session_test.cc b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_client_session_test.cc index 129c87ee662..8e6a0e27882 100644 --- a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_client_session_test.cc +++ b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_client_session_test.cc @@ -2,24 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_client_session.h" +#include "quic/quic_transport/quic_transport_client_session.h" #include <memory> #include <utility> #include "absl/base/macros.h" #include "url/gurl.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_transport_test_tools.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_server_id.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/quic_session_peer.h" +#include "quic/test_tools/quic_stream_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/quic_transport_test_tools.h" namespace quic { namespace test { @@ -65,7 +65,7 @@ class QuicTransportClientSessionTest : public QuicTest { session_ = std::make_unique<QuicTransportClientSession>( &connection_, nullptr, DefaultQuicConfig(), GetVersions(), GURL("quic-transport://test.example.com:50000" + url_suffix), - &crypto_config_, origin, &visitor_); + &crypto_config_, origin, &visitor_, /*datagram_observer=*/nullptr); session_->Initialize(); crypto_stream_ = static_cast<QuicCryptoClientStream*>( session_->GetMutableCryptoStream()); diff --git a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_integration_test.cc b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_integration_test.cc index 1965c6d56e2..1b42020d535 100644 --- a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_integration_test.cc +++ b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_integration_test.cc @@ -11,27 +11,27 @@ #include "absl/strings/string_view.h" #include "url/gurl.h" #include "url/origin.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" -#include "net/third_party/quiche/src/quic/core/quic_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_client_session.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_server_session.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_stream.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_transport_test_tools.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/link.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint_base.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/simulator.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/switch.h" -#include "net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.h" +#include "quic/core/crypto/quic_crypto_client_config.h" +#include "quic/core/crypto/quic_crypto_server_config.h" +#include "quic/core/quic_buffer_allocator.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" +#include "quic/quic_transport/quic_transport_client_session.h" +#include "quic/quic_transport/quic_transport_server_session.h" +#include "quic/quic_transport/quic_transport_stream.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/quic_session_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/quic_transport_test_tools.h" +#include "quic/test_tools/simulator/link.h" +#include "quic/test_tools/simulator/quic_endpoint_base.h" +#include "quic/test_tools/simulator/simulator.h" +#include "quic/test_tools/simulator/switch.h" +#include "quic/tools/quic_transport_simple_server_session.h" namespace quic { namespace test { @@ -90,7 +90,8 @@ class QuicTransportClientEndpoint : public QuicTransportEndpointBase { GURL("quic-transport://test.example.com:50000" + path), &crypto_config_, origin, - &visitor_) { + &visitor_, + /*datagram_observer=*/nullptr) { session_.Initialize(); } diff --git a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_protocol.h b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_protocol.h index 45b9ef41c0b..191d42c1400 100644 --- a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_protocol.h +++ b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_protocol.h @@ -5,10 +5,10 @@ #ifndef QUICHE_QUIC_QUIC_TRANSPORT_QUIC_TRANSPORT_PROTOCOL_H_ #define QUICHE_QUIC_QUIC_TRANSPORT_QUIC_TRANSPORT_PROTOCOL_H_ -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_logging.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_server_session.cc b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_server_session.cc index 083e6fcd315..e2cc59dc2a1 100644 --- a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_server_session.cc +++ b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_server_session.cc @@ -2,21 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_server_session.h" +#include "quic/quic_transport/quic_transport_server_session.h" #include <algorithm> #include <memory> #include <string> +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "url/gurl.h" #include "url/url_constants.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_protocol.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_stream.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_stream.h" +#include "quic/core/quic_types.h" +#include "quic/quic_transport/quic_transport_protocol.h" +#include "quic/quic_transport/quic_transport_stream.h" namespace quic { @@ -88,8 +88,8 @@ void QuicTransportServerSession::ClientIndication::OnDataAvailable() { if (buffer_.size() > ClientIndicationMaxSize()) { session_->connection()->CloseConnection( QUIC_TRANSPORT_INVALID_CLIENT_INDICATION, - quiche::QuicheStrCat("Client indication size exceeds ", - ClientIndicationMaxSize(), " bytes"), + absl::StrCat("Client indication size exceeds ", + ClientIndicationMaxSize(), " bytes"), ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); return; } @@ -111,7 +111,7 @@ bool QuicTransportServerSession::ClientIndicationParser::Parse() { absl::string_view value; if (!reader_.ReadStringPiece16(&value)) { - ParseError(quiche::QuicheStrCat("Failed to read value for key ", key)); + ParseError(absl::StrCat("Failed to read value for key ", key)); return false; } @@ -169,9 +169,9 @@ bool QuicTransportServerSession::ClientIndicationParser::ProcessPath( // TODO(b/145674008): use the SNI value from the handshake instead of the IP // address. - std::string url_text = quiche::QuicheStrCat( - url::kQuicTransportScheme, url::kStandardSchemeSeparator, - session_->self_address().ToString(), path); + std::string url_text = + absl::StrCat(url::kQuicTransportScheme, url::kStandardSchemeSeparator, + session_->self_address().ToString(), path); GURL url{url_text}; if (!url.is_valid()) { Error("Invalid path specified"); @@ -194,8 +194,8 @@ void QuicTransportServerSession::ClientIndicationParser::Error( void QuicTransportServerSession::ClientIndicationParser::ParseError( absl::string_view error_message) { - Error(quiche::QuicheStrCat("Failed to parse the client indication stream: ", - error_message, reader_.DebugString())); + Error(absl::StrCat("Failed to parse the client indication stream: ", + error_message, reader_.DebugString())); } void QuicTransportServerSession::ProcessClientIndication( diff --git a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_server_session.h b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_server_session.h index 4085998003d..485f3268b2b 100644 --- a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_server_session.h +++ b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_server_session.h @@ -8,12 +8,12 @@ #include "absl/strings/string_view.h" #include "url/gurl.h" #include "url/origin.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_protocol.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_session_interface.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_stream.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_crypto_server_stream_base.h" +#include "quic/core/quic_session.h" +#include "quic/quic_transport/quic_transport_protocol.h" +#include "quic/quic_transport/quic_transport_session_interface.h" +#include "quic/quic_transport/quic_transport_stream.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_server_session_test.cc b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_server_session_test.cc index c4e40d5f1b5..c58e658591b 100644 --- a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_server_session_test.cc +++ b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_server_session_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_server_session.h" +#include "quic/quic_transport/quic_transport_server_session.h" #include <cstddef> #include <memory> @@ -11,17 +11,17 @@ #include "absl/strings/string_view.h" #include "url/gurl.h" #include "url/origin.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_stream_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_protocol.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_transport_test_tools.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/quic_compressed_certs_cache.h" +#include "quic/core/crypto/quic_crypto_server_config.h" +#include "quic/core/frames/quic_stream_frame.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_test.h" +#include "quic/quic_transport/quic_transport_protocol.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/quic_transport_test_tools.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_session_interface.h b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_session_interface.h index cdb3e999790..d08aa6ce7c2 100644 --- a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_session_interface.h +++ b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_session_interface.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_QUIC_TRANSPORT_QUIC_TRANSPORT_SESSION_INTERFACE_H_ #define QUICHE_QUIC_QUIC_TRANSPORT_QUIC_TRANSPORT_SESSION_INTERFACE_H_ -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_stream.cc b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_stream.cc index 38614e185a0..e27f4692f9d 100644 --- a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_stream.cc +++ b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_stream.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_stream.h" +#include "quic/quic_transport/quic_transport_stream.h" #include <sys/types.h> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" +#include "quic/core/quic_buffer_allocator.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" namespace quic { @@ -47,7 +47,7 @@ size_t QuicTransportStream::Read(std::string* output) { const size_t bytes_to_read = ReadableBytes(); output->resize(old_size + bytes_to_read); size_t bytes_read = Read(&(*output)[old_size], bytes_to_read); - DCHECK_EQ(bytes_to_read, bytes_read); + QUICHE_DCHECK_EQ(bytes_to_read, bytes_read); output->resize(old_size + bytes_read); return bytes_read; } @@ -93,7 +93,7 @@ bool QuicTransportStream::SendFin() { QuicMemSlice empty; QuicConsumedData consumed = WriteMemSlices(QuicMemSliceSpan(&empty), /*fin=*/true); - DCHECK_EQ(consumed.bytes_consumed, 0u); + QUICHE_DCHECK_EQ(consumed.bytes_consumed, 0u); return consumed.fin_consumed; } diff --git a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_stream.h b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_stream.h index dfe943f67d3..70f947c544d 100644 --- a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_stream.h +++ b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_stream.h @@ -10,10 +10,10 @@ #include "absl/base/attributes.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_session_interface.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_stream.h" +#include "quic/core/quic_types.h" +#include "quic/quic_transport/quic_transport_session_interface.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_stream_test.cc b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_stream_test.cc index 82cd9149f7f..75446eb30c7 100644 --- a/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_stream_test.cc +++ b/chromium/net/third_party/quiche/src/quic/quic_transport/quic_transport_stream_test.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_stream.h" +#include "quic/quic_transport/quic_transport_stream.h" #include <memory> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_window_update_frame.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_session_interface.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_transport_test_tools.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/frames/quic_window_update_frame.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/platform/api/quic_test.h" +#include "quic/quic_transport/quic_transport_session_interface.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/quic_transport_test_tools.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/quic_transport/web_transport_fingerprint_proof_verifier.cc b/chromium/net/third_party/quiche/src/quic/quic_transport/web_transport_fingerprint_proof_verifier.cc index 5932b9c6b2b..974d25a588c 100644 --- a/chromium/net/third_party/quiche/src/quic/quic_transport/web_transport_fingerprint_proof_verifier.cc +++ b/chromium/net/third_party/quiche/src/quic/quic_transport/web_transport_fingerprint_proof_verifier.cc @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/quic_transport/web_transport_fingerprint_proof_verifier.h" +#include "quic/quic_transport/web_transport_fingerprint_proof_verifier.h" #include <cstdint> #include <memory> +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/sha.h" -#include "net/third_party/quiche/src/quic/core/crypto/certificate_view.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/certificate_view.h" +#include "quic/core/quic_time.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { namespace { @@ -163,9 +163,9 @@ QuicAsyncStatus WebTransportFingerprintProofVerifier::VerifyCertChain( if (!HasValidExpiry(*view)) { *details = std::make_unique<Details>(Status::kExpiryTooLong); - *error_details = quiche::QuicheStrCat( - "Certificate expiry exceeds the configured limit of ", - max_validity_days_, " days"); + *error_details = + absl::StrCat("Certificate expiry exceeds the configured limit of ", + max_validity_days_, " days"); return QUIC_FAILURE; } diff --git a/chromium/net/third_party/quiche/src/quic/quic_transport/web_transport_fingerprint_proof_verifier.h b/chromium/net/third_party/quiche/src/quic/quic_transport/web_transport_fingerprint_proof_verifier.h index ad83788ecff..f597565051a 100644 --- a/chromium/net/third_party/quiche/src/quic/quic_transport/web_transport_fingerprint_proof_verifier.h +++ b/chromium/net/third_party/quiche/src/quic/quic_transport/web_transport_fingerprint_proof_verifier.h @@ -8,9 +8,9 @@ #include <vector> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/certificate_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_verifier.h" -#include "net/third_party/quiche/src/quic/core/quic_clock.h" +#include "quic/core/crypto/certificate_view.h" +#include "quic/core/crypto/proof_verifier.h" +#include "quic/core/quic_clock.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/quic_transport/web_transport_fingerprint_proof_verifier_test.cc b/chromium/net/third_party/quiche/src/quic/quic_transport/web_transport_fingerprint_proof_verifier_test.cc index a84a8a53497..252af597658 100644 --- a/chromium/net/third_party/quiche/src/quic/quic_transport/web_transport_fingerprint_proof_verifier_test.cc +++ b/chromium/net/third_party/quiche/src/quic/quic_transport/web_transport_fingerprint_proof_verifier_test.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/quic_transport/web_transport_fingerprint_proof_verifier.h" +#include "quic/quic_transport/web_transport_fingerprint_proof_verifier.h" #include <memory> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_types.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/test_certificates.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" +#include "quic/test_tools/test_certificates.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/bad_packet_writer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/bad_packet_writer.cc index 3d00f8eeb11..dd164ba1de7 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/bad_packet_writer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/bad_packet_writer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/bad_packet_writer.h" +#include "quic/test_tools/bad_packet_writer.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/bad_packet_writer.h b/chromium/net/third_party/quiche/src/quic/test_tools/bad_packet_writer.h index 35bf6019486..b04798df2a8 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/bad_packet_writer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/bad_packet_writer.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_BAD_PACKET_WRITER_H_ #define QUICHE_QUIC_TEST_TOOLS_BAD_PACKET_WRITER_H_ -#include "net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.h" +#include "quic/core/quic_packet_writer_wrapper.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/crypto_test_utils.cc b/chromium/net/third_party/quiche/src/quic/test_tools/crypto_test_utils.cc index 00f7f1b4cd7..23f24d67cde 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/crypto_test_utils.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/crypto_test_utils.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/crypto_test_utils.h" #include <algorithm> #include <memory> @@ -16,32 +16,32 @@ #include "third_party/boringssl/src/include/openssl/ecdsa.h" #include "third_party/boringssl/src/include/openssl/nid.h" #include "third_party/boringssl/src/include/openssl/sha.h" -#include "net/third_party/quiche/src/quic/core/crypto/channel_id.h" -#include "net/third_party/quiche/src/quic/core/crypto/common_cert_set.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/proto/crypto_server_config_proto.h" -#include "net/third_party/quiche/src/quic/core/quic_clock.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_client_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.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/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_framer_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/simple_quic_framer.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" +#include "quic/core/crypto/channel_id.h" +#include "quic/core/crypto/common_cert_set.h" +#include "quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/quic_crypto_server_config.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/proto/crypto_server_config_proto.h" +#include "quic/core/quic_clock.h" +#include "quic/core/quic_crypto_client_stream.h" +#include "quic/core/quic_crypto_server_stream_base.h" +#include "quic/core/quic_crypto_stream.h" +#include "quic/core/quic_server_id.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_framer_peer.h" +#include "quic/test_tools/quic_stream_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/simple_quic_framer.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/test_tools/quiche_test_utils.h" namespace quic { namespace test { @@ -263,7 +263,7 @@ int HandshakeWithFakeServer(QuicConfig* server_quic_config, }); // The client's handshake must have been started already. - CHECK_NE(0u, client_conn->encrypted_packets_.size()); + QUICHE_CHECK_NE(0u, client_conn->encrypted_packets_.size()); CommunicateHandshakeMessages(client_conn, client, server_conn, server_session.GetMutableCryptoStream()); @@ -292,7 +292,7 @@ int HandshakeWithFakeClient(MockQuicConnectionHelper* helper, return version.handshake_protocol != PROTOCOL_TLS1_3; }), supported_versions.end()); - CHECK(!options.only_quic_crypto_versions); + QUICHE_CHECK(!options.only_quic_crypto_versions); } else if (options.only_quic_crypto_versions) { supported_versions.erase( std::remove_if(supported_versions.begin(), supported_versions.end(), @@ -326,7 +326,7 @@ int HandshakeWithFakeClient(MockQuicConnectionHelper* helper, {AlpnForVersion(client_conn->version())}))); } client_session.GetMutableCryptoStream()->CryptoConnect(); - CHECK_EQ(1u, client_conn->encrypted_packets_.size()); + QUICHE_CHECK_EQ(1u, client_conn->encrypted_packets_.size()); CommunicateHandshakeMessages(client_conn, client_session.GetMutableCryptoStream(), @@ -400,17 +400,21 @@ std::pair<size_t, size_t> AdvanceHandshake(PacketSavingConnection* client_conn, PacketSavingConnection* server_conn, QuicCryptoStream* server, size_t server_i) { - QUIC_LOG(INFO) << "Processing " - << client_conn->encrypted_packets_.size() - client_i - << " packets client->server"; - MovePackets(client_conn, &client_i, server, server_conn, - Perspective::IS_SERVER); - - QUIC_LOG(INFO) << "Processing " - << server_conn->encrypted_packets_.size() - server_i - << " packets server->client"; - MovePackets(server_conn, &server_i, client, client_conn, - Perspective::IS_CLIENT); + if (client_conn->encrypted_packets_.size() != client_i) { + QUIC_LOG(INFO) << "Processing " + << client_conn->encrypted_packets_.size() - client_i + << " packets client->server"; + MovePackets(client_conn, &client_i, server, server_conn, + Perspective::IS_SERVER); + } + + if (server_conn->encrypted_packets_.size() != server_i) { + QUIC_LOG(INFO) << "Processing " + << server_conn->encrypted_packets_.size() - server_i + << " packets server->client"; + MovePackets(server_conn, &server_i, client, client_conn, + Perspective::IS_CLIENT); + } return std::make_pair(client_i, server_i); } @@ -452,10 +456,10 @@ uint64_t LeafCertHashForTesting() { bool ok = false; proof_source->GetProof( server_address, client_address, "", "", - AllSupportedTransportVersions().front(), "", + AllSupportedVersionsWithQuicCrypto().front().transport_version, "", std::unique_ptr<ProofSource::Callback>(new Callback(&ok, &chain))); if (!ok || chain->certs.empty()) { - DCHECK(false) << "Proof generation failed"; + QUICHE_DCHECK(false) << "Proof generation failed"; return 0; } @@ -606,7 +610,7 @@ void CompareClientAndServerKeys(QuicCryptoClientStream* client, if (level == ENCRYPTION_FORWARD_SECURE || !((level == ENCRYPTION_HANDSHAKE || level == ENCRYPTION_ZERO_RTT || client_encrypter == nullptr) && - server_decrypter == nullptr)) { + (level == ENCRYPTION_ZERO_RTT || server_decrypter == nullptr))) { CompareCrypters(client_encrypter, server_decrypter, "client " + EncryptionLevelString(level) + " write"); } @@ -651,26 +655,26 @@ void CompareClientAndServerKeys(QuicCryptoClientStream* client, QuicTag ParseTag(const char* tagstr) { const size_t len = strlen(tagstr); - CHECK_NE(0u, len); + QUICHE_CHECK_NE(0u, len); QuicTag tag = 0; if (tagstr[0] == '#') { - CHECK_EQ(static_cast<size_t>(1 + 2 * 4), len); + QUICHE_CHECK_EQ(static_cast<size_t>(1 + 2 * 4), len); tagstr++; for (size_t i = 0; i < 8; i++) { tag <<= 4; uint8_t v = 0; - CHECK(HexChar(tagstr[i], &v)); + QUICHE_CHECK(HexChar(tagstr[i], &v)); tag |= v; } return tag; } - CHECK_LE(len, 4u); + QUICHE_CHECK_LE(len, 4u); for (size_t i = 0; i < 4; i++) { tag >>= 8; if (i < len) { @@ -719,7 +723,7 @@ CryptoHandshakeMessage CreateCHLO( CryptoFramer::ConstructHandshakeMessage(msg); std::unique_ptr<CryptoHandshakeMessage> parsed( CryptoFramer::ParseMessage(bytes->AsStringPiece())); - CHECK(parsed); + QUICHE_CHECK(parsed); return *parsed; } @@ -756,7 +760,9 @@ void MovePackets(PacketSavingConnection* source_conn, continue; } QuicConnectionPeer::SwapCrypters(dest_conn, framer.framer()); - dest_conn->OnDecryptedPacket(framer.last_decrypted_level()); + dest_conn->OnDecryptedPacket( + source_conn->encrypted_packets_[index]->length(), + framer.last_decrypted_level()); if (dest_stream->handshake_protocol() == PROTOCOL_TLS1_3) { // Try to process the packet with a framer that only has the NullDecrypter @@ -777,7 +783,9 @@ void MovePackets(PacketSavingConnection* source_conn, // packet was decrypted at. This is needed by TLS to know what encryption // level was used for the data it's receiving, so we plumb this information // from the SimpleQuicFramer back into the connection. - dest_conn->OnDecryptedPacket(framer.last_decrypted_level()); + dest_conn->OnDecryptedPacket( + source_conn->encrypted_packets_[index]->length(), + framer.last_decrypted_level()); QuicConnectionPeer::SetCurrentPacket( dest_conn, source_conn->encrypted_packets_[index]->AsStringPiece()); @@ -791,6 +799,9 @@ void MovePackets(PacketSavingConnection* source_conn, for (const auto& crypto_frame : framer.crypto_frames()) { dest_stream->OnCryptoFrame(*crypto_frame); } + if (!framer.connection_close_frames().empty() && dest_conn->connected()) { + dest_conn->OnConnectionCloseFrame(framer.connection_close_frames()[0]); + } } *inout_packet_index = index; @@ -810,7 +821,8 @@ CryptoHandshakeMessage GenerateDefaultInchoateCHLO( {"PUBS", GenerateClientPublicValuesHex().c_str()}, {"NONC", GenerateClientNonceHex(clock, crypto_config).c_str()}, {"VER\0", QuicVersionLabelToString( - QuicVersionToQuicVersionLabel(version)).c_str()}}, + CreateQuicVersionLabel( + ParsedQuicVersion(PROTOCOL_QUIC_CRYPTO, version))).c_str()}}, kClientHelloMinimumSize); // clang-format on } @@ -828,7 +840,7 @@ std::string GenerateClientNonceHex(const QuicClock* clock, std::unique_ptr<CryptoHandshakeMessage> msg = crypto_config->AddConfig(primary_config, clock->WallNow()); absl::string_view orbit; - CHECK(msg->GetStringPiece(kORBT, &orbit)); + QUICHE_CHECK(msg->GetStringPiece(kORBT, &orbit)); std::string nonce; CryptoUtils::GenerateNonce(clock->WallNow(), QuicRandom::GetInstance(), orbit, &nonce); diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h b/chromium/net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h index 32d761fabe4..d839c6c84d7 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h @@ -13,10 +13,10 @@ #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/evp.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/crypto/crypto_framer.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_packets.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { @@ -147,7 +147,7 @@ void FillInDummyReject(CryptoHandshakeMessage* rej); // ParseTag returns a QuicTag from parsing |tagstr|. |tagstr| may either be // in the format "EXMP" (i.e. ASCII format), or "#11223344" (an explicit hex -// format). It CHECK fails if there's a parse error. +// format). It QUICHE_CHECK fails if there's a parse error. QuicTag ParseTag(const char* tagstr); // Message constructs a CHLO message from a provided vector of tag/value pairs. diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/crypto_test_utils_test.cc b/chromium/net/third_party/quiche/src/quic/test_tools/crypto_test_utils_test.cc index 0769da4efdd..ce45b827551 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/crypto_test_utils_test.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/crypto_test_utils_test.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/crypto_test_utils.h" #include <utility> #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/proto/crypto_server_config_proto.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.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/common/platform/api/quiche_text_utils.h" +#include "quic/core/proto/crypto_server_config_proto.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { namespace test { @@ -165,8 +165,9 @@ TEST_F(CryptoTestUtilsTest, TestGenerateFullCHLO) { {"COPT", "SREJ"}, {"PUBS", pub_hex}, {"NONC", nonce_hex}, - {"VER\0", QuicVersionLabelToString( - QuicVersionToQuicVersionLabel(transport_version))}}, + {"VER\0", + QuicVersionLabelToString(CreateQuicVersionLabel( + ParsedQuicVersion(PROTOCOL_QUIC_CRYPTO, transport_version)))}}, kClientHelloMinimumSize); crypto_test_utils::GenerateFullCHLO(inchoate_chlo, &crypto_config, diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/failing_proof_source.cc b/chromium/net/third_party/quiche/src/quic/test_tools/failing_proof_source.cc index 576791c2b46..fad128d9a39 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/failing_proof_source.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/failing_proof_source.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/failing_proof_source.h" +#include "quic/test_tools/failing_proof_source.h" #include "absl/strings/string_view.h" diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/failing_proof_source.h b/chromium/net/third_party/quiche/src/quic/test_tools/failing_proof_source.h index b63a952dc1f..4f771a33ebc 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/failing_proof_source.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/failing_proof_source.h @@ -6,7 +6,7 @@ #define QUICHE_QUIC_TEST_TOOLS_FAILING_PROOF_SOURCE_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" +#include "quic/core/crypto/proof_source.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/fake_proof_source.cc b/chromium/net/third_party/quiche/src/quic/test_tools/fake_proof_source.cc index 00af20e01e2..bc75678872f 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/fake_proof_source.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/fake_proof_source.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/fake_proof_source.h" +#include "quic/test_tools/fake_proof_source.h" #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/test_tools/crypto_test_utils.h" namespace quic { namespace test { @@ -140,7 +140,7 @@ int FakeProofSource::NumPendingCallbacks() const { } void FakeProofSource::InvokePendingCallback(int n) { - CHECK(NumPendingCallbacks() > n); + QUICHE_CHECK(NumPendingCallbacks() > n); pending_ops_[n]->Run(); diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/fake_proof_source.h b/chromium/net/third_party/quiche/src/quic/test_tools/fake_proof_source.h index fc99974c32b..077f34d074f 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/fake_proof_source.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/fake_proof_source.h @@ -10,7 +10,7 @@ #include <vector> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" +#include "quic/core/crypto/proof_source.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/fake_proof_source_handle.cc b/chromium/net/third_party/quiche/src/quic/test_tools/fake_proof_source_handle.cc new file mode 100644 index 00000000000..5bba0728949 --- /dev/null +++ b/chromium/net/third_party/quiche/src/quic/test_tools/fake_proof_source_handle.cc @@ -0,0 +1,208 @@ +// Copyright (c) 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "quic/test_tools/fake_proof_source_handle.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_bug_tracker.h" + +namespace quic { +namespace test { +namespace { + +struct QUIC_EXPORT_PRIVATE ComputeSignatureResult { + bool ok; + std::string signature; + std::unique_ptr<ProofSource::Details> details; +}; + +class QUIC_EXPORT_PRIVATE ResultSavingSignatureCallback + : public ProofSource::SignatureCallback { + public: + explicit ResultSavingSignatureCallback( + absl::optional<ComputeSignatureResult>* result) + : result_(result) { + QUICHE_DCHECK(!result_->has_value()); + } + void Run(bool ok, + std::string signature, + std::unique_ptr<ProofSource::Details> details) override { + result_->emplace( + ComputeSignatureResult{ok, std::move(signature), std::move(details)}); + } + + private: + absl::optional<ComputeSignatureResult>* result_; +}; + +ComputeSignatureResult ComputeSignatureNow( + ProofSource* delegate, + const QuicSocketAddress& server_address, + const QuicSocketAddress& client_address, + const std::string& hostname, + uint16_t signature_algorithm, + absl::string_view in) { + absl::optional<ComputeSignatureResult> result; + delegate->ComputeTlsSignature( + server_address, client_address, hostname, signature_algorithm, in, + std::make_unique<ResultSavingSignatureCallback>(&result)); + QUICHE_CHECK(result.has_value()) + << "delegate->ComputeTlsSignature must computes a " + "signature immediately"; + return std::move(result.value()); +} +} // namespace + +FakeProofSourceHandle::FakeProofSourceHandle( + ProofSource* delegate, + ProofSourceHandleCallback* callback, + Action select_cert_action, + Action compute_signature_action) + : delegate_(delegate), + callback_(callback), + select_cert_action_(select_cert_action), + compute_signature_action_(compute_signature_action) {} + +void FakeProofSourceHandle::CancelPendingOperation() { + select_cert_op_.reset(); + compute_signature_op_.reset(); +} + +QuicAsyncStatus FakeProofSourceHandle::SelectCertificate( + const QuicSocketAddress& server_address, + const QuicSocketAddress& client_address, + const std::string& hostname, + absl::string_view client_hello, + const std::string& alpn, + const std::vector<uint8_t>& quic_transport_params, + const absl::optional<std::vector<uint8_t>>& early_data_context) { + all_select_cert_args_.push_back( + SelectCertArgs(server_address, client_address, hostname, client_hello, + alpn, quic_transport_params, early_data_context)); + + if (select_cert_action_ == Action::DELEGATE_ASYNC || + select_cert_action_ == Action::FAIL_ASYNC) { + select_cert_op_.emplace(delegate_, callback_, select_cert_action_, + all_select_cert_args_.back()); + return QUIC_PENDING; + } else if (select_cert_action_ == Action::FAIL_SYNC) { + callback()->OnSelectCertificateDone(/*ok=*/false, + /*is_sync=*/true, nullptr); + return QUIC_FAILURE; + } + + QUICHE_DCHECK(select_cert_action_ == Action::DELEGATE_SYNC); + QuicReferenceCountedPointer<ProofSource::Chain> chain = + delegate_->GetCertChain(server_address, client_address, hostname); + + bool ok = chain && !chain->certs.empty(); + callback_->OnSelectCertificateDone(ok, /*is_sync=*/true, chain.get()); + return ok ? QUIC_SUCCESS : QUIC_FAILURE; +} + +QuicAsyncStatus FakeProofSourceHandle::ComputeSignature( + const QuicSocketAddress& server_address, + const QuicSocketAddress& client_address, + const std::string& hostname, + uint16_t signature_algorithm, + absl::string_view in, + size_t max_signature_size) { + all_compute_signature_args_.push_back( + ComputeSignatureArgs(server_address, client_address, hostname, + signature_algorithm, in, max_signature_size)); + + if (compute_signature_action_ == Action::DELEGATE_ASYNC || + compute_signature_action_ == Action::FAIL_ASYNC) { + compute_signature_op_.emplace(delegate_, callback_, + compute_signature_action_, + all_compute_signature_args_.back()); + return QUIC_PENDING; + } else if (compute_signature_action_ == Action::FAIL_SYNC) { + callback()->OnComputeSignatureDone(/*ok=*/false, /*is_sync=*/true, + /*signature=*/"", /*details=*/nullptr); + return QUIC_FAILURE; + } + + QUICHE_DCHECK(compute_signature_action_ == Action::DELEGATE_SYNC); + ComputeSignatureResult result = + ComputeSignatureNow(delegate_, server_address, client_address, hostname, + signature_algorithm, in); + callback_->OnComputeSignatureDone( + result.ok, /*is_sync=*/true, result.signature, std::move(result.details)); + return result.ok ? QUIC_SUCCESS : QUIC_FAILURE; +} + +ProofSourceHandleCallback* FakeProofSourceHandle::callback() { + return callback_; +} + +bool FakeProofSourceHandle::HasPendingOperation() const { + int num_pending_operations = NumPendingOperations(); + return num_pending_operations > 0; +} + +void FakeProofSourceHandle::CompletePendingOperation() { + QUICHE_DCHECK_LE(NumPendingOperations(), 1); + + if (select_cert_op_.has_value()) { + select_cert_op_->Run(); + select_cert_op_.reset(); + } else if (compute_signature_op_.has_value()) { + compute_signature_op_->Run(); + compute_signature_op_.reset(); + } +} + +int FakeProofSourceHandle::NumPendingOperations() const { + return static_cast<int>(select_cert_op_.has_value()) + + static_cast<int>(compute_signature_op_.has_value()); +} + +FakeProofSourceHandle::SelectCertOperation::SelectCertOperation( + ProofSource* delegate, + ProofSourceHandleCallback* callback, + Action action, + SelectCertArgs args) + : PendingOperation(delegate, callback, action), args_(std::move(args)) {} + +void FakeProofSourceHandle::SelectCertOperation::Run() { + if (action_ == Action::FAIL_ASYNC) { + callback_->OnSelectCertificateDone(/*ok=*/false, + /*is_sync=*/false, nullptr); + } else if (action_ == Action::DELEGATE_ASYNC) { + QuicReferenceCountedPointer<ProofSource::Chain> chain = + delegate_->GetCertChain(args_.server_address, args_.client_address, + args_.hostname); + bool ok = chain && !chain->certs.empty(); + callback_->OnSelectCertificateDone(ok, /*is_sync=*/false, chain.get()); + } else { + QUIC_BUG << "Unexpected action: " << static_cast<int>(action_); + } +} + +FakeProofSourceHandle::ComputeSignatureOperation::ComputeSignatureOperation( + ProofSource* delegate, + ProofSourceHandleCallback* callback, + Action action, + ComputeSignatureArgs args) + : PendingOperation(delegate, callback, action), args_(std::move(args)) {} + +void FakeProofSourceHandle::ComputeSignatureOperation::Run() { + if (action_ == Action::FAIL_ASYNC) { + callback_->OnComputeSignatureDone( + /*ok=*/false, /*is_sync=*/false, + /*signature=*/"", /*details=*/nullptr); + } else if (action_ == Action::DELEGATE_ASYNC) { + ComputeSignatureResult result = ComputeSignatureNow( + delegate_, args_.server_address, args_.client_address, args_.hostname, + args_.signature_algorithm, args_.in); + callback_->OnComputeSignatureDone(result.ok, /*is_sync=*/false, + result.signature, + std::move(result.details)); + } else { + QUIC_BUG << "Unexpected action: " << static_cast<int>(action_); + } +} + +} // namespace test +} // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/fake_proof_source_handle.h b/chromium/net/third_party/quiche/src/quic/test_tools/fake_proof_source_handle.h new file mode 100644 index 00000000000..9c05ba4fa66 --- /dev/null +++ b/chromium/net/third_party/quiche/src/quic/test_tools/fake_proof_source_handle.h @@ -0,0 +1,183 @@ +// Copyright (c) 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef QUICHE_QUIC_TEST_TOOLS_FAKE_PROOF_SOURCE_HANDLE_H_ +#define QUICHE_QUIC_TEST_TOOLS_FAKE_PROOF_SOURCE_HANDLE_H_ + +#include "quic/core/crypto/proof_source.h" + +namespace quic { +namespace test { + +// FakeProofSourceHandle allows its behavior to be scripted for testing. +class FakeProofSourceHandle : public ProofSourceHandle { + public: + // What would an operation return when it is called. + enum class Action { + // Delegate the operation to |delegate_| immediately. + DELEGATE_SYNC = 0, + // Handle the operation asynchronously. Delegate the operation to + // |delegate_| when the caller calls CompletePendingOperation(). + DELEGATE_ASYNC, + // Fail the operation immediately. + FAIL_SYNC, + // Handle the operation asynchronously. Fail the operation when the caller + // calls CompletePendingOperation(). + FAIL_ASYNC, + }; + + // |delegate| must do cert selection and signature synchronously. + FakeProofSourceHandle(ProofSource* delegate, + ProofSourceHandleCallback* callback, + Action select_cert_action, + Action compute_signature_action); + + ~FakeProofSourceHandle() override = default; + + void CancelPendingOperation() override; + + QuicAsyncStatus SelectCertificate( + const QuicSocketAddress& server_address, + const QuicSocketAddress& client_address, + const std::string& hostname, + absl::string_view client_hello, + const std::string& alpn, + const std::vector<uint8_t>& quic_transport_params, + const absl::optional<std::vector<uint8_t>>& early_data_context) override; + + QuicAsyncStatus ComputeSignature(const QuicSocketAddress& server_address, + const QuicSocketAddress& client_address, + const std::string& hostname, + uint16_t signature_algorithm, + absl::string_view in, + size_t max_signature_size) override; + + ProofSourceHandleCallback* callback() override; + + // Whether there's a pending operation in |this|. + bool HasPendingOperation() const; + void CompletePendingOperation(); + + struct SelectCertArgs { + SelectCertArgs(QuicSocketAddress server_address, + QuicSocketAddress client_address, + std::string hostname, + absl::string_view client_hello, + std::string alpn, + std::vector<uint8_t> quic_transport_params, + absl::optional<std::vector<uint8_t>> early_data_context) + : server_address(server_address), + client_address(client_address), + hostname(hostname), + client_hello(client_hello), + alpn(alpn), + quic_transport_params(quic_transport_params), + early_data_context(early_data_context) {} + + QuicSocketAddress server_address; + QuicSocketAddress client_address; + std::string hostname; + std::string client_hello; + std::string alpn; + std::vector<uint8_t> quic_transport_params; + absl::optional<std::vector<uint8_t>> early_data_context; + }; + + struct ComputeSignatureArgs { + ComputeSignatureArgs(QuicSocketAddress server_address, + QuicSocketAddress client_address, + std::string hostname, + uint16_t signature_algorithm, + absl::string_view in, + size_t max_signature_size) + : server_address(server_address), + client_address(client_address), + hostname(hostname), + signature_algorithm(signature_algorithm), + in(in), + max_signature_size(max_signature_size) {} + + QuicSocketAddress server_address; + QuicSocketAddress client_address; + std::string hostname; + uint16_t signature_algorithm; + std::string in; + size_t max_signature_size; + }; + + std::vector<SelectCertArgs> all_select_cert_args() const { + return all_select_cert_args_; + } + + std::vector<ComputeSignatureArgs> all_compute_signature_args() const { + return all_compute_signature_args_; + } + + private: + class PendingOperation { + public: + PendingOperation(ProofSource* delegate, + ProofSourceHandleCallback* callback, + Action action) + : delegate_(delegate), callback_(callback), action_(action) {} + virtual ~PendingOperation() = default; + virtual void Run() = 0; + + protected: + ProofSource* delegate_; + ProofSourceHandleCallback* callback_; + Action action_; + }; + + class SelectCertOperation : public PendingOperation { + public: + SelectCertOperation(ProofSource* delegate, + ProofSourceHandleCallback* callback, + Action action, + SelectCertArgs args); + + ~SelectCertOperation() override = default; + + void Run() override; + + private: + const SelectCertArgs args_; + }; + + class ComputeSignatureOperation : public PendingOperation { + public: + ComputeSignatureOperation(ProofSource* delegate, + ProofSourceHandleCallback* callback, + Action action, + ComputeSignatureArgs args); + + ~ComputeSignatureOperation() override = default; + + void Run() override; + + private: + const ComputeSignatureArgs args_; + }; + + private: + int NumPendingOperations() const; + + ProofSource* delegate_; + ProofSourceHandleCallback* callback_; + // Action for the next select cert operation. + Action select_cert_action_ = Action::DELEGATE_SYNC; + // Action for the next compute signature operation. + Action compute_signature_action_ = Action::DELEGATE_SYNC; + absl::optional<SelectCertOperation> select_cert_op_; + absl::optional<ComputeSignatureOperation> compute_signature_op_; + + // Save all the select cert and compute signature args for tests to inspect. + std::vector<SelectCertArgs> all_select_cert_args_; + std::vector<ComputeSignatureArgs> all_compute_signature_args_; +}; + +} // namespace test +} // namespace quic + +#endif // QUICHE_QUIC_TEST_TOOLS_FAKE_PROOF_SOURCE_HANDLE_H_ diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/first_flight.cc b/chromium/net/third_party/quiche/src/quic/test_tools/first_flight.cc index 665f479fb5b..435bb83b790 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/first_flight.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/first_flight.cc @@ -2,24 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/first_flight.h" +#include "quic/test_tools/first_flight.h" #include <memory> #include <vector> -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.h" -#include "net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/crypto/quic_crypto_client_config.h" +#include "quic/core/http/quic_client_push_promise_index.h" +#include "quic/core/http/quic_spdy_client_session.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_packet_writer.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/first_flight.h b/chromium/net/third_party/quiche/src/quic/test_tools/first_flight.h index ad5f792e0b9..c18c879f110 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/first_flight.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/first_flight.h @@ -8,13 +8,13 @@ #include <memory> #include <vector> -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_packet_writer.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { namespace test { @@ -37,7 +37,7 @@ class QUIC_NO_EXPORT DelegatedPacketWriter : public QuicPacketWriter { // |delegate| MUST be valid for the duration of the DelegatedPacketWriter's // lifetime. explicit DelegatedPacketWriter(Delegate* delegate) : delegate_(delegate) { - CHECK_NE(delegate_, nullptr); + QUICHE_CHECK_NE(delegate_, nullptr); } // Overrides for QuicPacketWriter. diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/limited_mtu_test_writer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/limited_mtu_test_writer.cc index bc71c7cbcf5..5bbf7f70c2c 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/limited_mtu_test_writer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/limited_mtu_test_writer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/limited_mtu_test_writer.h" +#include "quic/test_tools/limited_mtu_test_writer.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/limited_mtu_test_writer.h b/chromium/net/third_party/quiche/src/quic/test_tools/limited_mtu_test_writer.h index ff3c5e64a7f..08f659c6125 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/limited_mtu_test_writer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/limited_mtu_test_writer.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_LIMITED_MTU_TEST_WRITER_H_ #define QUICHE_QUIC_TEST_TOOLS_LIMITED_MTU_TEST_WRITER_H_ -#include "net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" +#include "quic/core/quic_packet_writer_wrapper.h" +#include "quic/core/quic_packets.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/mock_clock.cc b/chromium/net/third_party/quiche/src/quic/test_tools/mock_clock.cc index 21c080a3c4c..15af152c6df 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/mock_clock.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/mock_clock.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/mock_clock.h" +#include "quic/test_tools/mock_clock.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/mock_clock.h b/chromium/net/third_party/quiche/src/quic/test_tools/mock_clock.h index 2ce2e966a9c..2ba25a25ee4 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/mock_clock.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/mock_clock.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_MOCK_CLOCK_H_ #define QUICHE_QUIC_TEST_TOOLS_MOCK_CLOCK_H_ -#include "net/third_party/quiche/src/quic/core/quic_clock.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" +#include "quic/core/quic_clock.h" +#include "quic/core/quic_time.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_client_promised_info.cc b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_client_promised_info.cc index 5b781046d4d..717641b868e 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_client_promised_info.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_client_promised_info.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/mock_quic_client_promised_info.h" +#include "quic/test_tools/mock_quic_client_promised_info.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_client_promised_info.h b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_client_promised_info.h index f89d5797d7f..d40a647f480 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_client_promised_info.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_client_promised_info.h @@ -7,9 +7,9 @@ #include <string> -#include "net/third_party/quiche/src/quic/core/http/quic_client_promised_info.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/http/quic_client_promised_info.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_dispatcher.cc b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_dispatcher.cc index 40869e022e3..38424901ab9 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_dispatcher.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_dispatcher.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/mock_quic_dispatcher.h" +#include "quic/test_tools/mock_quic_dispatcher.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_dispatcher.h b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_dispatcher.h index 21c3dca7143..7d7bec506b9 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_dispatcher.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_dispatcher.h @@ -5,12 +5,12 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_MOCK_QUIC_DISPATCHER_H_ #define QUICHE_QUIC_TEST_TOOLS_MOCK_QUIC_DISPATCHER_H_ -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h" +#include "quic/core/crypto/quic_crypto_server_config.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_test.h" +#include "quic/tools/quic_simple_dispatcher.h" +#include "quic/tools/quic_simple_server_backend.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_session_visitor.cc b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_session_visitor.cc index fea84140e88..5c5db3e8167 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_session_visitor.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_session_visitor.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/mock_quic_session_visitor.h" +#include "quic/test_tools/mock_quic_session_visitor.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_session_visitor.h b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_session_visitor.h index 5cc8476fe5e..77b176302a3 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_session_visitor.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_session_visitor.h @@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_MOCK_QUIC_SESSION_VISITOR_H_ #define QUICHE_QUIC_TEST_TOOLS_MOCK_QUIC_SESSION_VISITOR_H_ -#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.h" -#include "net/third_party/quiche/src/quic/core/quic_time_wait_list_manager.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/quic_crypto_server_stream_base.h" +#include "quic/core/quic_time_wait_list_manager.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { @@ -35,6 +35,15 @@ class MockQuicSessionVisitor : public QuicTimeWaitListManager::Visitor { (const QuicStopSendingFrame& frame), (override)); MOCK_METHOD(void, + OnNewConnectionIdSent, + (const QuicConnectionId& server_connection_id, + const QuicConnectionId& new_connection_id), + (override)); + MOCK_METHOD(void, + OnConnectionIdRetired, + (const quic::QuicConnectionId& server_connection_id), + (override)); + MOCK_METHOD(void, OnConnectionAddedToTimeWaitList, (QuicConnectionId connection_id), (override)); diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_spdy_client_stream.cc b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_spdy_client_stream.cc index 1d6e2f9b2bc..fdaa762b32a 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_spdy_client_stream.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_spdy_client_stream.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/mock_quic_spdy_client_stream.h" +#include "quic/test_tools/mock_quic_spdy_client_stream.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_spdy_client_stream.h b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_spdy_client_stream.h index f72822ef963..491f7009f85 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_spdy_client_stream.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_spdy_client_stream.h @@ -5,10 +5,10 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_MOCK_QUIC_SPDY_CLIENT_STREAM_H_ #define QUICHE_QUIC_TEST_TOOLS_MOCK_QUIC_SPDY_CLIENT_STREAM_H_ -#include "net/third_party/quiche/src/quic/core/http/quic_header_list.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/http/quic_header_list.h" +#include "quic/core/http/quic_spdy_client_stream.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_time_wait_list_manager.cc b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_time_wait_list_manager.cc index 310a22b420f..6274f201d86 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_time_wait_list_manager.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_time_wait_list_manager.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/mock_quic_time_wait_list_manager.h" +#include "quic/test_tools/mock_quic_time_wait_list_manager.h" using testing::_; using testing::Invoke; diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_time_wait_list_manager.h b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_time_wait_list_manager.h index 24c261f744c..aadba941939 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_time_wait_list_manager.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/mock_quic_time_wait_list_manager.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_MOCK_QUIC_TIME_WAIT_LIST_MANAGER_H_ #define QUICHE_QUIC_TEST_TOOLS_MOCK_QUIC_TIME_WAIT_LIST_MANAGER_H_ -#include "net/third_party/quiche/src/quic/core/quic_time_wait_list_manager.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/quic_time_wait_list_manager.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/mock_random.cc b/chromium/net/third_party/quiche/src/quic/test_tools/mock_random.cc index a01a5a7cbfb..c50c75cf432 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/mock_random.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/mock_random.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/mock_random.h" +#include "quic/test_tools/mock_random.h" #include <string.h> @@ -21,6 +21,14 @@ uint64_t MockRandom::RandUint64() { return base_ + increment_; } +void MockRandom::InsecureRandBytes(void* data, size_t len) { + RandBytes(data, len); +} + +uint64_t MockRandom::InsecureRandUint64() { + return RandUint64(); +} + void MockRandom::ChangeValue() { increment_++; } diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/mock_random.h b/chromium/net/third_party/quiche/src/quic/test_tools/mock_random.h index d5de2267ee1..63d438d457e 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/mock_random.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/mock_random.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_MOCK_RANDOM_H_ #define QUICHE_QUIC_TEST_TOOLS_MOCK_RANDOM_H_ -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" +#include "quic/core/crypto/quic_random.h" namespace quic { namespace test { @@ -24,6 +24,11 @@ class MockRandom : public QuicRandom { // Returns base + the current increment. uint64_t RandUint64() override; + // InsecureRandBytes behaves equivalently to RandBytes. + void InsecureRandBytes(void* data, size_t len) override; + // InsecureRandUint64 behaves equivalently to RandUint64. + uint64_t InsecureRandUint64() override; + // ChangeValue increments |increment_|. This causes the value returned by // |RandUint64| and the byte that |RandBytes| fills with, to change. void ChangeValue(); diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/packet_dropping_test_writer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/packet_dropping_test_writer.cc index d840e4db3b4..35cc9785209 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/packet_dropping_test_writer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/packet_dropping_test_writer.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/packet_dropping_test_writer.h" +#include "quic/test_tools/packet_dropping_test_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/quic_epoll_connection_helper.h" +#include "quic/platform/api/quic_logging.h" namespace quic { namespace test { @@ -118,7 +118,7 @@ WriteResult PacketDroppingTestWriter::WritePacket( if (fake_blocked_socket_percentage_ > 0 && simple_random_.RandUint64() % 100 < static_cast<uint64_t>(fake_blocked_socket_percentage_)) { - CHECK(on_can_write_ != nullptr); + QUICHE_CHECK(on_can_write_ != nullptr); QUIC_DVLOG(1) << "Blocking socket for packet " << num_calls_to_write_; if (!write_unblocked_alarm_->IsSet()) { // Set the alarm to fire immediately. @@ -206,7 +206,7 @@ QuicTime PacketDroppingTestWriter::ReleaseNextPacket() { QuicPacketWriterWrapper::WritePacket( iter->buffer.data(), iter->buffer.length(), iter->self_address, iter->peer_address, iter->options.get()); - DCHECK_GE(cur_buffer_size_, iter->buffer.length()); + QUICHE_DCHECK_GE(cur_buffer_size_, iter->buffer.length()); cur_buffer_size_ -= iter->buffer.length(); delayed_packets_.erase(iter); diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/packet_dropping_test_writer.h b/chromium/net/third_party/quiche/src/quic/test_tools/packet_dropping_test_writer.h index 01a07ce1a1f..c15b5de01b5 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/packet_dropping_test_writer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/packet_dropping_test_writer.h @@ -10,11 +10,11 @@ #include <memory> #include "absl/base/attributes.h" -#include "net/third_party/quiche/src/quic/core/quic_alarm.h" -#include "net/third_party/quiche/src/quic/core/quic_clock.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_client.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/quic_alarm.h" +#include "quic/core/quic_clock.h" +#include "quic/core/quic_packet_writer_wrapper.h" +#include "quic/test_tools/quic_test_client.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { @@ -93,22 +93,22 @@ class PacketDroppingTestWriter : public QuicPacketWriterWrapper { // to WRITE_STATUS_BLOCKED. void set_fake_blocked_socket_percentage( int32_t fake_blocked_socket_percentage) { - DCHECK(clock_); + QUICHE_DCHECK(clock_); QuicWriterMutexLock lock(&config_mutex_); fake_blocked_socket_percentage_ = fake_blocked_socket_percentage; } // The percent of time a packet is simulated as being reordered. void set_fake_reorder_percentage(int32_t fake_packet_reorder_percentage) { - DCHECK(clock_); + QUICHE_DCHECK(clock_); QuicWriterMutexLock lock(&config_mutex_); - DCHECK(!fake_packet_delay_.IsZero()); + QUICHE_DCHECK(!fake_packet_delay_.IsZero()); fake_packet_reorder_percentage_ = fake_packet_reorder_percentage; } // The delay before writing this packet. void set_fake_packet_delay(QuicTime::Delta fake_packet_delay) { - DCHECK(clock_); + QUICHE_DCHECK(clock_); QuicWriterMutexLock lock(&config_mutex_); fake_packet_delay_ = fake_packet_delay; } @@ -119,7 +119,7 @@ class PacketDroppingTestWriter : public QuicPacketWriterWrapper { // dropped. void set_max_bandwidth_and_buffer_size(QuicBandwidth fake_bandwidth, QuicByteCount buffer_size) { - DCHECK(clock_); + QUICHE_DCHECK(clock_); QuicWriterMutexLock lock(&config_mutex_); fake_bandwidth_ = fake_bandwidth; buffer_size_ = buffer_size; diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/packet_reordering_writer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/packet_reordering_writer.cc index 7bbec0d3533..1b931ebbea4 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/packet_reordering_writer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/packet_reordering_writer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/packet_reordering_writer.h" +#include "quic/test_tools/packet_reordering_writer.h" namespace quic { namespace test { @@ -32,7 +32,8 @@ WriteResult PacketReorderingWriter::WritePacket( return wr; } // Still have packet to wait. - DCHECK_LT(0u, num_packets_to_wait_) << "Only allow one packet to be delayed"; + QUICHE_DCHECK_LT(0u, num_packets_to_wait_) + << "Only allow one packet to be delayed"; delayed_data_ = std::string(buffer, buf_len); delayed_self_address_ = self_address; delayed_peer_address_ = peer_address; @@ -44,7 +45,7 @@ WriteResult PacketReorderingWriter::WritePacket( } void PacketReorderingWriter::SetDelay(size_t num_packets_to_wait) { - DCHECK_GT(num_packets_to_wait, 0u); + QUICHE_DCHECK_GT(num_packets_to_wait, 0u); num_packets_to_wait_ = num_packets_to_wait; delay_next_ = true; } diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/packet_reordering_writer.h b/chromium/net/third_party/quiche/src/quic/test_tools/packet_reordering_writer.h index 31cbd80700b..2711a9f365a 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/packet_reordering_writer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/packet_reordering_writer.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_PACKET_REORDERING_WRITER_H_ #define QUICHE_QUIC_TEST_TOOLS_PACKET_REORDERING_WRITER_H_ -#include "net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.h" +#include "quic/core/quic_packet_writer_wrapper.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.cc b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.cc index 9a79515ceea..ab76c445d02 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.h" +#include "quic/test_tools/qpack/qpack_decoder_test_utils.h" #include <algorithm> #include <cstddef> #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { @@ -46,8 +46,8 @@ void TestHeadersHandler::OnDecodingErrorDetected( } spdy::Http2HeaderBlock TestHeadersHandler::ReleaseHeaderList() { - DCHECK(decoding_completed_); - DCHECK(!decoding_error_detected_); + QUICHE_DCHECK(decoding_completed_); + QUICHE_DCHECK(!decoding_error_detected_); return std::move(header_list_); } @@ -61,7 +61,7 @@ bool TestHeadersHandler::decoding_error_detected() const { } const std::string& TestHeadersHandler::error_message() const { - DCHECK(decoding_error_detected_); + QUICHE_DCHECK(decoding_error_detected_); return error_message_; } diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.h b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.h index f38bf987de9..2220bd4e37a 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.h @@ -8,11 +8,11 @@ #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" -#include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" +#include "quic/core/qpack/qpack_decoder.h" +#include "quic/core/qpack/qpack_progressive_decoder.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/qpack/qpack_test_utils.h" +#include "spdy/core/spdy_header_block.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_peer.cc index 709686a85e8..b51684fed04 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_peer.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_peer.h" +#include "quic/test_tools/qpack/qpack_encoder_peer.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder.h" +#include "quic/core/qpack/qpack_encoder.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_test_utils.cc b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_test_utils.cc index 9c8fd922ccf..20be113d8d3 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_test_utils.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_test_utils.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_test_utils.h" +#include "quic/test_tools/qpack/qpack_encoder_test_utils.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/spdy/core/hpack/hpack_encoder.h" +#include "spdy/core/hpack/hpack_encoder.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_test_utils.h b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_test_utils.h index 9d4e23e421a..ec58c3f04de 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_test_utils.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_test_utils.h @@ -8,10 +8,10 @@ #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" -#include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" +#include "quic/core/qpack/qpack_encoder.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/qpack/qpack_test_utils.h" +#include "spdy/core/spdy_header_block.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_header_table_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_header_table_peer.cc index c554a97d1ce..4dbf09617ed 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_header_table_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_header_table_peer.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_header_table_peer.h" +#include "quic/test_tools/qpack/qpack_header_table_peer.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h" +#include "quic/core/qpack/qpack_header_table.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_offline_decoder.cc b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_offline_decoder.cc index 267fad320df..6bad8d6ff65 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_offline_decoder.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_offline_decoder.cc @@ -24,7 +24,7 @@ // $TEST_QIF_DATA/netbsd.qif // -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_offline_decoder.h" +#include "quic/test_tools/qpack/qpack_offline_decoder.h" #include <cstdint> #include <string> @@ -34,12 +34,12 @@ #include "absl/strings/numbers.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_file_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_file_utils.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/test_tools/qpack/qpack_test_utils.h" +#include "common/platform/api/quiche_text_utils.h" +#include "common/quiche_endian.h" namespace quic { @@ -218,7 +218,7 @@ bool QpackOfflineDecoder::DecodeHeaderBlocksFromFile( } if (!decoders_.empty()) { - DCHECK(!decoders_.front().headers_handler->decoding_completed()); + QUICHE_DCHECK(!decoders_.front().headers_handler->decoding_completed()); QUIC_LOG(ERROR) << "Blocked decoding uncomplete after reading entire" " file, on stream " diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_offline_decoder.h b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_offline_decoder.h index eea0b064d12..11dec698478 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_offline_decoder.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_offline_decoder.h @@ -8,11 +8,11 @@ #include <list> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" -#include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" +#include "quic/core/qpack/qpack_decoder.h" +#include "quic/core/quic_error_codes.h" +#include "quic/test_tools/qpack/qpack_decoder_test_utils.h" +#include "quic/test_tools/qpack/qpack_test_utils.h" +#include "spdy/core/spdy_header_block.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.cc b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.cc index 65636d50f1d..6cd3bf0bcf1 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" +#include "quic/test_tools/qpack/qpack_test_utils.h" #include <limits> -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_bug_tracker.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h index 0d0594df945..23d54aab638 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h @@ -9,8 +9,8 @@ #include <functional> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_stream_sender_delegate.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/qpack/qpack_stream_sender_delegate.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_buffered_packet_store_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_buffered_packet_store_peer.cc index 73b9e987eef..9b3c04097ec 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_buffered_packet_store_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_buffered_packet_store_peer.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_buffered_packet_store_peer.h" +#include "quic/test_tools/quic_buffered_packet_store_peer.h" -#include "net/third_party/quiche/src/quic/core/quic_buffered_packet_store.h" +#include "quic/core/quic_buffered_packet_store.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_buffered_packet_store_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_buffered_packet_store_peer.h index 625b1eb7f96..fddac0a940e 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_buffered_packet_store_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_buffered_packet_store_peer.h @@ -7,8 +7,8 @@ #include <memory> -#include "net/third_party/quiche/src/quic/core/quic_alarm.h" -#include "net/third_party/quiche/src/quic/core/quic_clock.h" +#include "quic/core/quic_alarm.h" +#include "quic/core/quic_clock.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_client_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_client_peer.cc index c8bfa6ab022..c80a0b5e643 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_client_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_client_peer.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_client_peer.h" +#include "quic/test_tools/quic_client_peer.h" -#include "net/third_party/quiche/src/quic/tools/quic_client.h" +#include "quic/tools/quic_client.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_client_promised_info_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_client_promised_info_peer.cc index 91fec1dfb25..cf14d0f2dc0 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_client_promised_info_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_client_promised_info_peer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_client_promised_info_peer.h" +#include "quic/test_tools/quic_client_promised_info_peer.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_client_promised_info_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_client_promised_info_peer.h index 4b2e2070d0a..15ae6bb8df9 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_client_promised_info_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_client_promised_info_peer.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_CLIENT_PROMISED_INFO_PEER_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_CLIENT_PROMISED_INFO_PEER_H_ -#include "net/third_party/quiche/src/quic/core/http/quic_client_promised_info.h" +#include "quic/core/http/quic_client_promised_info.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_config_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_config_peer.cc index b10453ec399..9bd5dd3bbbf 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_config_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_config_peer.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_connection_id.h" namespace quic { namespace test { @@ -60,7 +60,7 @@ void QuicConfigPeer::SetReceivedConnectionOptions( // static void QuicConfigPeer::SetReceivedBytesForConnectionId(QuicConfig* config, uint32_t bytes) { - DCHECK(bytes == 0 || bytes == 8); + QUICHE_DCHECK(bytes == 0 || bytes == 8); config->bytes_for_connection_id_.SetReceivedValue(bytes); } @@ -138,10 +138,5 @@ void QuicConfigPeer::SetReceivedMaxDatagramFrameSize( config->max_datagram_frame_size_.SetReceivedValue(max_datagram_frame_size); } -// static -void QuicConfigPeer::DisableSupportHandshakeDone(QuicConfig* config) { - config->support_handshake_done_.SetSendValue(0); -} - } // namespace test } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_config_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_config_peer.h index 98c35a175e3..7491e7ff834 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_config_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_config_peer.h @@ -5,10 +5,10 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_CONFIG_PEER_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_CONFIG_PEER_H_ -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_uint128.h" namespace quic { @@ -79,7 +79,6 @@ class QuicConfigPeer { static void SetReceivedMaxDatagramFrameSize(QuicConfig* config, uint64_t max_datagram_frame_size); - static void DisableSupportHandshakeDone(QuicConfig* config); }; } // namespace test diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_connection_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_connection_peer.cc index 30ed4fd6914..8d4186e4312 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_connection_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_connection_peer.cc @@ -2,15 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_connection_peer.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_received_packet_manager.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_framer_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.h" +#include "quic/core/congestion_control/send_algorithm_interface.h" +#include "quic/core/quic_packet_writer.h" +#include "quic/core/quic_received_packet_manager.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/test_tools/quic_framer_peer.h" +#include "quic/test_tools/quic_sent_packet_manager_peer.h" namespace quic { namespace test { @@ -64,13 +65,13 @@ void QuicConnectionPeer::SetPerspective(QuicConnection* connection, // static void QuicConnectionPeer::SetSelfAddress(QuicConnection* connection, const QuicSocketAddress& self_address) { - connection->self_address_ = self_address; + connection->default_path_.self_address = self_address; } // static void QuicConnectionPeer::SetPeerAddress(QuicConnection* connection, const QuicSocketAddress& peer_address) { - connection->peer_address_ = peer_address; + connection->UpdatePeerAddress(peer_address); } // static @@ -84,7 +85,7 @@ void QuicConnectionPeer::SetDirectPeerAddress( void QuicConnectionPeer::SetEffectivePeerAddress( QuicConnection* connection, const QuicSocketAddress& effective_peer_address) { - connection->effective_peer_address_ = effective_peer_address; + connection->default_path_.peer_address = effective_peer_address; } // static @@ -157,6 +158,12 @@ QuicAlarm* QuicConnectionPeer::GetDiscardPreviousOneRttKeysAlarm( } // static +QuicAlarm* QuicConnectionPeer::GetDiscardZeroRttDecryptionKeysAlarm( + QuicConnection* connection) { + return connection->discard_zero_rtt_decryption_keys_alarm_.get(); +} + +// static QuicPacketWriter* QuicConnectionPeer::GetWriter(QuicConnection* connection) { return connection->writer_; } @@ -287,26 +294,23 @@ void QuicConnectionPeer::SetLastHeaderFormat(QuicConnection* connection, void QuicConnectionPeer::AddBytesReceived(QuicConnection* connection, size_t length) { if (connection->EnforceAntiAmplificationLimit()) { - connection->bytes_received_before_address_validation_ += length; + connection->default_path_.bytes_received_before_address_validation += + length; } } // static void QuicConnectionPeer::SetAddressValidated(QuicConnection* connection) { - connection->address_validated_ = true; + connection->default_path_.validated = true; } // static -void QuicConnectionPeer::SetEnableAeadLimits(QuicConnection* connection, - bool enabled) { - connection->enable_aead_limits_ = enabled; -} - -// static -void QuicConnectionPeer::SendConnectionClosePacket(QuicConnection* connection, - QuicErrorCode error, - const std::string& details) { - connection->SendConnectionClosePacket(error, details); +void QuicConnectionPeer::SendConnectionClosePacket( + QuicConnection* connection, + QuicIetfTransportErrorCodes ietf_error, + QuicErrorCode error, + const std::string& details) { + connection->SendConnectionClosePacket(error, ietf_error, details); } // static @@ -384,10 +388,9 @@ size_t QuicConnectionPeer::NumUndecryptablePackets(QuicConnection* connection) { } // static -const QuicCircularDeque<std::pair<QuicPathFrameBuffer, QuicSocketAddress>>& -QuicConnectionPeer::pending_path_challenge_payloads( +size_t QuicConnectionPeer::NumPendingPathChallengesToResponse( QuicConnection* connection) { - return connection->pending_path_challenge_payloads_; + return connection->pending_path_challenge_payloads_.size(); } void QuicConnectionPeer::SetConnectionClose(QuicConnection* connection) { @@ -399,5 +402,50 @@ void QuicConnectionPeer::SendPing(QuicConnection* connection) { connection->SendPingAtLevel(connection->encryption_level()); } +// static +void QuicConnectionPeer::SetLastPacketDestinationAddress( + QuicConnection* connection, + const QuicSocketAddress& address) { + connection->last_packet_destination_address_ = address; +} + +// static +QuicPathValidator* QuicConnectionPeer::path_validator( + QuicConnection* connection) { + return &connection->path_validator_; +} + +// static +QuicByteCount QuicConnectionPeer::BytesSentOnAlternativePath( + QuicConnection* connection) { + return connection->alternative_path_.bytes_sent_before_address_validation; +} + +// static +QuicByteCount QuicConnectionPeer::BytesReceivedOnAlternativePath( + QuicConnection* connection) { + return connection->alternative_path_.bytes_received_before_address_validation; +} + +// static +bool QuicConnectionPeer::IsAlternativePathValidated( + QuicConnection* connection) { + return connection->alternative_path_.validated; +} + +// static +bool QuicConnectionPeer::IsAlternativePath( + QuicConnection* connection, + const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address) { + return connection->IsAlternativePath(self_address, peer_address); +} + +// static +QuicByteCount QuicConnectionPeer::BytesReceivedBeforeAddressValidation( + QuicConnection* connection) { + return connection->default_path_.bytes_received_before_address_validation; +} + } // namespace test } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h index 8859a58f515..e76b5b4212b 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h @@ -5,11 +5,13 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_CONNECTION_PEER_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_CONNECTION_PEER_H_ +#include <cstddef> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_stats.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_connection_stats.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { @@ -84,6 +86,8 @@ class QuicConnectionPeer { QuicConnection* connection); static QuicAlarm* GetDiscardPreviousOneRttKeysAlarm( QuicConnection* connection); + static QuicAlarm* GetDiscardZeroRttDecryptionKeysAlarm( + QuicConnection* connection); static QuicPacketWriter* GetWriter(QuicConnection* connection); // If |owns_writer| is true, takes ownership of |writer|. @@ -124,9 +128,9 @@ class QuicConnectionPeer { PacketHeaderFormat format); static void AddBytesReceived(QuicConnection* connection, size_t length); static void SetAddressValidated(QuicConnection* connection); - static void SetEnableAeadLimits(QuicConnection* connection, bool enabled); static void SendConnectionClosePacket(QuicConnection* connection, + QuicIetfTransportErrorCodes ietf_error, QuicErrorCode error, const std::string& details); @@ -157,13 +161,30 @@ class QuicConnectionPeer { static size_t NumUndecryptablePackets(QuicConnection* connection); - static const QuicCircularDeque< - std::pair<QuicPathFrameBuffer, QuicSocketAddress>>& - pending_path_challenge_payloads(QuicConnection* connection); + static size_t NumPendingPathChallengesToResponse(QuicConnection* connection); static void SetConnectionClose(QuicConnection* connection); static void SendPing(QuicConnection* connection); + + static void SetLastPacketDestinationAddress(QuicConnection* connection, + const QuicSocketAddress& address); + + static QuicPathValidator* path_validator(QuicConnection* connection); + + static QuicByteCount BytesSentOnAlternativePath(QuicConnection* connection); + + static QuicByteCount BytesReceivedOnAlternativePath( + QuicConnection* connection); + + static bool IsAlternativePath(QuicConnection* connection, + const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address); + + static bool IsAlternativePathValidated(QuicConnection* connection); + + static QuicByteCount BytesReceivedBeforeAddressValidation( + QuicConnection* connection); }; } // namespace test diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_crypto_server_config_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_crypto_server_config_peer.cc index 64fd271a3af..f2fff70931e 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_crypto_server_config_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_crypto_server_config_peer.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_crypto_server_config_peer.h" +#include "quic/test_tools/quic_crypto_server_config_peer.h" #include "absl/strings/string_view.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" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/mock_clock.h" +#include "quic/test_tools/mock_random.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { @@ -46,9 +46,9 @@ std::string QuicCryptoServerConfigPeer::NewSourceAddressToken( QuicRandom* rand, QuicWallTime now, CachedNetworkParameters* cached_network_params) { - return server_config_->NewSourceAddressToken(*GetConfig(config_id), - previous_tokens, ip, rand, now, - cached_network_params); + return server_config_->NewSourceAddressToken( + *GetConfig(config_id)->source_address_token_boxer, previous_tokens, ip, + rand, now, cached_network_params); } HandshakeFailureReason QuicCryptoServerConfigPeer::ValidateSourceAddressTokens( @@ -59,7 +59,7 @@ HandshakeFailureReason QuicCryptoServerConfigPeer::ValidateSourceAddressTokens( CachedNetworkParameters* cached_network_params) { SourceAddressTokens tokens; HandshakeFailureReason reason = server_config_->ParseSourceAddressToken( - *GetConfig(config_id), srct, &tokens); + *GetConfig(config_id)->source_address_token_boxer, srct, &tokens); if (reason != HANDSHAKE_OK) { return reason; } @@ -75,7 +75,7 @@ QuicCryptoServerConfigPeer::ValidateSingleSourceAddressToken( QuicWallTime now) { SourceAddressTokens tokens; HandshakeFailureReason parse_status = server_config_->ParseSourceAddressToken( - *GetPrimaryConfig(), token, &tokens); + *GetPrimaryConfig()->source_address_token_boxer, token, &tokens); if (HANDSHAKE_OK != parse_status) { return parse_status; } diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_crypto_server_config_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_crypto_server_config_peer.h index 9366eae1440..a76a58642f7 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_crypto_server_config_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_crypto_server_config_peer.h @@ -6,7 +6,7 @@ #define QUICHE_QUIC_TEST_TOOLS_QUIC_CRYPTO_SERVER_CONFIG_PEER_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" +#include "quic/core/crypto/quic_crypto_server_config.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_dispatcher_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_dispatcher_peer.cc index 467c689af94..57367737d52 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_dispatcher_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_dispatcher_peer.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_dispatcher_peer.h" +#include "quic/test_tools/quic_dispatcher_peer.h" -#include "net/third_party/quiche/src/quic/core/quic_dispatcher.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.h" +#include "quic/core/quic_dispatcher.h" +#include "quic/core/quic_packet_writer_wrapper.h" namespace quic { namespace test { @@ -74,12 +74,6 @@ QuicBufferedPacketStore* QuicDispatcherPeer::GetBufferedPackets( } // static -const QuicDispatcher::SessionMap& QuicDispatcherPeer::session_map( - QuicDispatcher* dispatcher) { - return dispatcher->session_map(); -} - -// static void QuicDispatcherPeer::set_new_sessions_allowed_per_event_loop( QuicDispatcher* dispatcher, size_t num_session_allowed) { @@ -119,5 +113,35 @@ std::string QuicDispatcherPeer::SelectAlpn( return dispatcher->SelectAlpn(alpns); } +// static +QuicSession* QuicDispatcherPeer::GetFirstSessionIfAny( + QuicDispatcher* dispatcher) { + if (dispatcher->use_reference_counted_session_map()) { + if (dispatcher->reference_counted_session_map_.empty()) { + return nullptr; + } + return dispatcher->reference_counted_session_map_.begin()->second.get(); + } else { + if (dispatcher->session_map_.empty()) { + return nullptr; + } + return dispatcher->session_map_.begin()->second.get(); + } +} + +// static +const QuicSession* QuicDispatcherPeer::FindSession( + const QuicDispatcher* dispatcher, + QuicConnectionId id) { + if (dispatcher->use_reference_counted_session_map()) { + auto it = dispatcher->reference_counted_session_map_.find(id); + return (it == dispatcher->reference_counted_session_map_.end()) + ? nullptr + : it->second.get(); + } + auto it = dispatcher->session_map_.find(id); + return (it == dispatcher->session_map_.end()) ? nullptr : it->second.get(); +} + } // namespace test } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_dispatcher_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_dispatcher_peer.h index ec22f94f480..f3be472126b 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_dispatcher_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_dispatcher_peer.h @@ -5,7 +5,8 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_DISPATCHER_PEER_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_DISPATCHER_PEER_H_ -#include "net/third_party/quiche/src/quic/core/quic_dispatcher.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_dispatcher.h" namespace quic { @@ -46,9 +47,6 @@ class QuicDispatcherPeer { static QuicBufferedPacketStore* GetBufferedPackets( QuicDispatcher* dispatcher); - static const QuicDispatcher::SessionMap& session_map( - QuicDispatcher* dispatcher); - static void set_new_sessions_allowed_per_event_loop( QuicDispatcher* dispatcher, size_t num_session_allowed); @@ -69,6 +67,14 @@ class QuicDispatcherPeer { static std::string SelectAlpn(QuicDispatcher* dispatcher, const std::vector<std::string>& alpns); + + // Get the first session in the session map. Returns nullptr if the map is + // empty. + static QuicSession* GetFirstSessionIfAny(QuicDispatcher* dispatcher); + + // Find the corresponding session if exsits. + static const QuicSession* FindSession(const QuicDispatcher* dispatcher, + QuicConnectionId id); }; } // namespace test diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_flow_controller_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_flow_controller_peer.cc index 32efe459379..b0c9cbc00c1 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_flow_controller_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_flow_controller_peer.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_flow_controller_peer.h" +#include "quic/test_tools/quic_flow_controller_peer.h" #include <list> -#include "net/third_party/quiche/src/quic/core/quic_flow_controller.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" +#include "quic/core/quic_flow_controller.h" +#include "quic/core/quic_packets.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_flow_controller_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_flow_controller_peer.h index 631871ade25..0a956205e19 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_flow_controller_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_flow_controller_peer.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_FLOW_CONTROLLER_PEER_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_FLOW_CONTROLLER_PEER_H_ -#include "net/third_party/quiche/src/quic/core/quic_packets.h" +#include "quic/core/quic_packets.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_framer_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_framer_peer.cc index cc94232f50d..14cc59418f5 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_framer_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_framer_peer.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_framer_peer.h" +#include "quic/test_tools/quic_framer_peer.h" -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_map_util.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_framer_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_framer_peer.h index fdfa0df5450..091a7d4bd18 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_framer_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_framer_peer.h @@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_FRAMER_PEER_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_FRAMER_PEER_H_ -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_packets.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_interval_deque_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_interval_deque_peer.h index e9a99ba02fc..de336e9f04b 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_interval_deque_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_interval_deque_peer.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_INTERVAL_DEQUE_PEER_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_INTERVAL_DEQUE_PEER_H_ -#include "net/third_party/quiche/src/quic/core/quic_interval_deque.h" +#include "quic/core/quic_interval_deque.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_mock_syscall_wrapper.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_mock_syscall_wrapper.cc index 3cce97eed80..743d5c3d672 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_mock_syscall_wrapper.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_mock_syscall_wrapper.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_mock_syscall_wrapper.h" +#include "quic/test_tools/quic_mock_syscall_wrapper.h" using testing::_; using testing::Invoke; diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_mock_syscall_wrapper.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_mock_syscall_wrapper.h index 8dac5ad00c9..681d1bcdf9b 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_mock_syscall_wrapper.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_mock_syscall_wrapper.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_PLATFORM_IMPL_QUIC_MOCK_SYSCALL_WRAPPER_H_ #define QUICHE_QUIC_PLATFORM_IMPL_QUIC_MOCK_SYSCALL_WRAPPER_H_ -#include "net/third_party/quiche/src/quic/core/quic_syscall_wrapper.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/core/quic_syscall_wrapper.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_packet_creator_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_packet_creator_peer.cc index f94620bd5d5..0caf2635be7 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_packet_creator_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_packet_creator_peer.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_packet_creator_peer.h" +#include "quic/test_tools/quic_packet_creator_peer.h" -#include "net/third_party/quiche/src/quic/core/frames/quic_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_creator.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/frames/quic_frame.h" +#include "quic/core/quic_packet_creator.h" +#include "quic/core/quic_types.h" namespace quic { namespace test { @@ -30,7 +30,7 @@ void QuicPacketCreatorPeer::SetSendVersionInPacket( creator->packet_.encryption_level = ENCRYPTION_FORWARD_SECURE; return; } - DCHECK(creator->packet_.encryption_level < ENCRYPTION_FORWARD_SECURE); + QUICHE_DCHECK(creator->packet_.encryption_level < ENCRYPTION_FORWARD_SECURE); } // static @@ -60,7 +60,7 @@ QuicVariableLengthIntegerLength QuicPacketCreatorPeer::GetLengthLength( void QuicPacketCreatorPeer::SetPacketNumber(QuicPacketCreator* creator, uint64_t s) { - DCHECK_NE(0u, s); + QUICHE_DCHECK_NE(0u, s); creator->packet_.packet_number = QuicPacketNumber(s); } @@ -105,15 +105,15 @@ SerializedPacket QuicPacketCreatorPeer::SerializeAllFrames( const QuicFrames& frames, char* buffer, size_t buffer_len) { - DCHECK(creator->queued_frames_.empty()); - DCHECK(!frames.empty()); + QUICHE_DCHECK(creator->queued_frames_.empty()); + QUICHE_DCHECK(!frames.empty()); for (const QuicFrame& frame : frames) { bool success = creator->AddFrame(frame, NOT_RETRANSMISSION); - DCHECK(success); + QUICHE_DCHECK(success); } const bool success = creator->SerializePacket( QuicOwnedPacketBuffer(buffer, nullptr), buffer_len); - DCHECK(success); + QUICHE_DCHECK(success); SerializedPacket packet = std::move(creator->packet_); // The caller takes ownership of the QuicEncryptedPacket. creator->packet_.encrypted_buffer = nullptr; @@ -131,7 +131,7 @@ QuicPacketCreatorPeer::SerializeConnectivityProbingPacket( std::unique_ptr<SerializedPacket> QuicPacketCreatorPeer::SerializePathChallengeConnectivityProbingPacket( QuicPacketCreator* creator, - QuicPathFrameBuffer* payload) { + const QuicPathFrameBuffer& payload) { return creator->SerializePathChallengeConnectivityProbingPacket(payload); } diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_packet_creator_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_packet_creator_peer.h index 2dc941388a0..12f00867244 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_packet_creator_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_packet_creator_peer.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_PACKET_CREATOR_PEER_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_PACKET_CREATOR_PEER_H_ -#include "net/third_party/quiche/src/quic/core/quic_packets.h" +#include "quic/core/quic_packets.h" namespace quic { class QuicFramer; @@ -53,8 +53,9 @@ class QuicPacketCreatorPeer { static std::unique_ptr<SerializedPacket> SerializeConnectivityProbingPacket( QuicPacketCreator* creator); static std::unique_ptr<SerializedPacket> - SerializePathChallengeConnectivityProbingPacket(QuicPacketCreator* creator, - QuicPathFrameBuffer* payload); + SerializePathChallengeConnectivityProbingPacket( + QuicPacketCreator* creator, + const QuicPathFrameBuffer& payload); static EncryptionLevel GetEncryptionLevel(QuicPacketCreator* creator); static QuicFramer* framer(QuicPacketCreator* creator); diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_path_validator_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_path_validator_peer.cc index 54d97d02527..901ca543436 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_path_validator_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_path_validator_peer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_path_validator_peer.h" +#include "quic/test_tools/quic_path_validator_peer.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_path_validator_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_path_validator_peer.h index 5b2b56c7e63..2495cd373d5 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_path_validator_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_path_validator_peer.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_PATH_VALIDATOR_PEER_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_PATH_VALIDATOR_PEER_H_ -#include "net/third_party/quiche/src/quic/core/quic_path_validator.h" +#include "quic/core/quic_path_validator.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.cc index f83189824d7..07899463fff 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.h" +#include "quic/test_tools/quic_sent_packet_manager_peer.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/loss_detection_interface.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_sent_packet_manager.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_unacked_packet_map_peer.h" +#include "quic/core/congestion_control/loss_detection_interface.h" +#include "quic/core/congestion_control/send_algorithm_interface.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_sent_packet_manager.h" +#include "quic/test_tools/quic_unacked_packet_map_peer.h" namespace quic { namespace test { @@ -82,7 +82,7 @@ RttStats* QuicSentPacketManagerPeer::GetRttStats( bool QuicSentPacketManagerPeer::IsRetransmission( QuicSentPacketManager* sent_packet_manager, uint64_t packet_number) { - DCHECK(HasRetransmittableFrames(sent_packet_manager, packet_number)); + QUICHE_DCHECK(HasRetransmittableFrames(sent_packet_manager, packet_number)); if (!HasRetransmittableFrames(sent_packet_manager, packet_number)) { return false; } diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.h index d57c499c5a8..23a866413d5 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_SENT_PACKET_MANAGER_PEER_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_SENT_PACKET_MANAGER_PEER_H_ -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_sent_packet_manager.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_sent_packet_manager.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_server_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_server_peer.cc index 9e8d9620d72..925f8516772 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_server_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_server_peer.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_server_peer.h" +#include "quic/test_tools/quic_server_peer.h" -#include "net/third_party/quiche/src/quic/core/quic_dispatcher.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_reader.h" -#include "net/third_party/quiche/src/quic/tools/quic_server.h" +#include "quic/core/quic_dispatcher.h" +#include "quic/core/quic_packet_reader.h" +#include "quic/tools/quic_server.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_server_session_base_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_server_session_base_peer.h index a4feefebbe7..d644c8224f5 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_server_session_base_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_server_session_base_peer.h @@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_SERVER_SESSION_BASE_PEER_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_SERVER_SESSION_BASE_PEER_H_ -#include "net/third_party/quiche/src/quic/core/http/quic_server_session_base.h" +#include "quic/core/http/quic_server_session_base.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" +#include "quic/core/quic_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_session_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_session_peer.cc index a57840e2157..4a8c8ca4094 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_session_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_session_peer.cc @@ -2,12 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_session_peer.h" +#include "quic/test_tools/quic_session_peer.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" +#include "absl/container/flat_hash_map.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_stream.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_map_util.h" namespace quic { namespace test { @@ -53,7 +54,7 @@ void QuicSessionPeer::SetMaxOpenIncomingStreams(QuicSession* session, void QuicSessionPeer::SetMaxOpenIncomingBidirectionalStreams( QuicSession* session, uint32_t max_streams) { - DCHECK(VersionHasIetfQuicFrames(session->transport_version())) + QUICHE_DCHECK(VersionHasIetfQuicFrames(session->transport_version())) << "SetmaxOpenIncomingBidirectionalStreams not supported for Google " "QUIC"; session->ietf_streamid_manager_.SetMaxOpenIncomingBidirectionalStreams( @@ -63,7 +64,7 @@ void QuicSessionPeer::SetMaxOpenIncomingBidirectionalStreams( void QuicSessionPeer::SetMaxOpenIncomingUnidirectionalStreams( QuicSession* session, uint32_t max_streams) { - DCHECK(VersionHasIetfQuicFrames(session->transport_version())) + QUICHE_DCHECK(VersionHasIetfQuicFrames(session->transport_version())) << "SetmaxOpenIncomingUnidirectionalStreams not supported for Google " "QUIC"; session->ietf_streamid_manager_.SetMaxOpenIncomingUnidirectionalStreams( @@ -84,7 +85,7 @@ void QuicSessionPeer::SetMaxOpenOutgoingStreams(QuicSession* session, void QuicSessionPeer::SetMaxOpenOutgoingBidirectionalStreams( QuicSession* session, uint32_t max_streams) { - DCHECK(VersionHasIetfQuicFrames(session->transport_version())) + QUICHE_DCHECK(VersionHasIetfQuicFrames(session->transport_version())) << "SetmaxOpenOutgoingBidirectionalStreams not supported for Google " "QUIC"; session->ietf_streamid_manager_.MaybeAllowNewOutgoingBidirectionalStreams( @@ -94,7 +95,7 @@ void QuicSessionPeer::SetMaxOpenOutgoingBidirectionalStreams( void QuicSessionPeer::SetMaxOpenOutgoingUnidirectionalStreams( QuicSession* session, uint32_t max_streams) { - DCHECK(VersionHasIetfQuicFrames(session->transport_version())) + QUICHE_DCHECK(VersionHasIetfQuicFrames(session->transport_version())) << "SetmaxOpenOutgoingUnidirectionalStreams not supported for Google " "QUIC"; session->ietf_streamid_manager_.MaybeAllowNewOutgoingUnidirectionalStreams( @@ -120,14 +121,14 @@ QuicStream* QuicSessionPeer::GetOrCreateStream(QuicSession* session, } // static -QuicHashMap<QuicStreamId, QuicStreamOffset>& +absl::flat_hash_map<QuicStreamId, QuicStreamOffset>& QuicSessionPeer::GetLocallyClosedStreamsHighestOffset(QuicSession* session) { return session->locally_closed_streams_highest_offset_; } // static QuicSession::StreamMap& QuicSessionPeer::stream_map(QuicSession* session) { - return session->stream_map(); + return session->stream_map_; } // static @@ -149,7 +150,7 @@ bool QuicSessionPeer::IsStreamClosed(QuicSession* session, QuicStreamId id) { // static bool QuicSessionPeer::IsStreamCreated(QuicSession* session, QuicStreamId id) { - return QuicContainsKey(session->stream_map(), id); + return QuicContainsKey(session->stream_map_, id); } // static diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_session_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_session_peer.h index fdcb4431ff6..94f0bf53799 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_session_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_session_peer.h @@ -9,10 +9,11 @@ #include <map> #include <memory> -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/quic_write_blocked_list.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" +#include "absl/container/flat_hash_map.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_session.h" +#include "quic/core/quic_write_blocked_list.h" +#include "quic/platform/api/quic_containers.h" namespace quic { @@ -54,7 +55,7 @@ class QuicSessionPeer { static QuicWriteBlockedList* GetWriteBlockedStreams(QuicSession* session); static QuicStream* GetOrCreateStream(QuicSession* session, QuicStreamId stream_id); - static QuicHashMap<QuicStreamId, QuicStreamOffset>& + static absl::flat_hash_map<QuicStreamId, QuicStreamOffset>& GetLocallyClosedStreamsHighestOffset(QuicSession* session); static QuicSession::StreamMap& stream_map(QuicSession* session); static const QuicSession::ClosedStreams& closed_streams(QuicSession* session); diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.cc index 4730ef99e02..58eedcc0106 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.cc @@ -2,11 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" +#include "quic/test_tools/quic_spdy_session_peer.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_session.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" +#include "quic/core/http/quic_spdy_session.h" +#include "quic/core/qpack/qpack_receive_stream.h" +#include "quic/core/quic_utils.h" +#include "quic/test_tools/quic_session_peer.h" namespace quic { namespace test { @@ -14,14 +15,14 @@ namespace test { // static QuicHeadersStream* QuicSpdySessionPeer::GetHeadersStream( QuicSpdySession* session) { - DCHECK(!VersionUsesHttp3(session->transport_version())); + QUICHE_DCHECK(!VersionUsesHttp3(session->transport_version())); return session->headers_stream(); } void QuicSpdySessionPeer::SetHeadersStream(QuicSpdySession* session, QuicHeadersStream* headers_stream) { - DCHECK(!VersionUsesHttp3(session->transport_version())); - for (auto& it : session->stream_map()) { + QUICHE_DCHECK(!VersionUsesHttp3(session->transport_version())); + for (auto& it : QuicSessionPeer::stream_map(session)) { if (it.first == QuicUtils::GetHeadersStreamId(session->transport_version())) { it.second.reset(headers_stream); diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h index 87eda44c0db..c0413c6a1b7 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h @@ -5,13 +5,13 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_SPDY_SESSION_PEER_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_SPDY_SESSION_PEER_H_ -#include "net/third_party/quiche/src/quic/core/http/quic_receive_control_stream.h" -#include "net/third_party/quiche/src/quic/core/http/quic_send_control_stream.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.h" -#include "net/third_party/quiche/src/quic/core/qpack/qpack_send_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_write_blocked_list.h" -#include "net/third_party/quiche/src/spdy/core/spdy_framer.h" +#include "quic/core/http/quic_receive_control_stream.h" +#include "quic/core/http/quic_send_control_stream.h" +#include "quic/core/qpack/qpack_receive_stream.h" +#include "quic/core/qpack/qpack_send_stream.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_write_blocked_list.h" +#include "spdy/core/spdy_framer.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_spdy_stream_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_spdy_stream_peer.cc index d7926bb6853..896a5b0c764 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_spdy_stream_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_spdy_stream_peer.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_stream_peer.h" +#include "quic/test_tools/quic_spdy_stream_peer.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_stream.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/http/quic_spdy_stream.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_spdy_stream_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_spdy_stream_peer.h index 9a216715c95..0f0433851a3 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_spdy_stream_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_spdy_stream_peer.h @@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_SPDY_STREAM_PEER_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_SPDY_STREAM_PEER_H_ -#include "net/third_party/quiche/src/quic/core/quic_ack_listener_interface.h" -#include "net/third_party/quiche/src/quic/core/quic_interval_set.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" +#include "quic/core/quic_ack_listener_interface.h" +#include "quic/core/quic_interval_set.h" +#include "quic/platform/api/quic_containers.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_id_manager_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_id_manager_peer.cc index 6c08ecea5ed..c8662a1e969 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_id_manager_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_id_manager_peer.cc @@ -1,13 +1,13 @@ // Copyright (c) 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_id_manager_peer.h" +#include "quic/test_tools/quic_stream_id_manager_peer.h" -#include "net/third_party/quiche/src/quic/core/quic_stream_id_manager.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/uber_quic_stream_id_manager.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/quic_stream_id_manager.h" +#include "quic/core/quic_utils.h" +#include "quic/core/uber_quic_stream_id_manager.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_logging.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_id_manager_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_id_manager_peer.h index 4c975121310..7c7359f935e 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_id_manager_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_id_manager_peer.h @@ -6,7 +6,7 @@ #include <stddef.h> -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/quic_types.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_peer.cc index aaf4bc3a792..c596d79be45 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_peer.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h" +#include "quic/test_tools/quic_stream_peer.h" #include <list> -#include "net/third_party/quiche/src/quic/core/quic_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_flow_controller_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_send_buffer_peer.h" +#include "quic/core/quic_stream.h" +#include "quic/core/quic_types.h" +#include "quic/test_tools/quic_flow_controller_peer.h" +#include "quic/test_tools/quic_stream_send_buffer_peer.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h index 8d9a136f7e5..963570cc6af 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h @@ -7,10 +7,10 @@ #include <cstdint> -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_stream_send_buffer.h" -#include "net/third_party/quiche/src/quic/core/quic_stream_sequencer.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_stream_send_buffer.h" +#include "quic/core/quic_stream_sequencer.h" +#include "quic/core/quic_types.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_send_buffer_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_send_buffer_peer.cc index 7257915ec2f..528ff16fe23 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_send_buffer_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_send_buffer_peer.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_send_buffer_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_interval_deque_peer.h" +#include "quic/test_tools/quic_stream_send_buffer_peer.h" +#include "quic/test_tools/quic_interval_deque_peer.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_send_buffer_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_send_buffer_peer.h index 310cda91921..0f234c0df37 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_send_buffer_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_send_buffer_peer.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_STREAM_SEND_BUFFER_PEER_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_STREAM_SEND_BUFFER_PEER_H_ -#include "net/third_party/quiche/src/quic/core/quic_stream_send_buffer.h" +#include "quic/core/quic_stream_send_buffer.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_buffer_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_buffer_peer.cc index 8f5553ac9dd..01ada82a741 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_buffer_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_buffer_peer.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_buffer_peer.h" +#include "quic/test_tools/quic_stream_sequencer_buffer_peer.h" #include <cstddef> -#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_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" using BufferBlock = quic::QuicStreamSequencerBuffer::BufferBlock; diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_buffer_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_buffer_peer.h index 4cac6f10dd8..b07f1f50bd5 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_buffer_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_buffer_peer.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_STREAM_SEQUENCER_BUFFER_PEER_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_STREAM_SEQUENCER_BUFFER_PEER_H_ -#include "net/third_party/quiche/src/quic/core/quic_stream_sequencer_buffer.h" +#include "quic/core/quic_stream_sequencer_buffer.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_peer.cc index 05cf35cdf5d..497b290c453 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_peer.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_peer.h" +#include "quic/test_tools/quic_stream_sequencer_peer.h" -#include "net/third_party/quiche/src/quic/core/quic_stream_sequencer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_buffer_peer.h" +#include "quic/core/quic_stream_sequencer.h" +#include "quic/test_tools/quic_stream_sequencer_buffer_peer.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_peer.h index d358995bc0e..c36b77fd59a 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_stream_sequencer_peer.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_STREAM_SEQUENCER_PEER_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_STREAM_SEQUENCER_PEER_H_ -#include "net/third_party/quiche/src/quic/core/quic_packets.h" +#include "quic/core/quic_packets.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_sustained_bandwidth_recorder_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_sustained_bandwidth_recorder_peer.cc index 9f08faf00e7..86206c64b48 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_sustained_bandwidth_recorder_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_sustained_bandwidth_recorder_peer.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_sustained_bandwidth_recorder_peer.h" +#include "quic/test_tools/quic_sustained_bandwidth_recorder_peer.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_sustained_bandwidth_recorder.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_sustained_bandwidth_recorder.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_sustained_bandwidth_recorder_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_sustained_bandwidth_recorder_peer.h index 24c0df27a8a..e1280353b61 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_sustained_bandwidth_recorder_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_sustained_bandwidth_recorder_peer.h @@ -7,7 +7,7 @@ #include <cstdint> -#include "net/third_party/quiche/src/quic/core/quic_packets.h" +#include "quic/core/quic_packets.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_client.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_client.cc index 5b93de5f64f..41339508501 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_client.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_client.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_test_client.h" +#include "quic/test_tools/quic_test_client.h" #include <memory> #include <utility> @@ -11,25 +11,25 @@ #include "absl/strings/match.h" #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/x509.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_verifier.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_writer_wrapper.h" -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#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_ptr_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_stack_trace.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_client_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_stream_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/tools/quic_url.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/proof_verifier.h" +#include "quic/core/http/quic_spdy_client_stream.h" +#include "quic/core/http/spdy_utils.h" +#include "quic/core/quic_epoll_connection_helper.h" +#include "quic/core/quic_packet_writer_wrapper.h" +#include "quic/core/quic_server_id.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/platform/api/quic_stack_trace.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/quic_client_peer.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_spdy_session_peer.h" +#include "quic/test_tools/quic_spdy_stream_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/tools/quic_url.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { namespace test { @@ -164,12 +164,12 @@ class MockableQuicClientEpollNetworkHelper } void UseWriter(QuicPacketWriterWrapper* writer) { - CHECK(test_writer_ == nullptr); + QUICHE_CHECK(test_writer_ == nullptr); test_writer_ = writer; } void set_peer_address(const QuicSocketAddress& address) { - CHECK(test_writer_ != nullptr); + QUICHE_CHECK(test_writer_ != nullptr); test_writer_->set_peer_address(address); } @@ -658,7 +658,9 @@ void QuicTestClient::ResetConnection() { void QuicTestClient::Disconnect() { ClearPerConnectionState(); - client_->Disconnect(); + if (client_->initialized()) { + client_->Disconnect(); + } connect_attempted_ = false; } @@ -832,24 +834,24 @@ void QuicTestClient::UseWriter(QuicPacketWriterWrapper* writer) { } void QuicTestClient::UseConnectionId(QuicConnectionId server_connection_id) { - DCHECK(!connected()); + QUICHE_DCHECK(!connected()); client_->UseConnectionId(server_connection_id); } void QuicTestClient::UseConnectionIdLength(int server_connection_id_length) { - DCHECK(!connected()); + QUICHE_DCHECK(!connected()); client_->UseConnectionIdLength(server_connection_id_length); } void QuicTestClient::UseClientConnectionId( QuicConnectionId client_connection_id) { - DCHECK(!connected()); + QUICHE_DCHECK(!connected()); client_->UseClientConnectionId(client_connection_id); } void QuicTestClient::UseClientConnectionIdLength( int client_connection_id_length) { - DCHECK(!connected()); + QUICHE_DCHECK(!connected()); client_->UseClientConnectionIdLength(client_connection_id_length); } diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_client.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_client.h index b4d8f467c51..d764ca9d2a5 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_client.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_client.h @@ -10,15 +10,15 @@ #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/proto/cached_network_parameters_proto.h" -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_creator.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_epoll.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/tools/quic_client.h" +#include "quic/core/proto/cached_network_parameters_proto.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_packet_creator.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_epoll.h" +#include "quic/platform/api/quic_map_util.h" +#include "quic/platform/api/quic_test.h" +#include "quic/tools/quic_client.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_server.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_server.cc index c69ec29f48c..55170b20d6d 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_server.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_server.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_test_server.h" +#include "quic/test_tools/quic_test_server.h" #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_crypto_server_stream_helper.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_session.h" +#include "quic/core/quic_epoll_alarm_factory.h" +#include "quic/core/quic_epoll_connection_helper.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/tools/quic_simple_crypto_server_stream_helper.h" +#include "quic/tools/quic_simple_dispatcher.h" +#include "quic/tools/quic_simple_server_session.h" namespace quic { @@ -127,23 +127,23 @@ class QuicTestDispatcher : public QuicSimpleDispatcher { void SetSessionFactory(QuicTestServer::SessionFactory* factory) { QuicWriterMutexLock lock(&factory_lock_); - DCHECK(session_factory_ == nullptr); - DCHECK(stream_factory_ == nullptr); - DCHECK(crypto_stream_factory_ == nullptr); + QUICHE_DCHECK(session_factory_ == nullptr); + QUICHE_DCHECK(stream_factory_ == nullptr); + QUICHE_DCHECK(crypto_stream_factory_ == nullptr); session_factory_ = factory; } void SetStreamFactory(QuicTestServer::StreamFactory* factory) { QuicWriterMutexLock lock(&factory_lock_); - DCHECK(session_factory_ == nullptr); - DCHECK(stream_factory_ == nullptr); + QUICHE_DCHECK(session_factory_ == nullptr); + QUICHE_DCHECK(stream_factory_ == nullptr); stream_factory_ = factory; } void SetCryptoStreamFactory(QuicTestServer::CryptoStreamFactory* factory) { QuicWriterMutexLock lock(&factory_lock_); - DCHECK(session_factory_ == nullptr); - DCHECK(crypto_stream_factory_ == nullptr); + QUICHE_DCHECK(session_factory_ == nullptr); + QUICHE_DCHECK(crypto_stream_factory_ == nullptr); crypto_stream_factory_ = factory; } @@ -195,7 +195,7 @@ QuicDispatcher* QuicTestServer::CreateQuicDispatcher() { } void QuicTestServer::SetSessionFactory(SessionFactory* factory) { - DCHECK(dispatcher()); + QUICHE_DCHECK(dispatcher()); static_cast<QuicTestDispatcher*>(dispatcher())->SetSessionFactory(factory); } @@ -229,7 +229,7 @@ ImmediateGoAwaySession::ImmediateGoAwaySession( void ImmediateGoAwaySession::OnStreamFrame(const QuicStreamFrame& frame) { if (VersionUsesHttp3(transport_version())) { - SendHttp3GoAway(); + SendHttp3GoAway(QUIC_PEER_GOING_AWAY, ""); } else { SendGoAway(QUIC_PEER_GOING_AWAY, ""); } @@ -253,7 +253,7 @@ void ImmediateGoAwaySession::OnNewEncryptionKeyAvailable( std::move(encrypter)); if (VersionUsesHttp3(transport_version())) { if (IsEncryptionEstablished() && !goaway_sent()) { - SendHttp3GoAway(); + SendHttp3GoAway(QUIC_PEER_GOING_AWAY, ""); } } } diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_server.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_server.h index 2fa3e2077e9..4fd2ce66660 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_server.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_server.h @@ -5,12 +5,12 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_TEST_SERVER_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_TEST_SERVER_H_ -#include "net/third_party/quiche/src/quic/core/quic_dispatcher.h" -#include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/tools/quic_server.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_session.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_stream.h" +#include "quic/core/quic_dispatcher.h" +#include "quic/core/quic_session.h" +#include "quic/tools/quic_server.h" +#include "quic/tools/quic_simple_server_backend.h" +#include "quic/tools/quic_simple_server_session.h" +#include "quic/tools/quic_simple_server_stream.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_utils.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_utils.cc index 8bf49d97be3..035680cf602 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_utils.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_utils.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/quic_test_utils.h" #include <algorithm> #include <cstdint> @@ -13,31 +13,31 @@ #include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/chacha.h" #include "third_party/boringssl/src/include/openssl/sha.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_framer.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h" -#include "net/third_party/quiche/src/quic/core/quic_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_creator.h" -#include "net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_error_code_wrappers.h" -#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/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/common/quiche_endian.h" -#include "net/third_party/quiche/src/spdy/core/spdy_frame_builder.h" +#include "quic/core/crypto/crypto_framer.h" +#include "quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/crypto_utils.h" +#include "quic/core/crypto/null_decrypter.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/core/http/quic_spdy_client_session.h" +#include "quic/core/quic_buffer_allocator.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_data_writer.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_packet_creator.h" +#include "quic/core/quic_simple_buffer_allocator.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_error_code_wrappers.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "common/quiche_endian.h" +#include "spdy/core/spdy_frame_builder.h" using testing::_; using testing::Invoke; @@ -71,7 +71,7 @@ QuicConnectionId TestConnectionIdNineBytesLong(uint64_t connection_number) { } uint64_t TestConnectionIdToUInt64(QuicConnectionId connection_id) { - DCHECK_EQ(connection_id.length(), kQuicDefaultConnectionIdLength); + QUICHE_DCHECK_EQ(connection_id.length(), kQuicDefaultConnectionIdLength); uint64_t connection_id64_net = 0; memcpy(&connection_id64_net, connection_id.data(), std::min<size_t>(static_cast<size_t>(connection_id.length()), @@ -97,13 +97,13 @@ QuicServerId TestServerId() { } QuicAckFrame InitAckFrame(const std::vector<QuicAckBlock>& ack_blocks) { - DCHECK_GT(ack_blocks.size(), 0u); + QUICHE_DCHECK_GT(ack_blocks.size(), 0u); QuicAckFrame ack; QuicPacketNumber end_of_previous_block(1); for (const QuicAckBlock& block : ack_blocks) { - DCHECK_GE(block.start, end_of_previous_block); - DCHECK_GT(block.limit, block.start); + QUICHE_DCHECK_GE(block.start, end_of_previous_block); + QUICHE_DCHECK_GT(block.limit, block.start); ack.packets.AddRange(block.start, block.limit); end_of_previous_block = block.limit; } @@ -170,13 +170,13 @@ std::unique_ptr<QuicPacket> BuildUnsizedDataPacket( framer->GetMaxPlaintextSize(kMaxOutgoingPacketSize); size_t packet_size = GetPacketHeaderSize(framer->transport_version(), header); for (size_t i = 0; i < frames.size(); ++i) { - DCHECK_LE(packet_size, max_plaintext_size); + QUICHE_DCHECK_LE(packet_size, max_plaintext_size); bool first_frame = i == 0; bool last_frame = i == frames.size() - 1; const size_t frame_size = framer->GetSerializedFrameLength( frames[i], max_plaintext_size - packet_size, first_frame, last_frame, header.packet_number_length); - DCHECK(frame_size); + QUICHE_DCHECK(frame_size); packet_size += frame_size; } return BuildUnsizedDataPacket(framer, header, frames, packet_size); @@ -191,7 +191,7 @@ std::unique_ptr<QuicPacket> BuildUnsizedDataPacket( EncryptionLevel level = HeaderToEncryptionLevel(header); size_t length = framer->BuildDataPacket(header, frames, buffer, packet_size, level); - DCHECK_NE(0u, length); + QUICHE_DCHECK_NE(0u, length); // Re-construct the data packet with data ownership. return std::make_unique<QuicPacket>( buffer, length, /* owns_buffer */ true, @@ -241,6 +241,14 @@ void SimpleRandom::RandBytes(void* data, size_t len) { } } +void SimpleRandom::InsecureRandBytes(void* data, size_t len) { + RandBytes(data, len); +} + +uint64_t SimpleRandom::InsecureRandUint64() { + return RandUint64(); +} + void SimpleRandom::FillBuffer() { uint8_t nonce[12]; memcpy(nonce, buffer_, sizeof(nonce)); @@ -638,11 +646,11 @@ QuicConsumedData MockQuicSession::ConsumeData( if (write_length > 0) { auto buf = std::make_unique<char[]>(write_length); QuicStream* stream = GetOrCreateStream(id); - DCHECK(stream); + QUICHE_DCHECK(stream); QuicDataWriter writer(write_length, buf.get(), quiche::HOST_BYTE_ORDER); stream->WriteStreamData(offset, write_length, &writer); } else { - DCHECK(state != NO_FIN); + QUICHE_DCHECK(state != NO_FIN); } return QuicConsumedData(write_length, state != NO_FIN); } @@ -727,11 +735,11 @@ QuicConsumedData MockQuicSpdySession::ConsumeData( if (write_length > 0) { auto buf = std::make_unique<char[]>(write_length); QuicStream* stream = GetOrCreateStream(id); - DCHECK(stream); + QUICHE_DCHECK(stream); QuicDataWriter writer(write_length, buf.get(), quiche::HOST_BYTE_ORDER); stream->WriteStreamData(offset, write_length, &writer); } else { - DCHECK(state != NO_FIN); + QUICHE_DCHECK(state != NO_FIN); } return QuicConsumedData(write_length, state != NO_FIN); } @@ -1208,10 +1216,10 @@ void CreateClientSessionForTest( QuicCryptoClientConfig* crypto_client_config, PacketSavingConnection** client_connection, TestQuicSpdyClientSession** client_session) { - CHECK(crypto_client_config); - CHECK(client_connection); - CHECK(client_session); - CHECK(!connection_start_time.IsZero()) + QUICHE_CHECK(crypto_client_config); + QUICHE_CHECK(client_connection); + QUICHE_CHECK(client_session); + QUICHE_CHECK(!connection_start_time.IsZero()) << "Connections must start at non-zero times, otherwise the " << "strike-register will be unhappy."; @@ -1234,10 +1242,10 @@ void CreateServerSessionForTest( QuicCompressedCertsCache* compressed_certs_cache, PacketSavingConnection** server_connection, TestQuicSpdyServerSession** server_session) { - CHECK(server_crypto_config); - CHECK(server_connection); - CHECK(server_session); - CHECK(!connection_start_time.IsZero()) + QUICHE_CHECK(server_crypto_config); + QUICHE_CHECK(server_connection); + QUICHE_CHECK(server_session); + QUICHE_CHECK(!connection_start_time.IsZero()) << "Connections must start at non-zero times, otherwise the " << "strike-register will be unhappy."; @@ -1465,7 +1473,7 @@ WriteResult TestPacketWriter::WritePacket(const char* buffer, } if (ShouldWriteFail()) { - return WriteResult(WRITE_STATUS_ERROR, 0); + return WriteResult(WRITE_STATUS_ERROR, write_error_code_); } last_packet_size_ = packet.length(); diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_utils.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_utils.h index f05859d9317..fe255b45d4f 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_utils.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_utils.h @@ -13,31 +13,32 @@ #include <utility> #include <vector> +#include "absl/container/flat_hash_map.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/loss_detection_interface.h" -#include "net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h" -#include "net/third_party/quiche/src/quic/core/crypto/transport_parameters.h" -#include "net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.h" -#include "net/third_party/quiche/src/quic/core/http/quic_server_session_base.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_session.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_connection_id.h" -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_path_validator.h" -#include "net/third_party/quiche/src/quic/core/quic_sent_packet_manager.h" -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" -#include "net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_mem_slice_storage.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_quic_session_visitor.h" -#include "net/third_party/quiche/src/quic/test_tools/mock_random.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_framer_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/simple_quic_framer.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "quic/core/congestion_control/loss_detection_interface.h" +#include "quic/core/congestion_control/send_algorithm_interface.h" +#include "quic/core/crypto/transport_parameters.h" +#include "quic/core/http/quic_client_push_promise_index.h" +#include "quic/core/http/quic_server_session_base.h" +#include "quic/core/http/quic_spdy_session.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_connection_id.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_packet_writer.h" +#include "quic/core/quic_path_validator.h" +#include "quic/core/quic_sent_packet_manager.h" +#include "quic/core/quic_server_id.h" +#include "quic/core/quic_simple_buffer_allocator.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_mem_slice_storage.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" +#include "quic/test_tools/mock_quic_session_visitor.h" +#include "quic/test_tools/mock_random.h" +#include "quic/test_tools/quic_framer_peer.h" +#include "quic/test_tools/simple_quic_framer.h" namespace quic { @@ -266,10 +267,15 @@ class SimpleRandom : public QuicRandom { SimpleRandom& operator=(const SimpleRandom&) = delete; ~SimpleRandom() override {} + // Generates |len| random bytes in the |data| buffer. + void RandBytes(void* data, size_t len) override; // Returns a random number in the range [0, kuint64max]. uint64_t RandUint64() override; - void RandBytes(void* data, size_t len) override; + // InsecureRandBytes behaves equivalently to RandBytes. + void InsecureRandBytes(void* data, size_t len) override; + // InsecureRandUint64 behaves equivalently to RandUint64. + uint64_t InsecureRandUint64() override; void set_seed(uint64_t seed); @@ -321,7 +327,10 @@ class MockFramerVisitor : public QuicFramerVisitorInterface { OnUnauthenticatedPublicHeader, (const QuicPacketHeader& header), (override)); - MOCK_METHOD(void, OnDecryptedPacket, (EncryptionLevel level), (override)); + MOCK_METHOD(void, + OnDecryptedPacket, + (size_t length, EncryptionLevel level), + (override)); MOCK_METHOD(bool, OnPacketHeader, (const QuicPacketHeader& header), @@ -458,7 +467,8 @@ class NoOpFramerVisitor : public QuicFramerVisitorInterface { bool OnProtocolVersionMismatch(ParsedQuicVersion version) override; bool OnUnauthenticatedHeader(const QuicPacketHeader& header) override; bool OnUnauthenticatedPublicHeader(const QuicPacketHeader& header) override; - void OnDecryptedPacket(EncryptionLevel /*level*/) override {} + void OnDecryptedPacket(size_t /*length*/, + EncryptionLevel /*level*/) override {} bool OnPacketHeader(const QuicPacketHeader& header) override; void OnCoalescedPacket(const QuicEncryptedPacket& packet) override; void OnUndecryptablePacket(const QuicEncryptedPacket& packet, @@ -529,6 +539,7 @@ class MockQuicConnectionVisitor : public QuicConnectionVisitorInterface { MOCK_METHOD(void, OnGoAway, (const QuicGoAwayFrame& frame), (override)); MOCK_METHOD(void, OnMessageReceived, (absl::string_view message), (override)); MOCK_METHOD(void, OnHandshakeDoneReceived, (), (override)); + MOCK_METHOD(void, OnNewTokenReceived, (absl::string_view token), (override)); MOCK_METHOD(void, OnConnectionClosed, (const QuicConnectionCloseFrame& frame, @@ -562,7 +573,6 @@ class MockQuicConnectionVisitor : public QuicConnectionVisitorInterface { bool is_connectivity_probe), (override)); MOCK_METHOD(void, OnAckNeedsRetransmittableFrame, (), (override)); - MOCK_METHOD(void, SendPing, (), (override)); MOCK_METHOD(void, SendAckFrequency, (const QuicAckFrequencyFrame& frame), @@ -594,6 +604,8 @@ class MockQuicConnectionVisitor : public QuicConnectionVisitorInterface { (), (override)); MOCK_METHOD(void, BeforeConnectionCloseSent, (), (override)); + MOCK_METHOD(bool, ValidateToken, (absl::string_view), (const, override)); + MOCK_METHOD(void, MaybeSendAddressToken, (), (override)); }; class MockQuicConnectionHelper : public QuicConnectionHelperInterface { @@ -691,8 +703,17 @@ class MockQuicConnection : public QuicConnection { ConnectionCloseBehavior connection_close_behavior), (override)); MOCK_METHOD(void, + CloseConnection, + (QuicErrorCode error, + QuicIetfTransportErrorCodes ietf_error, + const std::string& details, + ConnectionCloseBehavior connection_close_behavior), + (override)); + MOCK_METHOD(void, SendConnectionClosePacket, - (QuicErrorCode error, const std::string& details), + (QuicErrorCode error, + QuicIetfTransportErrorCodes ietf_error, + const std::string& details), (override)); MOCK_METHOD(void, OnCanWrite, (), (override)); MOCK_METHOD(void, @@ -723,6 +744,14 @@ class MockQuicConnection : public QuicConnection { SendMessage, (QuicMessageId, QuicMemSliceSpan, bool), (override)); + MOCK_METHOD(bool, + SendPathChallenge, + (const QuicPathFrameBuffer&, + const QuicSocketAddress&, + const QuicSocketAddress&, + const QuicSocketAddress&, + QuicPacketWriter*), + (override)); MOCK_METHOD(void, OnError, (QuicFramer*), (override)); void QuicConnection_OnError(QuicFramer* framer) { @@ -735,12 +764,17 @@ class MockQuicConnection : public QuicConnection { QuicErrorCode error, const std::string& details, ConnectionCloseBehavior connection_close_behavior) { - QuicConnection::CloseConnection(error, details, connection_close_behavior); + // Call the 4-param method directly instead of the 3-param method, so that + // it doesn't invoke the virtual 4-param method causing the mock 4-param + // method to trigger. + QuicConnection::CloseConnection(error, NO_IETF_QUIC_ERROR, details, + connection_close_behavior); } void ReallySendConnectionClosePacket(QuicErrorCode error, + QuicIetfTransportErrorCodes ietf_error, const std::string& details) { - QuicConnection::SendConnectionClosePacket(error, details); + QuicConnection::SendConnectionClosePacket(error, ietf_error, details); } void ReallyProcessUdpPacket(const QuicSocketAddress& self_address, @@ -766,6 +800,11 @@ class MockQuicConnection : public QuicConnection { const QuicSocketAddress& peer_address) { QuicConnection::SendConnectivityProbingResponsePacket(peer_address); } + + bool ReallyOnPathResponseFrame(const QuicPathResponseFrame& frame) { + return QuicConnection::OnPathResponseFrame(frame); + } + MOCK_METHOD(bool, OnPathResponseFrame, (const QuicPathResponseFrame&), @@ -846,14 +885,6 @@ class MockQuicSession : public QuicSession { WriteControlFrame, (const QuicFrame& frame, TransmissionType type), (override)); - - MOCK_METHOD(void, - SendRstStream, - (QuicStreamId stream_id, - QuicRstStreamErrorCode error, - QuicStreamOffset bytes_written, - bool send_rst_only), - (override)); MOCK_METHOD(void, MaybeSendRstStreamFrame, (QuicStreamId stream_id, @@ -888,13 +919,6 @@ class MockQuicSession : public QuicSession { TransmissionType type, absl::optional<EncryptionLevel> level); - void ReallySendRstStream(QuicStreamId id, - QuicRstStreamErrorCode error, - QuicStreamOffset bytes_written, - bool send_rst_only) { - QuicSession::SendRstStream(id, error, bytes_written, send_rst_only); - } - void ReallyMaybeSendRstStreamFrame(QuicStreamId id, QuicRstStreamErrorCode error, QuicStreamOffset bytes_written) { @@ -921,6 +945,11 @@ class MockQuicCryptoStream : public QuicCryptoStream { void OnOneRttPacketAcknowledged() override {} void OnHandshakePacketSent() override {} void OnHandshakeDoneReceived() override {} + void OnNewTokenReceived(absl::string_view /*token*/) override {} + std::string GetAddressToken() const override { return ""; } + bool ValidateAddressToken(absl::string_view /*token*/) const override { + return true; + } void OnConnectionClosed(QuicErrorCode /*error*/, ConnectionCloseSource /*source*/) override {} HandshakeState GetHandshakeState() const override { return HANDSHAKE_START; } @@ -995,13 +1024,6 @@ class MockQuicSpdySession : public QuicSpdySession { absl::optional<EncryptionLevel> level), (override)); MOCK_METHOD(void, - SendRstStream, - (QuicStreamId stream_id, - QuicRstStreamErrorCode error, - QuicStreamOffset bytes_written, - bool send_rst_only), - (override)); - MOCK_METHOD(void, MaybeSendRstStreamFrame, (QuicStreamId stream_id, QuicRstStreamErrorCode error, @@ -1072,6 +1094,11 @@ class MockHttp3DebugVisitor : public Http3DebugVisitor { (override)); MOCK_METHOD(void, + OnAcceptChFrameReceivedViaAlps, + (const AcceptChFrame&), + (override)); + + MOCK_METHOD(void, OnCancelPushFrameReceived, (const CancelPushFrame&), (override)); @@ -1088,6 +1115,10 @@ class MockHttp3DebugVisitor : public Http3DebugVisitor { OnPriorityUpdateFrameReceived, (const PriorityUpdateFrame&), (override)); + MOCK_METHOD(void, + OnAcceptChFrameReceived, + (const AcceptChFrame&), + (override)); MOCK_METHOD(void, OnDataFrameReceived, @@ -1445,13 +1476,6 @@ class MockQuicConnectionDebugVisitor : public QuicConnectionDebugVisitor { MockQuicConnectionDebugVisitor(); ~MockQuicConnectionDebugVisitor() override; - // TODO(wub): Delete when deprecating - // --quic_give_sent_packet_to_debug_visitor_after_sent. - MOCK_METHOD(void, - OnPacketSent, - (const SerializedPacket&, TransmissionType, QuicTime), - (override)); - MOCK_METHOD(void, OnPacketSent, (QuicPacketNumber, @@ -1638,8 +1662,11 @@ class MockQuicPathValidationContext : public QuicPathValidationContext { public: MockQuicPathValidationContext(const QuicSocketAddress& self_address, const QuicSocketAddress& peer_address, + const QuicSocketAddress& effective_peer_address, QuicPacketWriter* writer) - : QuicPathValidationContext(self_address, peer_address), + : QuicPathValidationContext(self_address, + peer_address, + effective_peer_address), writer_(writer) {} QuicPacketWriter* WriterToUse() override { return writer_; } @@ -1812,8 +1839,8 @@ MATCHER_P2(InRange, min, max, "") { // EXPECT_THAT(stream_->connection_error(), IsError(QUIC_INTERNAL_ERROR)); MATCHER_P(IsError, expected, - quiche::QuicheStrCat(negation ? "isn't equal to " : "is equal to ", - QuicErrorCodeToString(expected))) { + absl::StrCat(negation ? "isn't equal to " : "is equal to ", + QuicErrorCodeToString(expected))) { *result_listener << QuicErrorCodeToString(static_cast<QuicErrorCode>(arg)); return arg == expected; } @@ -1821,8 +1848,8 @@ MATCHER_P(IsError, // Shorthand for IsError(QUIC_NO_ERROR). // Example usage: EXPECT_THAT(stream_->connection_error(), IsQuicNoError()); MATCHER(IsQuicNoError, - quiche::QuicheStrCat(negation ? "isn't equal to " : "is equal to ", - QuicErrorCodeToString(QUIC_NO_ERROR))) { + absl::StrCat(negation ? "isn't equal to " : "is equal to ", + QuicErrorCodeToString(QUIC_NO_ERROR))) { *result_listener << QuicErrorCodeToString(arg); return arg == QUIC_NO_ERROR; } @@ -1832,8 +1859,8 @@ MATCHER(IsQuicNoError, // EXPECT_THAT(stream_->stream_error(), IsStreamError(QUIC_INTERNAL_ERROR)); MATCHER_P(IsStreamError, expected, - quiche::QuicheStrCat(negation ? "isn't equal to " : "is equal to ", - QuicRstStreamErrorCodeToString(expected))) { + absl::StrCat(negation ? "isn't equal to " : "is equal to ", + QuicRstStreamErrorCodeToString(expected))) { *result_listener << QuicRstStreamErrorCodeToString(arg); return arg == expected; } @@ -1841,9 +1868,8 @@ MATCHER_P(IsStreamError, // Shorthand for IsStreamError(QUIC_STREAM_NO_ERROR). Example usage: // EXPECT_THAT(stream_->stream_error(), IsQuicStreamNoError()); MATCHER(IsQuicStreamNoError, - quiche::QuicheStrCat( - negation ? "isn't equal to " : "is equal to ", - QuicRstStreamErrorCodeToString(QUIC_STREAM_NO_ERROR))) { + absl::StrCat(negation ? "isn't equal to " : "is equal to ", + QuicRstStreamErrorCodeToString(QUIC_STREAM_NO_ERROR))) { *result_listener << QuicRstStreamErrorCodeToString(arg); return arg == QUIC_STREAM_NO_ERROR; } @@ -2028,6 +2054,8 @@ class TestPacketWriter : public QuicPacketWriter { void SetShouldWriteFail() { write_should_fail_ = true; } + void SetWriteError(int error_code) { write_error_code_ = error_code; } + QuicByteCount GetMaxPacketSize( const QuicSocketAddress& /*peer_address*/) const override { return max_packet_size_; @@ -2217,12 +2245,14 @@ class TestPacketWriter : public QuicPacketWriter { // Used to verify writer-allocated packet buffers are properly released. std::vector<PacketBuffer*> packet_buffer_pool_; // Buffer address => Address of the owning PacketBuffer. - QuicHashMap<char*, PacketBuffer*> packet_buffer_pool_index_; + absl::flat_hash_map<char*, PacketBuffer*, absl::Hash<char*>> + packet_buffer_pool_index_; // Indices in packet_buffer_pool_ that are not allocated. std::list<PacketBuffer*> packet_buffer_free_list_; // The soruce/peer address passed into WritePacket(). QuicIpAddress last_write_source_address_; QuicSocketAddress last_write_peer_address_; + int write_error_code_{0}; }; // Parses a packet generated by diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_utils_test.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_utils_test.cc index 31e48041758..f7be77cca38 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_utils_test.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_test_utils_test.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_time_wait_list_manager_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_time_wait_list_manager_peer.cc index 7c90321883b..9d60443deb2 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_time_wait_list_manager_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_time_wait_list_manager_peer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_time_wait_list_manager_peer.h" +#include "quic/test_tools/quic_time_wait_list_manager_peer.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_time_wait_list_manager_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_time_wait_list_manager_peer.h index 0fdf976fb74..54fd6dd1768 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_time_wait_list_manager_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_time_wait_list_manager_peer.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_TIME_WAIT_LIST_MANAGER_PEER_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_TIME_WAIT_LIST_MANAGER_PEER_H_ -#include "net/third_party/quiche/src/quic/core/quic_time_wait_list_manager.h" +#include "quic/core/quic_time_wait_list_manager.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_transport_test_tools.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_transport_test_tools.h index ba0cc39f924..e0fcebc6ebd 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_transport_test_tools.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_transport_test_tools.h @@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_TRANSPORT_TEST_TOOLS_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_TRANSPORT_TEST_TOOLS_H_ -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_client_session.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_server_session.h" +#include "quic/platform/api/quic_test.h" +#include "quic/quic_transport/quic_transport_client_session.h" +#include "quic/quic_transport/quic_transport_server_session.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_unacked_packet_map_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/quic_unacked_packet_map_peer.cc index fa3408c0bb7..61fda95b40d 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_unacked_packet_map_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_unacked_packet_map_peer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/quic_unacked_packet_map_peer.h" +#include "quic/test_tools/quic_unacked_packet_map_peer.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/quic_unacked_packet_map_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/quic_unacked_packet_map_peer.h index 17c88fe93bb..c21bcee3952 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/quic_unacked_packet_map_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/quic_unacked_packet_map_peer.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_UNACKED_PACKET_MAP_PEER_H_ #define QUICHE_QUIC_TEST_TOOLS_QUIC_UNACKED_PACKET_MAP_PEER_H_ -#include "net/third_party/quiche/src/quic/core/quic_unacked_packet_map.h" +#include "quic/core/quic_unacked_packet_map.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/rtt_stats_peer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/rtt_stats_peer.cc index e8c6810fa52..79325c45ff4 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/rtt_stats_peer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/rtt_stats_peer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/rtt_stats_peer.h" +#include "quic/test_tools/rtt_stats_peer.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/rtt_stats_peer.h b/chromium/net/third_party/quiche/src/quic/test_tools/rtt_stats_peer.h index 6243b7a349f..bd06ecc5c5b 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/rtt_stats_peer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/rtt_stats_peer.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_RTT_STATS_PEER_H_ #define QUICHE_QUIC_TEST_TOOLS_RTT_STATS_PEER_H_ -#include "net/third_party/quiche/src/quic/core/congestion_control/rtt_stats.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" +#include "quic/core/congestion_control/rtt_stats.h" +#include "quic/core/quic_time.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/send_algorithm_test_utils.cc b/chromium/net/third_party/quiche/src/quic/test_tools/send_algorithm_test_utils.cc index f5ca6ee026b..074028ac792 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/send_algorithm_test_utils.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/send_algorithm_test_utils.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/send_algorithm_test_utils.h" +#include "quic/test_tools/send_algorithm_test_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test_output.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_cat.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test_output.h" namespace quic { namespace test { @@ -49,9 +49,8 @@ std::string GetFullSendAlgorithmTestName() { test_info->type_param() ? test_info->type_param() : ""; const std::string value_param = test_info->value_param() ? test_info->value_param() : ""; - return quiche::QuicheStrCat(test_info->test_suite_name(), ".", - test_info->name(), "_", type_param, "_", - value_param); + return absl::StrCat(test_info->test_suite_name(), ".", test_info->name(), "_", + type_param, "_", value_param); } std::string GetSendAlgorithmTestResultFilename() { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/send_algorithm_test_utils.h b/chromium/net/third_party/quiche/src/quic/test_tools/send_algorithm_test_utils.h index c36218d0928..430e42aa068 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/send_algorithm_test_utils.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/send_algorithm_test_utils.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_SEND_ALGORITHM_TEST_UTILS_H_ #define QUICHE_QUIC_TEST_TOOLS_SEND_ALGORITHM_TEST_UTILS_H_ -#include "net/third_party/quiche/src/quic/test_tools/send_algorithm_test_result.pb.h" +#include "quic/test_tools/send_algorithm_test_result.pb.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/server_thread.cc b/chromium/net/third_party/quiche/src/quic/test_tools/server_thread.cc index 77a23a656fe..f5c9b7e0725 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/server_thread.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/server_thread.cc @@ -2,12 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/server_thread.h" +#include "quic/test_tools/server_thread.h" -#include "net/third_party/quiche/src/quic/core/quic_dispatcher.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_server_peer.h" +#include "quic/core/quic_dispatcher.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/quic_dispatcher_peer.h" +#include "quic/test_tools/quic_server_peer.h" namespace quic { namespace test { @@ -60,7 +61,7 @@ int ServerThread::GetPort() { } void ServerThread::Schedule(std::function<void()> action) { - DCHECK(!quit_.HasBeenNotified()); + QUICHE_DCHECK(!quit_.HasBeenNotified()); QuicWriterMutexLock lock(&scheduled_actions_lock_); scheduled_actions_.push_back(std::move(action)); } @@ -88,14 +89,14 @@ bool ServerThread::WaitUntil(std::function<bool()> termination_predicate, } void ServerThread::Pause() { - DCHECK(!pause_.HasBeenNotified()); + QUICHE_DCHECK(!pause_.HasBeenNotified()); pause_.Notify(); paused_.WaitForNotification(); } void ServerThread::Resume() { - DCHECK(!resume_.HasBeenNotified()); - DCHECK(pause_.HasBeenNotified()); + QUICHE_DCHECK(!resume_.HasBeenNotified()); + QUICHE_DCHECK(pause_.HasBeenNotified()); resume_.Notify(); } @@ -114,11 +115,11 @@ void ServerThread::MaybeNotifyOfHandshakeConfirmation() { return; } QuicDispatcher* dispatcher = QuicServerPeer::GetDispatcher(server()); - if (dispatcher->session_map().empty()) { + if (dispatcher->NumSessions() == 0) { // Wait for a session to be created. return; } - QuicSession* session = dispatcher->session_map().begin()->second.get(); + QuicSession* session = QuicDispatcherPeer::GetFirstSessionIfAny(dispatcher); if (session->OneRttKeysAvailable()) { confirmed_.Notify(); } diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/server_thread.h b/chromium/net/third_party/quiche/src/quic/test_tools/server_thread.h index 31efed63c8a..fa604a8bf77 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/server_thread.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/server_thread.h @@ -7,12 +7,12 @@ #include <memory> -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_mutex.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_thread.h" -#include "net/third_party/quiche/src/quic/tools/quic_server.h" +#include "quic/core/quic_config.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_mutex.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_thread.h" +#include "quic/tools/quic_server.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simple_data_producer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/simple_data_producer.cc index 619051d4e7d..5ef53f4bf23 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simple_data_producer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simple_data_producer.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/simple_data_producer.h" +#include "quic/test_tools/simple_data_producer.h" #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" +#include "quic/core/quic_data_writer.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_map_util.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simple_data_producer.h b/chromium/net/third_party/quiche/src/quic/test_tools/simple_data_producer.h index 4904dd35a41..82021e1e1a1 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simple_data_producer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simple_data_producer.h @@ -5,11 +5,12 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_SIMPLE_DATA_PRODUCER_H_ #define QUICHE_QUIC_TEST_TOOLS_SIMPLE_DATA_PRODUCER_H_ +#include "absl/container/flat_hash_map.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_stream_frame_data_producer.h" -#include "net/third_party/quiche/src/quic/core/quic_stream_send_buffer.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" +#include "quic/core/quic_simple_buffer_allocator.h" +#include "quic/core/quic_stream_frame_data_producer.h" +#include "quic/core/quic_stream_send_buffer.h" +#include "quic/platform/api/quic_containers.h" namespace quic { @@ -59,12 +60,12 @@ class SimpleDataProducer : public QuicStreamFrameDataProducer { private: using SendBufferMap = - QuicHashMap<QuicStreamId, std::unique_ptr<QuicStreamSendBuffer>>; + absl::flat_hash_map<QuicStreamId, std::unique_ptr<QuicStreamSendBuffer>>; using CryptoBufferMap = - QuicHashMap<std::pair<EncryptionLevel, QuicStreamOffset>, - absl::string_view, - PairHash>; + absl::flat_hash_map<std::pair<EncryptionLevel, QuicStreamOffset>, + absl::string_view, + PairHash>; SimpleBufferAllocator allocator_; diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simple_quic_framer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/simple_quic_framer.cc index ccce52b9eba..96b131877fb 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simple_quic_framer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simple_quic_framer.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/simple_quic_framer.h" +#include "quic/test_tools/simple_quic_framer.h" #include <memory> #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" +#include "quic/core/crypto/quic_decrypter.h" +#include "quic/core/crypto/quic_encrypter.h" +#include "quic/platform/api/quic_ptr_util.h" namespace quic { namespace test { @@ -52,7 +52,7 @@ class SimpleFramerVisitor : public QuicFramerVisitorInterface { bool OnUnauthenticatedHeader(const QuicPacketHeader& /*header*/) override { return true; } - void OnDecryptedPacket(EncryptionLevel level) override { + void OnDecryptedPacket(size_t /*length*/, EncryptionLevel level) override { last_decrypted_level_ = level; } bool OnPacketHeader(const QuicPacketHeader& header) override { @@ -101,7 +101,7 @@ class SimpleFramerVisitor : public QuicFramerVisitorInterface { } bool OnAckRange(QuicPacketNumber start, QuicPacketNumber end) override { - DCHECK(!ack_frames_.empty()); + QUICHE_DCHECK(!ack_frames_.empty()); ack_frames_[ack_frames_.size() - 1].packets.AddRange(start, end); return true; } diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simple_quic_framer.h b/chromium/net/third_party/quiche/src/quic/test_tools/simple_quic_framer.h index 3e063d07334..6801dfe6c04 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simple_quic_framer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simple_quic_framer.h @@ -8,8 +8,8 @@ #include <memory> #include <vector> -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_packets.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_cache.cc b/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_cache.cc index 9f851b94831..3b30797c730 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_cache.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_cache.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/simple_session_cache.h" +#include "quic/test_tools/simple_session_cache.h" #include <memory> -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.h" +#include "quic/core/crypto/quic_crypto_client_config.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_cache.h b/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_cache.h index 6043a439e4d..6fc1f3dd521 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_cache.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_cache.h @@ -6,8 +6,8 @@ #define QUICHE_QUIC_TEST_TOOLS_SIMPLE_SESSION_CACHE_H_ #include <memory> -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.h" -#include "net/third_party/quiche/src/quic/core/crypto/transport_parameters.h" +#include "quic/core/crypto/quic_crypto_client_config.h" +#include "quic/core/crypto/transport_parameters.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_notifier.cc b/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_notifier.cc index cb3b711d053..415332ad274 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_notifier.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_notifier.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/simple_session_notifier.h" +#include "quic/test_tools/simple_session_notifier.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_map_util.h" +#include "quic/test_tools/quic_test_utils.h" namespace quic { @@ -125,6 +125,24 @@ void SimpleSessionNotifier::WriteOrBufferPing() { WriteBufferedControlFrames(); } +void SimpleSessionNotifier::WriteOrBufferAckFrequency( + const QuicAckFrequencyFrame& ack_frequency_frame) { + QUIC_DVLOG(1) << "Writing ACK_FREQUENCY"; + const bool had_buffered_data = + HasBufferedStreamData() || HasBufferedControlFrames(); + QuicControlFrameId control_frame_id = ++last_control_frame_id_; + control_frames_.emplace_back(( + QuicFrame(new QuicAckFrequencyFrame(control_frame_id, + /*sequence_number=*/control_frame_id, + ack_frequency_frame.packet_tolerance, + ack_frequency_frame.max_ack_delay)))); + if (had_buffered_data) { + QUIC_DLOG(WARNING) << "Connection is write blocked"; + return; + } + WriteBufferedControlFrames(); +} + void SimpleSessionNotifier::NeuterUnencryptedData() { if (QuicVersionUsesCryptoFrames(connection_->transport_version())) { for (const auto& interval : crypto_bytes_transferred_[ENCRYPTION_INITIAL]) { @@ -463,7 +481,7 @@ bool SimpleSessionNotifier::OnControlFrameAcked(const QuicFrame& frame) { if (id == kInvalidControlFrameId) { return false; } - DCHECK(id < least_unacked_ + control_frames_.size()); + QUICHE_DCHECK(id < least_unacked_ + control_frames_.size()); if (id < least_unacked_ || GetControlFrameId(control_frames_.at(id - least_unacked_)) == kInvalidControlFrameId) { @@ -486,7 +504,7 @@ void SimpleSessionNotifier::OnControlFrameLost(const QuicFrame& frame) { if (id == kInvalidControlFrameId) { return; } - DCHECK(id < least_unacked_ + control_frames_.size()); + QUICHE_DCHECK(id < least_unacked_ + control_frames_.size()); if (id < least_unacked_ || GetControlFrameId(control_frames_.at(id - least_unacked_)) == kInvalidControlFrameId) { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_notifier.h b/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_notifier.h index 65afacebf3c..2219c27d1a4 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_notifier.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_notifier.h @@ -5,10 +5,11 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_SIMPLE_SESSION_NOTIFIER_H_ #define QUICHE_QUIC_TEST_TOOLS_SIMPLE_SESSION_NOTIFIER_H_ -#include "net/third_party/quiche/src/quic/core/quic_circular_deque.h" -#include "net/third_party/quiche/src/quic/core/quic_interval_set.h" -#include "net/third_party/quiche/src/quic/core/session_notifier_interface.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "absl/container/flat_hash_map.h" +#include "quic/core/quic_circular_deque.h" +#include "quic/core/quic_interval_set.h" +#include "quic/core/session_notifier_interface.h" +#include "quic/platform/api/quic_test.h" namespace quic { @@ -35,6 +36,10 @@ class SimpleSessionNotifier : public SessionNotifierInterface { // Tries to write PING. void WriteOrBufferPing(); + // Tries to write ACK_FREQUENCY. + void WriteOrBufferAckFrequency( + const QuicAckFrequencyFrame& ack_frequency_frame); + // Tries to write CRYPTO data and returns the number of bytes written. size_t WriteCryptoData(EncryptionLevel level, QuicByteCount data_length, @@ -102,7 +107,7 @@ class SimpleSessionNotifier : public SessionNotifierInterface { friend std::ostream& operator<<(std::ostream& os, const StreamState& s); - using StreamMap = QuicHashMap<QuicStreamId, StreamState>; + using StreamMap = absl::flat_hash_map<QuicStreamId, StreamState>; void OnStreamDataConsumed(QuicStreamId id, QuicStreamOffset offset, diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_notifier_test.cc b/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_notifier_test.cc index bc65f448c2e..a88cb804b46 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_notifier_test.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simple_session_notifier_test.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/simple_session_notifier.h" +#include "quic/test_tools/simple_session_notifier.h" #include <utility> -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/simple_data_producer.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/simple_data_producer.h" using testing::_; using testing::InSequence; diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/actor.cc b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/actor.cc index 578b894aff5..acb548c8e8b 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/actor.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/actor.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/simulator/actor.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/simulator.h" +#include "quic/test_tools/simulator/actor.h" +#include "quic/test_tools/simulator/simulator.h" namespace quic { namespace simulator { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/actor.h b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/actor.h index 17a21b5e811..a333399a3ce 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/actor.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/actor.h @@ -7,8 +7,8 @@ #include <string> -#include "net/third_party/quiche/src/quic/core/quic_clock.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" +#include "quic/core/quic_clock.h" +#include "quic/core/quic_time.h" namespace quic { namespace simulator { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/alarm_factory.cc b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/alarm_factory.cc index 723605fbd06..86ee49e5f3d 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/alarm_factory.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/alarm_factory.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/simulator/alarm_factory.h" +#include "quic/test_tools/simulator/alarm_factory.h" -#include "net/third_party/quiche/src/quic/core/quic_alarm.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_format.h" +#include "quic/core/quic_alarm.h" namespace quic { namespace simulator { @@ -21,7 +21,7 @@ class Alarm : public QuicAlarm { ~Alarm() override {} void SetImpl() override { - DCHECK(deadline().IsInitialized()); + QUICHE_DCHECK(deadline().IsInitialized()); adapter_.Set(deadline()); } @@ -41,7 +41,7 @@ class Alarm : public QuicAlarm { void Cancel() { Unschedule(); } void Act() override { - DCHECK(clock_->Now() >= parent_->deadline()); + QUICHE_DCHECK(clock_->Now() >= parent_->deadline()); parent_->Fire(); } @@ -58,7 +58,7 @@ AlarmFactory::~AlarmFactory() {} std::string AlarmFactory::GetNewAlarmName() { ++counter_; - return quiche::QuicheStringPrintf("%s (alarm %i)", name_.c_str(), counter_); + return absl::StrFormat("%s (alarm %i)", name_, counter_); } QuicAlarm* AlarmFactory::CreateAlarm(QuicAlarm::Delegate* delegate) { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/alarm_factory.h b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/alarm_factory.h index d765175e18b..a9fdd33304d 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/alarm_factory.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/alarm_factory.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_SIMULATOR_ALARM_FACTORY_H_ #define QUICHE_QUIC_TEST_TOOLS_SIMULATOR_ALARM_FACTORY_H_ -#include "net/third_party/quiche/src/quic/core/quic_alarm_factory.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/actor.h" +#include "quic/core/quic_alarm_factory.h" +#include "quic/test_tools/simulator/actor.h" namespace quic { namespace simulator { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/link.cc b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/link.cc index b10024a8665..6d435978bc6 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/link.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/link.cc @@ -2,10 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/simulator/link.h" +#include "quic/test_tools/simulator/link.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/simulator.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "quic/test_tools/simulator/simulator.h" namespace quic { namespace simulator { @@ -35,7 +36,7 @@ OneWayLink::QueuedPacket::QueuedPacket(QueuedPacket&& other) = default; OneWayLink::QueuedPacket::~QueuedPacket() {} void OneWayLink::AcceptPacket(std::unique_ptr<Packet> packet) { - DCHECK(TimeUntilAvailable().IsZero()); + QUICHE_DCHECK(TimeUntilAvailable().IsZero()); QuicTime::Delta transfer_time = bandwidth_.TransferTime(packet->size); next_write_at_ = clock_->Now() + transfer_time; @@ -60,8 +61,8 @@ QuicTime::Delta OneWayLink::TimeUntilAvailable() { } void OneWayLink::Act() { - DCHECK(!packets_in_transit_.empty()); - DCHECK(packets_in_transit_.front().dequeue_time >= clock_->Now()); + QUICHE_DCHECK(!packets_in_transit_.empty()); + QUICHE_DCHECK(packets_in_transit_.front().dequeue_time >= clock_->Now()); sink_->AcceptPacket(std::move(packets_in_transit_.front().packet)); packets_in_transit_.pop_front(); @@ -96,12 +97,12 @@ SymmetricLink::SymmetricLink(Simulator* simulator, QuicBandwidth bandwidth, QuicTime::Delta propagation_delay) : a_to_b_link_(simulator, - quiche::QuicheStringPrintf("%s (A-to-B)", name.c_str()), + absl::StrCat(name, " (A-to-B)"), sink_b, bandwidth, propagation_delay), b_to_a_link_(simulator, - quiche::QuicheStringPrintf("%s (B-to-A)", name.c_str()), + absl::StrCat(name, " (B-to-A)"), sink_a, bandwidth, propagation_delay) {} @@ -111,9 +112,9 @@ SymmetricLink::SymmetricLink(Endpoint* endpoint_a, QuicBandwidth bandwidth, QuicTime::Delta propagation_delay) : SymmetricLink(endpoint_a->simulator(), - quiche::QuicheStringPrintf("Link [%s]<->[%s]", - endpoint_a->name().c_str(), - endpoint_b->name().c_str()), + absl::StrFormat("Link [%s]<->[%s]", + endpoint_a->name(), + endpoint_b->name()), endpoint_a->GetRxPort(), endpoint_b->GetRxPort(), bandwidth, diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/link.h b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/link.h index a832a7ee771..7d2f92dfdc4 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/link.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/link.h @@ -7,11 +7,11 @@ #include <utility> -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h" -#include "net/third_party/quiche/src/quic/core/quic_circular_deque.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/actor.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/port.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/quic_bandwidth.h" +#include "quic/core/quic_circular_deque.h" +#include "quic/test_tools/simulator/actor.h" +#include "quic/test_tools/simulator/port.h" namespace quic { namespace simulator { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/packet_filter.cc b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/packet_filter.cc index ad039039165..0cbb1f0d8a3 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/packet_filter.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/packet_filter.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/simulator/packet_filter.h" +#include "quic/test_tools/simulator/packet_filter.h" namespace quic { namespace simulator { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/packet_filter.h b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/packet_filter.h index 9873bec960b..d7443533f3c 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/packet_filter.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/packet_filter.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_SIMULATOR_PACKET_FILTER_H_ #define QUICHE_QUIC_TEST_TOOLS_SIMULATOR_PACKET_FILTER_H_ -#include "net/third_party/quiche/src/quic/test_tools/simulator/port.h" +#include "quic/test_tools/simulator/port.h" namespace quic { namespace simulator { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/port.cc b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/port.cc index 242ebd489b2..7aa4df325fb 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/port.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/port.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/simulator/port.h" +#include "quic/test_tools/simulator/port.h" namespace quic { namespace simulator { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/port.h b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/port.h index 15da6384f72..772b2d5745b 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/port.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/port.h @@ -8,8 +8,8 @@ #include <string> #include <utility> -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/actor.h" +#include "quic/core/quic_packets.h" +#include "quic/test_tools/simulator/actor.h" namespace quic { namespace simulator { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/queue.cc b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/queue.cc index 52f7fe683b7..5113cf79791 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/queue.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/queue.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/simulator/queue.h" +#include "quic/test_tools/simulator/queue.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/simulator.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/test_tools/simulator/simulator.h" namespace quic { namespace simulator { @@ -59,9 +59,9 @@ void Queue::AcceptPacket(std::unique_ptr<Packet> packet) { } void Queue::Act() { - DCHECK(!queue_.empty()); + QUICHE_DCHECK(!queue_.empty()); if (tx_port_->TimeUntilAvailable().IsZero()) { - DCHECK(bytes_queued_ >= queue_.front().packet->size); + QUICHE_DCHECK(bytes_queued_ >= queue_.front().packet->size); bytes_queued_ -= queue_.front().packet->size; tx_port_->AcceptPacket(std::move(queue_.front().packet)); @@ -76,10 +76,10 @@ void Queue::Act() { void Queue::EnableAggregation(QuicByteCount aggregation_threshold, QuicTime::Delta aggregation_timeout) { - DCHECK_EQ(bytes_queued_, 0u); - DCHECK_GT(aggregation_threshold, 0u); - DCHECK(!aggregation_timeout.IsZero()); - DCHECK(!aggregation_timeout.IsInfinite()); + QUICHE_DCHECK_EQ(bytes_queued_, 0u); + QUICHE_DCHECK_GT(aggregation_threshold, 0u); + QUICHE_DCHECK(!aggregation_timeout.IsZero()); + QUICHE_DCHECK(!aggregation_timeout.IsInfinite()); aggregation_threshold_ = aggregation_threshold; aggregation_timeout_ = aggregation_timeout; @@ -109,7 +109,7 @@ void Queue::NextBundle() { void Queue::ScheduleNextPacketDequeue() { if (queue_.empty()) { - DCHECK_EQ(bytes_queued_, 0u); + QUICHE_DCHECK_EQ(bytes_queued_, 0u); return; } diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/queue.h b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/queue.h index f9a75607911..a291f48eeab 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/queue.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/queue.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_SIMULATOR_QUEUE_H_ #define QUICHE_QUIC_TEST_TOOLS_SIMULATOR_QUEUE_H_ -#include "net/third_party/quiche/src/quic/core/quic_alarm.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/link.h" +#include "quic/core/quic_alarm.h" +#include "quic/test_tools/simulator/link.h" namespace quic { namespace simulator { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint.cc b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint.cc index c02ac7e83b6..cb0b58e9db5 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint.cc @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint.h" +#include "quic/test_tools/simulator/quic_endpoint.h" #include <memory> #include <utility> -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test_output.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/simulator.h" +#include "quic/core/crypto/crypto_handshake_message.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/quic_data_writer.h" +#include "quic/platform/api/quic_test_output.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/simulator/simulator.h" namespace quic { namespace simulator { @@ -74,8 +74,9 @@ QuicEndpoint::QuicEndpoint(Simulator* simulator, QuicErrorCode error_code = config.ProcessPeerHello( peer_hello, perspective == Perspective::IS_CLIENT ? SERVER : CLIENT, &error); - DCHECK_EQ(error_code, QUIC_NO_ERROR) << "Configuration failed: " << error; - if (connection_->version().AuthenticatesHandshakeConnectionIds()) { + QUICHE_DCHECK_EQ(error_code, QUIC_NO_ERROR) + << "Configuration failed: " << error; + if (connection_->version().UsesTls()) { if (connection_->perspective() == Perspective::IS_CLIENT) { test::QuicConfigPeer::SetReceivedOriginalConnectionId( &config, connection_->connection_id()); @@ -131,7 +132,7 @@ void QuicEndpoint::AddBytesToTransfer(QuicByteCount bytes) { void QuicEndpoint::OnStreamFrame(const QuicStreamFrame& frame) { // Verify that the data received always matches the expected. - DCHECK(frame.stream_id == kDataStream); + QUICHE_DCHECK(frame.stream_id == kDataStream); for (size_t i = 0; i < frame.data_length; i++) { if (frame.data_buffer[i] != kStreamDataContents) { wrong_data_received_ = true; @@ -139,7 +140,7 @@ void QuicEndpoint::OnStreamFrame(const QuicStreamFrame& frame) { } offsets_received_.Add(frame.offset, frame.offset + frame.data_length); // Sanity check against very pathological connections. - DCHECK_LE(offsets_received_.Size(), 1000u); + QUICHE_DCHECK_LE(offsets_received_.Size(), 1000u); } void QuicEndpoint::OnCryptoFrame(const QuicCryptoFrame& /*frame*/) {} @@ -184,18 +185,18 @@ bool QuicEndpoint::OnFrameAcked(const QuicFrame& frame, } void QuicEndpoint::OnFrameLost(const QuicFrame& frame) { - DCHECK(notifier_); + QUICHE_DCHECK(notifier_); notifier_->OnFrameLost(frame); } void QuicEndpoint::RetransmitFrames(const QuicFrames& frames, TransmissionType type) { - DCHECK(notifier_); + QUICHE_DCHECK(notifier_); notifier_->RetransmitFrames(frames, type); } bool QuicEndpoint::IsFrameOutstanding(const QuicFrame& frame) const { - DCHECK(notifier_); + QUICHE_DCHECK(notifier_); return notifier_->IsFrameOutstanding(frame); } @@ -243,7 +244,7 @@ void QuicEndpoint::WriteStreamData() { QuicConsumedData consumed_data = connection_->SendStreamData( kDataStream, transmission_size, bytes_transferred_, NO_FIN); - DCHECK(consumed_data.bytes_consumed <= transmission_size); + QUICHE_DCHECK(consumed_data.bytes_consumed <= transmission_size); bytes_transferred_ += consumed_data.bytes_consumed; bytes_to_transfer_ -= consumed_data.bytes_consumed; if (consumed_data.bytes_consumed != transmission_size) { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint.h b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint.h index 681cd33c93d..3d81c706550 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint.h @@ -6,18 +6,18 @@ #define QUICHE_QUIC_TEST_TOOLS_SIMULATOR_QUIC_ENDPOINT_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_default_packet_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_stream_frame_data_producer.h" -#include "net/third_party/quiche/src/quic/core/quic_trace_visitor.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/test_tools/simple_session_notifier.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/link.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/queue.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint_base.h" +#include "quic/core/crypto/null_decrypter.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_default_packet_writer.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_stream_frame_data_producer.h" +#include "quic/core/quic_trace_visitor.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/test_tools/simple_session_notifier.h" +#include "quic/test_tools/simulator/link.h" +#include "quic/test_tools/simulator/queue.h" +#include "quic/test_tools/simulator/quic_endpoint_base.h" namespace quic { namespace simulator { @@ -66,6 +66,7 @@ class QuicEndpoint : public QuicEndpointBase, void OnGoAway(const QuicGoAwayFrame& /*frame*/) override {} void OnMessageReceived(absl::string_view /*message*/) override {} void OnHandshakeDoneReceived() override {} + void OnNewTokenReceived(absl::string_view /*token*/) override {} void OnConnectionClosed(const QuicConnectionCloseFrame& /*frame*/, ConnectionCloseSource /*source*/) override {} void OnWriteBlocked() override {} @@ -79,7 +80,6 @@ class QuicEndpoint : public QuicEndpointBase, void OnPathDegrading() override {} void OnForwardProgressMadeAfterPathDegrading() override {} void OnAckNeedsRetransmittableFrame() override {} - void SendPing() override {} void SendAckFrequency(const QuicAckFrequencyFrame& /*frame*/) override {} bool AllowSelfAddressChange() const override; HandshakeState GetHandshakeState() const override; @@ -103,6 +103,10 @@ class QuicEndpoint : public QuicEndpointBase, return nullptr; } void BeforeConnectionCloseSent() override {} + bool ValidateToken(absl::string_view /*token*/) const override { + return true; + } + void MaybeSendAddressToken() override {} // End QuicConnectionVisitorInterface implementation. diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint_base.cc b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint_base.cc index c05740d6f00..b4882b8ebc6 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint_base.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint_base.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint_base.h" +#include "quic/test_tools/simulator/quic_endpoint_base.h" #include <memory> #include <utility> -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_data_writer.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test_output.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/simulator.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_cat.h" +#include "quic/core/crypto/crypto_handshake_message.h" +#include "quic/core/crypto/crypto_protocol.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_data_writer.h" +#include "quic/platform/api/quic_test_output.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/simulator/simulator.h" namespace quic { namespace simulator { @@ -60,7 +60,7 @@ QuicEndpointBase::QuicEndpointBase(Simulator* simulator, peer_name_(peer_name), writer_(this), nic_tx_queue_(simulator, - quiche::QuicheStringPrintf("%s (TX Queue)", name.c_str()), + absl::StrCat(name, " (TX Queue)"), kMaxOutgoingPacketSize * kTxQueueSize), connection_(nullptr), write_blocked_count_(0), @@ -73,7 +73,7 @@ QuicEndpointBase::~QuicEndpointBase() { const char* perspective_prefix = connection_->perspective() == Perspective::IS_CLIENT ? "C" : "S"; - std::string identifier = quiche::QuicheStrCat( + std::string identifier = absl::StrCat( perspective_prefix, connection_->connection_id().ToString()); QuicRecordTrace(identifier, trace_visitor_->trace()->SerializeAsString()); } @@ -132,9 +132,9 @@ WriteResult QuicEndpointBase::Writer::WritePacket( const QuicIpAddress& /*self_address*/, const QuicSocketAddress& /*peer_address*/, PerPacketOptions* options) { - DCHECK(!IsWriteBlocked()); - DCHECK(options == nullptr); - DCHECK(buf_len <= kMaxOutgoingPacketSize); + QUICHE_DCHECK(!IsWriteBlocked()); + QUICHE_DCHECK(options == nullptr); + QUICHE_DCHECK(buf_len <= kMaxOutgoingPacketSize); // Instead of losing a packet, become write-blocked when the egress queue is // full. diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint_base.h b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint_base.h index c9be24eb089..81b09f1d03e 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint_base.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint_base.h @@ -7,17 +7,18 @@ #include <memory> -#include "net/third_party/quiche/src/quic/core/crypto/null_decrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_default_packet_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_stream_frame_data_producer.h" -#include "net/third_party/quiche/src/quic/core/quic_trace_visitor.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/test_tools/simple_session_notifier.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/link.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/queue.h" +#include "absl/container/flat_hash_map.h" +#include "quic/core/crypto/null_decrypter.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_default_packet_writer.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_stream_frame_data_producer.h" +#include "quic/core/quic_trace_visitor.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/test_tools/simple_session_notifier.h" +#include "quic/test_tools/simulator/link.h" +#include "quic/test_tools/simulator/queue.h" namespace quic { namespace simulator { @@ -150,7 +151,7 @@ class QuicEndpointMultiplexer : public Endpoint, void Act() override {} private: - QuicHashMap<std::string, QuicEndpointBase*> mapping_; + absl::flat_hash_map<std::string, QuicEndpointBase*> mapping_; }; } // namespace simulator diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint_test.cc b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint_test.cc index 967a9b157ad..69b2682dfc0 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint_test.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint_test.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/simulator/quic_endpoint.h" +#include "quic/test_tools/simulator/quic_endpoint.h" #include <utility> -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/simulator.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/switch.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/simulator/simulator.h" +#include "quic/test_tools/simulator/switch.h" using ::testing::_; using ::testing::NiceMock; diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/simulator.cc b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/simulator.cc index 61ae9a3d739..8d68ee4145b 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/simulator.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/simulator.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/simulator/simulator.h" +#include "quic/test_tools/simulator/simulator.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/platform/api/quic_logging.h" namespace quic { namespace simulator { @@ -48,15 +48,15 @@ void Simulator::AddActor(Actor* actor) { auto emplace_names_result = actor_names_.insert(actor->name()); // Ensure that the object was actually placed into the map. - DCHECK(emplace_times_result.second); - DCHECK(emplace_names_result.second); + QUICHE_DCHECK(emplace_times_result.second); + QUICHE_DCHECK(emplace_names_result.second); } void Simulator::RemoveActor(Actor* actor) { auto scheduled_time_it = scheduled_times_.find(actor); auto actor_names_it = actor_names_.find(actor->name()); - DCHECK(scheduled_time_it != scheduled_times_.end()); - DCHECK(actor_names_it != actor_names_.end()); + QUICHE_DCHECK(scheduled_time_it != scheduled_times_.end()); + QUICHE_DCHECK(actor_names_it != actor_names_.end()); QuicTime scheduled_time = scheduled_time_it->second; if (scheduled_time != QuicTime::Infinite()) { @@ -69,7 +69,7 @@ void Simulator::RemoveActor(Actor* actor) { void Simulator::Schedule(Actor* actor, QuicTime new_time) { auto scheduled_time_it = scheduled_times_.find(actor); - DCHECK(scheduled_time_it != scheduled_times_.end()); + QUICHE_DCHECK(scheduled_time_it != scheduled_times_.end()); QuicTime scheduled_time = scheduled_time_it->second; if (scheduled_time <= new_time) { @@ -86,10 +86,10 @@ void Simulator::Schedule(Actor* actor, QuicTime new_time) { void Simulator::Unschedule(Actor* actor) { auto scheduled_time_it = scheduled_times_.find(actor); - DCHECK(scheduled_time_it != scheduled_times_.end()); + QUICHE_DCHECK(scheduled_time_it != scheduled_times_.end()); QuicTime scheduled_time = scheduled_time_it->second; - DCHECK(scheduled_time != QuicTime::Infinite()); + QUICHE_DCHECK(scheduled_time != QuicTime::Infinite()); auto range = schedule_.equal_range(scheduled_time); for (auto it = range.first; it != range.second; ++it) { if (it->second == actor) { @@ -98,7 +98,7 @@ void Simulator::Unschedule(Actor* actor) { return; } } - DCHECK(false); + QUICHE_DCHECK(false); } const QuicClock* Simulator::GetClock() const { @@ -129,7 +129,7 @@ void Simulator::RunForDelegate::OnAlarm() { } void Simulator::RunFor(QuicTime::Delta time_span) { - DCHECK(!run_for_alarm_->IsSet()); + QUICHE_DCHECK(!run_for_alarm_->IsSet()); // RunFor() ensures that the simulation stops at the exact time specified by // scheduling an alarm at that point and using that alarm to abort the @@ -141,8 +141,8 @@ void Simulator::RunFor(QuicTime::Delta time_span) { run_for_should_stop_ = false; bool simulation_result = RunUntil([this]() { return run_for_should_stop_; }); - DCHECK(simulation_result); - DCHECK(clock_.Now() == end_time); + QUICHE_DCHECK(simulation_result); + QUICHE_DCHECK(clock_.Now() == end_time); } void Simulator::HandleNextScheduledActor() { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/simulator.h b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/simulator.h index c1ce07397fc..8f31717e712 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/simulator.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/simulator.h @@ -7,12 +7,14 @@ #include <map> -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_simple_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/actor.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/alarm_factory.h" +#include "absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_set.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_simple_buffer_allocator.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/test_tools/simulator/actor.h" +#include "quic/test_tools/simulator/alarm_factory.h" namespace quic { namespace simulator { @@ -130,8 +132,8 @@ class Simulator : public QuicConnectionHelperInterface { std::multimap<QuicTime, Actor*> schedule_; // For each actor, maintain the time it is scheduled at. The value for // unscheduled actors is QuicTime::Infinite(). - QuicHashMap<Actor*, QuicTime> scheduled_times_; - QuicHashSet<std::string> actor_names_; + absl::flat_hash_map<Actor*, QuicTime> scheduled_times_; + absl::flat_hash_set<std::string> actor_names_; }; template <class TerminationPredicate> diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/simulator_test.cc b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/simulator_test.cc index 0bfce16c433..a71649eb4b5 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/simulator_test.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/simulator_test.cc @@ -2,20 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/simulator/simulator.h" +#include "quic/test_tools/simulator/simulator.h" #include <utility> -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/alarm_factory.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/link.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/packet_filter.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/queue.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/switch.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/traffic_policer.h" +#include "absl/container/node_hash_map.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/test_tools/simulator/alarm_factory.h" +#include "quic/test_tools/simulator/link.h" +#include "quic/test_tools/simulator/packet_filter.h" +#include "quic/test_tools/simulator/queue.h" +#include "quic/test_tools/simulator/switch.h" +#include "quic/test_tools/simulator/traffic_policer.h" using testing::_; using testing::Return; @@ -102,7 +103,7 @@ class CounterPort : public UnconstrainedPortInterface { QuicByteCount bytes_; QuicPacketCount packets_; - QuicUnorderedMap<std::string, QuicPacketCount> + absl::node_hash_map<std::string, QuicPacketCount> per_destination_packet_counter_; }; diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/switch.cc b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/switch.cc index dcfc2d851f4..3a8ee583fbd 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/switch.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/switch.cc @@ -5,8 +5,8 @@ #include <cinttypes> #include <utility> -#include "net/third_party/quiche/src/quic/test_tools/simulator/switch.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_cat.h" +#include "quic/test_tools/simulator/switch.h" namespace quic { namespace simulator { @@ -17,8 +17,8 @@ Switch::Switch(Simulator* simulator, QuicByteCount queue_capacity) { for (size_t port_number = 1; port_number <= port_count; port_number++) { ports_.emplace_back(simulator, - quiche::QuicheStrCat(name, " (port ", port_number, ")"), - this, port_number, queue_capacity); + absl::StrCat(name, " (port ", port_number, ")"), this, + port_number, queue_capacity); } } @@ -33,9 +33,7 @@ Switch::Port::Port(Simulator* simulator, parent_(parent), port_number_(port_number), connected_(false), - queue_(simulator, - quiche::QuicheStringPrintf("%s (queue)", name.c_str()), - queue_capacity) {} + queue_(simulator, absl::StrCat(name, " (queue)"), queue_capacity) {} void Switch::Port::AcceptPacket(std::unique_ptr<Packet> packet) { parent_->DispatchPacket(port_number_, std::move(packet)); diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/switch.h b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/switch.h index 750b24b93f3..bd4e7b619d7 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/switch.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/switch.h @@ -7,8 +7,9 @@ #include <deque> -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/queue.h" +#include "absl/container/flat_hash_map.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/test_tools/simulator/queue.h" namespace quic { namespace simulator { @@ -30,7 +31,7 @@ class Switch { // Returns Endpoint associated with the port under number |port_number|. Just // like on most real switches, port numbering starts with 1. inline Endpoint* port(SwitchPortNumber port_number) { - DCHECK_NE(port_number, 0u); + QUICHE_DCHECK_NE(port_number, 0u); return &ports_[port_number - 1]; } @@ -80,7 +81,7 @@ class Switch { // This can not be a QuicCircularDeque since pointers into this are // assumed to be stable. std::deque<Port> ports_; - QuicHashMap<std::string, Port*> switching_table_; + absl::flat_hash_map<std::string, Port*> switching_table_; }; } // namespace simulator diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/traffic_policer.cc b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/traffic_policer.cc index fa0bcfb6e59..be62669d383 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/traffic_policer.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/traffic_policer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/simulator/traffic_policer.h" +#include "quic/test_tools/simulator/traffic_policer.h" #include <algorithm> @@ -45,7 +45,7 @@ bool TrafficPolicer::FilterPacket(const Packet& packet) { } auto bucket = token_buckets_.find(packet.destination); - DCHECK(bucket != token_buckets_.end()); + QUICHE_DCHECK(bucket != token_buckets_.end()); // Silently drop the packet on the floor if out of tokens if (bucket->second < packet.size) { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/traffic_policer.h b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/traffic_policer.h index e33f51b6c23..bba2b83d118 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/traffic_policer.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/traffic_policer.h @@ -5,8 +5,9 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_SIMULATOR_TRAFFIC_POLICER_H_ #define QUICHE_QUIC_TEST_TOOLS_SIMULATOR_TRAFFIC_POLICER_H_ -#include "net/third_party/quiche/src/quic/test_tools/simulator/packet_filter.h" -#include "net/third_party/quiche/src/quic/test_tools/simulator/port.h" +#include "absl/container/flat_hash_map.h" +#include "quic/test_tools/simulator/packet_filter.h" +#include "quic/test_tools/simulator/port.h" namespace quic { namespace simulator { @@ -44,7 +45,7 @@ class TrafficPolicer : public PacketFilter { QuicTime last_refill_time_; // Maps each destination to the number of tokens it has left. - QuicHashMap<std::string, QuicByteCount> token_buckets_; + absl::flat_hash_map<std::string, QuicByteCount> token_buckets_; }; } // namespace simulator diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/test_certificates.cc b/chromium/net/third_party/quiche/src/quic/test_tools/test_certificates.cc index acbea922274..91949914452 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/test_certificates.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/test_certificates.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/test_certificates.h" +#include "quic/test_tools/test_certificates.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/test_ticket_crypter.cc b/chromium/net/third_party/quiche/src/quic/test_tools/test_ticket_crypter.cc index 40f28d2c125..4c4cfbbac2f 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/test_ticket_crypter.cc +++ b/chromium/net/third_party/quiche/src/quic/test_tools/test_ticket_crypter.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/test_tools/test_ticket_crypter.h" +#include "quic/test_tools/test_ticket_crypter.h" #include <cstring> #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" +#include "quic/core/crypto/quic_random.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/test_ticket_crypter.h b/chromium/net/third_party/quiche/src/quic/test_tools/test_ticket_crypter.h index 5785463b604..63919c61bba 100644 --- a/chromium/net/third_party/quiche/src/quic/test_tools/test_ticket_crypter.h +++ b/chromium/net/third_party/quiche/src/quic/test_tools/test_ticket_crypter.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_TEST_TOOLS_TEST_TICKET_CRYPTER_H_ #define QUICHE_QUIC_TEST_TOOLS_TEST_TICKET_CRYPTER_H_ -#include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" +#include "quic/core/crypto/proof_source.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/tools/fake_proof_verifier.h b/chromium/net/third_party/quiche/src/quic/tools/fake_proof_verifier.h index 87078798edf..a8e5eb8b149 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/fake_proof_verifier.h +++ b/chromium/net/third_party/quiche/src/quic/tools/fake_proof_verifier.h @@ -6,7 +6,7 @@ #define QUICHE_QUIC_TOOLS_FAKE_PROOF_VERIFIER_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_verifier.h" +#include "quic/core/crypto/proof_verifier.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_backend_response.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_backend_response.cc index defa9bfec02..f6177e0f292 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_backend_response.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_backend_response.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_backend_response.h" +#include "quic/tools/quic_backend_response.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_backend_response.h b/chromium/net/third_party/quiche/src/quic/tools/quic_backend_response.h index 9209038f4b3..a7edd78e6f8 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_backend_response.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_backend_response.h @@ -6,8 +6,8 @@ #define QUICHE_QUIC_TOOLS_QUIC_BACKEND_RESPONSE_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/tools/quic_url.h" -#include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" +#include "quic/tools/quic_url.h" +#include "spdy/core/spdy_protocol.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_client.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_client.cc index 16499d2f8aa..f8375ab3b13 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_client.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_client.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_client.h" +#include "quic/tools/quic_client.h" #include <errno.h> #include <netdb.h> @@ -14,19 +14,19 @@ #include <utility> -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_data_reader.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_client_session.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/http/spdy_utils.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_data_reader.h" +#include "quic/core/quic_epoll_alarm_factory.h" +#include "quic/core/quic_epoll_connection_helper.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_server_id.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/tools/quic_simple_client_session.h" namespace quic { @@ -48,7 +48,7 @@ QuicSocketAddress LookupAddress(int address_family_for_lookup, return QuicSocketAddress(); } - CHECK(info_list != nullptr); + QUICHE_CHECK(info_list != nullptr); std::unique_ptr<addrinfo, void (*)(addrinfo*)> info_list_owned(info_list, freeaddrinfo); return QuicSocketAddress(info_list->ai_addr, info_list->ai_addrlen); diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_client.h b/chromium/net/third_party/quiche/src/quic/tools/quic_client.h index ff01cec5831..cc6ec3738a5 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_client.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_client.h @@ -12,14 +12,14 @@ #include <memory> #include <string> -#include "net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_reader.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_epoll.h" -#include "net/third_party/quiche/src/quic/tools/quic_client_epoll_network_helper.h" -#include "net/third_party/quiche/src/quic/tools/quic_spdy_client_base.h" +#include "quic/core/http/quic_client_push_promise_index.h" +#include "quic/core/http/quic_spdy_client_session.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_packet_reader.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_epoll.h" +#include "quic/tools/quic_client_epoll_network_helper.h" +#include "quic/tools/quic_spdy_client_base.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_client_base.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_client_base.cc index 5d89797f8c9..1737f8cb549 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_client_base.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_client_base.cc @@ -2,17 +2,74 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_client_base.h" - -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#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 "quic/tools/quic_client_base.h" +#include <memory> + +#include "quic/core/crypto/quic_random.h" +#include "quic/core/http/spdy_utils.h" +#include "quic/core/quic_packet_writer.h" +#include "quic/core/quic_path_validator.h" +#include "quic/core/quic_server_id.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" namespace quic { +// A path context which owns the writer. +class QUIC_EXPORT_PRIVATE PathMigrationContext + : public QuicPathValidationContext { + public: + PathMigrationContext(std::unique_ptr<QuicPacketWriter> writer, + const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address) + : QuicPathValidationContext(self_address, peer_address), + alternative_writer_(std::move(writer)) {} + + QuicPacketWriter* WriterToUse() override { return alternative_writer_.get(); } + + QuicPacketWriter* ReleaseWriter() { return alternative_writer_.release(); } + + private: + std::unique_ptr<QuicPacketWriter> alternative_writer_; +}; + +// Implements the basic feature of a result delegate for path validation for +// connection migration. If the validation succeeds, migrate to the alternative +// path. Otherwise, stay on the current path. +class QuicClientSocketMigrationValidationResultDelegate + : public QuicPathValidator::ResultDelegate { + public: + QuicClientSocketMigrationValidationResultDelegate(QuicClientBase* client) + : QuicPathValidator::ResultDelegate(), client_(client) {} + + // QuicPathValidator::ResultDelegate + // Overridden to start migration and takes the ownership of the writer in the + // context. + void OnPathValidationSuccess( + std::unique_ptr<QuicPathValidationContext> context) override { + QUIC_DLOG(INFO) << "Successfully validated path from " << *context + << ". Migrate to it now."; + auto migration_context = std::unique_ptr<PathMigrationContext>( + static_cast<PathMigrationContext*>(context.release())); + client_->session()->MigratePath( + migration_context->self_address(), migration_context->peer_address(), + migration_context->WriterToUse(), /*owns_writer=*/false); + QUICHE_DCHECK(migration_context->WriterToUse() != nullptr); + // Hand the ownership of the alternative writer to the client. + client_->set_writer(migration_context->ReleaseWriter()); + } + + void OnPathValidationFailure( + std::unique_ptr<QuicPathValidationContext> context) override { + QUIC_LOG(WARNING) << "Fail to validate path " << *context + << ", stop migrating."; + } + + private: + QuicClientBase* client_; +}; + QuicClientBase::NetworkHelper::~NetworkHelper() = default; QuicClientBase::QuicClientBase( @@ -97,8 +154,8 @@ bool QuicClientBase::Connect() { } void QuicClientBase::StartConnect() { - DCHECK(initialized_); - DCHECK(!connected()); + QUICHE_DCHECK(initialized_); + QUICHE_DCHECK(!connected()); QuicPacketWriter* writer = network_helper_->CreateQuicPacketWriter(); ParsedQuicVersion mutual_version = UnsupportedQuicVersion(); const bool can_reconnect_with_different_version = @@ -148,7 +205,7 @@ void QuicClientBase::InitializeSession() { } void QuicClientBase::Disconnect() { - DCHECK(initialized_); + QUICHE_DCHECK(initialized_); initialized_ = false; if (connected()) { @@ -179,7 +236,7 @@ bool QuicClientBase::WaitForEvents() { network_helper_->RunEventLoop(); - DCHECK(session() != nullptr); + QUICHE_DCHECK(session() != nullptr); ParsedQuicVersion version = UnsupportedQuicVersion(); if (!connected() && CanReconnectWithDifferentVersion(&version)) { QUIC_DLOG(INFO) << "Can reconnect with version: " << version @@ -203,21 +260,56 @@ bool QuicClientBase::MigrateSocketWithSpecifiedPort( } network_helper_->CleanUpAllUDPSockets(); + std::unique_ptr<QuicPacketWriter> writer = + CreateWriterForNewNetwork(new_host, port); + if (writer == nullptr) { + return false; + } + session()->MigratePath(network_helper_->GetLatestClientAddress(), + session()->connection()->peer_address(), writer.get(), + false); + set_writer(writer.release()); + return true; +} + +bool QuicClientBase::ValidateAndMigrateSocket(const QuicIpAddress& new_host) { + QUICHE_DCHECK(VersionHasIetfQuicFrames( + session_->connection()->version().transport_version) && + session_->connection()->use_path_validator()); + if (!connected()) { + return false; + } + + std::unique_ptr<QuicPacketWriter> writer = + CreateWriterForNewNetwork(new_host, local_port_); + if (writer == nullptr) { + return false; + } + // Asynchronously start migration. + session_->ValidatePath( + std::make_unique<PathMigrationContext>( + std::move(writer), network_helper_->GetLatestClientAddress(), + session_->peer_address()), + std::make_unique<QuicClientSocketMigrationValidationResultDelegate>( + this)); + return true; +} +std::unique_ptr<QuicPacketWriter> QuicClientBase::CreateWriterForNewNetwork( + const QuicIpAddress& new_host, + int port) { set_bind_to_address(new_host); + set_local_port(port); if (!network_helper_->CreateUDPSocketAndBind(server_address_, bind_to_address_, port)) { - return false; + return nullptr; } - session()->connection()->SetSelfAddress( - network_helper_->GetLatestClientAddress()); - QuicPacketWriter* writer = network_helper_->CreateQuicPacketWriter(); - set_writer(writer); - session()->connection()->SetQuicPacketWriter(writer, false); - - return true; + QUIC_LOG_IF(WARNING, writer == writer_.get()) + << "The new writer is wrapped in the same wrapper as the old one, thus " + "appearing to have the same address as the old one."; + return std::unique_ptr<QuicPacketWriter>(writer); } bool QuicClientBase::ChangeEphemeralPort() { @@ -268,9 +360,10 @@ bool QuicClientBase::WaitForOneRttKeysAvailable() { } bool QuicClientBase::WaitForHandshakeConfirmed() { - if (!session_->connection()->version().HasHandshakeDone()) { + if (!session_->connection()->version().UsesTls()) { return WaitForOneRttKeysAvailable(); } + // Otherwise, wait for receipt of HANDSHAKE_DONE frame. while (connected() && session_->GetHandshakeState() < HANDSHAKE_CONFIRMED) { WaitForEvents(); } @@ -351,4 +444,46 @@ bool QuicClientBase::CanReconnectWithDifferentVersion( return false; } +bool QuicClientBase::HasPendingPathValidation() { + return session()->HasPendingPathValidation(); +} + +class ValidationResultDelegate : public QuicPathValidator::ResultDelegate { + public: + ValidationResultDelegate(QuicClientBase* client) + : QuicPathValidator::ResultDelegate(), client_(client) {} + + void OnPathValidationSuccess( + std::unique_ptr<QuicPathValidationContext> context) override { + QUIC_DLOG(INFO) << "Successfully validated path from " << *context; + client_->AddValidatedPath(std::move(context)); + } + void OnPathValidationFailure( + std::unique_ptr<QuicPathValidationContext> context) override { + QUIC_LOG(WARNING) << "Fail to validate path " << *context + << ", stop migrating."; + } + + private: + QuicClientBase* client_; +}; + +void QuicClientBase::ValidateNewNetwork(const QuicIpAddress& host) { + std::unique_ptr<QuicPacketWriter> writer = + CreateWriterForNewNetwork(host, local_port_); + auto result_delegate = std::make_unique<ValidationResultDelegate>(this); + if (writer == nullptr) { + result_delegate->OnPathValidationFailure( + std::make_unique<PathMigrationContext>( + nullptr, network_helper_->GetLatestClientAddress(), + session_->peer_address())); + return; + } + session()->ValidatePath( + std::make_unique<PathMigrationContext>( + std::move(writer), network_helper_->GetLatestClientAddress(), + session_->peer_address()), + std::move(result_delegate)); +} + } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_client_base.h b/chromium/net/third_party/quiche/src/quic/tools/quic_client_base.h index ce2444ce925..82ee39256cf 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_client_base.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_client_base.h @@ -8,16 +8,17 @@ #ifndef QUICHE_QUIC_TOOLS_QUIC_CLIENT_BASE_H_ #define QUICHE_QUIC_TOOLS_QUIC_CLIENT_BASE_H_ +#include <memory> #include <string> #include "absl/base/attributes.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/core/crypto/crypto_handshake.h" +#include "quic/core/http/quic_client_push_promise_index.h" +#include "quic/core/http/quic_spdy_client_session.h" +#include "quic/core/http/quic_spdy_client_stream.h" +#include "quic/core/quic_config.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { @@ -121,6 +122,11 @@ class QuicClientBase { // Migrate to a new socket (new_host, port) during an active connection. bool MigrateSocketWithSpecifiedPort(const QuicIpAddress& new_host, int port); + // Validate the new socket and migrate to it if the validation succeeds. + // Otherwise stay on the current socket. Return true if the validation has + // started. + bool ValidateAndMigrateSocket(const QuicIpAddress& new_host); + // Open a new socket to change to a new ephemeral port. bool ChangeEphemeralPort(); @@ -244,6 +250,19 @@ class QuicClientBase { client_connection_id_length_ = client_connection_id_length; } + bool HasPendingPathValidation(); + + void ValidateNewNetwork(const QuicIpAddress& host); + + void AddValidatedPath(std::unique_ptr<QuicPathValidationContext> context) { + validated_paths_.push_back(std::move(context)); + } + + const std::vector<std::unique_ptr<QuicPathValidationContext>>& + validated_paths() const { + return validated_paths_; + } + protected: // TODO(rch): Move GetNumSentClientHellosFromSession and // GetNumReceivedServerConfigUpdatesFromSession into a new/better @@ -299,6 +318,10 @@ class QuicClientBase { // version. bool CanReconnectWithDifferentVersion(ParsedQuicVersion* version) const; + std::unique_ptr<QuicPacketWriter> CreateWriterForNewNetwork( + const QuicIpAddress& new_host, + int port); + // |server_id_| is a tuple (hostname, port, is_https) of the server. QuicServerId server_id_; @@ -370,6 +393,9 @@ class QuicClientBase { // GetClientConnectionId creates a random connection ID of this length. // Defaults to 0. uint8_t client_connection_id_length_; + + // Stores validated paths. + std::vector<std::unique_ptr<QuicPathValidationContext>> validated_paths_; }; } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_client_bin.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_client_bin.cc index 226e647351a..0b981255200 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_client_bin.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_client_bin.cc @@ -44,9 +44,9 @@ #include <memory> #include <string> -#include "net/third_party/quiche/src/quic/platform/api/quic_system_event_loop.h" -#include "net/third_party/quiche/src/quic/tools/quic_epoll_client_factory.h" -#include "net/third_party/quiche/src/quic/tools/quic_toy_client.h" +#include "quic/platform/api/quic_system_event_loop.h" +#include "quic/tools/quic_epoll_client_factory.h" +#include "quic/tools/quic_toy_client.h" int main(int argc, char* argv[]) { QuicSystemEventLoop event_loop("quic_client"); diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_client_epoll_network_helper.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_client_epoll_network_helper.cc index 2a9ebbac0dd..2049f15f217 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_client_epoll_network_helper.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_client_epoll_network_helper.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_client_epoll_network_helper.h" +#include "quic/tools/quic_client_epoll_network_helper.h" #include <errno.h> #include <netinet/in.h> @@ -11,18 +11,18 @@ #include <sys/socket.h> #include <unistd.h> -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_data_reader.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" -#include "net/third_party/quiche/src/quic/core/quic_udp_socket.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_system_event_loop.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/http/spdy_utils.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_data_reader.h" +#include "quic/core/quic_epoll_alarm_factory.h" +#include "quic/core/quic_epoll_connection_helper.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_server_id.h" +#include "quic/core/quic_udp_socket.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_system_event_loop.h" namespace quic { @@ -110,7 +110,7 @@ void QuicClientEpollNetworkHelper::CleanUpUDPSocketImpl(int fd) { if (fd > -1) { epoll_server_->UnregisterFD(fd); int rc = close(fd); - DCHECK_EQ(0, rc); + QUICHE_DCHECK_EQ(0, rc); } } @@ -129,7 +129,7 @@ void QuicClientEpollNetworkHelper::OnUnregistration(int /*fd*/, void QuicClientEpollNetworkHelper::OnShutdown(QuicEpollServer* /*eps*/, int /*fd*/) {} -void QuicClientEpollNetworkHelper::OnEvent(int /*fd*/, QuicEpollEvent* event) { +void QuicClientEpollNetworkHelper::OnEvent(int fd, QuicEpollEvent* event) { if (event->in_events & EPOLLIN) { QUIC_DVLOG(1) << "Read packets on EPOLLIN"; int times_to_read = max_reads_per_epoll_loop_; @@ -137,9 +137,8 @@ void QuicClientEpollNetworkHelper::OnEvent(int /*fd*/, QuicEpollEvent* event) { QuicPacketCount packets_dropped = 0; while (client_->connected() && more_to_read && times_to_read > 0) { more_to_read = packet_reader_->ReadAndDispatchPackets( - GetLatestFD(), GetLatestClientAddress().port(), - *client_->helper()->GetClock(), this, - overflow_supported_ ? &packets_dropped : nullptr); + fd, GetLatestClientAddress().port(), *client_->helper()->GetClock(), + this, overflow_supported_ ? &packets_dropped : nullptr); --times_to_read; } if (packets_dropped_ < packets_dropped) { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_client_epoll_network_helper.h b/chromium/net/third_party/quiche/src/quic/tools/quic_client_epoll_network_helper.h index 1ca4280fabe..df0a3b4a4f5 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_client_epoll_network_helper.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_client_epoll_network_helper.h @@ -12,12 +12,12 @@ #include <memory> #include <string> -#include "net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_reader.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_epoll.h" -#include "net/third_party/quiche/src/quic/tools/quic_client_base.h" +#include "quic/core/http/quic_client_push_promise_index.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_packet_reader.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_epoll.h" +#include "quic/tools/quic_client_base.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_client_interop_test_bin.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_client_interop_test_bin.cc index e16afe686cf..f67a338b09c 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_client_interop_test_bin.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_client_interop_test_bin.cc @@ -7,18 +7,18 @@ #include <string> #include <utility> -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_epoll.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_system_event_loop.h" +#include "absl/strings/str_cat.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_epoll.h" +#include "quic/platform/api/quic_system_event_loop.h" #include "net/quic/platform/impl/quic_epoll_clock.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/simple_session_cache.h" -#include "net/third_party/quiche/src/quic/tools/fake_proof_verifier.h" -#include "net/third_party/quiche/src/quic/tools/quic_client.h" -#include "net/third_party/quiche/src/quic/tools/quic_url.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_session_peer.h" +#include "quic/test_tools/simple_session_cache.h" +#include "quic/tools/fake_proof_verifier.h" +#include "quic/tools/quic_client.h" +#include "quic/tools/quic_url.h" DEFINE_QUIC_COMMAND_LINE_FLAG(std::string, host, @@ -378,18 +378,19 @@ std::set<Feature> ServerSupport(std::string dns_host, break; } } - CHECK(version.IsKnown()); + QUICHE_CHECK(version.IsKnown()); QuicEnableVersion(version); + std::cout << "Attempting interop with version " << version << std::endl; + // Build the client, and try to connect. - QuicSocketAddress addr = - tools::LookupAddress(dns_host, quiche::QuicheStrCat(port)); + QuicSocketAddress addr = tools::LookupAddress(dns_host, absl::StrCat(port)); if (!addr.IsInitialized()) { QUIC_LOG(ERROR) << "Failed to resolve " << dns_host; return std::set<Feature>(); } QuicServerId server_id(url_host, port, false); - std::string authority = quiche::QuicheStrCat(url_host, ":", port); + std::string authority = absl::StrCat(url_host, ":", port); QuicClientInteropRunner runner; diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_client_test.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_client_test.cc index 034c4dda6ca..160f2553142 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_client_test.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_client_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_client.h" +#include "quic/tools/quic_client.h" #include <dirent.h> #include <sys/types.h> @@ -12,13 +12,13 @@ #include "absl/strings/match.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_epoll.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_port_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test_loopback.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_client_peer.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/platform/api/quic_epoll.h" +#include "quic/platform/api/quic_port_utils.h" +#include "quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test_loopback.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/quic_client_peer.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { namespace test { @@ -29,7 +29,8 @@ const char* kPathToFds = "/proc/self/fd"; std::string ReadLink(const std::string& path) { std::string result(PATH_MAX, '\0'); ssize_t result_size = readlink(path.c_str(), &result[0], result.size()); - CHECK(result_size > 0 && static_cast<size_t>(result_size) < result.size()); + QUICHE_CHECK(result_size > 0 && + static_cast<size_t>(result_size) < result.size()); result.resize(result_size); return result; } @@ -46,7 +47,7 @@ size_t NumOpenSocketFDs() { continue; } - std::string fd_path = ReadLink(quiche::QuicheStrCat(kPathToFds, "/", name)); + std::string fd_path = ReadLink(absl::StrCat(kPathToFds, "/", name)); if (absl::StartsWith(fd_path, "socket:")) { socket_count++; } diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_epoll_client_factory.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_epoll_client_factory.cc index b7dbb07fa7b..84830382f48 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_epoll_client_factory.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_epoll_client_factory.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_epoll_client_factory.h" +#include "quic/tools/quic_epoll_client_factory.h" #include <netdb.h> #include <sys/socket.h> @@ -10,10 +10,10 @@ #include <utility> -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/third_party/quiche/src/quic/tools/quic_client.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "absl/strings/str_cat.h" +#include "quic/core/quic_server_id.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/tools/quic_client.h" namespace quic { @@ -26,7 +26,7 @@ std::unique_ptr<QuicSpdyClientBase> QuicEpollClientFactory::CreateClient( const QuicConfig& config, std::unique_ptr<ProofVerifier> verifier) { QuicSocketAddress addr = tools::LookupAddress( - address_family_for_lookup, host_for_lookup, quiche::QuicheStrCat(port)); + address_family_for_lookup, host_for_lookup, absl::StrCat(port)); if (!addr.IsInitialized()) { QUIC_LOG(ERROR) << "Unable to resolve address: " << host_for_lookup; return nullptr; diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_epoll_client_factory.h b/chromium/net/third_party/quiche/src/quic/tools/quic_epoll_client_factory.h index 84dbc98ef28..e23eb634ea8 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_epoll_client_factory.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_epoll_client_factory.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_TOOLS_EPOLL_CLIENT_FACTORY_H_ #define QUICHE_QUIC_TOOLS_EPOLL_CLIENT_FACTORY_H_ -#include "net/third_party/quiche/src/quic/platform/api/quic_epoll.h" -#include "net/third_party/quiche/src/quic/tools/quic_toy_client.h" +#include "quic/platform/api/quic_epoll.h" +#include "quic/tools/quic_toy_client.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_epoll_server_factory.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_epoll_server_factory.cc index d216cd1d3ae..98c60ae09e1 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_epoll_server_factory.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_epoll_server_factory.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_epoll_server_factory.h" +#include "quic/tools/quic_epoll_server_factory.h" #include <utility> -#include "net/third_party/quiche/src/quic/tools/quic_server.h" +#include "quic/tools/quic_server.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_epoll_server_factory.h b/chromium/net/third_party/quiche/src/quic/tools/quic_epoll_server_factory.h index 90702918452..7fc61fb7094 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_epoll_server_factory.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_epoll_server_factory.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_TOOLS_EPOLL_SERVER_FACTORY_H_ #define QUICHE_QUIC_TOOLS_EPOLL_SERVER_FACTORY_H_ -#include "net/third_party/quiche/src/quic/platform/api/quic_epoll.h" -#include "net/third_party/quiche/src/quic/tools/quic_toy_server.h" +#include "quic/platform/api/quic_epoll.h" +#include "quic/tools/quic_toy_server.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.cc index 465e0a9f8bc..c67e5b35be8 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.cc @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h" +#include "quic/tools/quic_memory_cache_backend.h" #include <utility> #include "absl/strings/match.h" #include "absl/strings/numbers.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_file_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/http/spdy_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_file_utils.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_map_util.h" +#include "common/platform/api/quiche_text_utils.h" using spdy::Http2HeaderBlock; using spdy::kV3LowestPriority; @@ -105,7 +105,7 @@ void QuicMemoryCacheBackend::ResourceFile::Read() { void QuicMemoryCacheBackend::ResourceFile::SetHostPathFromBase( absl::string_view base) { - DCHECK(base[0] != '/') << base; + QUICHE_DCHECK(base[0] != '/') << base; size_t path_start = base.find_first_of('/'); if (path_start == absl::string_view::npos) { host_ = std::string(base); @@ -359,7 +359,8 @@ void QuicMemoryCacheBackend::AddResponseImpl( Http2HeaderBlock response_trailers) { QuicWriterMutexLock lock(&response_mutex_); - DCHECK(!host.empty()) << "Host must be populated, e.g. \"www.google.com\""; + QUICHE_DCHECK(!host.empty()) + << "Host must be populated, e.g. \"www.google.com\""; std::string key = GetKey(host, path); if (QuicContainsKey(responses_, key)) { QUIC_BUG << "Response for '" << key << "' already exists!"; diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h b/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h index e43bf60f823..5e4b2674dd9 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h @@ -10,14 +10,15 @@ #include <memory> #include <vector> +#include "absl/container/flat_hash_map.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_mutex.h" -#include "net/third_party/quiche/src/quic/tools/quic_backend_response.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h" -#include "net/third_party/quiche/src/quic/tools/quic_url.h" -#include "net/third_party/quiche/src/spdy/core/spdy_framer.h" +#include "quic/core/http/spdy_utils.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_mutex.h" +#include "quic/tools/quic_backend_response.h" +#include "quic/tools/quic_simple_server_backend.h" +#include "quic/tools/quic_url.h" +#include "spdy/core/spdy_framer.h" namespace quic { @@ -168,8 +169,8 @@ class QuicMemoryCacheBackend : public QuicSimpleServerBackend { QuicBackendResponse::ServerPushInfo resource); // Cached responses. - QuicHashMap<std::string, std::unique_ptr<QuicBackendResponse>> responses_ - QUIC_GUARDED_BY(response_mutex_); + absl::flat_hash_map<std::string, std::unique_ptr<QuicBackendResponse>> + responses_ QUIC_GUARDED_BY(response_mutex_); // The default response for cache misses, if set. std::unique_ptr<QuicBackendResponse> default_response_ diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend_test.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend_test.cc index 5940baaf849..e86bb872b47 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend_test.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_memory_cache_backend_test.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h" +#include "quic/tools/quic_memory_cache_backend.h" #include "absl/strings/match.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_file_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/tools/quic_backend_response.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "absl/strings/str_cat.h" +#include "quic/platform/api/quic_file_utils.h" +#include "quic/platform/api/quic_map_util.h" +#include "quic/platform/api/quic_test.h" +#include "quic/tools/quic_backend_response.h" +#include "common/platform/api/quiche_text_utils.h" namespace quic { namespace test { @@ -189,7 +189,7 @@ TEST_F(QuicMemoryCacheBackendTest, AddSimpleResponseWithServerPushResources) { std::string url = scheme + "://" + request_host + path; QuicUrl resource_url(url); std::string body = - quiche::QuicheStrCat("This is server push response body for ", path); + absl::StrCat("This is server push response body for ", path); spdy::Http2HeaderBlock response_headers; response_headers[":status"] = "200"; response_headers["content-length"] = diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_packet_printer_bin.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_packet_printer_bin.cc index cfe0b8d0d8c..9d67b09e5e8 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_packet_printer_bin.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_packet_printer_bin.cc @@ -28,10 +28,10 @@ #include <iostream> -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "common/platform/api/quiche_text_utils.h" #include "absl/strings/string_view.h" #include "absl/strings/escaping.h" @@ -80,9 +80,9 @@ class QuicPacketPrinter : public QuicFramerVisitorInterface { std::cerr << "OnUnauthenticatedHeader: " << header; return true; } - void OnDecryptedPacket(EncryptionLevel level) override { + void OnDecryptedPacket(size_t /*length*/, EncryptionLevel level) override { // This only currently supports "decrypting" null encrypted packets. - DCHECK_EQ(ENCRYPTION_INITIAL, level); + QUICHE_DCHECK_EQ(ENCRYPTION_INITIAL, level); std::cerr << "OnDecryptedPacket\n"; } bool OnPacketHeader(const QuicPacketHeader& /*header*/) override { @@ -270,13 +270,10 @@ int main(int argc, char* argv[]) { quic::QuicTime start(quic::QuicTime::Zero()); quic::QuicFramer framer(versions, start, perspective, quic::kQuicDefaultConnectionIdLength); - if (!GetQuicFlag(FLAGS_quic_version).empty()) { - for (const quic::ParsedQuicVersion& version : versions) { - if (quic::QuicVersionToString(version.transport_version) == - GetQuicFlag(FLAGS_quic_version)) { - framer.set_version(version); - } - } + const quic::ParsedQuicVersion& version = + quic::ParseQuicVersionString(GetQuicFlag(FLAGS_quic_version)); + if (version != quic::ParsedQuicVersion::Unsupported()) { + framer.set_version(version); } quic::QuicPacketPrinter visitor(&framer); framer.set_visitor(&visitor); diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_reject_reason_decoder_bin.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_reject_reason_decoder_bin.cc index f17cd031715..aecc8fe1fdf 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_reject_reason_decoder_bin.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_reject_reason_decoder_bin.cc @@ -8,10 +8,10 @@ #include <iostream> #include "absl/strings/numbers.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/crypto_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "common/platform/api/quiche_text_utils.h" using quic::CryptoUtils; using quic::HandshakeFailureReason; diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_server.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_server.cc index 53fb95f0334..fe10d12a389 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_server.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_server.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_server.h" +#include "quic/tools/quic_server.h" #include <errno.h> #include <features.h> @@ -14,23 +14,23 @@ #include <cstdint> #include <memory> -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/quic_clock.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_data_reader.h" -#include "net/third_party/quiche/src/quic/core/quic_default_packet_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_dispatcher.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_reader.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#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 "quic/core/crypto/crypto_handshake.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/quic_clock.h" +#include "quic/core/quic_crypto_stream.h" +#include "quic/core/quic_data_reader.h" +#include "quic/core/quic_default_packet_writer.h" +#include "quic/core/quic_dispatcher.h" +#include "quic/core/quic_epoll_alarm_factory.h" +#include "quic/core/quic_epoll_connection_helper.h" +#include "quic/core/quic_packet_reader.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" #include "net/quic/platform/impl/quic_epoll_clock.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_crypto_server_stream_helper.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h" +#include "quic/tools/quic_simple_crypto_server_stream_helper.h" +#include "quic/tools/quic_simple_dispatcher.h" +#include "quic/tools/quic_simple_server_backend.h" namespace quic { @@ -82,7 +82,7 @@ QuicServer::QuicServer( quic_simple_server_backend_(quic_simple_server_backend), expected_server_connection_id_length_( expected_server_connection_id_length) { - DCHECK(quic_simple_server_backend_); + QUICHE_DCHECK(quic_simple_server_backend_); Initialize(); } @@ -190,7 +190,7 @@ void QuicServer::Shutdown() { } void QuicServer::OnEvent(int fd, QuicEpollEvent* event) { - DCHECK_EQ(fd, fd_); + QUICHE_DCHECK_EQ(fd, fd_); event->out_ready_mask = 0; if (event->in_events & EPOLLIN) { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_server.h b/chromium/net/third_party/quiche/src/quic/tools/quic_server.h index bf1555ce3ef..931ac64ec46 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_server.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_server.h @@ -14,17 +14,17 @@ #include <memory> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h" -#include "net/third_party/quiche/src/quic/core/quic_framer.h" -#include "net/third_party/quiche/src/quic/core/quic_packet_writer.h" -#include "net/third_party/quiche/src/quic/core/quic_udp_socket.h" -#include "net/third_party/quiche/src/quic/core/quic_version_manager.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_epoll.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h" -#include "net/third_party/quiche/src/quic/tools/quic_spdy_server_base.h" +#include "quic/core/crypto/quic_crypto_server_config.h" +#include "quic/core/quic_config.h" +#include "quic/core/quic_epoll_connection_helper.h" +#include "quic/core/quic_framer.h" +#include "quic/core/quic_packet_writer.h" +#include "quic/core/quic_udp_socket.h" +#include "quic/core/quic_version_manager.h" +#include "quic/platform/api/quic_epoll.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/tools/quic_simple_server_backend.h" +#include "quic/tools/quic_spdy_server_base.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_server_bin.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_server_bin.cc index 541f6f9e13e..6ed8e994bea 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_server_bin.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_server_bin.cc @@ -7,10 +7,10 @@ #include <vector> -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/tools/quic_epoll_server_factory.h" -#include "net/third_party/quiche/src/quic/tools/quic_toy_server.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/tools/quic_epoll_server_factory.h" +#include "quic/tools/quic_toy_server.h" int main(int argc, char* argv[]) { const char* usage = "Usage: quic_server [options]"; diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_server_test.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_server_test.cc index 06aa105dd78..80ab7f798a1 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_server_test.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_server_test.cc @@ -2,24 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_server.h" +#include "quic/tools/quic_server.h" #include "absl/base/macros.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_alarm_factory.h" -#include "net/third_party/quiche/src/quic/core/quic_epoll_connection_helper.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#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_port_utils.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/platform/api/quic_test_loopback.h" -#include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/mock_quic_dispatcher.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_server_peer.h" -#include "net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_crypto_server_stream_helper.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/quic_epoll_alarm_factory.h" +#include "quic/core/quic_epoll_connection_helper.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_port_utils.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test_loopback.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/mock_quic_dispatcher.h" +#include "quic/test_tools/quic_server_peer.h" +#include "quic/tools/quic_memory_cache_backend.h" +#include "quic/tools/quic_simple_crypto_server_stream_helper.h" namespace quic { namespace test { @@ -118,7 +118,7 @@ TEST_F(QuicServerEpollInTest, ProcessBufferedCHLOsOnEpollin) { StartListening(); bool more_chlos = true; MockQuicSimpleDispatcher* dispatcher_ = server_.mock_dispatcher(); - DCHECK(dispatcher_ != nullptr); + QUICHE_DCHECK(dispatcher_ != nullptr); EXPECT_CALL(*dispatcher_, OnCanWrite()).Times(testing::AnyNumber()); EXPECT_CALL(*dispatcher_, ProcessBufferedChlos(_)).Times(2); EXPECT_CALL(*dispatcher_, HasPendingWrites()).Times(testing::AnyNumber()); diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_client_session.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_client_session.cc index 38ff4fce343..7f64495f0fd 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_client_session.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_client_session.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_simple_client_session.h" +#include "quic/tools/quic_simple_client_session.h" #include <utility> diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_client_session.h b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_client_session.h index 0ebca98fa04..5b5314183f8 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_client_session.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_client_session.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_TOOLS_QUIC_SIMPLE_CLIENT_SESSION_H_ #define QUICHE_QUIC_TOOLS_QUIC_SIMPLE_CLIENT_SESSION_H_ -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_client_stream.h" +#include "quic/core/http/quic_spdy_client_session.h" +#include "quic/tools/quic_simple_client_stream.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_client_stream.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_client_stream.cc index b851a1d7eb0..21145e1e2c7 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_client_stream.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_client_stream.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_simple_client_stream.h" +#include "quic/tools/quic_simple_client_stream.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_client_stream.h b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_client_stream.h index aa6d2f6fe44..471bdfb7553 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_client_stream.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_client_stream.h @@ -5,7 +5,7 @@ #ifndef QUICHE_QUIC_TOOLS_QUIC_SIMPLE_CLIENT_STREAM_H_ #define QUICHE_QUIC_TOOLS_QUIC_SIMPLE_CLIENT_STREAM_H_ -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.h" +#include "quic/core/http/quic_spdy_client_stream.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_crypto_server_stream_helper.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_crypto_server_stream_helper.cc index d27506ea06c..5c39d20e97b 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_crypto_server_stream_helper.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_crypto_server_stream_helper.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_simple_crypto_server_stream_helper.h" +#include "quic/tools/quic_simple_crypto_server_stream_helper.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" +#include "quic/core/quic_utils.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_crypto_server_stream_helper.h b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_crypto_server_stream_helper.h index 02745cd8acc..1fccfc0d447 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_crypto_server_stream_helper.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_crypto_server_stream_helper.h @@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_TOOLS_QUIC_SIMPLE_CRYPTO_SERVER_STREAM_HELPER_H_ #define QUICHE_QUIC_TOOLS_QUIC_SIMPLE_CRYPTO_SERVER_STREAM_HELPER_H_ -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/quic_crypto_server_stream_base.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.cc index 95d507155d5..736c061a2db 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.h" +#include "quic/tools/quic_simple_dispatcher.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_session.h" +#include "quic/tools/quic_simple_server_session.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.h b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.h index d213814e295..a629d3cd299 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_dispatcher.h @@ -6,9 +6,9 @@ #define QUICHE_QUIC_TOOLS_QUIC_SIMPLE_DISPATCHER_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/http/quic_server_session_base.h" -#include "net/third_party/quiche/src/quic/core/quic_dispatcher.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h" +#include "quic/core/http/quic_server_session_base.h" +#include "quic/core/quic_dispatcher.h" +#include "quic/tools/quic_simple_server_backend.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h index fad30415a37..9e16d4e9a88 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h @@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_TOOLS_QUIC_SIMPLE_SERVER_BACKEND_H_ #define QUICHE_QUIC_TOOLS_QUIC_SIMPLE_SERVER_BACKEND_H_ -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/tools/quic_backend_response.h" -#include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" +#include "quic/core/quic_types.h" +#include "quic/tools/quic_backend_response.h" +#include "spdy/core/spdy_header_block.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session.cc index 72d6259fdff..044998c9e16 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_session.h" +#include "quic/tools/quic_simple_server_session.h" #include <utility> -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_session.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#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_ptr_util.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_stream.h" +#include "quic/core/http/quic_spdy_session.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/tools/quic_simple_server_stream.h" namespace quic { @@ -35,7 +35,7 @@ QuicSimpleServerSession::QuicSimpleServerSession( highest_promised_stream_id_( QuicUtils::GetInvalidStreamId(connection->transport_version())), quic_simple_server_backend_(quic_simple_server_backend) { - DCHECK(quic_simple_server_backend_); + QUICHE_DCHECK(quic_simple_server_backend_); } QuicSimpleServerSession::~QuicSimpleServerSession() { @@ -65,7 +65,7 @@ void QuicSimpleServerSession::PromisePushResources( const std::string& request_url, const std::list<QuicBackendResponse::ServerPushInfo>& resources, QuicStreamId original_stream_id, - const spdy::SpdyStreamPrecedence& original_precedence, + const spdy::SpdyStreamPrecedence& /* original_precedence */, const spdy::Http2HeaderBlock& original_request_headers) { if (!server_push_enabled()) { return; @@ -85,11 +85,9 @@ void QuicSimpleServerSession::PromisePushResources( highest_promised_stream_id_ = new_highest_promised_stream_id; SendPushPromise(original_stream_id, highest_promised_stream_id_, headers.Clone()); - promised_streams_.push_back(PromisedStreamInfo( - std::move(headers), highest_promised_stream_id_, - use_http2_priority_write_scheduler() - ? original_precedence - : spdy::SpdyStreamPrecedence(resource.priority))); + promised_streams_.push_back( + PromisedStreamInfo(std::move(headers), highest_promised_stream_id_, + spdy::SpdyStreamPrecedence(resource.priority))); } // Procese promised push request as many as possible. @@ -117,7 +115,7 @@ QuicSpdyStream* QuicSimpleServerSession::CreateIncomingStream( QuicSimpleServerStream* QuicSimpleServerSession::CreateOutgoingBidirectionalStream() { - DCHECK(false); + QUICHE_DCHECK(false); return nullptr; } @@ -157,14 +155,15 @@ void QuicSimpleServerSession::HandleRstOnValidNonexistentStream( // Since PromisedStreamInfo are queued in sequence, the corresponding // index for it in promised_streams_ can be calculated. QuicStreamId next_stream_id = next_outgoing_unidirectional_stream_id(); - if (VersionHasIetfQuicFrames(transport_version())) { - DCHECK(!QuicUtils::IsBidirectionalStreamId(frame.stream_id, version())); + if ((!version().HasIetfQuicFrames() || + !QuicUtils::IsBidirectionalStreamId(frame.stream_id, version())) && + frame.stream_id >= next_stream_id) { + size_t index = (frame.stream_id - next_stream_id) / + QuicUtils::StreamIdDelta(transport_version()); + if (index <= promised_streams_.size()) { + promised_streams_[index].is_cancelled = true; + } } - DCHECK_GE(frame.stream_id, next_stream_id); - size_t index = (frame.stream_id - next_stream_id) / - QuicUtils::StreamIdDelta(transport_version()); - DCHECK_LE(index, promised_streams_.size()); - promised_streams_[index].is_cancelled = true; control_frame_manager().WriteOrBufferRstStream(frame.stream_id, QUIC_RST_ACKNOWLEDGEMENT, 0); connection()->OnStreamReset(frame.stream_id, QUIC_RST_ACKNOWLEDGEMENT); @@ -207,8 +206,8 @@ void QuicSimpleServerSession::HandlePromisedPushRequests() { while (!promised_streams_.empty() && ShouldCreateOutgoingUnidirectionalStream()) { PromisedStreamInfo& promised_info = promised_streams_.front(); - DCHECK_EQ(next_outgoing_unidirectional_stream_id(), - promised_info.stream_id); + QUICHE_DCHECK_EQ(next_outgoing_unidirectional_stream_id(), + promised_info.stream_id); if (promised_info.is_cancelled) { // This stream has been reset by client. Skip this stream id. @@ -220,8 +219,8 @@ void QuicSimpleServerSession::HandlePromisedPushRequests() { QuicSimpleServerStream* promised_stream = static_cast<QuicSimpleServerStream*>( CreateOutgoingUnidirectionalStream()); - DCHECK_NE(promised_stream, nullptr); - DCHECK_EQ(promised_info.stream_id, promised_stream->id()); + QUICHE_DCHECK_NE(promised_stream, nullptr); + QUICHE_DCHECK_EQ(promised_info.stream_id, promised_stream->id()); QUIC_DLOG(INFO) << "created server push stream " << promised_stream->id(); promised_stream->SetPriority(promised_info.precedence); @@ -246,7 +245,7 @@ void QuicSimpleServerSession::MaybeInitializeHttp3UnidirectionalStreams() { size_t previous_static_stream_count = num_static_streams(); QuicSpdySession::MaybeInitializeHttp3UnidirectionalStreams(); size_t current_static_stream_count = num_static_streams(); - DCHECK_GE(current_static_stream_count, previous_static_stream_count); + QUICHE_DCHECK_GE(current_static_stream_count, previous_static_stream_count); highest_promised_stream_id_ += QuicUtils::StreamIdDelta(transport_version()) * (current_static_stream_count - previous_static_stream_count); diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session.h b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session.h index 6d1bc81e64c..49aaae56b37 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session.h @@ -16,14 +16,14 @@ #include <utility> #include <vector> -#include "net/third_party/quiche/src/quic/core/http/quic_server_session_base.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_session.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream_base.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/tools/quic_backend_response.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_stream.h" +#include "quic/core/http/quic_server_session_base.h" +#include "quic/core/http/quic_spdy_session.h" +#include "quic/core/quic_crypto_server_stream_base.h" +#include "quic/core/quic_packets.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/tools/quic_backend_response.h" +#include "quic/tools/quic_simple_server_backend.h" +#include "quic/tools/quic_simple_server_stream.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session_test.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session_test.cc index 66ee8c4591a..80d3a930349 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session_test.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session_test.cc @@ -2,42 +2,42 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_session.h" +#include "quic/tools/quic_simple_server_session.h" #include <algorithm> #include <memory> #include <utility> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/http/http_encoder.h" -#include "net/third_party/quiche/src/quic/core/proto/cached_network_parameters_proto.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/core/tls_server_handshaker.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.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/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/mock_quic_session_visitor.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_sustained_bandwidth_recorder_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/tools/quic_backend_response.h" -#include "net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_stream.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/crypto/quic_crypto_server_config.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/http/http_encoder.h" +#include "quic/core/proto/cached_network_parameters_proto.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_crypto_server_stream.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/core/tls_server_handshaker.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/mock_quic_session_visitor.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_sent_packet_manager_peer.h" +#include "quic/test_tools/quic_session_peer.h" +#include "quic/test_tools/quic_spdy_session_peer.h" +#include "quic/test_tools/quic_stream_peer.h" +#include "quic/test_tools/quic_sustained_bandwidth_recorder_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/tools/quic_backend_response.h" +#include "quic/tools/quic_memory_cache_backend.h" +#include "quic/tools/quic_simple_server_stream.h" +#include "common/platform/api/quiche_text_utils.h" using testing::_; using testing::AnyNumber; @@ -107,7 +107,7 @@ class MockQuicCryptoServerStream : public QuicCryptoServerStream { class MockTlsServerHandshaker : public TlsServerHandshaker { public: explicit MockTlsServerHandshaker(QuicSession* session, - const QuicCryptoServerConfig& crypto_config) + const QuicCryptoServerConfig* crypto_config) : TlsServerHandshaker(session, crypto_config) {} MockTlsServerHandshaker(const MockTlsServerHandshaker&) = delete; MockTlsServerHandshaker& operator=(const MockTlsServerHandshaker&) = delete; @@ -131,7 +131,7 @@ QuicCryptoServerStreamBase* CreateMockCryptoServerStream( return new MockQuicCryptoServerStream( crypto_config, compressed_certs_cache, session, helper); case PROTOCOL_TLS1_3: - return new MockTlsServerHandshaker(session, *crypto_config); + return new MockTlsServerHandshaker(session, crypto_config); case PROTOCOL_UNSUPPORTED: break; } diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream.cc index 93b43562842..800608bf0ba 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream.cc @@ -2,23 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_stream.h" +#include "quic/tools/quic_simple_server_stream.h" #include <list> #include <utility> +#include "absl/strings/match.h" #include "absl/strings/numbers.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_stream.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#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_map_util.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_session.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" -#include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" +#include "quic/core/http/quic_spdy_stream.h" +#include "quic/core/http/spdy_utils.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_bug_tracker.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/platform/api/quic_map_util.h" +#include "quic/tools/quic_simple_server_session.h" +#include "common/platform/api/quiche_text_utils.h" +#include "spdy/core/spdy_protocol.h" using spdy::Http2HeaderBlock; @@ -33,7 +34,7 @@ QuicSimpleServerStream::QuicSimpleServerStream( content_length_(-1), generate_bytes_length_(0), quic_simple_server_backend_(quic_simple_server_backend) { - DCHECK(quic_simple_server_backend_); + QUICHE_DCHECK(quic_simple_server_backend_); } QuicSimpleServerStream::QuicSimpleServerStream( @@ -45,7 +46,7 @@ QuicSimpleServerStream::QuicSimpleServerStream( content_length_(-1), generate_bytes_length_(0), quic_simple_server_backend_(quic_simple_server_backend) { - DCHECK(quic_simple_server_backend_); + QUICHE_DCHECK(quic_simple_server_backend_); } QuicSimpleServerStream::~QuicSimpleServerStream() { @@ -63,6 +64,16 @@ void QuicSimpleServerStream::OnInitialHeadersComplete( SendErrorResponse(); } ConsumeHeaderList(); + if (!fin) { + // CONNECT and other CONNECT-like methods (such as CONNECT-UDP) require + // sending the response right after parsing the headers even though the FIN + // bit has not been received on the request stream. + auto it = request_headers_.find(":method"); + if (it != request_headers_.end() && + absl::StartsWith(it->second, "CONNECT")) { + SendResponse(); + } + } } void QuicSimpleServerStream::OnTrailingHeadersComplete( @@ -121,7 +132,7 @@ void QuicSimpleServerStream::PushResponse( content_length_ = 0; QUIC_DVLOG(1) << "Stream " << id() << " ready to receive server push response."; - DCHECK(reading_stopped()); + QUICHE_DCHECK(reading_stopped()); // Directly send response based on the emulated request_headers_. SendResponse(); diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream.h b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream.h index 6b8826cd866..bbed95a2bcd 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream.h @@ -6,11 +6,11 @@ #define QUICHE_QUIC_TOOLS_QUIC_SIMPLE_SERVER_STREAM_H_ #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_server_stream_base.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/tools/quic_backend_response.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h" -#include "net/third_party/quiche/src/spdy/core/spdy_framer.h" +#include "quic/core/http/quic_spdy_server_stream_base.h" +#include "quic/core/quic_packets.h" +#include "quic/tools/quic_backend_response.h" +#include "quic/tools/quic_simple_server_backend.h" +#include "spdy/core/spdy_framer.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream_test.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream_test.cc index 4b21ccaded1..5806ad72de1 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream_test.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_stream_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_stream.h" +#include "quic/tools/quic_simple_server_stream.h" #include <list> #include <memory> @@ -11,26 +11,26 @@ #include "absl/base/macros.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" -#include "net/third_party/quiche/src/quic/core/http/http_encoder.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_error_codes.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.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/crypto_test_utils.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h" -#include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/quic/tools/quic_backend_response.h" -#include "net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_session.h" +#include "quic/core/crypto/null_encrypter.h" +#include "quic/core/http/http_encoder.h" +#include "quic/core/http/spdy_utils.h" +#include "quic/core/quic_error_codes.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_utils.h" +#include "quic/platform/api/quic_expect_bug.h" +#include "quic/platform/api/quic_ptr_util.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_test.h" +#include "quic/test_tools/crypto_test_utils.h" +#include "quic/test_tools/quic_config_peer.h" +#include "quic/test_tools/quic_connection_peer.h" +#include "quic/test_tools/quic_session_peer.h" +#include "quic/test_tools/quic_spdy_session_peer.h" +#include "quic/test_tools/quic_stream_peer.h" +#include "quic/test_tools/quic_test_utils.h" +#include "quic/tools/quic_backend_response.h" +#include "quic/tools/quic_memory_cache_backend.h" +#include "quic/tools/quic_simple_server_session.h" using testing::_; using testing::AnyNumber; @@ -76,12 +76,22 @@ class TestStream : public QuicSimpleServerStream { void set_body(std::string body) { body_ = std::move(body); } const std::string& body() const { return body_; } int content_length() const { return content_length_; } + bool send_response_was_called() const { return send_response_was_called_; } absl::string_view GetHeader(absl::string_view key) const { auto it = request_headers_.find(key); - DCHECK(it != request_headers_.end()); + QUICHE_DCHECK(it != request_headers_.end()); return it->second; } + + protected: + void SendResponse() override { + send_response_was_called_ = true; + QuicSimpleServerStream::SendResponse(); + } + + private: + bool send_response_was_called_ = false; }; namespace { @@ -154,13 +164,6 @@ class MockQuicSimpleServerSession : public QuicSimpleServerSession { const spdy::SpdyStreamPrecedence& precedence), (override)); MOCK_METHOD(void, - SendRstStream, - (QuicStreamId stream_id, - QuicRstStreamErrorCode error, - QuicStreamOffset bytes_written, - bool send_rst_only), - (override)); - MOCK_METHOD(void, MaybeSendRstStreamFrame, (QuicStreamId stream_id, QuicRstStreamErrorCode error, @@ -201,11 +204,11 @@ class MockQuicSimpleServerSession : public QuicSimpleServerSession { if (write_length > 0) { auto buf = std::make_unique<char[]>(write_length); QuicStream* stream = GetOrCreateStream(id); - DCHECK(stream); + QUICHE_DCHECK(stream); QuicDataWriter writer(write_length, buf.get(), quiche::HOST_BYTE_ORDER); stream->WriteStreamData(offset, write_length, &writer); } else { - DCHECK(state != NO_FIN); + QUICHE_DCHECK(state != NO_FIN); } return QuicConsumedData(write_length, state != NO_FIN); } @@ -356,17 +359,12 @@ TEST_P(QuicSimpleServerStreamTest, SendQuicRstStreamNoErrorInStopReading) { QuicStreamPeer::SetFinSent(stream_); stream_->CloseWriteSide(); - if (!session_.split_up_send_rst()) { - EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _, _)) + if (session_.version().UsesHttp3()) { + EXPECT_CALL(session_, MaybeSendStopSendingFrame(_, QUIC_STREAM_NO_ERROR)) .Times(1); } else { - if (session_.version().UsesHttp3()) { - EXPECT_CALL(session_, MaybeSendStopSendingFrame(_, QUIC_STREAM_NO_ERROR)) - .Times(1); - } else { - EXPECT_CALL(session_, MaybeSendRstStreamFrame(_, QUIC_STREAM_NO_ERROR, _)) - .Times(1); - } + EXPECT_CALL(session_, MaybeSendRstStreamFrame(_, QUIC_STREAM_NO_ERROR, _)) + .Times(1); } stream_->StopReading(); } @@ -383,8 +381,6 @@ TEST_P(QuicSimpleServerStreamTest, TestFramingExtraData) { } EXPECT_CALL(session_, WritevData(_, kErrorLength, _, FIN, _, _)); - EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _, _)).Times(0); - stream_->OnStreamHeaderList(false, kFakeFrameLen, header_list_); std::unique_ptr<char[]> buffer; QuicByteCount header_length = @@ -495,16 +491,12 @@ TEST_P(QuicSimpleServerStreamTest, SendPushResponseWith404Response) { std::move(response_headers_), body); InSequence s; - if (!session_.split_up_send_rst()) { - EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_CANCELLED, 0, _)); - } else { - if (session_.version().UsesHttp3()) { - EXPECT_CALL(session_, MaybeSendStopSendingFrame(promised_stream->id(), - QUIC_STREAM_CANCELLED)); - } - EXPECT_CALL(session_, MaybeSendRstStreamFrame(promised_stream->id(), - QUIC_STREAM_CANCELLED, 0)); + if (session_.version().UsesHttp3()) { + EXPECT_CALL(session_, MaybeSendStopSendingFrame(promised_stream->id(), + QUIC_STREAM_CANCELLED)); } + EXPECT_CALL(session_, MaybeSendRstStreamFrame(promised_stream->id(), + QUIC_STREAM_CANCELLED, 0)); promised_stream->DoSendResponse(); } @@ -640,8 +632,6 @@ TEST_P(QuicSimpleServerStreamTest, PushResponseOnServerInitiatedStream) { } TEST_P(QuicSimpleServerStreamTest, TestSendErrorResponse) { - EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _, _)).Times(0); - QuicStreamPeer::SetFinReceived(stream_); InSequence s; @@ -658,8 +648,6 @@ TEST_P(QuicSimpleServerStreamTest, TestSendErrorResponse) { } TEST_P(QuicSimpleServerStreamTest, InvalidMultipleContentLength) { - EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _, _)).Times(0); - spdy::Http2HeaderBlock request_headers; // \000 is a way to write the null byte when followed by a literal digit. header_list_.OnHeader("content-length", absl::string_view("11\00012", 5)); @@ -676,8 +664,6 @@ TEST_P(QuicSimpleServerStreamTest, InvalidMultipleContentLength) { } TEST_P(QuicSimpleServerStreamTest, InvalidLeadingNullContentLength) { - EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _, _)).Times(0); - spdy::Http2HeaderBlock request_headers; // \000 is a way to write the null byte when followed by a literal digit. header_list_.OnHeader("content-length", absl::string_view("\00012", 3)); @@ -710,7 +696,6 @@ TEST_P(QuicSimpleServerStreamTest, DoNotSendQuicRstStreamNoErrorWithRstReceived) { EXPECT_FALSE(stream_->reading_stopped()); - EXPECT_CALL(session_, SendRstStream(_, QUIC_STREAM_NO_ERROR, _, _)).Times(0); if (VersionUsesHttp3(connection_->transport_version())) { // Unidirectional stream type and then a Stream Cancellation instruction is // sent on the QPACK decoder stream. Ignore these writes without any @@ -721,22 +706,12 @@ TEST_P(QuicSimpleServerStreamTest, .Times(AnyNumber()); } - if (!session_.split_up_send_rst()) { - EXPECT_CALL(session_, SendRstStream(_, - session_.version().UsesHttp3() - ? QUIC_STREAM_CANCELLED - : QUIC_RST_ACKNOWLEDGEMENT, - _, _)) - .Times(1); - } else { - EXPECT_CALL(session_, - MaybeSendRstStreamFrame(_, - session_.version().UsesHttp3() - ? QUIC_STREAM_CANCELLED - : QUIC_RST_ACKNOWLEDGEMENT, - _)) - .Times(1); - } + EXPECT_CALL(session_, MaybeSendRstStreamFrame(_, + session_.version().UsesHttp3() + ? QUIC_STREAM_CANCELLED + : QUIC_RST_ACKNOWLEDGEMENT, + _)) + .Times(1); QuicRstStreamFrame rst_frame(kInvalidControlFrameId, stream_->id(), QUIC_STREAM_CANCELLED, 1234); stream_->OnStreamReset(rst_frame); @@ -782,6 +757,29 @@ TEST_P(QuicSimpleServerStreamTest, InvalidHeadersWithFin) { stream_->OnStreamFrame(frame); } +TEST_P(QuicSimpleServerStreamTest, ConnectSendsResponseBeforeFinReceived) { + EXPECT_CALL(session_, WritevData(_, _, _, _, _, _)) + .WillRepeatedly( + Invoke(&session_, &MockQuicSimpleServerSession::ConsumeData)); + QuicHeaderList header_list; + header_list.OnHeaderBlockStart(); + header_list.OnHeader(":authority", "www.google.com:4433"); + header_list.OnHeader(":method", "CONNECT-SILLY"); + header_list.OnHeaderBlockEnd(128, 128); + EXPECT_CALL(*stream_, WriteHeadersMock(/*fin=*/false)); + stream_->OnStreamHeaderList(/*fin=*/false, kFakeFrameLen, header_list); + std::unique_ptr<char[]> buffer; + QuicByteCount header_length = + HttpEncoder::SerializeDataFrameHeader(body_.length(), &buffer); + std::string header = std::string(buffer.get(), header_length); + std::string data = UsesHttp3() ? header + body_ : body_; + stream_->OnStreamFrame( + QuicStreamFrame(stream_->id(), /*fin=*/false, /*offset=*/0, data)); + EXPECT_EQ("CONNECT-SILLY", StreamHeadersValue(":method")); + EXPECT_EQ(body_, StreamBody()); + EXPECT_TRUE(stream_->send_response_was_called()); +} + } // namespace } // namespace test } // namespace quic diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_client_base.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_client_base.cc index 134e673dd9f..d28eb771a7d 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_client_base.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_client_base.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_spdy_client_base.h" +#include "quic/tools/quic_spdy_client_base.h" #include <utility> #include "absl/strings/numbers.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" -#include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" -#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/common/platform/api/quiche_text_utils.h" +#include "quic/core/crypto/quic_random.h" +#include "quic/core/http/spdy_utils.h" +#include "quic/core/quic_server_id.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "common/platform/api/quiche_text_utils.h" using spdy::Http2HeaderBlock; @@ -77,7 +77,7 @@ void QuicSpdyClientBase::InitializeSession() { } void QuicSpdyClientBase::OnClose(QuicSpdyStream* stream) { - DCHECK(stream != nullptr); + QUICHE_DCHECK(stream != nullptr); QuicSpdyClientStream* client_stream = static_cast<QuicSpdyClientStream*>(stream); diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_client_base.h b/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_client_base.h index 90dfe8a92d2..54c73f780cf 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_client_base.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_client_base.h @@ -11,13 +11,13 @@ #include <string> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" -#include "net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h" -#include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.h" -#include "net/third_party/quiche/src/quic/core/quic_config.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/third_party/quiche/src/quic/tools/quic_client_base.h" +#include "quic/core/crypto/crypto_handshake.h" +#include "quic/core/http/quic_client_push_promise_index.h" +#include "quic/core/http/quic_spdy_client_session.h" +#include "quic/core/http/quic_spdy_client_stream.h" +#include "quic/core/quic_config.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/tools/quic_client_base.h" namespace quic { @@ -175,8 +175,8 @@ class QuicSpdyClientBase : public QuicClientBase, bool fin, QuicSpdyClientBase* client) : QuicDataToResend(std::move(headers), body, fin), client_(client) { - DCHECK(headers_); - DCHECK(client); + QUICHE_DCHECK(headers_); + QUICHE_DCHECK(client); } ClientQuicDataToResend(const ClientQuicDataToResend&) = delete; diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_server_base.h b/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_server_base.h index 1130cfcba4e..c84398fe13d 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_server_base.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_spdy_server_base.h @@ -8,7 +8,7 @@ #ifndef QUICHE_QUIC_TOOLS_QUIC_SPDY_SERVER_BASE_H_ #define QUICHE_QUIC_TOOLS_QUIC_SPDY_SERVER_BASE_H_ -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_socket_address.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_tcp_like_trace_converter.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_tcp_like_trace_converter.cc index 1e6cc54043a..37e23b60c76 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_tcp_like_trace_converter.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_tcp_like_trace_converter.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_tcp_like_trace_converter.h" +#include "quic/tools/quic_tcp_like_trace_converter.h" -#include "net/third_party/quiche/src/quic/core/quic_constants.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" +#include "quic/core/quic_constants.h" +#include "quic/platform/api/quic_bug_tracker.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_tcp_like_trace_converter.h b/chromium/net/third_party/quiche/src/quic/tools/quic_tcp_like_trace_converter.h index 1380296e0ea..b90d4553dd5 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_tcp_like_trace_converter.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_tcp_like_trace_converter.h @@ -7,11 +7,12 @@ #include <vector> -#include "net/third_party/quiche/src/quic/core/frames/quic_stream_frame.h" -#include "net/third_party/quiche/src/quic/core/quic_interval.h" -#include "net/third_party/quiche/src/quic/core/quic_interval_set.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" +#include "absl/container/flat_hash_map.h" +#include "quic/core/frames/quic_stream_frame.h" +#include "quic/core/quic_interval.h" +#include "quic/core/quic_interval_set.h" +#include "quic/core/quic_types.h" +#include "quic/platform/api/quic_containers.h" namespace quic { @@ -73,8 +74,9 @@ class QuicTcpLikeTraceConverter { StreamInfo* info); StreamInfo crypto_frames_info_[NUM_ENCRYPTION_LEVELS]; - QuicHashMap<QuicStreamId, StreamInfo> streams_info_; - QuicHashMap<QuicControlFrameId, QuicInterval<uint64_t>> control_frames_info_; + absl::flat_hash_map<QuicStreamId, StreamInfo> streams_info_; + absl::flat_hash_map<QuicControlFrameId, QuicInterval<uint64_t>> + control_frames_info_; QuicControlFrameId largest_observed_control_frame_id_; diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_tcp_like_trace_converter_test.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_tcp_like_trace_converter_test.cc index fa751ae885e..97edd4d445f 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_tcp_like_trace_converter_test.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_tcp_like_trace_converter_test.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_tcp_like_trace_converter.h" +#include "quic/tools/quic_tcp_like_trace_converter.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_toy_client.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_toy_client.cc index c25411d9bb5..15cdc291d27 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_toy_client.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_toy_client.cc @@ -40,7 +40,7 @@ // After submitting changes to this file, you will need to follow the // instructions at go/quic_client_binary_update -#include "net/third_party/quiche/src/quic/tools/quic_toy_client.h" +#include "quic/tools/quic_toy_client.h" #include <iostream> #include <memory> @@ -51,17 +51,17 @@ #include "absl/strings/escaping.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/quic/core/quic_server_id.h" -#include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_default_proof_providers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_system_event_loop.h" -#include "net/third_party/quiche/src/quic/tools/fake_proof_verifier.h" -#include "net/third_party/quiche/src/quic/tools/quic_url.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" +#include "quic/core/quic_packets.h" +#include "quic/core/quic_server_id.h" +#include "quic/core/quic_utils.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_default_proof_providers.h" +#include "quic/platform/api/quic_ip_address.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/platform/api/quic_system_event_loop.h" +#include "quic/tools/fake_proof_verifier.h" +#include "quic/tools/quic_url.h" +#include "common/platform/api/quiche_text_utils.h" namespace { @@ -154,6 +154,13 @@ DEFINE_QUIC_COMMAND_LINE_FLAG( DEFINE_QUIC_COMMAND_LINE_FLAG( bool, + multi_packet_chlo, + false, + "If true, add a transport parameter to make the ClientHello span two " + "packets. Only works with QUIC+TLS."); + +DEFINE_QUIC_COMMAND_LINE_FLAG( + bool, redirect_is_success, true, "If true, an HTTP response code of 3xx is considered to be a " @@ -266,6 +273,15 @@ int QuicToyClient::SendRequestsAndPrintResponses( config.SetClientConnectionOptions( ParseQuicTagVector(client_connection_options_string)); } + if (GetQuicFlag(FLAGS_multi_packet_chlo)) { + // Make the ClientHello span multiple packets by adding a custom transport + // parameter. + constexpr auto kCustomParameter = + static_cast<TransportParameters::TransportParameterId>(0x173E); + std::string custom_value(2000, '?'); + config.custom_transport_parameters_to_send()[kCustomParameter] = + custom_value; + } int address_family_for_lookup = AF_UNSPEC; if (GetQuicFlag(FLAGS_ip_version_for_host_lookup) == "4") { @@ -321,7 +337,7 @@ int QuicToyClient::SendRequestsAndPrintResponses( // Construct the string body from flags, if provided. std::string body = GetQuicFlag(FLAGS_body); if (!GetQuicFlag(FLAGS_body_hex).empty()) { - DCHECK(GetQuicFlag(FLAGS_body).empty()) + QUICHE_DCHECK(GetQuicFlag(FLAGS_body).empty()) << "Only set one of --body and --body_hex."; body = absl::HexStringToBytes(GetQuicFlag(FLAGS_body_hex)); } diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_toy_client.h b/chromium/net/third_party/quiche/src/quic/tools/quic_toy_client.h index bf56bf8946d..085e749e310 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_toy_client.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_toy_client.h @@ -8,7 +8,7 @@ #ifndef QUICHE_QUIC_TOOLS_QUIC_TOY_CLIENT_H_ #define QUICHE_QUIC_TOOLS_QUIC_TOY_CLIENT_H_ -#include "net/third_party/quiche/src/quic/tools/quic_spdy_client_base.h" +#include "quic/tools/quic_spdy_client_base.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_toy_server.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_toy_server.cc index 1f34849f9a3..93f699ba55a 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_toy_server.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_toy_server.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_toy_server.h" +#include "quic/tools/quic_toy_server.h" #include <utility> #include <vector> -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_default_proof_providers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_default_proof_providers.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_socket_address.h" +#include "quic/tools/quic_memory_cache_backend.h" DEFINE_QUIC_COMMAND_LINE_FLAG(int32_t, port, diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_toy_server.h b/chromium/net/third_party/quiche/src/quic/tools/quic_toy_server.h index 6168b3f038d..94e28eed477 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_toy_server.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_toy_server.h @@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_TOOLS_QUIC_TOY_SERVER_H_ #define QUICHE_QUIC_TOOLS_QUIC_TOY_SERVER_H_ -#include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" -#include "net/third_party/quiche/src/quic/tools/quic_simple_server_backend.h" -#include "net/third_party/quiche/src/quic/tools/quic_spdy_server_base.h" +#include "quic/core/crypto/proof_source.h" +#include "quic/tools/quic_simple_server_backend.h" +#include "quic/tools/quic_spdy_server_base.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_dispatcher.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_dispatcher.cc index ec52d3a35ca..7029cf70be9 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_dispatcher.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_dispatcher.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_transport_simple_server_dispatcher.h" +#include "quic/tools/quic_transport_simple_server_dispatcher.h" #include <memory> #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/quic/core/quic_connection.h" -#include "net/third_party/quiche/src/quic/core/quic_dispatcher.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.h" +#include "quic/core/quic_connection.h" +#include "quic/core/quic_dispatcher.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" +#include "quic/tools/quic_transport_simple_server_session.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_dispatcher.h b/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_dispatcher.h index 62e4432a2d6..500b02d55fb 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_dispatcher.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_dispatcher.h @@ -7,8 +7,8 @@ #include "absl/strings/string_view.h" #include "url/origin.h" -#include "net/third_party/quiche/src/quic/core/quic_dispatcher.h" -#include "net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.h" +#include "quic/core/quic_dispatcher.h" +#include "quic/tools/quic_transport_simple_server_session.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.cc index 386bd0056fa..ad93115705f 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.cc @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.h" +#include "quic/tools/quic_transport_simple_server_session.h" #include <memory> #include "url/gurl.h" #include "url/origin.h" -#include "net/third_party/quiche/src/quic/core/quic_buffer_allocator.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#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/quic_transport/quic_transport_protocol.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_stream.h" +#include "quic/core/quic_buffer_allocator.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/platform/api/quic_logging.h" +#include "quic/quic_transport/quic_transport_protocol.h" +#include "quic/quic_transport/quic_transport_stream.h" namespace quic { @@ -51,7 +51,7 @@ class BidirectionalEchoVisitor : public QuicTransportStream::Visitor { void OnFinRead() override { bool success = stream_->SendFin(); - DCHECK(success); + QUICHE_DCHECK(success); } void OnCanWrite() override { @@ -79,7 +79,7 @@ class UnidirectionalEchoReadVisitor : public QuicTransportStream::Visitor { void OnCanRead() override { bool success = stream_->Read(&buffer_); - DCHECK(success); + QUICHE_DCHECK(success); } void OnFinRead() override { @@ -114,7 +114,7 @@ class UnidirectionalEchoWriteVisitor : public QuicTransportStream::Visitor { } data_ = ""; bool fin_sent = stream_->SendFin(); - DCHECK(fin_sent); + QUICHE_DCHECK(fin_sent); } private: diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.h b/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.h index fc018fbd5a1..2d3be8a0fe2 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_transport_simple_server_session.h @@ -9,12 +9,12 @@ #include <vector> #include "url/origin.h" -#include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/quic/core/quic_versions.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_server_session.h" -#include "net/third_party/quiche/src/quic/quic_transport/quic_transport_stream.h" +#include "quic/core/quic_types.h" +#include "quic/core/quic_versions.h" +#include "quic/platform/api/quic_containers.h" +#include "quic/platform/api/quic_flags.h" +#include "quic/quic_transport/quic_transport_server_session.h" +#include "quic/quic_transport/quic_transport_stream.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_url.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_url.cc index 9f9e98aeaf5..53b9ab0ab60 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_url.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_url.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_url.h" +#include "quic/tools/quic_url.h" +#include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" namespace quic { @@ -19,7 +19,7 @@ QuicUrl::QuicUrl(absl::string_view url, absl::string_view default_scheme) return; } - url_ = GURL(quiche::QuicheStrCat(default_scheme, "://", url)); + url_ = GURL(absl::StrCat(default_scheme, "://", url)); } std::string QuicUrl::ToString() const { @@ -51,7 +51,7 @@ std::string QuicUrl::HostPort() const { if (port == url::PORT_UNSPECIFIED) { return host; } - return quiche::QuicheStrCat(host, ":", port); + return absl::StrCat(host, ":", port); } std::string QuicUrl::PathParamsQuery() const { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_url.h b/chromium/net/third_party/quiche/src/quic/tools/quic_url.h index ca4ac8e346f..bc2ec99cd24 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_url.h +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_url.h @@ -9,7 +9,7 @@ #include "absl/strings/string_view.h" #include "url/gurl.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "quic/platform/api/quic_export.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/quic_url_test.cc b/chromium/net/third_party/quiche/src/quic/tools/quic_url_test.cc index 8ffee252a7c..ccb7aea0ebd 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/quic_url_test.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/quic_url_test.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/quic_url.h" +#include "quic/tools/quic_url.h" #include <string> -#include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "quic/platform/api/quic_test.h" namespace quic { namespace test { diff --git a/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter.cc b/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter.cc index b742dbff322..0130352ecfd 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/simple_ticket_crypter.h" +#include "quic/tools/simple_ticket_crypter.h" #include "third_party/boringssl/src/include/openssl/aead.h" #include "third_party/boringssl/src/include/openssl/rand.h" diff --git a/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter.h b/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter.h index c150ae24579..d547a25bf9e 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter.h +++ b/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter.h @@ -6,9 +6,9 @@ #define QUICHE_QUIC_TOOLS_SIMPLE_TICKET_CRYPTER_H_ #include "third_party/boringssl/src/include/openssl/aead.h" -#include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" -#include "net/third_party/quiche/src/quic/core/quic_clock.h" -#include "net/third_party/quiche/src/quic/core/quic_time.h" +#include "quic/core/crypto/proof_source.h" +#include "quic/core/quic_clock.h" +#include "quic/core/quic_time.h" namespace quic { diff --git a/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter_test.cc b/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter_test.cc index 568fa2b846c..ad041c10de8 100644 --- a/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter_test.cc +++ b/chromium/net/third_party/quiche/src/quic/tools/simple_ticket_crypter_test.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/third_party/quiche/src/quic/tools/simple_ticket_crypter.h" +#include "quic/tools/simple_ticket_crypter.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 "quic/platform/api/quic_test.h" +#include "quic/test_tools/mock_clock.h" namespace quic { namespace test { |