Bug 1321783 - Make updater be networking conservative r=dkeeler r=rstrong r=dragana

This commit is contained in:
Patrick McManus 2016-12-02 16:49:23 -05:00
Родитель 416e1ecb8f
Коммит eefe030798
17 изменённых файлов: 89 добавлений и 4 удалений

Просмотреть файл

@ -221,6 +221,13 @@ interface nsISocketTransport : nsITransport
*/
const unsigned long MITM_OK = (1 << 6);
/**
* If set, do not use newer protocol features that might have interop problems
* on the Internet. Intended only for use with critical infra like the updater.
* default is false.
*/
const unsigned long BE_CONSERVATIVE = (1 << 7);
/**
* Socket QoS/ToS markings. Valid values are IPTOS_DSCP_AFxx or
* IPTOS_CLASS_CSx (or IPTOS_DSCP_EF, but currently no supported

Просмотреть файл

@ -1159,6 +1159,9 @@ nsSocketTransport::BuildSocket(PRFileDesc *&fd, bool &proxyTransparent, bool &us
if (mConnectionFlags & nsISocketTransport::MITM_OK)
controlFlags |= nsISocketProvider::MITM_OK;
if (mConnectionFlags & nsISocketTransport::BE_CONSERVATIVE)
controlFlags |= nsISocketProvider::BE_CONSERVATIVE;
nsCOMPtr<nsISupports> secinfo;
if (i == 0) {
// if this is the first type, we'll want the

Просмотреть файл

@ -117,6 +117,7 @@ struct HttpChannelOpenArgs
nsCString appCacheClientID;
bool allowSpdy;
bool allowAltSvc;
bool beConservative;
OptionalLoadInfoArgs loadInfo;
OptionalHttpResponseHead synthesizedResponseHead;
nsCString synthesizedSecurityInfoSerialization;

Просмотреть файл

@ -87,6 +87,7 @@ HttpBaseChannel::HttpBaseChannel()
, mTimingEnabled(false)
, mAllowSpdy(true)
, mAllowAltSvc(true)
, mBeConservative(false)
, mResponseTimeoutEnabled(true)
, mAllRedirectsSameOrigin(true)
, mAllRedirectsPassTimingAllowCheck(true)
@ -2304,6 +2305,22 @@ HttpBaseChannel::SetAllowAltSvc(bool aAllowAltSvc)
return NS_OK;
}
NS_IMETHODIMP
HttpBaseChannel::GetBeConservative(bool *aBeConservative)
{
NS_ENSURE_ARG_POINTER(aBeConservative);
*aBeConservative = mBeConservative;
return NS_OK;
}
NS_IMETHODIMP
HttpBaseChannel::SetBeConservative(bool aBeConservative)
{
mBeConservative = aBeConservative;
return NS_OK;
}
NS_IMETHODIMP
HttpBaseChannel::GetApiRedirectToURI(nsIURI ** aResult)
{
@ -3069,10 +3086,11 @@ HttpBaseChannel::SetupReplacementChannel(nsIURI *newURI,
httpChannel->SetRequestContextID(mRequestContextID);
if (httpInternal) {
// Convey third party cookie and spdy flags.
// Convey third party cookie, conservative, and spdy flags.
httpInternal->SetThirdPartyFlags(mThirdPartyFlags);
httpInternal->SetAllowSpdy(mAllowSpdy);
httpInternal->SetAllowAltSvc(mAllowAltSvc);
httpInternal->SetBeConservative(mBeConservative);
RefPtr<nsHttpChannel> realChannel;
CallQueryInterface(newChannel, realChannel.StartAssignment());

Просмотреть файл

@ -211,6 +211,8 @@ public:
NS_IMETHOD SetAllowSpdy(bool aAllowSpdy) override;
NS_IMETHOD GetAllowAltSvc(bool *aAllowAltSvc) override;
NS_IMETHOD SetAllowAltSvc(bool aAllowAltSvc) override;
NS_IMETHOD GetBeConservative(bool *aBeConservative) override;
NS_IMETHOD SetBeConservative(bool aBeConservative) override;
NS_IMETHOD GetApiRedirectToURI(nsIURI * *aApiRedirectToURI) override;
virtual nsresult AddSecurityMessage(const nsAString &aMessageTag, const nsAString &aMessageCategory);
NS_IMETHOD TakeAllSecurityMessages(nsCOMArray<nsISecurityConsoleMessage> &aMessages) override;
@ -459,6 +461,7 @@ protected:
uint32_t mTimingEnabled : 1;
uint32_t mAllowSpdy : 1;
uint32_t mAllowAltSvc : 1;
uint32_t mBeConservative : 1;
uint32_t mResponseTimeoutEnabled : 1;
// A flag that should be false only if a cross-domain redirect occurred
uint32_t mAllRedirectsSameOrigin : 1;

Просмотреть файл

@ -2084,6 +2084,7 @@ HttpChannelChild::ContinueAsyncOpen()
openArgs.appCacheClientID() = appCacheClientId;
openArgs.allowSpdy() = mAllowSpdy;
openArgs.allowAltSvc() = mAllowAltSvc;
openArgs.beConservative() = mBeConservative;
openArgs.initialRwin() = mInitialRwin;
uint32_t cacheKey = 0;

Просмотреть файл

@ -123,7 +123,7 @@ HttpChannelParent::Init(const HttpChannelCreationArgs& aArgs)
a.redirectionLimit(), a.allowPipelining(), a.allowSTS(),
a.thirdPartyFlags(), a.resumeAt(), a.startPos(),
a.entityID(), a.chooseApplicationCache(),
a.appCacheClientID(), a.allowSpdy(), a.allowAltSvc(),
a.appCacheClientID(), a.allowSpdy(), a.allowAltSvc(), a.beConservative(),
a.loadInfo(), a.synthesizedResponseHead(),
a.synthesizedSecurityInfoSerialization(),
a.cacheKey(), a.requestContextID(), a.preflightArgs(),
@ -315,6 +315,7 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
const nsCString& appCacheClientID,
const bool& allowSpdy,
const bool& allowAltSvc,
const bool& beConservative,
const OptionalLoadInfoArgs& aLoadInfoArgs,
const OptionalHttpResponseHead& aSynthesizedResponseHead,
const nsCString& aSecurityInfoSerialization,
@ -525,6 +526,7 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
mChannel->SetThirdPartyFlags(thirdPartyFlags);
mChannel->SetAllowSpdy(allowSpdy);
mChannel->SetAllowAltSvc(allowAltSvc);
mChannel->SetBeConservative(beConservative);
mChannel->SetInitialRwin(aInitialRwin);
mChannel->SetBlockAuthPrompt(aBlockAuthPrompt);

Просмотреть файл

@ -129,6 +129,7 @@ protected:
const nsCString& appCacheClientID,
const bool& allowSpdy,
const bool& allowAltSvc,
const bool& beConservative,
const OptionalLoadInfoArgs& aLoadInfoArgs,
const OptionalHttpResponseHead& aSynthesizedResponseHead,
const nsCString& aSecurityInfoSerialization,

Просмотреть файл

@ -88,6 +88,11 @@ typedef uint8_t nsHttpVersion;
// First user is to prevent clearing of alt-svc cache on failed probe
#define NS_HTTP_ERROR_SOFTLY (1<<10)
// This corresponds to nsIHttpChannelInternal.beConservative
// it disables any cutting edge features that we are worried might result in
// interop problems with critical infrastructure
#define NS_HTTP_BE_CONSERVATIVE (1<<11)
//-----------------------------------------------------------------------------
// some default values
//-----------------------------------------------------------------------------

Просмотреть файл

@ -375,6 +375,7 @@ nsHttpChannel::Connect()
mConnectionInfo->SetAnonymous((mLoadFlags & LOAD_ANONYMOUS) != 0);
mConnectionInfo->SetPrivate(mPrivateBrowsing);
mConnectionInfo->SetNoSpdy(mCaps & NS_HTTP_DISALLOW_SPDY);
mConnectionInfo->SetBeConservative((mCaps & NS_HTTP_BE_CONSERVATIVE) || mBeConservative);
// Consider opening a TCP connection right away.
SpeculativeConnect();
@ -789,8 +790,12 @@ nsHttpChannel::SetupTransaction()
}
}
if (!mAllowSpdy)
if (!mAllowSpdy) {
mCaps |= NS_HTTP_DISALLOW_SPDY;
}
if (mBeConservative) {
mCaps |= NS_HTTP_BE_CONSERVATIVE;
}
// Use the URI path if not proxying (transparent proxying such as proxy
// CONNECT does not count here). Also figure out what HTTP version to use.

Просмотреть файл

@ -145,8 +145,9 @@ void nsHttpConnectionInfo::BuildHashKey()
// byte 3 is P/. P is for a private browising channel
// byte 4 is I/. I is for insecure scheme on TLS for http:// uris
// byte 5 is X/. X is for disallow_spdy flag
// byte 6 is C/. C is for be Conservative
mHashKey.AssignLiteral("......");
mHashKey.AssignLiteral(".......");
mHashKey.Append(keyHost);
if (!mNetworkInterfaceId.IsEmpty()) {
mHashKey.Append('(');
@ -257,6 +258,7 @@ nsHttpConnectionInfo::Clone() const
clone->SetPrivate(GetPrivate());
clone->SetInsecureScheme(GetInsecureScheme());
clone->SetNoSpdy(GetNoSpdy());
clone->SetBeConservative(GetBeConservative());
MOZ_ASSERT(clone->Equals(this));
return clone;
@ -279,6 +281,7 @@ nsHttpConnectionInfo::CloneAsDirectRoute(nsHttpConnectionInfo **outCI)
clone->SetPrivate(GetPrivate());
clone->SetInsecureScheme(GetInsecureScheme());
clone->SetNoSpdy(GetNoSpdy());
clone->SetBeConservative(GetBeConservative());
if (!mNetworkInterfaceId.IsEmpty()) {
clone->SetNetworkInterfaceId(mNetworkInterfaceId);
}

Просмотреть файл

@ -118,6 +118,10 @@ public:
{ mHashKey.SetCharAt(aNoSpdy ? 'X' : '.', 5); }
bool GetNoSpdy() const { return mHashKey.CharAt(5) == 'X'; }
void SetBeConservative(bool aBeConservative)
{ mHashKey.SetCharAt(aBeConservative ? 'C' : '.', 6); }
bool GetBeConservative() const { return mHashKey.CharAt(6) == 'C'; }
const nsCString &GetNetworkInterfaceId() const { return mNetworkInterfaceId; }
const nsCString &GetNPNToken() { return mNPNToken; }

Просмотреть файл

@ -3062,6 +3062,11 @@ nsHalfOpenSocket::SetupStreams(nsISocketTransport **transport,
if (ci->GetPrivate())
tmpFlags |= nsISocketTransport::NO_PERMANENT_STORAGE;
if ((mCaps & NS_HTTP_BE_CONSERVATIVE) || ci->GetBeConservative()) {
LOG(("Setting Socket to BE_CONSERVATIVE"));
tmpFlags |= nsISocketTransport::BE_CONSERVATIVE;
}
// For backup connections, we disable IPv6. That's because some users have
// broken IPv6 connectivity (leading to very long timeouts), and disabling
// IPv6 on the backup connection gives them a much better user experience

Просмотреть файл

@ -205,6 +205,13 @@ interface nsIHttpChannelInternal : nsISupports
*/
attribute boolean allowAltSvc;
/**
* If true, do not use newer protocol features that might have interop problems
* on the Internet. Intended only for use with critical infra like the updater.
* default is false.
*/
attribute boolean beConservative;
readonly attribute PRTime lastModifiedTime;
/**

Просмотреть файл

@ -105,6 +105,13 @@ interface nsISocketProvider : nsISupports
* a TLS socket without authentication.
*/
const unsigned long MITM_OK = 1 << 3;
/**
* If set, do not use newer protocol features that might have interop problems
* on the Internet. Intended only for use with critical infra like the updater.
* default is false.
*/
const unsigned long BE_CONSERVATIVE = 1 << 4;
};
%{C++

Просмотреть файл

@ -2381,6 +2381,14 @@ nsSSLIOLayerSetOptions(PRFileDesc* fd, bool forSTARTTLS,
return NS_ERROR_FAILURE;
}
if ((infoObject->GetProviderFlags() & nsISocketProvider::BE_CONSERVATIVE) &&
(range.max > SSL_LIBRARY_VERSION_TLS_1_2)) {
MOZ_LOG(gPIPNSSLog, LogLevel::Debug,
("[%p] nsSSLIOLayerSetOptions: range.max limited to 1.2 due to BE_CONSERVATIVE flag\n",
fd));
range.max = SSL_LIBRARY_VERSION_TLS_1_2;
}
uint16_t maxEnabledVersion = range.max;
infoObject->SharedState().IOLayerHelpers()
.adjustForTLSIntolerance(infoObject->GetHostName(), infoObject->GetPort(),
@ -2460,6 +2468,9 @@ nsSSLIOLayerSetOptions(PRFileDesc* fd, bool forSTARTTLS,
if (flags & nsISocketProvider::MITM_OK) {
peerId.AppendLiteral("bypassAuth:");
}
if (flags & nsISocketProvider::BE_CONSERVATIVE) {
peerId.AppendLiteral("beConservative:");
}
peerId.Append(host);
peerId.Append(':');
peerId.AppendInt(port);

Просмотреть файл

@ -3260,6 +3260,8 @@ Checker.prototype = {
this._request.channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
// Prevent the request from writing to the cache.
this._request.channel.loadFlags |= Ci.nsIRequest.INHIBIT_CACHING;
// Disable cutting edge features, like TLS 1.3, where middleboxes might brick us
this._request.channel.QueryInterface(Ci.nsIHttpChannelInternal).beConservative = true;
this._request.overrideMimeType("text/xml");
// The Cache-Control header is only interpreted by proxies and the