| Index: net/quic/core/quic_connection.cc
|
| diff --git a/net/quic/core/quic_connection.cc b/net/quic/core/quic_connection.cc
|
| index a3765d60248cf3033a8428eaa50f3f30b8ef547a..6985d7dfd0d62c312a7d73d53be1a2d1f66371ad 100644
|
| --- a/net/quic/core/quic_connection.cc
|
| +++ b/net/quic/core/quic_connection.cc
|
| @@ -374,7 +374,10 @@ void QuicConnection::SetFromConfig(const QuicConfig& config) {
|
| ack_decimation_delay_ = kShortAckDecimationDelay;
|
| }
|
| if (config.HasClientSentConnectionOption(k5RTO, perspective_)) {
|
| - close_connection_after_five_rtos_ = true;
|
| + if (perspective_ == Perspective::IS_CLIENT ||
|
| + !FLAGS_quic_only_5rto_client_side) {
|
| + close_connection_after_five_rtos_ = true;
|
| + }
|
| }
|
| }
|
|
|
| @@ -593,18 +596,6 @@ bool QuicConnection::OnUnauthenticatedHeader(const QuicPacketHeader& header) {
|
| // here.
|
| DCHECK_EQ(connection_id_, header.public_header.connection_id);
|
|
|
| - if (!FLAGS_quic_postpone_multipath_flag_validation) {
|
| - // Multipath is not enabled, but a packet with multipath flag on is
|
| - // received.
|
| - if (!multipath_enabled_ && header.public_header.multipath_flag) {
|
| - const string error_details =
|
| - "Received a packet with multipath flag but multipath is not enabled.";
|
| - QUIC_BUG << error_details;
|
| - CloseConnection(QUIC_BAD_MULTIPATH_FLAG, error_details,
|
| - ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
|
| - return false;
|
| - }
|
| - }
|
| if (!packet_generator_.IsPendingPacketEmpty()) {
|
| // Incoming packets may change a queued ACK frame.
|
| const string error_details =
|
| @@ -1430,17 +1421,15 @@ bool QuicConnection::ProcessValidatedPacket(const QuicPacketHeader& header) {
|
| return false;
|
| }
|
|
|
| - if (FLAGS_quic_postpone_multipath_flag_validation) {
|
| - // Multipath is not enabled, but a packet with multipath flag on is
|
| - // received.
|
| - if (!multipath_enabled_ && header.public_header.multipath_flag) {
|
| - const string error_details =
|
| - "Received a packet with multipath flag but multipath is not enabled.";
|
| - QUIC_BUG << error_details;
|
| - CloseConnection(QUIC_BAD_MULTIPATH_FLAG, error_details,
|
| - ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
|
| - return false;
|
| - }
|
| + // Multipath is not enabled, but a packet with multipath flag on is
|
| + // received.
|
| + if (!multipath_enabled_ && header.public_header.multipath_flag) {
|
| + const string error_details =
|
| + "Received a packet with multipath flag but multipath is not enabled.";
|
| + QUIC_BUG << error_details;
|
| + CloseConnection(QUIC_BAD_MULTIPATH_FLAG, error_details,
|
| + ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
|
| + return false;
|
| }
|
|
|
| if (version_negotiation_state_ != NEGOTIATED_VERSION) {
|
| @@ -1618,6 +1607,9 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) {
|
| }
|
|
|
| QuicPacketNumber packet_number = packet->packet_number;
|
| + // TODO(ianswett): Remove packet_number_of_last_sent_packet_ because it's
|
| + // redundant to SentPacketManager_->GetLargestPacket in most cases, and wrong
|
| + // for multipath.
|
| DCHECK_LE(packet_number_of_last_sent_packet_, packet_number);
|
| packet_number_of_last_sent_packet_ = packet_number;
|
|
|
| @@ -1675,6 +1667,34 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) {
|
| return false;
|
| }
|
| }
|
| +
|
| + if (FLAGS_quic_only_track_sent_packets) {
|
| + // In some cases, an MTU probe can cause EMSGSIZE. This indicates that the
|
| + // MTU discovery is permanently unsuccessful.
|
| + if (FLAGS_graceful_emsgsize_on_mtu_probe &&
|
| + result.status == WRITE_STATUS_ERROR &&
|
| + result.error_code == kMessageTooBigErrorCode &&
|
| + packet->retransmittable_frames.empty() &&
|
| + packet->encrypted_length > long_term_mtu_) {
|
| + mtu_discovery_target_ = 0;
|
| + mtu_discovery_alarm_->Cancel();
|
| + // The write failed, but the writer is not blocked, so return true.
|
| + return true;
|
| + }
|
| +
|
| + if (result.status == WRITE_STATUS_ERROR) {
|
| + OnWriteError(result.error_code);
|
| + DLOG(ERROR) << ENDPOINT << "failed writing " << encrypted_length
|
| + << " from host "
|
| + << (self_address().address().empty()
|
| + ? " empty address "
|
| + : self_address().ToStringWithoutPort())
|
| + << " to address " << peer_address().ToString()
|
| + << " with error code " << result.error_code;
|
| + return false;
|
| + }
|
| + }
|
| +
|
| if (result.status != WRITE_STATUS_ERROR && debug_visitor_ != nullptr) {
|
| // Pass the write result to the visitor.
|
| debug_visitor_->OnPacketSent(*packet, packet->original_path_id,
|
| @@ -1705,15 +1725,6 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) {
|
| DVLOG(1) << ENDPOINT << "time we began writing last sent packet: "
|
| << packet_send_time.ToDebuggingValue();
|
|
|
| - if (!FLAGS_quic_simple_packet_number_length_2) {
|
| - // TODO(ianswett): Change the packet number length and other packet creator
|
| - // options by a more explicit API than setting a struct value directly,
|
| - // perhaps via the NetworkChangeVisitor.
|
| - packet_generator_.UpdateSequenceNumberLength(
|
| - sent_packet_manager_->GetLeastUnacked(packet->path_id),
|
| - sent_packet_manager_->EstimateMaxPacketsInFlight(max_packet_length()));
|
| - }
|
| -
|
| bool reset_retransmission_alarm = sent_packet_manager_->OnPacketSent(
|
| packet, packet->original_path_id, packet->original_packet_number,
|
| packet_send_time, packet->transmission_type, IsRetransmittable(*packet));
|
| @@ -1722,13 +1733,11 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) {
|
| SetRetransmissionAlarm();
|
| }
|
|
|
| - if (FLAGS_quic_simple_packet_number_length_2) {
|
| - // The packet number length must be updated after OnPacketSent, because it
|
| - // may change the packet number length in packet.
|
| - packet_generator_.UpdateSequenceNumberLength(
|
| - sent_packet_manager_->GetLeastUnacked(packet->path_id),
|
| - sent_packet_manager_->EstimateMaxPacketsInFlight(max_packet_length()));
|
| - }
|
| + // The packet number length must be updated after OnPacketSent, because it
|
| + // may change the packet number length in packet.
|
| + packet_generator_.UpdateSequenceNumberLength(
|
| + sent_packet_manager_->GetLeastUnacked(packet->path_id),
|
| + sent_packet_manager_->EstimateMaxPacketsInFlight(max_packet_length()));
|
|
|
| stats_.bytes_sent += result.bytes_written;
|
| ++stats_.packets_sent;
|
| @@ -1737,28 +1746,30 @@ bool QuicConnection::WritePacket(SerializedPacket* packet) {
|
| ++stats_.packets_retransmitted;
|
| }
|
|
|
| - // In some cases, an MTU probe can cause ERR_MSG_TOO_BIG. This indicates that
|
| - // the MTU discovery is permanently unsuccessful.
|
| - if (FLAGS_graceful_emsgsize_on_mtu_probe &&
|
| - result.status == WRITE_STATUS_ERROR &&
|
| - result.error_code == kMessageTooBigErrorCode &&
|
| - packet->retransmittable_frames.empty() &&
|
| - packet->encrypted_length > long_term_mtu_) {
|
| - mtu_discovery_target_ = 0;
|
| - mtu_discovery_alarm_->Cancel();
|
| - return true;
|
| - }
|
| + if (!FLAGS_quic_only_track_sent_packets) {
|
| + // In some cases, an MTU probe can cause EMSGSIZE. This indicates that the
|
| + // MTU discovery is permanently unsuccessful.
|
| + if (FLAGS_graceful_emsgsize_on_mtu_probe &&
|
| + result.status == WRITE_STATUS_ERROR &&
|
| + result.error_code == kMessageTooBigErrorCode &&
|
| + packet->retransmittable_frames.empty() &&
|
| + packet->encrypted_length > long_term_mtu_) {
|
| + mtu_discovery_target_ = 0;
|
| + mtu_discovery_alarm_->Cancel();
|
| + return true;
|
| + }
|
|
|
| - if (result.status == WRITE_STATUS_ERROR) {
|
| - OnWriteError(result.error_code);
|
| - DLOG(ERROR) << ENDPOINT << "failed writing " << encrypted_length
|
| - << " bytes "
|
| - << " from host " << (self_address().address().empty()
|
| - ? " empty address "
|
| - : self_address().ToStringWithoutPort())
|
| - << " to address " << peer_address().ToString()
|
| - << " with error code " << result.error_code;
|
| - return false;
|
| + if (result.status == WRITE_STATUS_ERROR) {
|
| + OnWriteError(result.error_code);
|
| + DLOG(ERROR) << ENDPOINT << "failed writing " << encrypted_length
|
| + << " from host "
|
| + << (self_address().address().empty()
|
| + ? " empty address "
|
| + : self_address().ToStringWithoutPort())
|
| + << " to address " << peer_address().ToString()
|
| + << " with error code " << result.error_code;
|
| + return false;
|
| + }
|
| }
|
|
|
| return true;
|
| @@ -1784,7 +1795,7 @@ bool QuicConnection::ShouldDiscardPacket(const SerializedPacket& packet) {
|
| }
|
|
|
| void QuicConnection::OnWriteError(int error_code) {
|
| - if (FLAGS_quic_close_connection_on_packet_too_large && write_error_occured_) {
|
| + if (write_error_occured_) {
|
| // A write error already occurred. The connection is being closed.
|
| return;
|
| }
|
| @@ -1797,15 +1808,10 @@ void QuicConnection::OnWriteError(int error_code) {
|
| // We can't send an error as the socket is presumably borked.
|
| switch (error_code) {
|
| case kMessageTooBigErrorCode:
|
| - if (FLAGS_quic_close_connection_on_packet_too_large) { // NOLINT
|
| - CloseConnection(
|
| - QUIC_PACKET_WRITE_ERROR, error_details,
|
| - FLAGS_quic_do_not_send_ack_on_emsgsize
|
| - ? ConnectionCloseBehavior::
|
| - SEND_CONNECTION_CLOSE_PACKET_WITH_NO_ACK
|
| - : ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
|
| - break;
|
| - }
|
| + CloseConnection(
|
| + QUIC_PACKET_WRITE_ERROR, error_details,
|
| + ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET_WITH_NO_ACK);
|
| + break;
|
| default:
|
| // We can't send an error as the socket is presumably borked.
|
| TearDownLocalConnectionState(QUIC_PACKET_WRITE_ERROR, error_details,
|
|
|