Bug 1525640 - Pass TRR status from sockettransport to channel r=dragana
☠☠ backed out by 3be80123e3af ☠ ☠
authorValentin Gosu <valentin.gosu@gmail.com>
Thu, 02 May 2019 12:53:36 +0000
changeset 531124 4294abed890fec277a09c1f66e1b4a3a2798bbd5
parent 531123 a0cad7a2f14350c12ad6dba4ea1c50b2958dc442
child 531125 19aa991328cb7752f5b7b871424872eb44a80801
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdragana
bugs1525640
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1525640 - Pass TRR status from sockettransport to channel r=dragana Differential Revision: https://phabricator.services.mozilla.com/D26882
netwerk/base/nsISocketTransport.idl
netwerk/base/nsSocketTransport2.cpp
netwerk/base/nsSocketTransport2.h
netwerk/protocol/http/TunnelUtils.cpp
netwerk/protocol/http/nsHttpChannel.cpp
netwerk/protocol/http/nsHttpChannel.h
netwerk/protocol/http/nsHttpTransaction.cpp
netwerk/protocol/http/nsHttpTransaction.h
--- a/netwerk/base/nsISocketTransport.idl
+++ b/netwerk/base/nsISocketTransport.idl
@@ -309,9 +309,14 @@ interface nsISocketTransport : nsITransp
      */
     readonly attribute boolean resetIPFamilyPreference;
 
     /**
      * This attribute holds information whether esni has been used.
      * The value is set after PR_Connect is called.
      */
    readonly attribute boolean esniUsed;
+
+    /**
+     * IP address resolved using TRR.
+     */
+    bool resolvedByTRR();
 };
--- a/netwerk/base/nsSocketTransport2.cpp
+++ b/netwerk/base/nsSocketTransport2.cpp
@@ -703,16 +703,17 @@ nsSocketTransport::nsSocketTransport()
       mResetFamilyPreference(false),
       mTlsFlags(0),
       mReuseAddrPort(false),
       mState(STATE_CLOSED),
       mAttached(false),
       mInputClosed(true),
       mOutputClosed(true),
       mResolving(false),
+      mResolvedByTRR(false),
       mDNSLookupStatus(NS_OK),
       mDNSARequestFinished(0),
       mEsniQueried(false),
       mEsniUsed(false),
       mNetAddrIsSet(false),
       mSelfAddrIsSet(false),
       mLock("nsSocketTransport.mLock"),
       mFD(this),
@@ -1798,16 +1799,17 @@ bool nsSocketTransport::RecoverFromError
       // connection entry
       mResetFamilyPreference = true;
       tryAgain = true;
     }
 
     // try next ip address only if past the resolver stage...
     if (mState == STATE_CONNECTING && mDNSRecord) {
       nsresult rv = mDNSRecord->GetNextAddr(SocketPort(), &mNetAddr);
+      mDNSRecord->IsTRR(&mResolvedByTRR);
       if (NS_SUCCEEDED(rv)) {
         SOCKET_LOG(("  trying again with next ip address\n"));
         tryAgain = true;
       } else if (mConnectionFlags & RETRY_WITH_DIFFERENT_IP_FAMILY) {
         SOCKET_LOG(("  failed to connect, trying with opposite ip family\n"));
         // Drop state to closed.  This will trigger new round of DNS
         // resolving bellow.
         mState = STATE_CLOSED;
@@ -2091,16 +2093,17 @@ void nsSocketTransport::OnSocketEvent(ui
         SendStatus(NS_NET_STATUS_RESOLVED_HOST);
       }
 
       SOCKET_LOG(("  MSG_DNS_LOOKUP_COMPLETE\n"));
       mDNSRequest = nullptr;
       mDNSTxtRequest = nullptr;
       if (mDNSRecord) {
         mDNSRecord->GetNextAddr(SocketPort(), &mNetAddr);
+        mDNSRecord->IsTRR(&mResolvedByTRR);
       }
       // status contains DNS lookup status
       if (NS_FAILED(status)) {
         // When using a HTTP proxy, NS_ERROR_UNKNOWN_HOST means the HTTP
         // proxy host is not found, so we fixup the error code.
         // For SOCKS proxies (mProxyTransparent == true), the socket
         // transport resolves the real host here, so there's no fixup
         // (see bug 226943).
@@ -3518,10 +3521,16 @@ nsSocketTransport::GetResetIPFamilyPrefe
 }
 
 NS_IMETHODIMP
 nsSocketTransport::GetEsniUsed(bool* aEsniUsed) {
   *aEsniUsed = mEsniUsed;
   return NS_OK;
 }
 
+NS_IMETHODIMP
+nsSocketTransport::ResolvedByTRR(bool* aResolvedByTRR) {
+  *aResolvedByTRR = mResolvedByTRR;
+  return NS_OK;
+}
+
 }  // namespace net
 }  // namespace mozilla
--- a/netwerk/base/nsSocketTransport2.h
+++ b/netwerk/base/nsSocketTransport2.h
@@ -323,16 +323,17 @@ class nsSocketTransport final : public n
   bool mOutputClosed;
 
   // this flag is used to determine if the results of a host lookup arrive
   // recursively or not.  this flag is not protected by any lock.
   bool mResolving;
 
   nsCOMPtr<nsICancelable> mDNSRequest;
   nsCOMPtr<nsIDNSRecord> mDNSRecord;
+  bool mResolvedByTRR;
 
   nsresult mDNSLookupStatus;
   PRIntervalTime mDNSARequestFinished;
   nsCOMPtr<nsICancelable> mDNSTxtRequest;
   nsCString mDNSRecordTxt;
   bool mEsniQueried;
   bool mEsniUsed;
 
--- a/netwerk/protocol/http/TunnelUtils.cpp
+++ b/netwerk/protocol/http/TunnelUtils.cpp
@@ -1822,16 +1822,24 @@ SocketTransportShim::GetFirstRetryError(
 NS_IMETHODIMP
 SocketTransportShim::GetEsniUsed(bool* aEsniUsed) {
   if (mIsWebsocket) {
     LOG3(("WARNING: SocketTransportShim::GetEsniUsed %p", this));
   }
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
+NS_IMETHODIMP
+SocketTransportShim::ResolvedByTRR(bool* aResolvedByTRR) {
+  if (mIsWebsocket) {
+    LOG3(("WARNING: SocketTransportShim::IsTRR %p", this));
+  }
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
 #define FWD_TS_PTR(fx, ts) \
   NS_IMETHODIMP            \
   SocketTransportShim::fx(ts* arg) { return mWrapped->fx(arg); }
 
 #define FWD_TS_ADDREF(fx, ts) \
   NS_IMETHODIMP               \
   SocketTransportShim::fx(ts** arg) { return mWrapped->fx(arg); }
 
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -8424,21 +8424,25 @@ nsHttpChannel::OnTransportStatus(nsITran
   MOZ_ASSERT(NS_IsMainThread(), "Should be on main thread only");
   // cache the progress sink so we don't have to query for it each time.
   if (!mProgressSink) GetCallback(mProgressSink);
 
   if (status == NS_NET_STATUS_CONNECTED_TO ||
       status == NS_NET_STATUS_WAITING_FOR) {
     if (mTransaction) {
       mTransaction->GetNetworkAddresses(mSelfAddr, mPeerAddr);
+      mResolvedByTRR = mTransaction->ResolvedByTRR();
     } else {
       nsCOMPtr<nsISocketTransport> socketTransport = do_QueryInterface(trans);
       if (socketTransport) {
         socketTransport->GetSelfAddr(&mSelfAddr);
         socketTransport->GetPeerAddr(&mPeerAddr);
+        bool isTrr = false;
+        socketTransport->ResolvedByTRR(&isTrr);
+        mResolvedByTRR = isTrr;
       }
     }
   }
 
   // block socket status event after Cancel or OnStopRequest has been called.
   if (mProgressSink && NS_SUCCEEDED(mStatus) && mIsPending) {
     LOG(("sending progress%s notification [this=%p status=%" PRIx32
          " progress=%" PRId64 "/%" PRId64 "]\n",
--- a/netwerk/protocol/http/nsHttpChannel.h
+++ b/netwerk/protocol/http/nsHttpChannel.h
@@ -543,17 +543,17 @@ class nsHttpChannel final : public HttpB
 
   void SetLoadGroupUserAgentOverride();
 
   void SetOriginHeader();
   void SetDoNotTrack();
 
   bool IsIsolated();
 
-  const nsCString &GetTopWindowOrigin();
+  const nsCString& GetTopWindowOrigin();
 
   already_AddRefed<nsChannelClassifier> GetOrCreateChannelClassifier();
 
   // Start an internal redirect to a new InterceptedHttpChannel which will
   // resolve in firing a ServiceWorker FetchEvent.
   MOZ_MUST_USE nsresult RedirectToInterceptedChannel();
 
   // Determines and sets content type in the cache entry. It's called when
@@ -717,16 +717,20 @@ class nsHttpChannel final : public HttpB
   // to the safe-browsing classifier rules, but the asynchronous cancellation
   // process hasn't finished yet.
   uint32_t mChannelClassifierCancellationPending : 1;
 
   // True only when we are between Resume and async fire of mCallOnResume.
   // Used to suspend any newly created pumps in mCallOnResume handler.
   uint32_t mAsyncResumePending : 1;
 
+  // If the request was performed to a TRR resolved IP address.
+  // Will be false if loaded from the cache.
+  uint32_t mResolvedByTRR : 1;
+
   // True only when we have checked whether this channel has been isolated for
   // anti-tracking purposes.
   uint32_t mHasBeenIsolatedChecked : 1;
   // True only when we have determined this channel should be isolated for
   // anti-tracking purposes.  Can never ben true unless mHasBeenIsolatedChecked
   // is true.
   uint32_t mIsIsolated : 1;
 
--- a/netwerk/protocol/http/nsHttpTransaction.cpp
+++ b/netwerk/protocol/http/nsHttpTransaction.cpp
@@ -138,16 +138,17 @@ nsHttpTransaction::nsHttpTransaction()
       mResponseHeadTaken(false),
       mForTakeResponseTrailers(nullptr),
       mResponseTrailersTaken(false),
       mTopLevelOuterContentWindowId(0),
       mSubmittedRatePacing(false),
       mPassedRatePacing(false),
       mSynchronousRatePaceRequest(false),
       mClassOfService(0),
+      mResolvedByTRR(false),
       m0RTTInProgress(false),
       mDoNotTryEarlyData(false),
       mEarlyDataDisposition(EARLY_NONE),
       mFastOpenStatus(TFO_NOT_TRIED),
       mTrafficCategory(HttpTrafficCategory::eInvalid) {
   this->mSelfAddr.inet = {};
   this->mPeerAddr.inet = {};
   LOG(("Creating nsHttpTransaction @%p\n", this));
@@ -588,16 +589,17 @@ void nsHttpTransaction::OnTransportStatu
   if (status == NS_NET_STATUS_CONNECTED_TO ||
       status == NS_NET_STATUS_WAITING_FOR) {
     nsISocketTransport* socketTransport =
         mConnection ? mConnection->Transport() : nullptr;
     if (socketTransport) {
       MutexAutoLock lock(mLock);
       socketTransport->GetSelfAddr(&mSelfAddr);
       socketTransport->GetPeerAddr(&mPeerAddr);
+      socketTransport->ResolvedByTRR(&mResolvedByTRR);
     }
   }
 
   // If the timing is enabled, and we are not using a persistent connection
   // then the requestStart timestamp will be null, so we mark the timestamps
   // for domainLookupStart/End and connectStart/End
   // If we are using a persistent connection they will remain null,
   // and the correct value will be returned in Performance.
--- a/netwerk/protocol/http/nsHttpTransaction.h
+++ b/netwerk/protocol/http/nsHttpTransaction.h
@@ -458,20 +458,22 @@ class nsHttpTransaction final : public n
     mTransactionObserver = arg;
   }
 
  private:
   RefPtr<TransactionObserver> mTransactionObserver;
 
  public:
   void GetNetworkAddresses(NetAddr& self, NetAddr& peer);
+  bool ResolvedByTRR() { return mResolvedByTRR; }
 
  private:
   NetAddr mSelfAddr;
   NetAddr mPeerAddr;
+  bool mResolvedByTRR;
 
   bool m0RTTInProgress;
   bool mDoNotTryEarlyData;
   enum {
     EARLY_NONE,
     EARLY_SENT,
     EARLY_ACCEPTED,
     EARLY_425