OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/core/quic_config.h" | 5 #include "net/quic/core/quic_config.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "net/quic/core/crypto/crypto_handshake_message.h" | 9 #include "net/quic/core/crypto/crypto_handshake_message.h" |
10 #include "net/quic/core/crypto/crypto_protocol.h" | 10 #include "net/quic/core/crypto/crypto_protocol.h" |
11 #include "net/quic/core/quic_flags.h" | 11 #include "net/quic/core/quic_flags.h" |
12 #include "net/quic/core/quic_socket_address_coder.h" | 12 #include "net/quic/core/quic_socket_address_coder.h" |
13 #include "net/quic/core/quic_utils.h" | 13 #include "net/quic/core/quic_utils.h" |
14 #include "net/quic/platform/api/quic_bug_tracker.h" | 14 #include "net/quic/platform/api/quic_bug_tracker.h" |
| 15 #include "net/quic/platform/api/quic_flag_utils.h" |
15 #include "net/quic/platform/api/quic_logging.h" | 16 #include "net/quic/platform/api/quic_logging.h" |
16 #include "net/quic/platform/api/quic_string_piece.h" | 17 #include "net/quic/platform/api/quic_string_piece.h" |
17 | 18 |
18 using std::string; | 19 using std::string; |
19 | 20 |
20 namespace net { | 21 namespace net { |
21 | 22 |
22 // Reads the value corresponding to |name_| from |msg| into |out|. If the | 23 // Reads the value corresponding to |name_| from |msg| into |out|. If the |
23 // |name_| is absent in |msg| and |presence| is set to OPTIONAL |out| is set | 24 // |name_| is absent in |msg| and |presence| is set to OPTIONAL |out| is set |
24 // to |default_value|. | 25 // to |default_value|. |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 client_connection_options_(kCLOP, PRESENCE_OPTIONAL), | 331 client_connection_options_(kCLOP, PRESENCE_OPTIONAL), |
331 idle_network_timeout_seconds_(kICSL, PRESENCE_REQUIRED), | 332 idle_network_timeout_seconds_(kICSL, PRESENCE_REQUIRED), |
332 silent_close_(kSCLS, PRESENCE_OPTIONAL), | 333 silent_close_(kSCLS, PRESENCE_OPTIONAL), |
333 max_streams_per_connection_(kMSPC, PRESENCE_OPTIONAL), | 334 max_streams_per_connection_(kMSPC, PRESENCE_OPTIONAL), |
334 max_incoming_dynamic_streams_(kMIDS, PRESENCE_OPTIONAL), | 335 max_incoming_dynamic_streams_(kMIDS, PRESENCE_OPTIONAL), |
335 bytes_for_connection_id_(kTCID, PRESENCE_OPTIONAL), | 336 bytes_for_connection_id_(kTCID, PRESENCE_OPTIONAL), |
336 initial_round_trip_time_us_(kIRTT, PRESENCE_OPTIONAL), | 337 initial_round_trip_time_us_(kIRTT, PRESENCE_OPTIONAL), |
337 initial_stream_flow_control_window_bytes_(kSFCW, PRESENCE_OPTIONAL), | 338 initial_stream_flow_control_window_bytes_(kSFCW, PRESENCE_OPTIONAL), |
338 initial_session_flow_control_window_bytes_(kCFCW, PRESENCE_OPTIONAL), | 339 initial_session_flow_control_window_bytes_(kCFCW, PRESENCE_OPTIONAL), |
339 socket_receive_buffer_(kSRBF, PRESENCE_OPTIONAL), | 340 socket_receive_buffer_(kSRBF, PRESENCE_OPTIONAL), |
340 multipath_enabled_(kMPTH, PRESENCE_OPTIONAL), | |
341 connection_migration_disabled_(kNCMR, PRESENCE_OPTIONAL), | 341 connection_migration_disabled_(kNCMR, PRESENCE_OPTIONAL), |
342 alternate_server_address_(kASAD, PRESENCE_OPTIONAL), | 342 alternate_server_address_(kASAD, PRESENCE_OPTIONAL), |
343 force_hol_blocking_(kFHL2, PRESENCE_OPTIONAL), | 343 force_hol_blocking_(kFHL2, PRESENCE_OPTIONAL), |
344 support_max_header_list_size_(kSMHL, PRESENCE_OPTIONAL) { | 344 support_max_header_list_size_(kSMHL, PRESENCE_OPTIONAL), |
| 345 latched_no_socket_receive_buffer_( |
| 346 FLAGS_quic_reloadable_flag_quic_no_socket_receive_buffer) { |
345 SetDefaults(); | 347 SetDefaults(); |
346 } | 348 } |
347 | 349 |
348 QuicConfig::QuicConfig(const QuicConfig& other) = default; | 350 QuicConfig::QuicConfig(const QuicConfig& other) = default; |
349 | 351 |
350 QuicConfig::~QuicConfig() {} | 352 QuicConfig::~QuicConfig() {} |
351 | 353 |
352 bool QuicConfig::SetInitialReceivedConnectionOptions( | 354 bool QuicConfig::SetInitialReceivedConnectionOptions( |
353 const QuicTagVector& tags) { | 355 const QuicTagVector& tags) { |
354 if (HasReceivedConnectionOptions()) { | 356 if (HasReceivedConnectionOptions()) { |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 | 538 |
537 bool QuicConfig::HasReceivedInitialSessionFlowControlWindowBytes() const { | 539 bool QuicConfig::HasReceivedInitialSessionFlowControlWindowBytes() const { |
538 return initial_session_flow_control_window_bytes_.HasReceivedValue(); | 540 return initial_session_flow_control_window_bytes_.HasReceivedValue(); |
539 } | 541 } |
540 | 542 |
541 uint32_t QuicConfig::ReceivedInitialSessionFlowControlWindowBytes() const { | 543 uint32_t QuicConfig::ReceivedInitialSessionFlowControlWindowBytes() const { |
542 return initial_session_flow_control_window_bytes_.GetReceivedValue(); | 544 return initial_session_flow_control_window_bytes_.GetReceivedValue(); |
543 } | 545 } |
544 | 546 |
545 void QuicConfig::SetSocketReceiveBufferToSend(uint32_t tcp_receive_window) { | 547 void QuicConfig::SetSocketReceiveBufferToSend(uint32_t tcp_receive_window) { |
546 socket_receive_buffer_.SetSendValue(tcp_receive_window); | 548 if (latched_no_socket_receive_buffer_) { |
| 549 QUIC_FLAG_COUNT_N(gfe2_reloadable_flag_quic_no_socket_receive_buffer, 1, 3); |
| 550 } else { |
| 551 socket_receive_buffer_.SetSendValue(tcp_receive_window); |
| 552 } |
547 } | 553 } |
548 | 554 |
549 bool QuicConfig::HasReceivedSocketReceiveBuffer() const { | 555 bool QuicConfig::HasReceivedSocketReceiveBuffer() const { |
550 return socket_receive_buffer_.HasReceivedValue(); | 556 return socket_receive_buffer_.HasReceivedValue(); |
551 } | 557 } |
552 | 558 |
553 uint32_t QuicConfig::ReceivedSocketReceiveBuffer() const { | 559 uint32_t QuicConfig::ReceivedSocketReceiveBuffer() const { |
554 return socket_receive_buffer_.GetReceivedValue(); | 560 return socket_receive_buffer_.GetReceivedValue(); |
555 } | 561 } |
556 | 562 |
557 void QuicConfig::SetMultipathEnabled(bool multipath_enabled) { | |
558 uint32_t value = multipath_enabled ? 1 : 0; | |
559 multipath_enabled_.set(value, value); | |
560 } | |
561 | |
562 bool QuicConfig::MultipathEnabled() const { | |
563 return multipath_enabled_.GetUint32() > 0; | |
564 } | |
565 | |
566 void QuicConfig::SetDisableConnectionMigration() { | 563 void QuicConfig::SetDisableConnectionMigration() { |
567 connection_migration_disabled_.SetSendValue(1); | 564 connection_migration_disabled_.SetSendValue(1); |
568 } | 565 } |
569 | 566 |
570 bool QuicConfig::DisableConnectionMigration() const { | 567 bool QuicConfig::DisableConnectionMigration() const { |
571 return connection_migration_disabled_.HasReceivedValue(); | 568 return connection_migration_disabled_.HasReceivedValue(); |
572 } | 569 } |
573 | 570 |
574 void QuicConfig::SetAlternateServerAddressToSend( | 571 void QuicConfig::SetAlternateServerAddressToSend( |
575 const QuicSocketAddress& alternate_server_address) { | 572 const QuicSocketAddress& alternate_server_address) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 | 631 |
635 void QuicConfig::ToHandshakeMessage(CryptoHandshakeMessage* out) const { | 632 void QuicConfig::ToHandshakeMessage(CryptoHandshakeMessage* out) const { |
636 idle_network_timeout_seconds_.ToHandshakeMessage(out); | 633 idle_network_timeout_seconds_.ToHandshakeMessage(out); |
637 silent_close_.ToHandshakeMessage(out); | 634 silent_close_.ToHandshakeMessage(out); |
638 max_streams_per_connection_.ToHandshakeMessage(out); | 635 max_streams_per_connection_.ToHandshakeMessage(out); |
639 max_incoming_dynamic_streams_.ToHandshakeMessage(out); | 636 max_incoming_dynamic_streams_.ToHandshakeMessage(out); |
640 bytes_for_connection_id_.ToHandshakeMessage(out); | 637 bytes_for_connection_id_.ToHandshakeMessage(out); |
641 initial_round_trip_time_us_.ToHandshakeMessage(out); | 638 initial_round_trip_time_us_.ToHandshakeMessage(out); |
642 initial_stream_flow_control_window_bytes_.ToHandshakeMessage(out); | 639 initial_stream_flow_control_window_bytes_.ToHandshakeMessage(out); |
643 initial_session_flow_control_window_bytes_.ToHandshakeMessage(out); | 640 initial_session_flow_control_window_bytes_.ToHandshakeMessage(out); |
644 socket_receive_buffer_.ToHandshakeMessage(out); | 641 if (latched_no_socket_receive_buffer_) { |
| 642 QUIC_FLAG_COUNT_N(gfe2_reloadable_flag_quic_no_socket_receive_buffer, 2, 3); |
| 643 } else { |
| 644 socket_receive_buffer_.ToHandshakeMessage(out); |
| 645 } |
645 connection_migration_disabled_.ToHandshakeMessage(out); | 646 connection_migration_disabled_.ToHandshakeMessage(out); |
646 connection_options_.ToHandshakeMessage(out); | 647 connection_options_.ToHandshakeMessage(out); |
647 alternate_server_address_.ToHandshakeMessage(out); | 648 alternate_server_address_.ToHandshakeMessage(out); |
648 force_hol_blocking_.ToHandshakeMessage(out); | 649 force_hol_blocking_.ToHandshakeMessage(out); |
649 support_max_header_list_size_.ToHandshakeMessage(out); | 650 support_max_header_list_size_.ToHandshakeMessage(out); |
650 } | 651 } |
651 | 652 |
652 QuicErrorCode QuicConfig::ProcessPeerHello( | 653 QuicErrorCode QuicConfig::ProcessPeerHello( |
653 const CryptoHandshakeMessage& peer_hello, | 654 const CryptoHandshakeMessage& peer_hello, |
654 HelloType hello_type, | 655 HelloType hello_type, |
(...skipping 26 matching lines...) Expand all Loading... |
681 error_details); | 682 error_details); |
682 } | 683 } |
683 if (error == QUIC_NO_ERROR) { | 684 if (error == QUIC_NO_ERROR) { |
684 error = initial_stream_flow_control_window_bytes_.ProcessPeerHello( | 685 error = initial_stream_flow_control_window_bytes_.ProcessPeerHello( |
685 peer_hello, hello_type, error_details); | 686 peer_hello, hello_type, error_details); |
686 } | 687 } |
687 if (error == QUIC_NO_ERROR) { | 688 if (error == QUIC_NO_ERROR) { |
688 error = initial_session_flow_control_window_bytes_.ProcessPeerHello( | 689 error = initial_session_flow_control_window_bytes_.ProcessPeerHello( |
689 peer_hello, hello_type, error_details); | 690 peer_hello, hello_type, error_details); |
690 } | 691 } |
691 if (error == QUIC_NO_ERROR) { | 692 if (latched_no_socket_receive_buffer_) { |
| 693 QUIC_FLAG_COUNT_N(gfe2_reloadable_flag_quic_no_socket_receive_buffer, 3, 3); |
| 694 } else if (error == QUIC_NO_ERROR) { |
692 error = socket_receive_buffer_.ProcessPeerHello(peer_hello, hello_type, | 695 error = socket_receive_buffer_.ProcessPeerHello(peer_hello, hello_type, |
693 error_details); | 696 error_details); |
694 } | 697 } |
695 if (error == QUIC_NO_ERROR) { | 698 if (error == QUIC_NO_ERROR) { |
696 error = connection_migration_disabled_.ProcessPeerHello( | 699 error = connection_migration_disabled_.ProcessPeerHello( |
697 peer_hello, hello_type, error_details); | 700 peer_hello, hello_type, error_details); |
698 } | 701 } |
699 if (error == QUIC_NO_ERROR) { | 702 if (error == QUIC_NO_ERROR) { |
700 error = connection_options_.ProcessPeerHello(peer_hello, hello_type, | 703 error = connection_options_.ProcessPeerHello(peer_hello, hello_type, |
701 error_details); | 704 error_details); |
702 } | 705 } |
703 if (error == QUIC_NO_ERROR) { | 706 if (error == QUIC_NO_ERROR) { |
704 error = alternate_server_address_.ProcessPeerHello(peer_hello, hello_type, | 707 error = alternate_server_address_.ProcessPeerHello(peer_hello, hello_type, |
705 error_details); | 708 error_details); |
706 } | 709 } |
707 if (error == QUIC_NO_ERROR) { | 710 if (error == QUIC_NO_ERROR) { |
708 error = force_hol_blocking_.ProcessPeerHello(peer_hello, hello_type, | 711 error = force_hol_blocking_.ProcessPeerHello(peer_hello, hello_type, |
709 error_details); | 712 error_details); |
710 } | 713 } |
711 if (error == QUIC_NO_ERROR) { | 714 if (error == QUIC_NO_ERROR) { |
712 error = support_max_header_list_size_.ProcessPeerHello( | 715 error = support_max_header_list_size_.ProcessPeerHello( |
713 peer_hello, hello_type, error_details); | 716 peer_hello, hello_type, error_details); |
714 } | 717 } |
715 return error; | 718 return error; |
716 } | 719 } |
717 | 720 |
718 } // namespace net | 721 } // namespace net |
OLD | NEW |