Commit b863d471 authored by Fan Yang's avatar Fan Yang Committed by Commit Bot

Roll src/net/third_party/quiche/src/ f54082a01..d58736db7 (4 commits)

https://quiche.googlesource.com/quiche.git/+log/f54082a0145f..d58736db7b79

$ git log f54082a01..e62e63cbd --date=short --no-merges --format='%ad %ae %s'
2019-11-27 fayang gfe-relnote: Use HandshakerDelegateInterface in QUIC handshakers. Abstract keys installation, keys discarding, default encryption level change and mark handshake complete to HandshakerDelegateInterface. Protected by gfe2_reloadable_flag_quic_use_handshaker_delegate.
2019-11-27 bnc Enforce header list size limit in QpackDecodedHeadersAccumulator.
2019-11-27 bnc Rename qpack_constants.* to qpack_instructions.*.
2019-11-27 renjietang Switch the order of QPACK streams sending stream type.

Created with:
  roll-dep src/net/third_party/quiche/src src/third_party/quic_trace/src

Change-Id: I9b46c079f94def86e82d0abc19b556ab63771b60
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1949151
Commit-Queue: Fan Yang <fayang@chromium.org>
Commit-Queue: Nick Harper <nharper@chromium.org>
Reviewed-by: default avatarSteve Anton <steveanton@chromium.org>
Reviewed-by: default avatarNick Harper <nharper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721732}
parent 68182431
......@@ -307,7 +307,7 @@ vars = {
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling feed
# and whatever else without interference from each other.
'quiche_revision': 'f54082a0145f7e06a30d451ae84a66bb32718a6d',
'quiche_revision': 'd58736db7b79ab31e6dc652c0fa2d6b2f0564881',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling ios_webkit
# and whatever else without interference from each other.
......
......@@ -1385,8 +1385,6 @@ component("net") {
"third_party/quiche/src/quic/core/proto/source_address_token_proto.h",
"third_party/quiche/src/quic/core/qpack/qpack_blocking_manager.cc",
"third_party/quiche/src/quic/core/qpack/qpack_blocking_manager.h",
"third_party/quiche/src/quic/core/qpack/qpack_constants.cc",
"third_party/quiche/src/quic/core/qpack/qpack_constants.h",
"third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.cc",
"third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.h",
"third_party/quiche/src/quic/core/qpack/qpack_decoder.cc",
......@@ -1409,6 +1407,8 @@ component("net") {
"third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h",
"third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.cc",
"third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.h",
"third_party/quiche/src/quic/core/qpack/qpack_instructions.cc",
"third_party/quiche/src/quic/core/qpack/qpack_instructions.h",
"third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.cc",
"third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.h",
"third_party/quiche/src/quic/core/qpack/qpack_receive_stream.cc",
......
......@@ -135,8 +135,12 @@ bool MockCryptoClientStream::CryptoConnect() {
ENCRYPTION_ZERO_RTT,
std::make_unique<NullEncrypter>(Perspective::IS_CLIENT));
}
session()->connection()->SetDefaultEncryptionLevel(ENCRYPTION_ZERO_RTT);
session()->OnCryptoHandshakeEvent(QuicSession::ENCRYPTION_ESTABLISHED);
if (session()->use_handshake_delegate()) {
session()->SetDefaultEncryptionLevel(ENCRYPTION_ZERO_RTT);
} else {
session()->connection()->SetDefaultEncryptionLevel(ENCRYPTION_ZERO_RTT);
session()->OnCryptoHandshakeEvent(QuicSession::ENCRYPTION_ESTABLISHED);
}
break;
}
......@@ -177,10 +181,16 @@ bool MockCryptoClientStream::CryptoConnect() {
ENCRYPTION_FORWARD_SECURE,
std::make_unique<NullEncrypter>(Perspective::IS_CLIENT));
}
session()->connection()->SetDefaultEncryptionLevel(
ENCRYPTION_FORWARD_SECURE);
session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED);
session()->connection()->OnHandshakeComplete();
if (session()->use_handshake_delegate()) {
session()->SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
session()->DiscardOldEncryptionKey(ENCRYPTION_INITIAL);
session()->NeuterHandshakeData();
} else {
session()->connection()->SetDefaultEncryptionLevel(
ENCRYPTION_FORWARD_SECURE);
session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED);
session()->connection()->OnHandshakeComplete();
}
break;
}
......@@ -252,10 +262,17 @@ void MockCryptoClientStream::SendOnCryptoHandshakeEvent(
ENCRYPTION_FORWARD_SECURE,
std::make_unique<NullEncrypter>(Perspective::IS_CLIENT));
}
session()->connection()->SetDefaultEncryptionLevel(
ENCRYPTION_FORWARD_SECURE);
if (session()->use_handshake_delegate()) {
session()->SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
session()->DiscardOldEncryptionKey(ENCRYPTION_INITIAL);
} else {
session()->connection()->SetDefaultEncryptionLevel(
ENCRYPTION_FORWARD_SECURE);
}
}
if (!session()->use_handshake_delegate()) {
session()->OnCryptoHandshakeEvent(event);
}
session()->OnCryptoHandshakeEvent(event);
}
// static
......
......@@ -1556,45 +1556,28 @@ void QuicChromiumClientSession::OnCryptoHandshakeEvent(
std::move(callback_).Run(OK);
}
if (event == HANDSHAKE_CONFIRMED) {
if (stream_factory_)
stream_factory_->set_is_quic_known_to_work_on_current_network(true);
// Update |connect_end| only when handshake is confirmed. This should also
// take care of any failed 0-RTT request.
connect_timing_.connect_end = tick_clock_->NowTicks();
DCHECK_LE(connect_timing_.connect_start, connect_timing_.connect_end);
UMA_HISTOGRAM_TIMES(
"Net.QuicSession.HandshakeConfirmedTime",
connect_timing_.connect_end - connect_timing_.connect_start);
// Track how long it has taken to finish handshake after we have finished
// DNS host resolution.
if (!connect_timing_.dns_end.is_null()) {
UMA_HISTOGRAM_TIMES(
"Net.QuicSession.HostResolution.HandshakeConfirmedTime",
tick_clock_->NowTicks() - connect_timing_.dns_end);
}
auto it = handles_.begin();
while (it != handles_.end()) {
Handle* handle = *it;
++it;
handle->OnCryptoHandshakeConfirmed();
}
NotifyRequestsOfConfirmation(OK);
// Attempt to migrate back to the default network after handshake has been
// confirmed if the session is not created on the default network.
if (migrate_session_on_network_change_v2_ &&
default_network_ != NetworkChangeNotifier::kInvalidNetworkHandle &&
GetDefaultSocket()->GetBoundNetwork() != default_network_) {
current_migration_cause_ = ON_MIGRATE_BACK_TO_DEFAULT_NETWORK;
StartMigrateBackToDefaultNetworkTimer(
base::TimeDelta::FromSeconds(kMinRetryTimeForDefaultNetworkSecs));
}
OnCryptoHandshakeComplete();
}
quic::QuicSpdySession::OnCryptoHandshakeEvent(event);
}
void QuicChromiumClientSession::SetDefaultEncryptionLevel(
quic::EncryptionLevel level) {
if (!callback_.is_null() &&
(!require_confirmation_ || level == quic::ENCRYPTION_FORWARD_SECURE ||
level == quic::ENCRYPTION_ZERO_RTT)) {
// TODO(rtenneti): Currently for all CryptoHandshakeEvent events, callback_
// could be called because there are no error events in CryptoHandshakeEvent
// enum. If error events are added to CryptoHandshakeEvent, then the
// following code needs to changed.
std::move(callback_).Run(OK);
}
if (level == quic::ENCRYPTION_FORWARD_SECURE) {
OnCryptoHandshakeComplete();
}
quic::QuicSpdySession::SetDefaultEncryptionLevel(level);
}
void QuicChromiumClientSession::OnCryptoHandshakeMessageSent(
const quic::CryptoHandshakeMessage& message) {
logger_->OnCryptoHandshakeMessageSent(message);
......@@ -2988,6 +2971,43 @@ void QuicChromiumClientSession::NotifyFactoryOfSessionClosed() {
stream_factory_->OnSessionClosed(this);
}
void QuicChromiumClientSession::OnCryptoHandshakeComplete() {
if (stream_factory_)
stream_factory_->set_is_quic_known_to_work_on_current_network(true);
// Update |connect_end| only when handshake is confirmed. This should also
// take care of any failed 0-RTT request.
connect_timing_.connect_end = tick_clock_->NowTicks();
DCHECK_LE(connect_timing_.connect_start, connect_timing_.connect_end);
UMA_HISTOGRAM_TIMES(
"Net.QuicSession.HandshakeConfirmedTime",
connect_timing_.connect_end - connect_timing_.connect_start);
// Track how long it has taken to finish handshake after we have finished
// DNS host resolution.
if (!connect_timing_.dns_end.is_null()) {
UMA_HISTOGRAM_TIMES("Net.QuicSession.HostResolution.HandshakeConfirmedTime",
tick_clock_->NowTicks() - connect_timing_.dns_end);
}
auto it = handles_.begin();
while (it != handles_.end()) {
Handle* handle = *it;
++it;
handle->OnCryptoHandshakeConfirmed();
}
NotifyRequestsOfConfirmation(OK);
// Attempt to migrate back to the default network after handshake has been
// confirmed if the session is not created on the default network.
if (migrate_session_on_network_change_v2_ &&
default_network_ != NetworkChangeNotifier::kInvalidNetworkHandle &&
GetDefaultSocket()->GetBoundNetwork() != default_network_) {
current_migration_cause_ = ON_MIGRATE_BACK_TO_DEFAULT_NETWORK;
StartMigrateBackToDefaultNetworkTimer(
base::TimeDelta::FromSeconds(kMinRetryTimeForDefaultNetworkSecs));
}
}
MigrationResult QuicChromiumClientSession::Migrate(
NetworkChangeNotifier::NetworkHandle network,
IPEndPoint peer_address,
......
......@@ -495,6 +495,7 @@ class NET_EXPORT_PRIVATE QuicChromiumClientSession
quic::QuicRstStreamErrorCode error,
quic::QuicStreamOffset bytes_written) override;
void OnCryptoHandshakeEvent(CryptoHandshakeEvent event) override;
void SetDefaultEncryptionLevel(quic::EncryptionLevel level) override;
void OnCryptoHandshakeMessageSent(
const quic::CryptoHandshakeMessage& message) override;
void OnCryptoHandshakeMessageReceived(
......@@ -772,6 +773,9 @@ class NET_EXPORT_PRIVATE QuicChromiumClientSession
// delete |this|.
void NotifyFactoryOfSessionClosed();
// Called when default encryption level switches to forward secure.
void OnCryptoHandshakeComplete();
QuicSessionKey session_key_;
bool require_confirmation_;
bool migrate_session_early_v2_;
......
......@@ -384,3 +384,7 @@ QUIC_FLAG(
QUIC_FLAG(bool,
FLAGS_quic_reloadable_flag_quic_delete_send_rst_stream_inner,
false)
// If true, QUIC crypto handshaker uses handshaker delegate to notify session
// about handshake events.
QUIC_FLAG(bool, FLAGS_quic_reloadable_flag_quic_use_handshaker_delegate, true)
......@@ -1577,13 +1577,8 @@ void QuicTestPacketMaker::MaybeAddHttp3SettingsFrames(
for (const auto& frame : GenerateNextStreamFrames(stream_id, false, data))
frames->push_back(frame);
if (coalesce_http_frames_) {
frames->push_back(GenerateNextStreamFrame(stream_id + 4, false, "\x03"));
frames->push_back(GenerateNextStreamFrame(stream_id + 8, false, "\x02"));
} else {
frames->push_back(GenerateNextStreamFrame(stream_id + 8, false, "\x02"));
frames->push_back(GenerateNextStreamFrame(stream_id + 4, false, "\x03"));
}
frames->push_back(GenerateNextStreamFrame(stream_id + 4, false, "\x03"));
frames->push_back(GenerateNextStreamFrame(stream_id + 8, false, "\x02"));
}
} // namespace test
......
......@@ -548,6 +548,26 @@ void P2PQuicTransportImpl::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) {
}
}
void P2PQuicTransportImpl::SetDefaultEncryptionLevel(
quic::EncryptionLevel level) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
QuicSession::SetDefaultEncryptionLevel(level);
if (level == quic::ENCRYPTION_FORWARD_SECURE) {
DCHECK(IsEncryptionEstablished());
DCHECK(IsCryptoHandshakeConfirmed());
P2PQuicNegotiatedParams negotiated_params;
// The guaranteed largest message payload will not change throughout the
// connection.
uint16_t max_datagram_length =
quic::QuicSession::GetGuaranteedLargestMessagePayload();
if (max_datagram_length > 0) {
// Datagrams are supported in this case.
negotiated_params.set_max_datagram_length(max_datagram_length);
}
delegate_->OnConnected(negotiated_params);
}
}
void P2PQuicTransportImpl::OnCanWrite() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
while (!datagram_buffer_.empty()) {
......
......@@ -140,6 +140,7 @@ class MODULES_EXPORT P2PQuicTransportImpl final
P2PQuicStreamImpl* CreateOutgoingBidirectionalStream();
void OnCryptoHandshakeEvent(CryptoHandshakeEvent event) override;
void SetDefaultEncryptionLevel(quic::EncryptionLevel level) override;
private:
// This is for testing connection failures and handshake failures.
......
......@@ -481,7 +481,12 @@ class ConnectedCryptoClientStream final : public quic::QuicCryptoClientStream {
session()->config()->ProcessPeerHello(message, quic::CLIENT,
&error_details);
session()->OnConfigNegotiated();
session()->OnCryptoHandshakeEvent(quic::QuicSession::HANDSHAKE_CONFIRMED);
if (session()->use_handshake_delegate()) {
session()->SetDefaultEncryptionLevel(quic::ENCRYPTION_FORWARD_SECURE);
session()->DiscardOldEncryptionKey(quic::ENCRYPTION_INITIAL);
} else {
session()->OnCryptoHandshakeEvent(quic::QuicSession::HANDSHAKE_CONFIRMED);
}
return true;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment