| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/quic/quic_connection.h" | 5 #include "net/quic/quic_connection.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <sys/types.h> | 8 #include <sys/types.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 migrating_peer_port_(0), | 271 migrating_peer_port_(0), |
| 272 last_packet_decrypted_(false), | 272 last_packet_decrypted_(false), |
| 273 last_packet_revived_(false), | 273 last_packet_revived_(false), |
| 274 last_size_(0), | 274 last_size_(0), |
| 275 last_decrypted_packet_level_(ENCRYPTION_NONE), | 275 last_decrypted_packet_level_(ENCRYPTION_NONE), |
| 276 should_last_packet_instigate_acks_(false), | 276 should_last_packet_instigate_acks_(false), |
| 277 largest_seen_packet_with_ack_(0), | 277 largest_seen_packet_with_ack_(0), |
| 278 largest_seen_packet_with_stop_waiting_(0), | 278 largest_seen_packet_with_stop_waiting_(0), |
| 279 max_undecryptable_packets_(0), | 279 max_undecryptable_packets_(0), |
| 280 pending_version_negotiation_packet_(false), | 280 pending_version_negotiation_packet_(false), |
| 281 save_crypto_packets_as_termination_packets_(false), |
| 281 silent_close_enabled_(false), | 282 silent_close_enabled_(false), |
| 282 received_packet_manager_(&stats_), | 283 received_packet_manager_(&stats_), |
| 283 ack_queued_(false), | 284 ack_queued_(false), |
| 284 num_packets_received_since_last_ack_sent_(0), | 285 num_packets_received_since_last_ack_sent_(0), |
| 285 stop_waiting_count_(0), | 286 stop_waiting_count_(0), |
| 286 delay_setting_retransmission_alarm_(false), | 287 delay_setting_retransmission_alarm_(false), |
| 287 pending_retransmission_alarm_(false), | 288 pending_retransmission_alarm_(false), |
| 288 ack_alarm_(helper->CreateAlarm(new AckAlarm(this))), | 289 ack_alarm_(helper->CreateAlarm(new AckAlarm(this))), |
| 289 retransmission_alarm_(helper->CreateAlarm(new RetransmissionAlarm(this))), | 290 retransmission_alarm_(helper->CreateAlarm(new RetransmissionAlarm(this))), |
| 290 send_alarm_(helper->CreateAlarm(new SendAlarm(this))), | 291 send_alarm_(helper->CreateAlarm(new SendAlarm(this))), |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 SetMaxPacketLength(perspective_ == Perspective::IS_SERVER | 335 SetMaxPacketLength(perspective_ == Perspective::IS_SERVER |
| 335 ? kDefaultServerMaxPacketSize | 336 ? kDefaultServerMaxPacketSize |
| 336 : kDefaultMaxPacketSize); | 337 : kDefaultMaxPacketSize); |
| 337 } | 338 } |
| 338 | 339 |
| 339 QuicConnection::~QuicConnection() { | 340 QuicConnection::~QuicConnection() { |
| 340 if (owns_writer_) { | 341 if (owns_writer_) { |
| 341 delete writer_; | 342 delete writer_; |
| 342 } | 343 } |
| 343 STLDeleteElements(&undecryptable_packets_); | 344 STLDeleteElements(&undecryptable_packets_); |
| 345 if (termination_packets_.get() != nullptr) { |
| 346 STLDeleteElements(termination_packets_.get()); |
| 347 } |
| 344 STLDeleteValues(&group_map_); | 348 STLDeleteValues(&group_map_); |
| 345 ClearQueuedPackets(); | 349 ClearQueuedPackets(); |
| 346 } | 350 } |
| 347 | 351 |
| 348 void QuicConnection::ClearQueuedPackets() { | 352 void QuicConnection::ClearQueuedPackets() { |
| 349 for (QueuedPacketList::iterator it = queued_packets_.begin(); | 353 for (QueuedPacketList::iterator it = queued_packets_.begin(); |
| 350 it != queued_packets_.end(); ++it) { | 354 it != queued_packets_.end(); ++it) { |
| 351 delete it->serialized_packet.retransmittable_frames; | 355 delete it->serialized_packet.retransmittable_frames; |
| 352 delete it->serialized_packet.packet; | 356 delete it->serialized_packet.packet; |
| 353 } | 357 } |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 } | 840 } |
| 837 | 841 |
| 838 if (!sent_entropy_manager_.IsValidEntropy( | 842 if (!sent_entropy_manager_.IsValidEntropy( |
| 839 incoming_ack.largest_observed, | 843 incoming_ack.largest_observed, |
| 840 incoming_ack.missing_packets, | 844 incoming_ack.missing_packets, |
| 841 incoming_ack.entropy_hash)) { | 845 incoming_ack.entropy_hash)) { |
| 842 DLOG(ERROR) << ENDPOINT << "Peer sent invalid entropy."; | 846 DLOG(ERROR) << ENDPOINT << "Peer sent invalid entropy."; |
| 843 return false; | 847 return false; |
| 844 } | 848 } |
| 845 | 849 |
| 846 for (QuicPacketNumber revived_packet : incoming_ack.revived_packets) { | 850 if (incoming_ack.latest_revived_packet != 0 && |
| 847 if (!incoming_ack.missing_packets.Contains(revived_packet)) { | 851 !incoming_ack.missing_packets.Contains( |
| 848 DLOG(ERROR) << ENDPOINT | 852 incoming_ack.latest_revived_packet)) { |
| 849 << "Peer specified revived packet which was not missing."; | 853 DLOG(ERROR) << ENDPOINT |
| 850 return false; | 854 << "Peer specified revived packet which was not missing."; |
| 851 } | 855 return false; |
| 852 } | 856 } |
| 853 return true; | 857 return true; |
| 854 } | 858 } |
| 855 | 859 |
| 856 bool QuicConnection::ValidateStopWaitingFrame( | 860 bool QuicConnection::ValidateStopWaitingFrame( |
| 857 const QuicStopWaitingFrame& stop_waiting) { | 861 const QuicStopWaitingFrame& stop_waiting) { |
| 858 if (stop_waiting.least_unacked < | 862 if (stop_waiting.least_unacked < |
| 859 received_packet_manager_.peer_least_packet_awaiting_ack()) { | 863 received_packet_manager_.peer_least_packet_awaiting_ack()) { |
| 860 DLOG(ERROR) << ENDPOINT << "Peer's sent low least_unacked: " | 864 DLOG(ERROR) << ENDPOINT << "Peer's sent low least_unacked: " |
| 861 << stop_waiting.least_unacked << " vs " | 865 << stop_waiting.least_unacked << " vs " |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 DVLOG(1) << ENDPOINT << "Sending version negotiation packet: {" | 1100 DVLOG(1) << ENDPOINT << "Sending version negotiation packet: {" |
| 1097 << QuicVersionVectorToString(framer_.supported_versions()) << "}"; | 1101 << QuicVersionVectorToString(framer_.supported_versions()) << "}"; |
| 1098 scoped_ptr<QuicEncryptedPacket> version_packet( | 1102 scoped_ptr<QuicEncryptedPacket> version_packet( |
| 1099 packet_generator_.SerializeVersionNegotiationPacket( | 1103 packet_generator_.SerializeVersionNegotiationPacket( |
| 1100 framer_.supported_versions())); | 1104 framer_.supported_versions())); |
| 1101 WriteResult result = writer_->WritePacket( | 1105 WriteResult result = writer_->WritePacket( |
| 1102 version_packet->data(), version_packet->length(), | 1106 version_packet->data(), version_packet->length(), |
| 1103 self_address().address(), peer_address()); | 1107 self_address().address(), peer_address()); |
| 1104 | 1108 |
| 1105 if (result.status == WRITE_STATUS_ERROR) { | 1109 if (result.status == WRITE_STATUS_ERROR) { |
| 1106 // We can't send an error as the socket is presumably borked. | 1110 OnWriteError(result.error_code); |
| 1107 CloseConnection(QUIC_PACKET_WRITE_ERROR, false); | |
| 1108 return; | 1111 return; |
| 1109 } | 1112 } |
| 1110 if (result.status == WRITE_STATUS_BLOCKED) { | 1113 if (result.status == WRITE_STATUS_BLOCKED) { |
| 1111 visitor_->OnWriteBlocked(); | 1114 visitor_->OnWriteBlocked(); |
| 1112 if (writer_->IsWriteBlockedDataBuffered()) { | 1115 if (writer_->IsWriteBlockedDataBuffered()) { |
| 1113 pending_version_negotiation_packet_ = false; | 1116 pending_version_negotiation_packet_ = false; |
| 1114 } | 1117 } |
| 1115 return; | 1118 return; |
| 1116 } | 1119 } |
| 1117 | 1120 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1333 } | 1336 } |
| 1334 | 1337 |
| 1335 bool QuicConnection::ProcessValidatedPacket() { | 1338 bool QuicConnection::ProcessValidatedPacket() { |
| 1336 if (self_ip_changed_ || self_port_changed_) { | 1339 if (self_ip_changed_ || self_port_changed_) { |
| 1337 SendConnectionCloseWithDetails(QUIC_ERROR_MIGRATING_ADDRESS, | 1340 SendConnectionCloseWithDetails(QUIC_ERROR_MIGRATING_ADDRESS, |
| 1338 "Self address migration is not supported."); | 1341 "Self address migration is not supported."); |
| 1339 return false; | 1342 return false; |
| 1340 } | 1343 } |
| 1341 | 1344 |
| 1342 if (peer_ip_changed_ || peer_port_changed_) { | 1345 if (peer_ip_changed_ || peer_port_changed_) { |
| 1346 PeerAddressChangeType type = DeterminePeerAddressChangeType(); |
| 1347 if (type != NO_CHANGE && type != UNKNOWN && |
| 1348 (FLAGS_quic_disable_non_nat_address_migration && |
| 1349 type != NAT_PORT_REBINDING && type != IPV4_SUBNET_REBINDING)) { |
| 1350 SendConnectionCloseWithDetails(QUIC_ERROR_MIGRATING_ADDRESS, |
| 1351 "Invalid peer address migration."); |
| 1352 return false; |
| 1353 } |
| 1354 |
| 1343 IPEndPoint old_peer_address = peer_address_; | 1355 IPEndPoint old_peer_address = peer_address_; |
| 1344 peer_address_ = IPEndPoint( | 1356 peer_address_ = IPEndPoint( |
| 1345 peer_ip_changed_ ? migrating_peer_ip_ : peer_address_.address(), | 1357 peer_ip_changed_ ? migrating_peer_ip_ : peer_address_.address(), |
| 1346 peer_port_changed_ ? migrating_peer_port_ : peer_address_.port()); | 1358 peer_port_changed_ ? migrating_peer_port_ : peer_address_.port()); |
| 1347 | 1359 |
| 1348 DVLOG(1) << ENDPOINT << "Peer's ip:port changed from " | 1360 DVLOG(1) << ENDPOINT << "Peer's ip:port changed from " |
| 1349 << old_peer_address.ToString() << " to " | 1361 << old_peer_address.ToString() << " to " |
| 1350 << peer_address_.ToString() << ", migrating connection."; | 1362 << peer_address_.ToString() << ", migrating connection."; |
| 1351 | 1363 |
| 1352 visitor_->OnConnectionMigration(); | 1364 visitor_->OnConnectionMigration(); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1491 << packet->serialized_packet.packet_number | 1503 << packet->serialized_packet.packet_number |
| 1492 << " after:" << sent_packet_manager_.largest_sent_packet(); | 1504 << " after:" << sent_packet_manager_.largest_sent_packet(); |
| 1493 SendConnectionCloseWithDetails(QUIC_INTERNAL_ERROR, | 1505 SendConnectionCloseWithDetails(QUIC_INTERNAL_ERROR, |
| 1494 "Packet written out of order."); | 1506 "Packet written out of order."); |
| 1495 return true; | 1507 return true; |
| 1496 } | 1508 } |
| 1497 if (ShouldDiscardPacket(*packet)) { | 1509 if (ShouldDiscardPacket(*packet)) { |
| 1498 ++stats_.packets_discarded; | 1510 ++stats_.packets_discarded; |
| 1499 return true; | 1511 return true; |
| 1500 } | 1512 } |
| 1501 // Connection close packets are encrypted and saved, so don't exit early. | 1513 // Termination packets are encrypted and saved, so don't exit early. |
| 1502 const bool is_connection_close = IsConnectionClose(*packet); | 1514 const bool is_termination_packet = IsTerminationPacket(*packet); |
| 1503 if (writer_->IsWriteBlocked() && !is_connection_close) { | 1515 if (writer_->IsWriteBlocked() && !is_termination_packet) { |
| 1504 return false; | 1516 return false; |
| 1505 } | 1517 } |
| 1506 | 1518 |
| 1507 QuicPacketNumber packet_number = packet->serialized_packet.packet_number; | 1519 QuicPacketNumber packet_number = packet->serialized_packet.packet_number; |
| 1508 DCHECK_LE(packet_number_of_last_sent_packet_, packet_number); | 1520 DCHECK_LE(packet_number_of_last_sent_packet_, packet_number); |
| 1509 packet_number_of_last_sent_packet_ = packet_number; | 1521 packet_number_of_last_sent_packet_ = packet_number; |
| 1510 | 1522 |
| 1511 QuicEncryptedPacket* encrypted = packet->serialized_packet.packet; | 1523 QuicEncryptedPacket* encrypted = packet->serialized_packet.packet; |
| 1512 // Connection close packets are eventually owned by TimeWaitListManager. | 1524 // Termination packets are eventually owned by TimeWaitListManager. |
| 1513 // Others are deleted at the end of this call. | 1525 // Others are deleted at the end of this call. |
| 1514 if (is_connection_close) { | 1526 if (is_termination_packet) { |
| 1515 DCHECK(connection_close_packet_.get() == nullptr); | 1527 if (termination_packets_.get() == nullptr) { |
| 1528 termination_packets_.reset(new std::vector<QuicEncryptedPacket*>); |
| 1529 } |
| 1516 // Clone the packet so it's owned in the future. | 1530 // Clone the packet so it's owned in the future. |
| 1517 connection_close_packet_.reset(encrypted->Clone()); | 1531 termination_packets_->push_back(encrypted->Clone()); |
| 1518 // This assures we won't try to write *forced* packets when blocked. | 1532 // This assures we won't try to write *forced* packets when blocked. |
| 1519 // Return true to stop processing. | 1533 // Return true to stop processing. |
| 1520 if (writer_->IsWriteBlocked()) { | 1534 if (writer_->IsWriteBlocked()) { |
| 1521 visitor_->OnWriteBlocked(); | 1535 visitor_->OnWriteBlocked(); |
| 1522 return true; | 1536 return true; |
| 1523 } | 1537 } |
| 1524 } | 1538 } |
| 1525 | 1539 |
| 1526 if (!FLAGS_quic_allow_oversized_packets_for_test) { | 1540 DCHECK_LE(encrypted->length(), kMaxPacketSize); |
| 1527 DCHECK_LE(encrypted->length(), kMaxPacketSize); | |
| 1528 } | |
| 1529 DCHECK_LE(encrypted->length(), packet_generator_.GetMaxPacketLength()); | 1541 DCHECK_LE(encrypted->length(), packet_generator_.GetMaxPacketLength()); |
| 1530 DVLOG(1) << ENDPOINT << "Sending packet " << packet_number << " : " | 1542 DVLOG(1) << ENDPOINT << "Sending packet " << packet_number << " : " |
| 1531 << (packet->serialized_packet.is_fec_packet | 1543 << (packet->serialized_packet.is_fec_packet |
| 1532 ? "FEC " | 1544 ? "FEC " |
| 1533 : (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA | 1545 : (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA |
| 1534 ? "data bearing " | 1546 ? "data bearing " |
| 1535 : " ack only ")) | 1547 : " ack only ")) |
| 1536 << ", encryption level: " | 1548 << ", encryption level: " |
| 1537 << QuicUtils::EncryptionLevelToString(packet->encryption_level) | 1549 << QuicUtils::EncryptionLevelToString(packet->encryption_level) |
| 1538 << ", encrypted length:" << encrypted->length(); | 1550 << ", encrypted length:" << encrypted->length(); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1731 // next packet number is the first packet which requires | 1743 // next packet number is the first packet which requires |
| 1732 // forward security, start using the forward-secure encrypter. | 1744 // forward security, start using the forward-secure encrypter. |
| 1733 if (encryption_level_ != ENCRYPTION_FORWARD_SECURE && | 1745 if (encryption_level_ != ENCRYPTION_FORWARD_SECURE && |
| 1734 has_forward_secure_encrypter_ && | 1746 has_forward_secure_encrypter_ && |
| 1735 packet.serialized_packet.packet_number >= | 1747 packet.serialized_packet.packet_number >= |
| 1736 first_required_forward_secure_packet_ - 1) { | 1748 first_required_forward_secure_packet_ - 1) { |
| 1737 SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); | 1749 SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); |
| 1738 } | 1750 } |
| 1739 } | 1751 } |
| 1740 | 1752 |
| 1753 PeerAddressChangeType QuicConnection::DeterminePeerAddressChangeType() { |
| 1754 return UNKNOWN; |
| 1755 } |
| 1756 |
| 1741 void QuicConnection::SendPing() { | 1757 void QuicConnection::SendPing() { |
| 1742 if (retransmission_alarm_->IsSet()) { | 1758 if (retransmission_alarm_->IsSet()) { |
| 1743 return; | 1759 return; |
| 1744 } | 1760 } |
| 1745 packet_generator_.AddControlFrame(QuicFrame(QuicPingFrame())); | 1761 packet_generator_.AddControlFrame(QuicFrame(QuicPingFrame())); |
| 1746 } | 1762 } |
| 1747 | 1763 |
| 1748 void QuicConnection::SendAck() { | 1764 void QuicConnection::SendAck() { |
| 1749 ack_alarm_->Cancel(); | 1765 ack_alarm_->Cancel(); |
| 1750 ack_queued_ = false; | 1766 ack_queued_ = false; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2020 void QuicConnection::SetMaxPacketLength(QuicByteCount length) { | 2036 void QuicConnection::SetMaxPacketLength(QuicByteCount length) { |
| 2021 return packet_generator_.SetMaxPacketLength(LimitMaxPacketSize(length), | 2037 return packet_generator_.SetMaxPacketLength(LimitMaxPacketSize(length), |
| 2022 /*force=*/false); | 2038 /*force=*/false); |
| 2023 } | 2039 } |
| 2024 | 2040 |
| 2025 bool QuicConnection::HasQueuedData() const { | 2041 bool QuicConnection::HasQueuedData() const { |
| 2026 return pending_version_negotiation_packet_ || | 2042 return pending_version_negotiation_packet_ || |
| 2027 !queued_packets_.empty() || packet_generator_.HasQueuedFrames(); | 2043 !queued_packets_.empty() || packet_generator_.HasQueuedFrames(); |
| 2028 } | 2044 } |
| 2029 | 2045 |
| 2046 void QuicConnection::EnableSavingCryptoPackets() { |
| 2047 save_crypto_packets_as_termination_packets_ = true; |
| 2048 } |
| 2049 |
| 2030 bool QuicConnection::CanWriteStreamData() { | 2050 bool QuicConnection::CanWriteStreamData() { |
| 2031 // Don't write stream data if there are negotiation or queued data packets | 2051 // Don't write stream data if there are negotiation or queued data packets |
| 2032 // to send. Otherwise, continue and bundle as many frames as possible. | 2052 // to send. Otherwise, continue and bundle as many frames as possible. |
| 2033 if (pending_version_negotiation_packet_ || !queued_packets_.empty()) { | 2053 if (pending_version_negotiation_packet_ || !queued_packets_.empty()) { |
| 2034 return false; | 2054 return false; |
| 2035 } | 2055 } |
| 2036 | 2056 |
| 2037 IsHandshake pending_handshake = visitor_->HasPendingHandshake() ? | 2057 IsHandshake pending_handshake = visitor_->HasPendingHandshake() ? |
| 2038 IS_HANDSHAKE : NOT_HANDSHAKE; | 2058 IS_HANDSHAKE : NOT_HANDSHAKE; |
| 2039 // Sending queued packets may have caused the socket to become write blocked, | 2059 // Sending queued packets may have caused the socket to become write blocked, |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2224 // Retransmitted packets retransmittable frames are owned by the unacked | 2244 // Retransmitted packets retransmittable frames are owned by the unacked |
| 2225 // packet map, but are not present in the serialized packet. | 2245 // packet map, but are not present in the serialized packet. |
| 2226 if (packet.transmission_type != NOT_RETRANSMISSION || | 2246 if (packet.transmission_type != NOT_RETRANSMISSION || |
| 2227 packet.serialized_packet.retransmittable_frames != nullptr) { | 2247 packet.serialized_packet.retransmittable_frames != nullptr) { |
| 2228 return HAS_RETRANSMITTABLE_DATA; | 2248 return HAS_RETRANSMITTABLE_DATA; |
| 2229 } else { | 2249 } else { |
| 2230 return NO_RETRANSMITTABLE_DATA; | 2250 return NO_RETRANSMITTABLE_DATA; |
| 2231 } | 2251 } |
| 2232 } | 2252 } |
| 2233 | 2253 |
| 2234 bool QuicConnection::IsConnectionClose(const QueuedPacket& packet) { | 2254 bool QuicConnection::IsTerminationPacket(const QueuedPacket& packet) { |
| 2235 const RetransmittableFrames* retransmittable_frames = | 2255 const RetransmittableFrames* retransmittable_frames = |
| 2236 packet.serialized_packet.retransmittable_frames; | 2256 packet.serialized_packet.retransmittable_frames; |
| 2237 if (retransmittable_frames == nullptr) { | 2257 if (retransmittable_frames == nullptr) { |
| 2238 return false; | 2258 return false; |
| 2239 } | 2259 } |
| 2240 for (const QuicFrame& frame : retransmittable_frames->frames()) { | 2260 for (const QuicFrame& frame : retransmittable_frames->frames()) { |
| 2241 if (frame.type == CONNECTION_CLOSE_FRAME) { | 2261 if (frame.type == CONNECTION_CLOSE_FRAME) { |
| 2242 return true; | 2262 return true; |
| 2243 } | 2263 } |
| 2264 if (save_crypto_packets_as_termination_packets_ && |
| 2265 frame.type == STREAM_FRAME && |
| 2266 frame.stream_frame->stream_id == kCryptoStreamId) { |
| 2267 return true; |
| 2268 } |
| 2244 } | 2269 } |
| 2245 return false; | 2270 return false; |
| 2246 } | 2271 } |
| 2247 | 2272 |
| 2248 void QuicConnection::SetMtuDiscoveryTarget(QuicByteCount target) { | 2273 void QuicConnection::SetMtuDiscoveryTarget(QuicByteCount target) { |
| 2249 mtu_discovery_target_ = LimitMaxPacketSize(target); | 2274 mtu_discovery_target_ = LimitMaxPacketSize(target); |
| 2250 } | 2275 } |
| 2251 | 2276 |
| 2252 QuicByteCount QuicConnection::LimitMaxPacketSize( | 2277 QuicByteCount QuicConnection::LimitMaxPacketSize( |
| 2253 QuicByteCount suggested_max_packet_size) { | 2278 QuicByteCount suggested_max_packet_size) { |
| 2254 if (FLAGS_quic_allow_oversized_packets_for_test) { | |
| 2255 return suggested_max_packet_size; | |
| 2256 } | |
| 2257 | |
| 2258 if (peer_address_.address().empty()) { | 2279 if (peer_address_.address().empty()) { |
| 2259 LOG(DFATAL) << "Attempted to use a connection without a valid peer address"; | 2280 LOG(DFATAL) << "Attempted to use a connection without a valid peer address"; |
| 2260 return suggested_max_packet_size; | 2281 return suggested_max_packet_size; |
| 2261 } | 2282 } |
| 2262 | 2283 |
| 2263 const QuicByteCount writer_limit = writer_->GetMaxPacketSize(peer_address()); | 2284 const QuicByteCount writer_limit = writer_->GetMaxPacketSize(peer_address()); |
| 2264 | 2285 |
| 2265 QuicByteCount max_packet_size = suggested_max_packet_size; | 2286 QuicByteCount max_packet_size = suggested_max_packet_size; |
| 2266 if (max_packet_size > writer_limit) { | 2287 if (max_packet_size > writer_limit) { |
| 2267 max_packet_size = writer_limit; | 2288 max_packet_size = writer_limit; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2305 packet_number_of_last_sent_packet_ + packets_between_mtu_probes_ + 1; | 2326 packet_number_of_last_sent_packet_ + packets_between_mtu_probes_ + 1; |
| 2306 ++mtu_probe_count_; | 2327 ++mtu_probe_count_; |
| 2307 | 2328 |
| 2308 DVLOG(2) << "Sending a path MTU discovery packet #" << mtu_probe_count_; | 2329 DVLOG(2) << "Sending a path MTU discovery packet #" << mtu_probe_count_; |
| 2309 SendMtuDiscoveryPacket(mtu_discovery_target_); | 2330 SendMtuDiscoveryPacket(mtu_discovery_target_); |
| 2310 | 2331 |
| 2311 DCHECK(!mtu_discovery_alarm_->IsSet()); | 2332 DCHECK(!mtu_discovery_alarm_->IsSet()); |
| 2312 } | 2333 } |
| 2313 | 2334 |
| 2314 } // namespace net | 2335 } // namespace net |
| OLD | NEW |