Commit 405ed7a8 authored by rch's avatar rch Committed by Commit bot

Add a new disable_insecure_quic finch parameter to disable insecure QUIC.

Review URL: https://codereview.chromium.org/1137073003

Cr-Commit-Position: refs/heads/master@{#329306}
parent 293783ba
...@@ -1182,6 +1182,7 @@ void IOThread::InitializeNetworkSessionParamsFromGlobals( ...@@ -1182,6 +1182,7 @@ void IOThread::InitializeNetworkSessionParamsFromGlobals(
&params->alternative_service_probability_threshold); &params->alternative_service_probability_threshold);
globals.enable_quic.CopyToIfSet(&params->enable_quic); globals.enable_quic.CopyToIfSet(&params->enable_quic);
globals.disable_insecure_quic.CopyToIfSet(&params->disable_insecure_quic);
globals.enable_quic_for_proxies.CopyToIfSet(&params->enable_quic_for_proxies); globals.enable_quic_for_proxies.CopyToIfSet(&params->enable_quic_for_proxies);
globals.quic_always_require_handshake_confirmation.CopyToIfSet( globals.quic_always_require_handshake_confirmation.CopyToIfSet(
&params->quic_always_require_handshake_confirmation); &params->quic_always_require_handshake_confirmation);
...@@ -1318,6 +1319,8 @@ void IOThread::ConfigureQuicGlobals( ...@@ -1318,6 +1319,8 @@ void IOThread::ConfigureQuicGlobals(
command_line, quic_trial_group, quic_allowed_by_policy); command_line, quic_trial_group, quic_allowed_by_policy);
globals->enable_quic_for_proxies.set(enable_quic_for_proxies); globals->enable_quic_for_proxies.set(enable_quic_for_proxies);
if (enable_quic) { if (enable_quic) {
globals->disable_insecure_quic.set(
ShouldDisableInsecureQuic(quic_trial_params));
globals->quic_always_require_handshake_confirmation.set( globals->quic_always_require_handshake_confirmation.set(
ShouldQuicAlwaysRequireHandshakeConfirmation(quic_trial_params)); ShouldQuicAlwaysRequireHandshakeConfirmation(quic_trial_params));
globals->quic_disable_connection_pooling.set( globals->quic_disable_connection_pooling.set(
...@@ -1429,6 +1432,14 @@ bool IOThread::ShouldEnableQuicForDataReductionProxy() { ...@@ -1429,6 +1432,14 @@ bool IOThread::ShouldEnableQuicForDataReductionProxy() {
IsIncludedInQuicFieldTrial(); IsIncludedInQuicFieldTrial();
} }
// static
bool IOThread::ShouldDisableInsecureQuic(
const VariationParameters& quic_trial_params) {
return LowerCaseEqualsASCII(
GetVariationParam(quic_trial_params, "disable_insecure_quic"),
"true");
}
bool IOThread::ShouldEnableQuicPortSelection( bool IOThread::ShouldEnableQuicPortSelection(
const base::CommandLine& command_line) { const base::CommandLine& command_line) {
if (command_line.HasSwitch(switches::kDisableQuicPortSelection)) if (command_line.HasSwitch(switches::kDisableQuicPortSelection))
......
...@@ -178,6 +178,7 @@ class IOThread : public content::BrowserThreadDelegate { ...@@ -178,6 +178,7 @@ class IOThread : public content::BrowserThreadDelegate {
Optional<double> alternative_service_probability_threshold; Optional<double> alternative_service_probability_threshold;
Optional<bool> enable_quic; Optional<bool> enable_quic;
Optional<bool> disable_insecure_quic;
Optional<bool> enable_quic_for_proxies; Optional<bool> enable_quic_for_proxies;
Optional<bool> enable_quic_port_selection; Optional<bool> enable_quic_port_selection;
Optional<bool> quic_always_require_handshake_confirmation; Optional<bool> quic_always_require_handshake_confirmation;
...@@ -333,6 +334,11 @@ class IOThread : public content::BrowserThreadDelegate { ...@@ -333,6 +334,11 @@ class IOThread : public content::BrowserThreadDelegate {
base::StringPiece quic_trial_group, base::StringPiece quic_trial_group,
bool quic_allowed_by_policy); bool quic_allowed_by_policy);
// Returns true if QUIC should be disabled for http:// URLs, as a result
// of a field trial.
static bool ShouldDisableInsecureQuic(
const VariationParameters& quic_trial_params);
// Returns true if the selection of the ephemeral port in bind() should be // Returns true if the selection of the ephemeral port in bind() should be
// performed by Chromium, and false if the OS should select the port. The OS // performed by Chromium, and false if the OS should select the port. The OS
// option is used to prevent Windows from posting a security security warning // option is used to prevent Windows from posting a security security warning
......
...@@ -200,6 +200,7 @@ TEST_F(IOThreadTest, EnableQuicFromFieldTrialGroup) { ...@@ -200,6 +200,7 @@ TEST_F(IOThreadTest, EnableQuicFromFieldTrialGroup) {
net::HttpNetworkSession::Params params; net::HttpNetworkSession::Params params;
InitializeNetworkSessionParams(&params); InitializeNetworkSessionParams(&params);
EXPECT_TRUE(params.enable_quic); EXPECT_TRUE(params.enable_quic);
EXPECT_FALSE(params.disable_insecure_quic);
EXPECT_TRUE(params.enable_quic_for_proxies); EXPECT_TRUE(params.enable_quic_for_proxies);
EXPECT_EQ(1350u, params.quic_max_packet_length); EXPECT_EQ(1350u, params.quic_max_packet_length);
EXPECT_EQ(1.0, params.alternative_service_probability_threshold); EXPECT_EQ(1.0, params.alternative_service_probability_threshold);
...@@ -254,6 +255,15 @@ TEST_F(IOThreadTest, EnablePacingFromCommandLine) { ...@@ -254,6 +255,15 @@ TEST_F(IOThreadTest, EnablePacingFromCommandLine) {
options.push_back(net::kPACE); options.push_back(net::kPACE);
EXPECT_EQ(options, params.quic_connection_options); EXPECT_EQ(options, params.quic_connection_options);
} }
TEST_F(IOThreadTest, DisableInsecureQuicFromFieldTrialParams) {
field_trial_group_ = "Enabled";
field_trial_params_["disable_insecure_quic"] = "true";
ConfigureQuicGlobals();
net::HttpNetworkSession::Params params;
InitializeNetworkSessionParams(&params);
EXPECT_TRUE(params.disable_insecure_quic);
}
TEST_F(IOThreadTest, EnablePacingFromFieldTrialParams) { TEST_F(IOThreadTest, EnablePacingFromFieldTrialParams) {
field_trial_group_ = "Enabled"; field_trial_group_ = "Enabled";
......
...@@ -89,6 +89,7 @@ HttpNetworkSession::Params::Params() ...@@ -89,6 +89,7 @@ HttpNetworkSession::Params::Params()
use_alternate_protocols(false), use_alternate_protocols(false),
alternative_service_probability_threshold(1), alternative_service_probability_threshold(1),
enable_quic(false), enable_quic(false),
disable_insecure_quic(false),
enable_quic_for_proxies(false), enable_quic_for_proxies(false),
enable_quic_port_selection(true), enable_quic_port_selection(true),
quic_always_require_handshake_confirmation(false), quic_always_require_handshake_confirmation(false),
......
...@@ -106,6 +106,7 @@ class NET_EXPORT HttpNetworkSession ...@@ -106,6 +106,7 @@ class NET_EXPORT HttpNetworkSession
double alternative_service_probability_threshold; double alternative_service_probability_threshold;
bool enable_quic; bool enable_quic;
bool disable_insecure_quic;
bool enable_quic_for_proxies; bool enable_quic_for_proxies;
bool enable_quic_port_selection; bool enable_quic_port_selection;
bool quic_always_require_handshake_confirmation; bool quic_always_require_handshake_confirmation;
......
...@@ -197,12 +197,18 @@ AlternativeService HttpStreamFactoryImpl::GetAlternativeServiceFor( ...@@ -197,12 +197,18 @@ AlternativeService HttpStreamFactoryImpl::GetAlternativeServiceFor(
// QUIC, then remove the following two lines. // QUIC, then remove the following two lines.
if (alternative_service.host != origin.host()) if (alternative_service.host != origin.host())
return kNoAlternativeService; return kNoAlternativeService;
if (!session_->params().enable_quic) if (!session_->params().enable_quic)
return kNoAlternativeService; return kNoAlternativeService;
if (session_->quic_stream_factory()->IsQuicDisabled(origin.port())) if (session_->quic_stream_factory()->IsQuicDisabled(origin.port()))
return kNoAlternativeService; return kNoAlternativeService;
if (session_->params().disable_insecure_quic &&
!original_url.SchemeIs("https")) {
return kNoAlternativeService;
}
return alternative_service; return alternative_service;
} }
......
...@@ -691,6 +691,29 @@ TEST_P(QuicNetworkTransactionTest, DontUseAlternateProtocolProbabilityForQuic) { ...@@ -691,6 +691,29 @@ TEST_P(QuicNetworkTransactionTest, DontUseAlternateProtocolProbabilityForQuic) {
SendRequestAndExpectHttpResponse("hello world"); SendRequestAndExpectHttpResponse("hello world");
} }
TEST_P(QuicNetworkTransactionTest, DontUseAlternateProtocolForInsecureQuic) {
MockRead http_reads[] = {MockRead("HTTP/1.1 200 OK\r\n"),
MockRead("Content-length: 11\r\n"),
MockRead("Alternate-Protocol: 443:quic\r\n\r\n"),
MockRead("hello world"),
MockRead("HTTP/1.1 200 OK\r\n"),
MockRead("Content-length: 11\r\n"),
MockRead("Alternate-Protocol: 443:quic\r\n\r\n"),
MockRead("hello world"),
MockRead(ASYNC, OK)};
StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr,
0);
socket_factory_.AddSocketDataProvider(&http_data);
socket_factory_.AddSocketDataProvider(&http_data);
params_.disable_insecure_quic = true;
CreateSessionWithNextProtos();
SendRequestAndExpectHttpResponse("hello world");
SendRequestAndExpectHttpResponse("hello world");
}
TEST_P(QuicNetworkTransactionTest, TEST_P(QuicNetworkTransactionTest,
DontUseAlternateProtocolWithBadProbabilityForQuic) { DontUseAlternateProtocolWithBadProbabilityForQuic) {
MockRead http_reads[] = { MockRead http_reads[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment