From 48f371c687a11f0098c86ca521ad7a0c53800293 Mon Sep 17 00:00:00 2001 From: rtenneti Date: Wed, 26 Aug 2015 22:34:26 -0700 Subject: [PATCH] Landing Recent QUIC changes until 8/19/2015 17:00 UTC. relnote: Compute parity faster by only XORing bytes which are needed and doing that word at a time. No behavior change. FIXED=22811863 Merge internal change: 101033533 https://codereview.chromium.org/1320743002/ Added QuicConfig::SetInitialReceivedConnectionOptions to set initial received connection options and added unittests. The following is the internal merge note: Enable setting of connection options via relodable flag for testing Added a new flag for setting server-side connection options explicitly via command-line flag. Previously, the only way to turn an option on for the server was through a message sent from the client. For live testing, we sometimes want to be able to turn such options on the server, without having to introduce a special flag for enabling each option. The new flag takes a comma-separated list of options as its value. It parses the list and sets the tag for each value. If the flag is set on a live server, it will only have effect on newly created sessions, not existing ones. relnote: n/a. New options flag will only be used for testing. Merge internal change: 100966796 https://codereview.chromium.org/1302263003/ relnote: n/a (QUIC test only). Remove RunValidate method from crypto_server_test.cc. Not very helpful, only used in a couple of places. Merge internal change: 100955404 https://codereview.chromium.org/1301333003/ relnote: n/a (QUIC test only). Remove CryptoTestUtils::BuildMessage and InchoateClientHello (confusingly named as it was often called with tags not from an inchoate CHLO...). Changes due to "git cl format net" and added clang-format off/on to avoid reformatting. Merge internal change: 100952704 https://codereview.chromium.org/1311813003/ Working on other changes in this file, getting annoyed that clang formatting my CL was resulting in more changes than I'd expected. This CL runs clang-format against quic/crypto/crypto_server_test.cc (and protects some handshake message formatting) $ clang-format --style="{BasedOnStyle: Chromium, Standard: Cpp11}" ./quic/crypto/crypto_server_test.cc Merge internal change: 100955098 https://codereview.chromium.org/1311813003/ relnote: After a server silo receives a packet from a migrated client, a GO_AWAY frame is sent to the client. Protected behind FLAGS_send_goaway_after_client_migration. Merge internal change: 100947609 https://codereview.chromium.org/1319433006/ relnote: Deprecate FLAGS_increase_time_wait_list. Merge internal change: 100922172 https://codereview.chromium.org/1320713002/ relnote: Depreacate FLAGS_quic_limit_pacing_burst. Merge internal change: 100852361 https://codereview.chromium.org/1305313006/ relnote: Cleanup changes. No behavior changes expected. Change name of FakeTimeEpollServer::AdvanceByAndCallCallbacks to AdvanceByAndWaitForEventsAndExecuteCallbacks. Merge internal change: 100850550 https://codereview.chromium.org/1302233005/ R=rch@chromium.org Review URL: https://codereview.chromium.org/1315023003 Cr-Commit-Position: refs/heads/master@{#345803} --- net/quic/congestion_control/pacing_sender.cc | 12 +- net/quic/congestion_control/pacing_sender_test.cc | 19 +-- net/quic/crypto/crypto_server_test.cc | 178 +++++++++++---------- net/quic/quic_config.cc | 11 ++ net/quic/quic_config.h | 7 + net/quic/quic_config_test.cc | 17 +- net/quic/quic_connection.cc | 4 + net/quic/quic_connection.h | 3 + net/quic/quic_fec_group.cc | 40 ++++- net/quic/quic_fec_group.h | 4 + net/quic/quic_fec_group_test.cc | 70 ++++++++ net/quic/quic_flags.cc | 13 +- net/quic/quic_flags.h | 3 +- net/quic/quic_sent_packet_manager_test.cc | 18 +-- net/quic/quic_session.cc | 2 + net/quic/quic_session.h | 1 + net/quic/quic_session_test.cc | 6 +- net/quic/test_tools/crypto_test_utils.cc | 9 +- net/quic/test_tools/crypto_test_utils.h | 7 - net/quic/test_tools/quic_test_utils.h | 1 + net/tools/quic/end_to_end_test.cc | 26 +++ .../quic/quic_epoll_connection_helper_test.cc | 3 +- net/tools/quic/quic_time_wait_list_manager.cc | 32 +--- net/tools/quic/test_tools/mock_epoll_server.h | 2 +- 24 files changed, 306 insertions(+), 182 deletions(-) diff --git a/net/quic/congestion_control/pacing_sender.cc b/net/quic/congestion_control/pacing_sender.cc index c6f33efd5c43..a8bd13f1705a 100644 --- a/net/quic/congestion_control/pacing_sender.cc +++ b/net/quic/congestion_control/pacing_sender.cc @@ -4,8 +4,6 @@ #include "net/quic/congestion_control/pacing_sender.h" -#include "net/quic/quic_flags.h" - using std::min; namespace net { @@ -68,13 +66,9 @@ bool PacingSender::OnPacketSent( // Add more burst tokens anytime the connection is leaving quiescence, but // limit it to the equivalent of a single bulk write, not exceeding the // current CWND in packets. - if (FLAGS_quic_limit_pacing_burst) { - burst_tokens_ = min( - initial_packet_burst_, - static_cast(sender_->GetCongestionWindow() / kDefaultTCPMSS)); - } else { - burst_tokens_ = initial_packet_burst_; - } + burst_tokens_ = min( + initial_packet_burst_, + static_cast(sender_->GetCongestionWindow() / kDefaultTCPMSS)); } if (burst_tokens_ > 0) { --burst_tokens_; diff --git a/net/quic/congestion_control/pacing_sender_test.cc b/net/quic/congestion_control/pacing_sender_test.cc index 8412f3495810..b7e375590e45 100644 --- a/net/quic/congestion_control/pacing_sender_test.cc +++ b/net/quic/congestion_control/pacing_sender_test.cc @@ -6,7 +6,6 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" -#include "net/quic/quic_flags.h" #include "net/quic/quic_protocol.h" #include "net/quic/test_tools/mock_clock.h" #include "net/quic/test_tools/quic_test_utils.h" @@ -200,10 +199,8 @@ TEST_F(PacingSenderTest, InitialBurst) { InitPacingRate(10, QuicBandwidth::FromBytesAndTimeDelta( kMaxPacketSize, QuicTime::Delta::FromMilliseconds(1))); - if (FLAGS_quic_limit_pacing_burst) { - EXPECT_CALL(*mock_sender_, GetCongestionWindow()) - .WillOnce(Return(10 * kDefaultTCPMSS)); - } + EXPECT_CALL(*mock_sender_, GetCongestionWindow()) + .WillOnce(Return(10 * kDefaultTCPMSS)); // Update the RTT and verify that the first 10 packets aren't paced. UpdateRtt(); @@ -240,10 +237,8 @@ TEST_F(PacingSenderTest, InitialBurstNoRttMeasurement) { InitPacingRate(10, QuicBandwidth::FromBytesAndTimeDelta( kMaxPacketSize, QuicTime::Delta::FromMilliseconds(1))); - if (FLAGS_quic_limit_pacing_burst) { - EXPECT_CALL(*mock_sender_, GetCongestionWindow()) - .WillOnce(Return(10 * kDefaultTCPMSS)); - } + EXPECT_CALL(*mock_sender_, GetCongestionWindow()) + .WillOnce(Return(10 * kDefaultTCPMSS)); // Send 10 packets, and verify that they are not paced. for (int i = 0 ; i < kInitialBurstPackets; ++i) { CheckPacketIsSentImmediately(); @@ -281,10 +276,8 @@ TEST_F(PacingSenderTest, FastSending) { QuicBandwidth::FromBytesAndTimeDelta( 2 * kMaxPacketSize, QuicTime::Delta::FromMilliseconds(1))); - if (FLAGS_quic_limit_pacing_burst) { - EXPECT_CALL(*mock_sender_, GetCongestionWindow()) - .WillOnce(Return(10 * kDefaultTCPMSS)); - } + EXPECT_CALL(*mock_sender_, GetCongestionWindow()) + .WillOnce(Return(10 * kDefaultTCPMSS)); // Update the RTT and verify that the first 10 packets aren't paced. UpdateRtt(); diff --git a/net/quic/crypto/crypto_server_test.cc b/net/quic/crypto/crypto_server_test.cc index 46db1662a5a2..c8c8cfead974 100644 --- a/net/quic/crypto/crypto_server_test.cc +++ b/net/quic/crypto/crypto_server_test.cc @@ -107,8 +107,7 @@ class CryptoServerTest : public ::testing::TestWithParam { void SetUp() override { scoped_ptr msg( - config_.AddDefaultConfig(rand_, &clock_, - config_options_)); + config_.AddDefaultConfig(rand_, &clock_, config_options_)); StringPiece orbit; CHECK(msg->GetStringPiece(kORBT, &orbit)); @@ -122,6 +121,7 @@ class CryptoServerTest : public ::testing::TestWithParam { nonce_hex_ = "#" + base::HexEncode(nonce_str.data(), nonce_str.size()); pub_hex_ = "#" + base::HexEncode(public_value, sizeof(public_value)); + // clang-format off CryptoHandshakeMessage client_hello = CryptoTestUtils::Message( "CHLO", "AEAD", "AESG", @@ -131,13 +131,13 @@ class CryptoServerTest : public ::testing::TestWithParam { "VER\0", client_version_.data(), "$padding", static_cast(kClientHelloMinimumSize), nullptr); + // clang-format on ShouldSucceed(client_hello); // The message should be rejected because the source-address token is // missing. CheckRejectTag(); const HandshakeFailureReason kRejectReasons[] = { - SERVER_CONFIG_INCHOATE_HELLO_FAILURE - }; + SERVER_CONFIG_INCHOATE_HELLO_FAILURE}; CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); CheckForServerDesignatedConnectionId(); @@ -181,8 +181,8 @@ class CryptoServerTest : public ::testing::TestWithParam { base::AutoLock lock(*m); } ASSERT_FALSE(*called_); - test_->ProcessValidationResult( - client_hello, result, should_succeed_, error_substr_); + test_->ProcessValidationResult(client_hello, result, should_succeed_, + error_substr_); *called_ = true; } @@ -212,15 +212,9 @@ class CryptoServerTest : public ::testing::TestWithParam { void ShouldSucceed(const CryptoHandshakeMessage& message) { bool called = false; - RunValidate(message, new ValidateCallback(this, true, "", &called)); - EXPECT_TRUE(called); - } - - void RunValidate( - const CryptoHandshakeMessage& message, - ValidateClientHelloResultCallback* cb) { config_.ValidateClientHello(message, client_address_.address(), &clock_, - cb); + new ValidateCallback(this, true, "", &called)); + EXPECT_TRUE(called); } void ShouldFailMentioning(const char* error_substr, @@ -253,30 +247,18 @@ class CryptoServerTest : public ::testing::TestWithParam { ¶ms_, &out_, &error_details); if (should_succeed) { - ASSERT_EQ(error, QUIC_NO_ERROR) - << "Message failed with error " << error_details << ": " - << message.DebugString(); + ASSERT_EQ(error, QUIC_NO_ERROR) << "Message failed with error " + << error_details << ": " + << message.DebugString(); } else { - ASSERT_NE(error, QUIC_NO_ERROR) - << "Message didn't fail: " << message.DebugString(); + ASSERT_NE(error, QUIC_NO_ERROR) << "Message didn't fail: " + << message.DebugString(); EXPECT_TRUE(error_details.find(error_substr) != string::npos) << error_substr << " not in " << error_details; } } - CryptoHandshakeMessage InchoateClientHello(const char* message_tag, ...) { - va_list ap; - va_start(ap, message_tag); - - CryptoHandshakeMessage message = - CryptoTestUtils::BuildMessage(message_tag, ap); - va_end(ap); - - message.SetStringPiece(kPAD, string(kClientHelloMinimumSize, '-')); - return message; - } - string GenerateNonce() { string nonce; CryptoUtils::GenerateNonce( @@ -292,8 +274,8 @@ class CryptoServerTest : public ::testing::TestWithParam { const uint32* reject_reasons; size_t num_reject_reasons; COMPILE_ASSERT(sizeof(QuicTag) == sizeof(uint32), header_out_of_sync); - QuicErrorCode error_code = out_.GetTaglist(kRREJ, &reject_reasons, - &num_reject_reasons); + QuicErrorCode error_code = + out_.GetTaglist(kRREJ, &reject_reasons, &num_reject_reasons); ASSERT_EQ(QUIC_NO_ERROR, error_code); if (FLAGS_use_early_return_when_verifying_chlo) { @@ -350,8 +332,8 @@ class CryptoServerTest : public ::testing::TestWithParam { uint8 orbit_[kOrbitSize]; bool use_stateless_rejects_; - // These strings contain hex escaped values from the server suitable for - // passing to |InchoateClientHello| when constructing client hello messages. + // These strings contain hex escaped values from the server suitable for using + // when constructing client hello messages. string nonce_hex_, pub_hex_, srct_hex_, scid_hex_; scoped_ptr server_config_; }; @@ -363,6 +345,7 @@ INSTANTIATE_TEST_CASE_P(CryptoServerTests, ::testing::ValuesIn(GetTestParams())); TEST_P(CryptoServerTest, BadSNI) { + // clang-format off static const char* const kBadSNIs[] = { "", "foo", @@ -371,19 +354,23 @@ TEST_P(CryptoServerTest, BadSNI) { "127.0.0.1", "ffee::1", }; + // clang-format on - string client_version = QuicUtils::TagToString( - QuicVersionToQuicTag(supported_versions_.front())); + string client_version = + QuicUtils::TagToString(QuicVersionToQuicTag(supported_versions_.front())); for (size_t i = 0; i < arraysize(kBadSNIs); i++) { - ShouldFailMentioning("SNI", InchoateClientHello( + // clang-format off + CryptoHandshakeMessage msg = CryptoTestUtils::Message( "CHLO", "SNI", kBadSNIs[i], "VER\0", client_version.data(), - nullptr)); + "$padding", static_cast(kClientHelloMinimumSize), + nullptr); + // clang-format on + ShouldFailMentioning("SNI", msg); const HandshakeFailureReason kRejectReasons[] = { - SERVER_CONFIG_INCHOATE_HELLO_FAILURE - }; + SERVER_CONFIG_INCHOATE_HELLO_FAILURE}; CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); } } @@ -393,7 +380,8 @@ TEST_P(CryptoServerTest, BadSNI) { TEST_F(CryptoServerTest, DISABLED_DefaultCert) { // Check that the server replies with a default certificate when no SNI is // specified. - ShouldSucceed(InchoateClientHello( + // clang-format off + CryptoHandshakeMessage msg = CryptoTestUtils::Message( "CHLO", "AEAD", "AESG", "KEXS", "C255", @@ -401,72 +389,83 @@ TEST_F(CryptoServerTest, DISABLED_DefaultCert) { "#004b5453", srct_hex_.c_str(), "PUBS", pub_hex_.c_str(), "NONC", nonce_hex_.c_str(), - "$padding", static_cast(kClientHelloMinimumSize), "PDMD", "X509", "VER\0", client_version_.data(), - nullptr)); + "$padding", static_cast(kClientHelloMinimumSize), + nullptr); + // clang-format on + ShouldSucceed(msg); StringPiece cert, proof; EXPECT_TRUE(out_.GetStringPiece(kCertificateTag, &cert)); EXPECT_TRUE(out_.GetStringPiece(kPROF, &proof)); EXPECT_NE(0u, cert.size()); EXPECT_NE(0u, proof.size()); const HandshakeFailureReason kRejectReasons[] = { - CLIENT_NONCE_INVALID_TIME_FAILURE - }; + CLIENT_NONCE_INVALID_TIME_FAILURE}; CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); } TEST_P(CryptoServerTest, TooSmall) { + // clang-format off ShouldFailMentioning("too small", CryptoTestUtils::Message( "CHLO", "VER\0", client_version_.data(), nullptr)); + // clang-format on const HandshakeFailureReason kRejectReasons[] = { - SERVER_CONFIG_INCHOATE_HELLO_FAILURE - }; + SERVER_CONFIG_INCHOATE_HELLO_FAILURE}; CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); } TEST_P(CryptoServerTest, BadSourceAddressToken) { // Invalid source-address tokens should be ignored. + // clang-format off static const char* const kBadSourceAddressTokens[] = { "", "foo", "#0000", "#0000000000000000000000000000000000000000", }; + // clang-format on for (size_t i = 0; i < arraysize(kBadSourceAddressTokens); i++) { - ShouldSucceed(InchoateClientHello( + // clang-format off + CryptoHandshakeMessage msg = CryptoTestUtils::Message( "CHLO", "STK", kBadSourceAddressTokens[i], "VER\0", client_version_.data(), - nullptr)); + "$padding", static_cast(kClientHelloMinimumSize), nullptr); + // clang-format on + ShouldSucceed(msg); const HandshakeFailureReason kRejectReasons[] = { - SERVER_CONFIG_INCHOATE_HELLO_FAILURE - }; + SERVER_CONFIG_INCHOATE_HELLO_FAILURE}; CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); } } TEST_P(CryptoServerTest, BadClientNonce) { // Invalid nonces should be ignored. + // clang-format off static const char* const kBadNonces[] = { "", "#0000", "#0000000000000000000000000000000000000000", }; + // clang-format on for (size_t i = 0; i < arraysize(kBadNonces); i++) { - ShouldSucceed(InchoateClientHello( + // clang-format off + CryptoHandshakeMessage msg = CryptoTestUtils::Message( "CHLO", "NONC", kBadNonces[i], "VER\0", client_version_.data(), - nullptr)); + "$padding", static_cast(kClientHelloMinimumSize), + nullptr); + // clang-format on + ShouldSucceed(msg); const HandshakeFailureReason kRejectReasons[] = { - SERVER_CONFIG_INCHOATE_HELLO_FAILURE - }; + SERVER_CONFIG_INCHOATE_HELLO_FAILURE}; CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); } } @@ -478,21 +477,25 @@ TEST_P(CryptoServerTest, DowngradeAttack) { } // Set the client's preferred version to a supported version that // is not the "current" version (supported_versions_.front()). - string bad_version = QuicUtils::TagToString( - QuicVersionToQuicTag(supported_versions_.back())); + string bad_version = + QuicUtils::TagToString(QuicVersionToQuicTag(supported_versions_.back())); - ShouldFailMentioning("Downgrade", InchoateClientHello( + // clang-format off + CryptoHandshakeMessage msg = CryptoTestUtils::Message( "CHLO", "VER\0", bad_version.data(), - nullptr)); + "$padding", static_cast(kClientHelloMinimumSize), + nullptr); + // clang-format on + ShouldFailMentioning("Downgrade", msg); const HandshakeFailureReason kRejectReasons[] = { - SERVER_CONFIG_INCHOATE_HELLO_FAILURE - }; + SERVER_CONFIG_INCHOATE_HELLO_FAILURE}; CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); } TEST_P(CryptoServerTest, CorruptServerConfig) { // This tests corrupted server config. + // clang-format off CryptoHandshakeMessage msg = CryptoTestUtils::Message( "CHLO", "AEAD", "AESG", @@ -504,16 +507,17 @@ TEST_P(CryptoServerTest, CorruptServerConfig) { "VER\0", client_version_.data(), "$padding", static_cast(kClientHelloMinimumSize), nullptr); + // clang-format on ShouldSucceed(msg); CheckRejectTag(); const HandshakeFailureReason kRejectReasons[] = { - SERVER_CONFIG_UNKNOWN_CONFIG_FAILURE - }; + SERVER_CONFIG_UNKNOWN_CONFIG_FAILURE}; CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); } TEST_P(CryptoServerTest, CorruptSourceAddressToken) { // This tests corrupted source address token. + // clang-format off CryptoHandshakeMessage msg = CryptoTestUtils::Message( "CHLO", "AEAD", "AESG", @@ -525,16 +529,17 @@ TEST_P(CryptoServerTest, CorruptSourceAddressToken) { "VER\0", client_version_.data(), "$padding", static_cast(kClientHelloMinimumSize), nullptr); + // clang-format on ShouldSucceed(msg); CheckRejectTag(); const HandshakeFailureReason kRejectReasons[] = { - SOURCE_ADDRESS_TOKEN_DECRYPTION_FAILURE - }; + SOURCE_ADDRESS_TOKEN_DECRYPTION_FAILURE}; CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); } TEST_P(CryptoServerTest, CorruptClientNonceAndSourceAddressToken) { // This test corrupts client nonce and source address token. + // clang-format off CryptoHandshakeMessage msg = CryptoTestUtils::Message( "CHLO", "AEAD", "AESG", @@ -546,17 +551,17 @@ TEST_P(CryptoServerTest, CorruptClientNonceAndSourceAddressToken) { "VER\0", client_version_.data(), "$padding", static_cast(kClientHelloMinimumSize), nullptr); + // clang-format on ShouldSucceed(msg); CheckRejectTag(); const HandshakeFailureReason kRejectReasons[] = { - SOURCE_ADDRESS_TOKEN_DECRYPTION_FAILURE, - CLIENT_NONCE_INVALID_FAILURE - }; + SOURCE_ADDRESS_TOKEN_DECRYPTION_FAILURE, CLIENT_NONCE_INVALID_FAILURE}; CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); } TEST_P(CryptoServerTest, CorruptMultipleTags) { // This test corrupts client nonce, server nonce and source address token. + // clang-format off CryptoHandshakeMessage msg = CryptoTestUtils::Message( "CHLO", "AEAD", "AESG", @@ -569,18 +574,19 @@ TEST_P(CryptoServerTest, CorruptMultipleTags) { "VER\0", client_version_.data(), "$padding", static_cast(kClientHelloMinimumSize), nullptr); + // clang-format on ShouldSucceed(msg); CheckRejectTag(); const HandshakeFailureReason kRejectReasons[] = { - SOURCE_ADDRESS_TOKEN_DECRYPTION_FAILURE, - CLIENT_NONCE_INVALID_FAILURE, - SERVER_NONCE_DECRYPTION_FAILURE, + SOURCE_ADDRESS_TOKEN_DECRYPTION_FAILURE, CLIENT_NONCE_INVALID_FAILURE, + SERVER_NONCE_DECRYPTION_FAILURE, }; CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); } TEST_P(CryptoServerTest, ReplayProtection) { // This tests that disabling replay protection works. + // clang-format off CryptoHandshakeMessage msg = CryptoTestUtils::Message( "CHLO", "AEAD", "AESG", @@ -592,14 +598,14 @@ TEST_P(CryptoServerTest, ReplayProtection) { "VER\0", client_version_.data(), "$padding", static_cast(kClientHelloMinimumSize), nullptr); + // clang-format on ShouldSucceed(msg); // The message should be rejected because the strike-register is still // quiescent. CheckRejectTag(); const HandshakeFailureReason kRejectReasons[] = { - CLIENT_NONCE_INVALID_TIME_FAILURE - }; + CLIENT_NONCE_INVALID_TIME_FAILURE}; CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); config_.set_replay_protection(false); @@ -692,21 +698,23 @@ class CryptoServerTestNoConfig : public CryptoServerTest { }; TEST_P(CryptoServerTestNoConfig, DontCrash) { - ShouldFailMentioning("No config", InchoateClientHello( + // clang-format off + CryptoHandshakeMessage msg = CryptoTestUtils::Message( "CHLO", "VER\0", client_version_.data(), - nullptr)); + "$padding", static_cast(kClientHelloMinimumSize), + nullptr); + // clang-format on + ShouldFailMentioning("No config", msg); const HandshakeFailureReason kRejectReasons[] = { - SERVER_CONFIG_INCHOATE_HELLO_FAILURE - }; + SERVER_CONFIG_INCHOATE_HELLO_FAILURE}; CheckRejectReasons(kRejectReasons, arraysize(kRejectReasons)); } class AsyncStrikeServerVerificationTest : public CryptoServerTest { protected: - AsyncStrikeServerVerificationTest() { - } + AsyncStrikeServerVerificationTest() {} void SetUp() override { const string kOrbit = "12345678"; @@ -715,7 +723,7 @@ class AsyncStrikeServerVerificationTest : public CryptoServerTest { 10000, // strike_register_max_entries static_cast(clock_.WallNow().ToUNIXSeconds()), 60, // strike_register_window_secs - reinterpret_cast(kOrbit.data()), + reinterpret_cast(kOrbit.data()), StrikeRegister::NO_STARTUP_PERIOD_NEEDED); config_.SetStrikeRegisterClient(strike_register_client_); CryptoServerTest::SetUp(); @@ -727,6 +735,7 @@ class AsyncStrikeServerVerificationTest : public CryptoServerTest { TEST_P(AsyncStrikeServerVerificationTest, AsyncReplayProtection) { // This tests async validation with a strike register works. + // clang-format off CryptoHandshakeMessage msg = CryptoTestUtils::Message( "CHLO", "AEAD", "AESG", @@ -738,12 +747,14 @@ TEST_P(AsyncStrikeServerVerificationTest, AsyncReplayProtection) { "VER\0", client_version_.data(), "$padding", static_cast(kClientHelloMinimumSize), nullptr); + // clang-format on // Clear the message tag. out_.set_tag(0); bool called = false; - RunValidate(msg, new ValidateCallback(this, true, "", &called)); + config_.ValidateClientHello(msg, client_address_.address(), &clock_, + new ValidateCallback(this, true, "", &called)); // The verification request was queued. ASSERT_FALSE(called); EXPECT_EQ(0u, out_.tag()); @@ -757,7 +768,8 @@ TEST_P(AsyncStrikeServerVerificationTest, AsyncReplayProtection) { EXPECT_EQ(kSHLO, out_.tag()); // Rejected if replayed. - RunValidate(msg, new ValidateCallback(this, true, "", &called)); + config_.ValidateClientHello(msg, client_address_.address(), &clock_, + new ValidateCallback(this, true, "", &called)); // The verification request was queued. ASSERT_FALSE(called); EXPECT_EQ(1, strike_register_client_->PendingVerifications()); diff --git a/net/quic/quic_config.cc b/net/quic/quic_config.cc index 675716c2ca5a..d91fd7bc9edb 100644 --- a/net/quic/quic_config.cc +++ b/net/quic/quic_config.cc @@ -366,6 +366,17 @@ QuicConfig::QuicConfig() QuicConfig::~QuicConfig() {} +bool QuicConfig::SetInitialReceivedConnectionOptions( + const QuicTagVector& tags) { + if (HasReceivedConnectionOptions()) { + // If we have already received connection options (via handshake or due to a + // previous call), don't re-initialize. + return false; + } + connection_options_.SetReceivedValues(tags); + return true; +} + void QuicConfig::SetConnectionOptionsToSend( const QuicTagVector& connection_options) { connection_options_.SetSendValues(connection_options); diff --git a/net/quic/quic_config.h b/net/quic/quic_config.h index 20d71c60a26d..755aa3922ca3 100644 --- a/net/quic/quic_config.h +++ b/net/quic/quic_config.h @@ -223,6 +223,13 @@ class NET_EXPORT_PRIVATE QuicConfig { bool HasReceivedConnectionOptions() const; + // Sets initial received connection options. All received connection options + // will be initialized with these fields. Initial received options may only be + // set once per config, prior to the setting of any other options. If options + // have already been set (either by previous calls or via handshake), this + // function does nothing and returns false. + bool SetInitialReceivedConnectionOptions(const QuicTagVector& tags); + QuicTagVector ReceivedConnectionOptions() const; bool HasSendConnectionOptions() const; diff --git a/net/quic/quic_config_test.cc b/net/quic/quic_config_test.cc index dcf19a580578..0a568c2ffef4 100644 --- a/net/quic/quic_config_test.cc +++ b/net/quic/quic_config_test.cc @@ -83,8 +83,18 @@ TEST_F(QuicConfigTest, ProcessClientHello) { client_config.ToHandshakeMessage(&msg); string error_details; + QuicTagVector initial_received_options; + initial_received_options.push_back(kIW50); + EXPECT_TRUE( + config_.SetInitialReceivedConnectionOptions(initial_received_options)); + EXPECT_FALSE( + config_.SetInitialReceivedConnectionOptions(initial_received_options)) + << "You can only set initial options once."; const QuicErrorCode error = config_.ProcessPeerHello(msg, CLIENT, &error_details); + EXPECT_FALSE( + config_.SetInitialReceivedConnectionOptions(initial_received_options)) + << "You cannot set initial options after the hello."; EXPECT_EQ(QUIC_NO_ERROR, error); EXPECT_TRUE(config_.negotiated()); EXPECT_EQ(QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs), @@ -93,9 +103,10 @@ TEST_F(QuicConfigTest, ProcessClientHello) { config_.MaxStreamsPerConnection()); EXPECT_EQ(10 * kNumMicrosPerMilli, config_.ReceivedInitialRoundTripTimeUs()); EXPECT_TRUE(config_.HasReceivedConnectionOptions()); - EXPECT_EQ(2u, config_.ReceivedConnectionOptions().size()); - EXPECT_EQ(config_.ReceivedConnectionOptions()[0], kTBBR); - EXPECT_EQ(config_.ReceivedConnectionOptions()[1], kFHDR); + EXPECT_EQ(3u, config_.ReceivedConnectionOptions().size()); + EXPECT_EQ(config_.ReceivedConnectionOptions()[0], kIW50); + EXPECT_EQ(config_.ReceivedConnectionOptions()[1], kTBBR); + EXPECT_EQ(config_.ReceivedConnectionOptions()[2], kFHDR); EXPECT_EQ(config_.ReceivedInitialStreamFlowControlWindowBytes(), 2 * kInitialStreamFlowControlWindowForTest); EXPECT_EQ(config_.ReceivedInitialSessionFlowControlWindowBytes(), diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc index 7ed5942e7f12..47be9cec8408 100644 --- a/net/quic/quic_connection.cc +++ b/net/quic/quic_connection.cc @@ -1476,6 +1476,10 @@ bool QuicConnection::ProcessValidatedPacket() { DVLOG(1) << ENDPOINT << "Peer's ip:port changed from " << old_peer_address.ToString() << " to " << peer_address_.ToString() << ", migrating connection."; + + if (FLAGS_send_goaway_after_client_migration) { + visitor_->OnConnectionMigration(); + } } time_of_last_received_packet_ = clock_->Now(); diff --git a/net/quic/quic_connection.h b/net/quic/quic_connection.h index b2dc6461a7a8..b5f44c4307f9 100644 --- a/net/quic/quic_connection.h +++ b/net/quic/quic_connection.h @@ -128,6 +128,9 @@ class NET_EXPORT_PRIVATE QuicConnectionVisitorInterface { // Called when the connection experiences a change in congestion window. virtual void OnCongestionWindowChange(QuicTime now) = 0; + // Called when the connection receives a packet from a migrated client. + virtual void OnConnectionMigration() = 0; + // Called to ask if the visitor wants to schedule write resumption as it both // has pending data to write, and is able to write (e.g. based on flow control // limits). diff --git a/net/quic/quic_fec_group.cc b/net/quic/quic_fec_group.cc index b06f63ed232d..9a784e991e90 100644 --- a/net/quic/quic_fec_group.cc +++ b/net/quic/quic_fec_group.cc @@ -152,10 +152,7 @@ bool QuicFecGroup::UpdateParity(StringPiece payload) { return true; } // Update the parity by XORing in the data (padding with 0s if necessary). - for (size_t i = 0; i < kMaxPacketSize; ++i) { - uint8 byte = i < payload.size() ? payload[i] : 0x00; - payload_parity_[i] ^= byte; - } + XorBuffers(payload.data(), payload.size(), payload_parity_); return true; } @@ -168,4 +165,39 @@ QuicPacketCount QuicFecGroup::NumMissingPackets() const { received_packets_.size()); } +void QuicFecGroup::XorBuffers(const char* input, + size_t size_in_bytes, + char* output) { +#if defined(__i386__) || defined(__x86_64__) + // On x86, alignment is not required and casting bytes to words is safe. + + // size_t is a reasonable approximation of how large a general-purpose + // register is for the platforms and compilers Chrome is built on. + typedef size_t platform_word; + const size_t size_in_words = size_in_bytes / sizeof(platform_word); + + const platform_word* input_words = + reinterpret_cast(input); + platform_word* output_words = reinterpret_cast(output); + + // Handle word-sized part of the buffer. + size_t offset_in_words = 0; + for (; offset_in_words < size_in_words; offset_in_words++) { + output_words[offset_in_words] ^= input_words[offset_in_words]; + } + + // Handle the tail which does not fit into the word. + for (size_t offset_in_bytes = offset_in_words * sizeof(platform_word); + offset_in_bytes < size_in_bytes; offset_in_bytes++) { + output[offset_in_bytes] ^= input[offset_in_bytes]; + } +#else + // On ARM and most other plaforms, the code above could fail due to the + // alignment errors. Stick to byte-by-byte comparison. + for (size_t offset = 0; offset < size_in_bytes; offset++) { + output[offset] ^= input[offset]; + } +#endif /* defined(__i386__) || defined(__x86_64__) */ +} + } // namespace net diff --git a/net/quic/quic_fec_group.h b/net/quic/quic_fec_group.h index 0ce0987d3d5e..b3982cf8f7b0 100644 --- a/net/quic/quic_fec_group.h +++ b/net/quic/quic_fec_group.h @@ -72,6 +72,10 @@ class NET_EXPORT_PRIVATE QuicFecGroup { return effective_encryption_level_; } + // An optimized version of running |output| ^= |input|, where ^ is + // byte-by-byte XOR and both |output| and |input| are of size |size_in_bytes|. + static void XorBuffers(const char* input, size_t size_in_bytes, char* output); + private: bool UpdateParity(base::StringPiece payload); // Returns the number of missing packets, or QuicPacketCount max diff --git a/net/quic/quic_fec_group_test.cc b/net/quic/quic_fec_group_test.cc index 9f38da7fcabc..e793511f3f10 100644 --- a/net/quic/quic_fec_group_test.cc +++ b/net/quic/quic_fec_group_test.cc @@ -14,6 +14,7 @@ using ::testing::_; using base::StringPiece; +using std::string; namespace net { @@ -249,4 +250,73 @@ TEST_F(QuicFecGroupTest, EffectiveEncryptionLevel) { EXPECT_EQ(ENCRYPTION_NONE, group.effective_encryption_level()); } +// Test the code assuming it is going to be operating in 128-bit chunks (which +// is something that can happen if it is compiled with full vectorization). +const QuicByteCount kWordSize = 128 / 8; + +// A buffer which stores the data with the specified offset with respect to word +// alignment boundary. +class MisalignedBuffer { + public: + MisalignedBuffer(const string& original, size_t offset); + + char* buffer() { return buffer_; } + size_t size() { return size_; } + + StringPiece AsStringPiece() { return StringPiece(buffer_, size_); } + + private: + char* buffer_; + size_t size_; + + scoped_ptr allocation_; +}; + +MisalignedBuffer::MisalignedBuffer(const string& original, size_t offset) { + CHECK_LT(offset, kWordSize); + size_ = original.size(); + + // Allocate aligned buffer two words larger than needed. + const size_t aligned_buffer_size = size_ + 2 * kWordSize; + allocation_.reset(new char[aligned_buffer_size]); + char* aligned_buffer = + allocation_.get() + + (kWordSize - reinterpret_cast(allocation_.get()) % kWordSize); + CHECK_EQ(0u, reinterpret_cast(aligned_buffer) % kWordSize); + + buffer_ = aligned_buffer + offset; + CHECK_EQ(offset, reinterpret_cast(buffer_) % kWordSize); + memcpy(buffer_, original.data(), size_); +} + +// Checks whether XorBuffers works correctly with buffers aligned in various +// ways. +TEST(XorBuffersTest, XorBuffers) { + const string longer_data = + "Having to care about memory alignment can be incredibly frustrating."; + const string shorter_data = "strict aliasing"; + + // Compute the reference XOR using simpler slow way. + string output_reference; + for (size_t i = 0; i < longer_data.size(); i++) { + char shorter_byte = i < shorter_data.size() ? shorter_data[i] : 0; + output_reference.push_back(longer_data[i] ^ shorter_byte); + } + + // Check whether XorBuffers works correctly for all possible misalignments. + for (size_t offset_shorter = 0; offset_shorter < kWordSize; + offset_shorter++) { + for (size_t offset_longer = 0; offset_longer < kWordSize; offset_longer++) { + // Prepare the misaligned buffer. + MisalignedBuffer longer(longer_data, offset_longer); + MisalignedBuffer shorter(shorter_data, offset_shorter); + + // XOR the buffers and compare the result with the reference. + QuicFecGroup::XorBuffers(shorter.buffer(), shorter.size(), + longer.buffer()); + EXPECT_EQ(output_reference, longer.AsStringPiece()); + } + } +} + } // namespace net diff --git a/net/quic/quic_flags.cc b/net/quic/quic_flags.cc index d63db76e8675..b0bf2c0f4b9b 100644 --- a/net/quic/quic_flags.cc +++ b/net/quic/quic_flags.cc @@ -63,11 +63,6 @@ bool FLAGS_quic_allow_ip_migration = true; // Estimate that only 60% of QUIC's receive buffer is usable as opposed to 95%. bool FLAGS_quic_use_conservative_receive_buffer = true; -// If true, default quic_time_wait_list_seconds (time to keep a connection ID on -// the time-wait list) is 200 seconds rather than 5 seconds and increase the -// maximum time-wait list size to 600,000. -bool FLAGS_increase_time_wait_list = true; - // Limits QUIC's max CWND to 200 packets. bool FLAGS_quic_limit_max_cwnd = true; @@ -76,10 +71,6 @@ bool FLAGS_quic_limit_max_cwnd = true; // get_max_open_streams(). bool FLAGS_exact_stream_id_delta = true; -// Limits the pacing burst out of quiescence to the current congestion window in -// packets. -bool FLAGS_quic_limit_pacing_burst = true; - // If true, require handshake confirmation for QUIC connections, functionally // disabling 0-rtt handshakes. // TODO(rtenneti): Enable this flag after fixing tests. @@ -88,3 +79,7 @@ bool FLAGS_quic_require_handshake_confirmation = false; // Disables special treatment of truncated acks, since older retransmissions are // proactively discarded in QUIC. bool FLAGS_quic_disable_truncated_ack_handling = true; + +// If true, after a server silo receives a packet from a migrated QUIC +// client, a GO_AWAY frame is sent to the client. +bool FLAGS_send_goaway_after_client_migration = true; diff --git a/net/quic/quic_flags.h b/net/quic/quic_flags.h index 140a46334a59..de30e86d38b4 100644 --- a/net/quic/quic_flags.h +++ b/net/quic/quic_flags.h @@ -24,11 +24,10 @@ NET_EXPORT_PRIVATE extern bool FLAGS_quic_process_frames_inline; NET_EXPORT_PRIVATE extern bool FLAGS_quic_dont_write_when_flow_unblocked; NET_EXPORT_PRIVATE extern bool FLAGS_quic_allow_ip_migration; NET_EXPORT_PRIVATE extern bool FLAGS_quic_use_conservative_receive_buffer; -NET_EXPORT_PRIVATE extern bool FLAGS_increase_time_wait_list; NET_EXPORT_PRIVATE extern bool FLAGS_quic_limit_max_cwnd; NET_EXPORT_PRIVATE extern bool FLAGS_exact_stream_id_delta; -NET_EXPORT_PRIVATE extern bool FLAGS_quic_limit_pacing_burst; NET_EXPORT_PRIVATE extern bool FLAGS_quic_require_handshake_confirmation; NET_EXPORT_PRIVATE extern bool FLAGS_quic_disable_truncated_ack_handling; +NET_EXPORT_PRIVATE extern bool FLAGS_send_goaway_after_client_migration; #endif // NET_QUIC_QUIC_FLAGS_H_ diff --git a/net/quic/quic_sent_packet_manager_test.cc b/net/quic/quic_sent_packet_manager_test.cc index fe76de000f7b..2245fd936ced 100644 --- a/net/quic/quic_sent_packet_manager_test.cc +++ b/net/quic/quic_sent_packet_manager_test.cc @@ -1119,10 +1119,8 @@ TEST_F(QuicSentPacketManagerTest, NewRetransmissionTimeout) { EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); EXPECT_CALL(*send_algorithm_, PacingRate()) .WillRepeatedly(Return(QuicBandwidth::Zero())); - if (FLAGS_quic_limit_pacing_burst) { - EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) - .WillOnce(Return(10 * kDefaultTCPMSS)); - } + EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) + .WillOnce(Return(10 * kDefaultTCPMSS)); manager_.SetFromConfig(client_config); EXPECT_TRUE(QuicSentPacketManagerPeer::GetUseNewRto(&manager_)); @@ -1625,10 +1623,8 @@ TEST_F(QuicSentPacketManagerTest, NegotiateReceiveWindowFromOptions) { SetMaxCongestionWindow(kMinSocketReceiveBuffer * 0.95)); EXPECT_CALL(*send_algorithm_, PacingRate()) .WillRepeatedly(Return(QuicBandwidth::Zero())); - if (FLAGS_quic_limit_pacing_burst) { - EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) - .WillOnce(Return(10 * kDefaultTCPMSS)); - } + EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) + .WillOnce(Return(10 * kDefaultTCPMSS)); EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange()); EXPECT_CALL(*network_change_visitor_, OnRttChange()); manager_.SetFromConfig(client_config); @@ -1670,10 +1666,8 @@ TEST_F(QuicSentPacketManagerTest, SetMaxCongestionWindow(kMinSocketReceiveBuffer * 0.6)); EXPECT_CALL(*send_algorithm_, PacingRate()) .WillRepeatedly(Return(QuicBandwidth::Zero())); - if (FLAGS_quic_limit_pacing_burst) { - EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) - .WillOnce(Return(10 * kDefaultTCPMSS)); - } + EXPECT_CALL(*send_algorithm_, GetCongestionWindow()) + .WillOnce(Return(10 * kDefaultTCPMSS)); EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange()); EXPECT_CALL(*network_change_visitor_, OnRttChange()); manager_.SetFromConfig(client_config); diff --git a/net/quic/quic_session.cc b/net/quic/quic_session.cc index 3c4e3620cf85..6085704d9641 100644 --- a/net/quic/quic_session.cc +++ b/net/quic/quic_session.cc @@ -83,6 +83,8 @@ class VisitorShim : public QuicConnectionVisitorInterface { void OnWriteBlocked() override { session_->OnWriteBlocked(); } + void OnConnectionMigration() override { session_->OnConnectionMigration(); } + bool WillingAndAbleToWrite() const override { return session_->WillingAndAbleToWrite(); } diff --git a/net/quic/quic_session.h b/net/quic/quic_session.h index 8538e2b37859..731f05f6826d 100644 --- a/net/quic/quic_session.h +++ b/net/quic/quic_session.h @@ -82,6 +82,7 @@ class NET_EXPORT_PRIVATE QuicSession : public QuicConnectionVisitorInterface { void OnSuccessfulVersionNegotiation(const QuicVersion& version) override; void OnCanWrite() override; void OnCongestionWindowChange(QuicTime now) override {} + void OnConnectionMigration() override {} bool WillingAndAbleToWrite() const override; bool HasPendingHandshake() const override; bool HasOpenDynamicStreams() const override; diff --git a/net/quic/quic_session_test.cc b/net/quic/quic_session_test.cc index 89e2bab6b42e..d7dae9fb2bde 100644 --- a/net/quic/quic_session_test.cc +++ b/net/quic/quic_session_test.cc @@ -357,12 +357,12 @@ TEST_P(QuicSessionTestServer, ManyImplicitlyOpenedStreams) { TEST_P(QuicSessionTestServer, DebugDFatalIfMarkingClosedStreamWriteBlocked) { TestStream* stream2 = session_.CreateOutgoingDynamicStream(); - QuicStreamId kClosedStreamId = stream2->id(); + QuicStreamId closed_stream_id = stream2->id(); // Close the stream. - EXPECT_CALL(*connection_, SendRstStream(kClosedStreamId, _, _)); + EXPECT_CALL(*connection_, SendRstStream(closed_stream_id, _, _)); stream2->Reset(QUIC_BAD_APPLICATION_PAYLOAD); EXPECT_DEBUG_DFATAL(session_.MarkConnectionLevelWriteBlocked( - kClosedStreamId, kSomeMiddlePriority), + closed_stream_id, kSomeMiddlePriority), "Marking unknown stream 2 blocked."); } diff --git a/net/quic/test_tools/crypto_test_utils.cc b/net/quic/test_tools/crypto_test_utils.cc index 811da803f1a5..3f0847b47d15 100644 --- a/net/quic/test_tools/crypto_test_utils.cc +++ b/net/quic/test_tools/crypto_test_utils.cc @@ -560,14 +560,6 @@ CryptoHandshakeMessage CryptoTestUtils::Message(const char* message_tag, ...) { va_list ap; va_start(ap, message_tag); - CryptoHandshakeMessage message = BuildMessage(message_tag, ap); - va_end(ap); - return message; -} - -// static -CryptoHandshakeMessage CryptoTestUtils::BuildMessage(const char* message_tag, - va_list ap) { CryptoHandshakeMessage msg; msg.set_tag(ParseTag(message_tag)); @@ -624,6 +616,7 @@ CryptoHandshakeMessage CryptoTestUtils::BuildMessage(const char* message_tag, CryptoFramer::ParseMessage(bytes->AsStringPiece())); CHECK(parsed.get()); + va_end(ap); return *parsed; } diff --git a/net/quic/test_tools/crypto_test_utils.h b/net/quic/test_tools/crypto_test_utils.h index c72b904cefa9..240bd36b3f34 100644 --- a/net/quic/test_tools/crypto_test_utils.h +++ b/net/quic/test_tools/crypto_test_utils.h @@ -164,13 +164,6 @@ class CryptoTestUtils { // nullptr); static CryptoHandshakeMessage Message(const char* message_tag, ...); - // BuildMessage is the same as |Message|, but takes the variable arguments - // explicitly. TODO(rtenneti): Investigate whether it'd be better for - // Message() and BuildMessage() to return a CryptoHandshakeMessage* pointer - // instead, to avoid copying the return value. - static CryptoHandshakeMessage BuildMessage(const char* message_tag, - va_list ap); - // ChannelIDSourceForTesting returns a ChannelIDSource that generates keys // deterministically based on the hostname given in the GetChannelIDKey call. // This ChannelIDSource works in synchronous mode, i.e., its GetChannelIDKey diff --git a/net/quic/test_tools/quic_test_utils.h b/net/quic/test_tools/quic_test_utils.h index 46b7975d35f4..bf58c76db549 100644 --- a/net/quic/test_tools/quic_test_utils.h +++ b/net/quic/test_tools/quic_test_utils.h @@ -285,6 +285,7 @@ class MockConnectionVisitor : public QuicConnectionVisitorInterface { MOCK_METHOD0(OnWriteBlocked, void()); MOCK_METHOD0(OnCanWrite, void()); MOCK_METHOD1(OnCongestionWindowChange, void(QuicTime now)); + MOCK_METHOD0(OnConnectionMigration, void()); MOCK_CONST_METHOD0(WillingAndAbleToWrite, bool()); MOCK_CONST_METHOD0(HasPendingHandshake, bool()); MOCK_CONST_METHOD0(HasOpenDynamicStreams, bool()); diff --git a/net/tools/quic/end_to_end_test.cc b/net/tools/quic/end_to_end_test.cc index fc9173e5c72b..1fd94dad096e 100644 --- a/net/tools/quic/end_to_end_test.cc +++ b/net/tools/quic/end_to_end_test.cc @@ -882,6 +882,32 @@ TEST_P(EndToEndTest, StatelessRejectWithPacketLoss) { ASSERT_EQ(!BothSidesSupportStatelessRejects(), Initialize()); } +TEST_P(EndToEndTest, SetInitialReceivedConnectionOptions) { + QuicTagVector initial_received_options; + initial_received_options.push_back(kTBBR); + initial_received_options.push_back(kIW10); + initial_received_options.push_back(kPRST); + EXPECT_TRUE(server_config_.SetInitialReceivedConnectionOptions( + initial_received_options)); + + ASSERT_TRUE(Initialize()); + client_->client()->WaitForCryptoHandshakeConfirmed(); + server_thread_->WaitForCryptoHandshakeConfirmed(); + + EXPECT_FALSE(server_config_.SetInitialReceivedConnectionOptions( + initial_received_options)); + + // Verify that server's configuration is correct. + server_thread_->Pause(); + EXPECT_TRUE(server_config_.HasReceivedConnectionOptions()); + EXPECT_TRUE( + ContainsQuicTag(server_config_.ReceivedConnectionOptions(), kTBBR)); + EXPECT_TRUE( + ContainsQuicTag(server_config_.ReceivedConnectionOptions(), kIW10)); + EXPECT_TRUE( + ContainsQuicTag(server_config_.ReceivedConnectionOptions(), kPRST)); +} + TEST_P(EndToEndTest, CorrectlyConfiguredFec) { ASSERT_TRUE(Initialize()); client_->client()->WaitForCryptoHandshakeConfirmed(); diff --git a/net/tools/quic/quic_epoll_connection_helper_test.cc b/net/tools/quic/quic_epoll_connection_helper_test.cc index 0b31cdf98c9f..36ea8bd2983f 100644 --- a/net/tools/quic/quic_epoll_connection_helper_test.cc +++ b/net/tools/quic/quic_epoll_connection_helper_test.cc @@ -62,7 +62,8 @@ TEST_F(QuicEpollConnectionHelperTest, CreateAlarm) { QuicTime::Delta delta = QuicTime::Delta::FromMicroseconds(1); alarm->Set(start.Add(delta)); - epoll_server_.AdvanceByAndCallCallbacks(delta.ToMicroseconds()); + epoll_server_.AdvanceByAndWaitForEventsAndExecuteCallbacks( + delta.ToMicroseconds()); EXPECT_EQ(start.Add(delta), clock->Now()); } diff --git a/net/tools/quic/quic_time_wait_list_manager.cc b/net/tools/quic/quic_time_wait_list_manager.cc index 0068f7d77ffe..37ea89caf9b1 100644 --- a/net/tools/quic/quic_time_wait_list_manager.cc +++ b/net/tools/quic/quic_time_wait_list_manager.cc @@ -83,14 +83,7 @@ QuicTimeWaitListManager::QuicTimeWaitListManager( QuicConnectionHelperInterface* helper, const QuicVersionVector& supported_versions) : time_wait_period_( - // If FLAGS_increase_time_wait_list is not set and - // FLAGS_quic_time_wait_list_seconds has the new default value (200), - // replace it with the old default value (5). - !FLAGS_increase_time_wait_list && - FLAGS_quic_time_wait_list_seconds == 200 - ? QuicTime::Delta::FromSeconds(5) - : QuicTime::Delta::FromSeconds( - FLAGS_quic_time_wait_list_seconds)), + QuicTime::Delta::FromSeconds(FLAGS_quic_time_wait_list_seconds)), connection_id_clean_up_alarm_( helper->CreateAlarm(new ConnectionIdCleanUpAlarm(this))), clock_(helper->GetClock()), @@ -126,15 +119,8 @@ void QuicTimeWaitListManager::AddConnectionIdToTimeWait( connection_id_map_.erase(it); } TrimTimeWaitListIfNeeded(); - DCHECK_LT( - num_connections(), - // If FLAGS_increase_time_wait_list is not set and - // FLAGS_quic_time_wait_list_max_connections has the new default - // value (600000), replace it with the old default value (50000). - !FLAGS_increase_time_wait_list && - FLAGS_quic_time_wait_list_max_connections == 600000 - ? static_cast(50000) - : static_cast(FLAGS_quic_time_wait_list_max_connections)); + DCHECK_LT(num_connections(), + static_cast(FLAGS_quic_time_wait_list_max_connections)); ConnectionIdData data(num_packets, version, clock_->ApproximateNow(), close_packet, connection_rejected_statelessly); connection_id_map_.insert(std::make_pair(connection_id, data)); @@ -322,16 +308,8 @@ void QuicTimeWaitListManager::TrimTimeWaitListIfNeeded() { if (FLAGS_quic_time_wait_list_max_connections < 0) { return; } - size_t temp_max_connections = - static_cast(FLAGS_quic_time_wait_list_max_connections); - // If FLAGS_increase_time_wait_list is not set and - // FLAGS_quic_time_wait_list_max_connections has the new default value - // (600000), replace it with the old default value (50000). - if (!FLAGS_increase_time_wait_list && - FLAGS_quic_time_wait_list_max_connections == 600000) { - temp_max_connections = static_cast(50000); - } - while (num_connections() >= temp_max_connections) { + while (num_connections() >= + static_cast(FLAGS_quic_time_wait_list_max_connections)) { MaybeExpireOldestConnection(QuicTime::Infinite()); } } diff --git a/net/tools/quic/test_tools/mock_epoll_server.h b/net/tools/quic/test_tools/mock_epoll_server.h index 742a957d8822..38c8be5b3356 100644 --- a/net/tools/quic/test_tools/mock_epoll_server.h +++ b/net/tools/quic/test_tools/mock_epoll_server.h @@ -36,7 +36,7 @@ class FakeTimeEpollServer : public EpollServer { // Note that the WaitForEventsAndExecuteCallbacks invocation // may cause NowInUs to advance beyond what was specified here. // If that is not desired, use the AdvanceByExactly calls. - void AdvanceByAndCallCallbacks(int64 advancement_usec) { + void AdvanceByAndWaitForEventsAndExecuteCallbacks(int64 advancement_usec) { AdvanceBy(advancement_usec); WaitForEventsAndExecuteCallbacks(); } -- 2.11.4.GIT