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

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: fixing linker error. 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
« no previous file with comments | « net/quic/quic_stream_factory.h ('k') | net/quic/quic_stream_factory_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 int threshold_public_resets_post_handshake, 625 int threshold_public_resets_post_handshake,
626 int threshold_timeouts_with_open_streams, 626 int threshold_timeouts_with_open_streams,
627 int socket_receive_buffer_size, 627 int socket_receive_buffer_size,
628 bool delay_tcp_race, 628 bool delay_tcp_race,
629 int max_server_configs_stored_in_properties, 629 int max_server_configs_stored_in_properties,
630 bool close_sessions_on_ip_change, 630 bool close_sessions_on_ip_change,
631 bool disable_quic_on_timeout_with_open_streams, 631 bool disable_quic_on_timeout_with_open_streams,
632 int idle_connection_timeout_seconds, 632 int idle_connection_timeout_seconds,
633 bool migrate_sessions_on_network_change, 633 bool migrate_sessions_on_network_change,
634 bool migrate_sessions_early, 634 bool migrate_sessions_early,
635 bool allow_server_migration,
635 bool force_hol_blocking, 636 bool force_hol_blocking,
636 const QuicTagVector& connection_options, 637 const QuicTagVector& connection_options,
637 bool enable_token_binding) 638 bool enable_token_binding)
638 : require_confirmation_(true), 639 : require_confirmation_(true),
639 net_log_(net_log), 640 net_log_(net_log),
640 host_resolver_(host_resolver), 641 host_resolver_(host_resolver),
641 client_socket_factory_(client_socket_factory), 642 client_socket_factory_(client_socket_factory),
642 http_server_properties_(http_server_properties), 643 http_server_properties_(http_server_properties),
643 transport_security_state_(transport_security_state), 644 transport_security_state_(transport_security_state),
644 cert_transparency_verifier_(cert_transparency_verifier), 645 cert_transparency_verifier_(cert_transparency_verifier),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 delay_tcp_race_(delay_tcp_race), 680 delay_tcp_race_(delay_tcp_race),
680 yield_after_packets_(kQuicYieldAfterPacketsRead), 681 yield_after_packets_(kQuicYieldAfterPacketsRead),
681 yield_after_duration_(QuicTime::Delta::FromMilliseconds( 682 yield_after_duration_(QuicTime::Delta::FromMilliseconds(
682 kQuicYieldAfterDurationMilliseconds)), 683 kQuicYieldAfterDurationMilliseconds)),
683 close_sessions_on_ip_change_(close_sessions_on_ip_change), 684 close_sessions_on_ip_change_(close_sessions_on_ip_change),
684 migrate_sessions_on_network_change_( 685 migrate_sessions_on_network_change_(
685 migrate_sessions_on_network_change && 686 migrate_sessions_on_network_change &&
686 NetworkChangeNotifier::AreNetworkHandlesSupported()), 687 NetworkChangeNotifier::AreNetworkHandlesSupported()),
687 migrate_sessions_early_(migrate_sessions_early && 688 migrate_sessions_early_(migrate_sessions_early &&
688 migrate_sessions_on_network_change_), 689 migrate_sessions_on_network_change_),
690 allow_server_migration_(allow_server_migration),
689 force_hol_blocking_(force_hol_blocking), 691 force_hol_blocking_(force_hol_blocking),
690 port_seed_(random_generator_->RandUint64()), 692 port_seed_(random_generator_->RandUint64()),
691 check_persisted_supports_quic_(true), 693 check_persisted_supports_quic_(true),
692 has_initialized_data_(false), 694 has_initialized_data_(false),
693 num_push_streams_created_(0), 695 num_push_streams_created_(0),
694 status_(OPEN), 696 status_(OPEN),
695 task_runner_(nullptr), 697 task_runner_(nullptr),
696 ssl_config_service_(ssl_config_service), 698 ssl_config_service_(ssl_config_service),
697 weak_factory_(this) { 699 weak_factory_(this) {
698 if (ssl_config_service_.get()) 700 if (ssl_config_service_.get())
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 session->connection_id(), "Non-migratable stream"); 1440 session->connection_id(), "Non-migratable stream");
1439 if (force_close) { 1441 if (force_close) {
1440 // Close sessions with non-migratable streams. 1442 // Close sessions with non-migratable streams.
1441 session->CloseSessionOnError( 1443 session->CloseSessionOnError(
1442 ERR_NETWORK_CHANGED, 1444 ERR_NETWORK_CHANGED,
1443 QUIC_CONNECTION_MIGRATION_NON_MIGRATABLE_STREAM); 1445 QUIC_CONNECTION_MIGRATION_NON_MIGRATABLE_STREAM);
1444 } 1446 }
1445 continue; 1447 continue;
1446 } 1448 }
1447 1449
1448 MigrateSessionToNetwork(session, new_network, bound_net_log, nullptr); 1450 MigrateSessionToNewNetwork(session, new_network, bound_net_log, nullptr);
1449 } 1451 }
1450 } 1452 }
1451 1453
1452 void QuicStreamFactory::MaybeMigrateSingleSession( 1454 void QuicStreamFactory::MaybeMigrateSingleSession(
1453 QuicChromiumClientSession* session, 1455 QuicChromiumClientSession* session,
1454 MigrationCause migration_cause, 1456 MigrationCause migration_cause,
1455 scoped_refptr<StringIOBuffer> packet) { 1457 scoped_refptr<StringIOBuffer> packet) {
1456 ScopedConnectionMigrationEventLog scoped_event_log( 1458 ScopedConnectionMigrationEventLog scoped_event_log(
1457 net_log_, 1459 net_log_,
1458 migration_cause == EARLY_MIGRATION ? "EarlyMigration" : "WriteError"); 1460 migration_cause == EARLY_MIGRATION ? "EarlyMigration" : "WriteError");
(...skipping 11 matching lines...) Expand all
1470 if (new_network == NetworkChangeNotifier::kInvalidNetworkHandle) { 1472 if (new_network == NetworkChangeNotifier::kInvalidNetworkHandle) {
1471 // No alternate network found. 1473 // No alternate network found.
1472 // TODO (jri): Add histogram for this failure case. 1474 // TODO (jri): Add histogram for this failure case.
1473 scoped_event_log.net_log().AddEvent( 1475 scoped_event_log.net_log().AddEvent(
1474 NetLog::TYPE_QUIC_CONNECTION_MIGRATION_FAILURE, 1476 NetLog::TYPE_QUIC_CONNECTION_MIGRATION_FAILURE,
1475 base::Bind(&NetLogQuicConnectionMigrationFailureCallback, 1477 base::Bind(&NetLogQuicConnectionMigrationFailureCallback,
1476 session->connection_id(), "No new network")); 1478 session->connection_id(), "No new network"));
1477 return; 1479 return;
1478 } 1480 }
1479 OnSessionGoingAway(session); 1481 OnSessionGoingAway(session);
1480 MigrateSessionToNetwork(session, new_network, scoped_event_log.net_log(), 1482 MigrateSessionToNewNetwork(session, new_network, scoped_event_log.net_log(),
1481 packet); 1483 packet);
1482 } 1484 }
1483 1485
1484 void QuicStreamFactory::MigrateSessionToNetwork( 1486 void QuicStreamFactory::MigrateSessionToNewPeerAddress(
1485 QuicChromiumClientSession* session, 1487 QuicChromiumClientSession* session,
1486 NetworkHandle new_network, 1488 IPEndPoint peer_address,
1489 const BoundNetLog& bound_net_log) {
1490 if (!allow_server_migration_)
1491 return;
1492 // Specifying kInvalidNetworkHandle for the |network| parameter
1493 // causes the session to use the default network for the new socket.
1494 MigrateSession(session, peer_address,
1495 NetworkChangeNotifier::kInvalidNetworkHandle, bound_net_log,
1496 nullptr);
1497 }
1498
1499 void QuicStreamFactory::MigrateSessionToNewNetwork(
1500 QuicChromiumClientSession* session,
1501 NetworkHandle network,
1487 const BoundNetLog& bound_net_log, 1502 const BoundNetLog& bound_net_log,
1488 scoped_refptr<StringIOBuffer> packet) { 1503 scoped_refptr<StringIOBuffer> packet) {
1504 MigrateSession(session, session->connection()->peer_address(), network,
1505 bound_net_log, packet);
1506 }
1507
1508 void QuicStreamFactory::MigrateSession(QuicChromiumClientSession* session,
1509 IPEndPoint peer_address,
1510 NetworkHandle network,
1511 const BoundNetLog& bound_net_log,
1512 scoped_refptr<StringIOBuffer> packet) {
1489 // Use OS-specified port for socket (DEFAULT_BIND) instead of 1513 // Use OS-specified port for socket (DEFAULT_BIND) instead of
1490 // using the PortSuggester since the connection is being migrated 1514 // using the PortSuggester since the connection is being migrated
1491 // and not being newly created. 1515 // and not being newly created.
1492 std::unique_ptr<DatagramClientSocket> socket( 1516 std::unique_ptr<DatagramClientSocket> socket(
1493 client_socket_factory_->CreateDatagramClientSocket( 1517 client_socket_factory_->CreateDatagramClientSocket(
1494 DatagramSocket::DEFAULT_BIND, RandIntCallback(), 1518 DatagramSocket::DEFAULT_BIND, RandIntCallback(),
1495 session->net_log().net_log(), session->net_log().source())); 1519 session->net_log().net_log(), session->net_log().source()));
1496 QuicConnection* connection = session->connection(); 1520 if (ConfigureSocket(socket.get(), peer_address, network) != OK) {
1497 if (ConfigureSocket(socket.get(), connection->peer_address(), new_network) !=
1498 OK) {
1499 session->CloseSessionOnError(ERR_NETWORK_CHANGED, QUIC_INTERNAL_ERROR); 1521 session->CloseSessionOnError(ERR_NETWORK_CHANGED, QUIC_INTERNAL_ERROR);
1500 HistogramAndLogMigrationFailure( 1522 HistogramAndLogMigrationFailure(
1501 bound_net_log, MIGRATION_STATUS_INTERNAL_ERROR, 1523 bound_net_log, MIGRATION_STATUS_INTERNAL_ERROR,
1502 session->connection_id(), "Socket configuration failed"); 1524 session->connection_id(), "Socket configuration failed");
1503 return; 1525 return;
1504 } 1526 }
1505 std::unique_ptr<QuicChromiumPacketReader> new_reader( 1527 std::unique_ptr<QuicChromiumPacketReader> new_reader(
1506 new QuicChromiumPacketReader(socket.get(), clock_.get(), session, 1528 new QuicChromiumPacketReader(socket.get(), clock_.get(), session,
1507 yield_after_packets_, yield_after_duration_, 1529 yield_after_packets_, yield_after_duration_,
1508 session->net_log())); 1530 session->net_log()));
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 // Since the session was active, there's no longer an 1903 // Since the session was active, there's no longer an
1882 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP 1904 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP
1883 // job also fails. So to avoid not using QUIC when we otherwise could, we mark 1905 // job also fails. So to avoid not using QUIC when we otherwise could, we mark
1884 // it as recently broken, which means that 0-RTT will be disabled but we'll 1906 // it as recently broken, which means that 0-RTT will be disabled but we'll
1885 // still race. 1907 // still race.
1886 http_server_properties_->MarkAlternativeServiceRecentlyBroken( 1908 http_server_properties_->MarkAlternativeServiceRecentlyBroken(
1887 alternative_service); 1909 alternative_service);
1888 } 1910 }
1889 1911
1890 } // namespace net 1912 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_stream_factory.h ('k') | net/quic/quic_stream_factory_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698