| Index: net/quic/quic_connection.cc
|
| diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc
|
| index 3b8765259f6d2e1ab62698dc9e13fa2e0c0015db..31603b76a410e229bb422d94212e4ec579b11525 100644
|
| --- a/net/quic/quic_connection.cc
|
| +++ b/net/quic/quic_connection.cc
|
| @@ -223,7 +223,6 @@ QuicConnection::QuicConnection(QuicConnectionId connection_id,
|
| random_generator_(helper->GetRandomGenerator()),
|
| connection_id_(connection_id),
|
| peer_address_(address),
|
| - migrating_peer_port_(0),
|
| last_packet_decrypted_(false),
|
| last_size_(0),
|
| current_packet_data_(nullptr),
|
| @@ -282,10 +281,6 @@ QuicConnection::QuicConnection(QuicConnectionId connection_id,
|
| version_negotiation_state_(START_NEGOTIATION),
|
| perspective_(perspective),
|
| connected_(true),
|
| - peer_ip_changed_(false),
|
| - peer_port_changed_(false),
|
| - self_ip_changed_(false),
|
| - self_port_changed_(false),
|
| can_truncate_connection_ids_(true),
|
| mtu_discovery_target_(0),
|
| mtu_probe_count_(0),
|
| @@ -1217,17 +1212,13 @@ void QuicConnection::ProcessUdpPacket(const IPEndPoint& self_address,
|
| last_size_ = packet.length();
|
| current_packet_data_ = packet.data();
|
|
|
| - if (FLAGS_check_peer_address_change_after_decryption) {
|
| - last_packet_destination_address_ = self_address;
|
| - last_packet_source_address_ = peer_address;
|
| - if (!IsInitializedIPEndPoint(self_address_)) {
|
| - self_address_ = last_packet_destination_address_;
|
| - }
|
| - if (!IsInitializedIPEndPoint(peer_address_)) {
|
| - peer_address_ = last_packet_source_address_;
|
| - }
|
| - } else {
|
| - CheckForAddressMigration(self_address, peer_address);
|
| + last_packet_destination_address_ = self_address;
|
| + last_packet_source_address_ = peer_address;
|
| + if (!IsInitializedIPEndPoint(self_address_)) {
|
| + self_address_ = last_packet_destination_address_;
|
| + }
|
| + if (!IsInitializedIPEndPoint(peer_address_)) {
|
| + peer_address_ = last_packet_source_address_;
|
| }
|
|
|
| stats_.bytes_received += packet.length();
|
| @@ -1258,35 +1249,6 @@ void QuicConnection::ProcessUdpPacket(const IPEndPoint& self_address,
|
| current_packet_data_ = nullptr;
|
| }
|
|
|
| -void QuicConnection::CheckForAddressMigration(const IPEndPoint& self_address,
|
| - const IPEndPoint& peer_address) {
|
| - peer_ip_changed_ = false;
|
| - peer_port_changed_ = false;
|
| - self_ip_changed_ = false;
|
| - self_port_changed_ = false;
|
| -
|
| - if (peer_address_.address().empty()) {
|
| - peer_address_ = peer_address;
|
| - }
|
| - if (self_address_.address().empty()) {
|
| - self_address_ = self_address;
|
| - }
|
| -
|
| - if (!peer_address.address().empty() && !peer_address_.address().empty()) {
|
| - peer_ip_changed_ = (peer_address.address() != peer_address_.address());
|
| - peer_port_changed_ = (peer_address.port() != peer_address_.port());
|
| -
|
| - // Store in case we want to migrate connection in ProcessValidatedPacket.
|
| - migrating_peer_ip_ = peer_address.address();
|
| - migrating_peer_port_ = peer_address.port();
|
| - }
|
| -
|
| - if (!self_address.address().empty() && !self_address_.address().empty()) {
|
| - self_ip_changed_ = (self_address.address() != self_address_.address());
|
| - self_port_changed_ = (self_address.port() != self_address_.port());
|
| - }
|
| -}
|
| -
|
| void QuicConnection::OnCanWrite() {
|
| DCHECK(!writer_->IsWriteBlocked());
|
|
|
| @@ -1337,24 +1299,14 @@ bool QuicConnection::ProcessValidatedPacket(const QuicPacketHeader& header) {
|
| return false;
|
| }
|
|
|
| - if (FLAGS_check_peer_address_change_after_decryption) {
|
| - if (perspective_ == Perspective::IS_SERVER &&
|
| - IsInitializedIPEndPoint(self_address_) &&
|
| - IsInitializedIPEndPoint(last_packet_destination_address_) &&
|
| - (!(self_address_ == last_packet_destination_address_))) {
|
| - SendConnectionCloseWithDetails(
|
| - QUIC_ERROR_MIGRATING_ADDRESS,
|
| - "Self address migration is not supported at the server.");
|
| - return false;
|
| - }
|
| - } else {
|
| - if (perspective_ == Perspective::IS_SERVER &&
|
| - (self_ip_changed_ || self_port_changed_)) {
|
| - SendConnectionCloseWithDetails(
|
| - QUIC_ERROR_MIGRATING_ADDRESS,
|
| - "Self address migration is not supported at the server.");
|
| - return false;
|
| - }
|
| + if (perspective_ == Perspective::IS_SERVER &&
|
| + IsInitializedIPEndPoint(self_address_) &&
|
| + IsInitializedIPEndPoint(last_packet_destination_address_) &&
|
| + (!(self_address_ == last_packet_destination_address_))) {
|
| + SendConnectionCloseWithDetails(
|
| + QUIC_ERROR_MIGRATING_ADDRESS,
|
| + "Self address migration is not supported at the server.");
|
| + return false;
|
| }
|
|
|
| if (!Near(header.packet_number, last_header_.packet_number)) {
|
| @@ -2299,50 +2251,25 @@ void QuicConnection::DiscoverMtu() {
|
|
|
| void QuicConnection::MaybeMigrateConnectionToNewPeerAddress() {
|
| IPEndPoint last_peer_address;
|
| - if (FLAGS_check_peer_address_change_after_decryption) {
|
| - last_peer_address = last_packet_source_address_;
|
| - } else {
|
| - last_peer_address = IPEndPoint(
|
| - peer_ip_changed_ ? migrating_peer_ip_ : peer_address_.address(),
|
| - peer_port_changed_ ? migrating_peer_port_ : peer_address_.port());
|
| - }
|
| + last_peer_address = last_packet_source_address_;
|
| PeerAddressChangeType peer_address_change_type =
|
| QuicUtils::DetermineAddressChangeType(peer_address_, last_peer_address);
|
| // TODO(fayang): Currently, all peer address change type are allowed. Need to
|
| // add a method ShouldAllowPeerAddressChange(PeerAddressChangeType type) to
|
| - // determine whehter |type| is allowed.
|
| - if (FLAGS_check_peer_address_change_after_decryption) {
|
| - if (peer_address_change_type == NO_CHANGE) {
|
| - return;
|
| - }
|
| -
|
| - IPEndPoint old_peer_address = peer_address_;
|
| - peer_address_ = last_packet_source_address_;
|
| -
|
| - DVLOG(1) << ENDPOINT << "Peer's ip:port changed from "
|
| - << old_peer_address.ToString() << " to "
|
| - << peer_address_.ToString() << ", migrating connection.";
|
| -
|
| - visitor_->OnConnectionMigration(peer_address_change_type);
|
| - sent_packet_manager_.OnConnectionMigration(peer_address_change_type);
|
| -
|
| + // determine whether |type| is allowed.
|
| + if (peer_address_change_type == NO_CHANGE) {
|
| return;
|
| }
|
|
|
| - if (peer_ip_changed_ || peer_port_changed_) {
|
| - IPEndPoint old_peer_address = peer_address_;
|
| - peer_address_ = IPEndPoint(
|
| - peer_ip_changed_ ? migrating_peer_ip_ : peer_address_.address(),
|
| - peer_port_changed_ ? migrating_peer_port_ : peer_address_.port());
|
| + IPEndPoint old_peer_address = peer_address_;
|
| + peer_address_ = last_packet_source_address_;
|
|
|
| - DVLOG(1) << ENDPOINT << "Peer's ip:port changed from "
|
| - << old_peer_address.ToString() << " to "
|
| - << peer_address_.ToString() << ", migrating connection.";
|
| + DVLOG(1) << ENDPOINT << "Peer's ip:port changed from "
|
| + << old_peer_address.ToString() << " to " << peer_address_.ToString()
|
| + << ", migrating connection.";
|
|
|
| - visitor_->OnConnectionMigration(peer_address_change_type);
|
| - DCHECK_NE(peer_address_change_type, NO_CHANGE);
|
| - sent_packet_manager_.OnConnectionMigration(peer_address_change_type);
|
| - }
|
| + visitor_->OnConnectionMigration(peer_address_change_type);
|
| + sent_packet_manager_.OnConnectionMigration(peer_address_change_type);
|
| }
|
|
|
| void QuicConnection::OnPathClosed(QuicPathId path_id) {
|
|
|