Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: net/quic/quic_stream_factory.cc

Issue 2124753005: Implements migration of a QUIC connection to a different destination address if specified by the se… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@write-error
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_stream_factory.h" 5 #include "net/quic/quic_stream_factory.h"
6 6
7 #include <openssl/aead.h> 7 #include <openssl/aead.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <tuple> 10 #include <tuple>
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 session->connection_id(), "Non-migratable stream"); 1436 session->connection_id(), "Non-migratable stream");
1437 if (force_close) { 1437 if (force_close) {
1438 // Close sessions with non-migratable streams. 1438 // Close sessions with non-migratable streams.
1439 session->CloseSessionOnError( 1439 session->CloseSessionOnError(
1440 ERR_NETWORK_CHANGED, 1440 ERR_NETWORK_CHANGED,
1441 QUIC_CONNECTION_MIGRATION_NON_MIGRATABLE_STREAM); 1441 QUIC_CONNECTION_MIGRATION_NON_MIGRATABLE_STREAM);
1442 } 1442 }
1443 continue; 1443 continue;
1444 } 1444 }
1445 1445
1446 MigrateSessionToNetwork(session, new_network, bound_net_log, nullptr); 1446 MigrateSessionToNewSocket(session, session->connection()->peer_address(),
1447 new_network, bound_net_log, nullptr);
1447 } 1448 }
1448 } 1449 }
1449 1450
1450 void QuicStreamFactory::MaybeMigrateSingleSession( 1451 void QuicStreamFactory::MaybeMigrateSingleSession(
1451 QuicChromiumClientSession* session, 1452 QuicChromiumClientSession* session,
1452 MigrationCause migration_cause, 1453 MigrationCause migration_cause,
1453 scoped_refptr<StringIOBuffer> packet) { 1454 scoped_refptr<StringIOBuffer> packet) {
1454 ScopedConnectionMigrationEventLog scoped_event_log( 1455 ScopedConnectionMigrationEventLog scoped_event_log(
1455 net_log_, 1456 net_log_,
1456 migration_cause == EARLY_MIGRATION ? "EarlyMigration" : "WriteError"); 1457 migration_cause == EARLY_MIGRATION ? "EarlyMigration" : "WriteError");
(...skipping 11 matching lines...) Expand all
1468 if (new_network == NetworkChangeNotifier::kInvalidNetworkHandle) { 1469 if (new_network == NetworkChangeNotifier::kInvalidNetworkHandle) {
1469 // No alternate network found. 1470 // No alternate network found.
1470 // TODO (jri): Add histogram for this failure case. 1471 // TODO (jri): Add histogram for this failure case.
1471 scoped_event_log.net_log().AddEvent( 1472 scoped_event_log.net_log().AddEvent(
1472 NetLog::TYPE_QUIC_CONNECTION_MIGRATION_FAILURE, 1473 NetLog::TYPE_QUIC_CONNECTION_MIGRATION_FAILURE,
1473 base::Bind(&NetLogQuicConnectionMigrationFailureCallback, 1474 base::Bind(&NetLogQuicConnectionMigrationFailureCallback,
1474 session->connection_id(), "No new network")); 1475 session->connection_id(), "No new network"));
1475 return; 1476 return;
1476 } 1477 }
1477 OnSessionGoingAway(session); 1478 OnSessionGoingAway(session);
1478 MigrateSessionToNetwork(session, new_network, scoped_event_log.net_log(), 1479 MigrateSessionToNewSocket(session, session->connection()->peer_address(),
1479 packet); 1480 new_network, scoped_event_log.net_log(), packet);
1480 } 1481 }
1481 1482
1482 void QuicStreamFactory::MigrateSessionToNetwork( 1483 void QuicStreamFactory::MigrateSessionToNewSocket(
Ryan Hamilton 2016/07/06 19:29:37 (Alternative name "MigrateSession"?)
Jana 2016/07/12 22:34:10 Done.
1483 QuicChromiumClientSession* session, 1484 QuicChromiumClientSession* session,
1484 NetworkHandle new_network, 1485 IPEndPoint peer_address,
1486 NetworkHandle network,
1485 const BoundNetLog& bound_net_log, 1487 const BoundNetLog& bound_net_log,
1486 scoped_refptr<StringIOBuffer> packet) { 1488 scoped_refptr<StringIOBuffer> packet) {
1487 // Use OS-specified port for socket (DEFAULT_BIND) instead of 1489 // Use OS-specified port for socket (DEFAULT_BIND) instead of
1488 // using the PortSuggester since the connection is being migrated 1490 // using the PortSuggester since the connection is being migrated
1489 // and not being newly created. 1491 // and not being newly created.
1490 std::unique_ptr<DatagramClientSocket> socket( 1492 std::unique_ptr<DatagramClientSocket> socket(
1491 client_socket_factory_->CreateDatagramClientSocket( 1493 client_socket_factory_->CreateDatagramClientSocket(
1492 DatagramSocket::DEFAULT_BIND, RandIntCallback(), 1494 DatagramSocket::DEFAULT_BIND, RandIntCallback(),
1493 session->net_log().net_log(), session->net_log().source())); 1495 session->net_log().net_log(), session->net_log().source()));
1494 QuicConnection* connection = session->connection(); 1496 if (ConfigureSocket(socket.get(), peer_address, network) != OK) {
1495 if (ConfigureSocket(socket.get(), connection->peer_address(), new_network) !=
1496 OK) {
1497 session->CloseSessionOnError(ERR_NETWORK_CHANGED, QUIC_INTERNAL_ERROR); 1497 session->CloseSessionOnError(ERR_NETWORK_CHANGED, QUIC_INTERNAL_ERROR);
1498 HistogramAndLogMigrationFailure( 1498 HistogramAndLogMigrationFailure(
1499 bound_net_log, MIGRATION_STATUS_INTERNAL_ERROR, 1499 bound_net_log, MIGRATION_STATUS_INTERNAL_ERROR,
1500 session->connection_id(), "Socket configuration failed"); 1500 session->connection_id(), "Socket configuration failed");
1501 return; 1501 return;
1502 } 1502 }
1503 std::unique_ptr<QuicChromiumPacketReader> new_reader( 1503 std::unique_ptr<QuicChromiumPacketReader> new_reader(
1504 new QuicChromiumPacketReader(socket.get(), clock_.get(), session, 1504 new QuicChromiumPacketReader(socket.get(), clock_.get(), session,
1505 yield_after_packets_, yield_after_duration_, 1505 yield_after_packets_, yield_after_duration_,
1506 session->net_log())); 1506 session->net_log()));
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 // Since the session was active, there's no longer an 1876 // Since the session was active, there's no longer an
1877 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP 1877 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP
1878 // job also fails. So to avoid not using QUIC when we otherwise could, we mark 1878 // job also fails. So to avoid not using QUIC when we otherwise could, we mark
1879 // it as recently broken, which means that 0-RTT will be disabled but we'll 1879 // it as recently broken, which means that 0-RTT will be disabled but we'll
1880 // still race. 1880 // still race.
1881 http_server_properties_->MarkAlternativeServiceRecentlyBroken( 1881 http_server_properties_->MarkAlternativeServiceRecentlyBroken(
1882 alternative_service); 1882 alternative_service);
1883 } 1883 }
1884 1884
1885 } // namespace net 1885 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698