Backed out changeset e8c352c1055e (Bug 1582472); was: Exclude DHCP Search Suffixes from TRR. a=pascalc FIREFOX_71_0_BUILD5 FIREFOX_71_0_RELEASE
authorValentin Gosu <valentin.gosu@gmail.com>
Mon, 02 Dec 2019 10:30:08 +0100
changeset 563500 501aef7fe1d9622236600a7e53843d40d163a123
parent 563499 e92c4aeac6c046e5f6e3954ffee9fcc9d19045dd
child 563501 adf22e9ae3ef87696287d1de247e1dc903ce29b0
push id2205
push userarchaeopteryx@coole-files.de
push dateMon, 02 Dec 2019 09:33:17 +0000
treeherdermozilla-release@501aef7fe1d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspascalc
bugs1582472
milestone71.0
backs oute8c352c1055e008d3ede8f39bd62a7f3e6de397a
Backed out changeset e8c352c1055e (Bug 1582472); was: Exclude DHCP Search Suffixes from TRR. a=pascalc
netwerk/dns/TRRService.cpp
netwerk/dns/TRRService.h
netwerk/test/unit/test_trr.js
--- a/netwerk/dns/TRRService.cpp
+++ b/netwerk/dns/TRRService.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsICaptivePortalService.h"
 #include "nsIParentalControlsService.h"
-#include "nsINetworkLinkService.h"
 #include "nsIObserverService.h"
 #include "nsIURIMutator.h"
 #include "nsNetUtil.h"
 #include "nsStandardURL.h"
 #include "TRR.h"
 #include "TRRService.h"
 
 #include "mozilla/Preferences.h"
@@ -66,17 +65,16 @@ nsresult TRRService::Init() {
 
   nsCOMPtr<nsIObserverService> observerService =
       mozilla::services::GetObserverService();
   if (observerService) {
     observerService->AddObserver(this, NS_CAPTIVE_PORTAL_CONNECTIVITY, true);
     observerService->AddObserver(this, kOpenCaptivePortalLoginEvent, true);
     observerService->AddObserver(this, kClearPrivateData, true);
     observerService->AddObserver(this, kPurge, true);
-    observerService->AddObserver(this, NS_NETWORK_LINK_TOPIC, true);
   }
   nsCOMPtr<nsIPrefBranch> prefBranch;
   GetPrefBranch(getter_AddRefs(prefBranch));
   if (prefBranch) {
     prefBranch->AddObserver(TRR_PREF_PREFIX, this, true);
     prefBranch->AddObserver(kDisableIpv6Pref, this, true);
     prefBranch->AddObserver(kCaptivedetectCanonicalURL, this, true);
   }
@@ -445,31 +443,16 @@ TRRService::Observe(nsISupports* aSubjec
 
     mCaptiveIsPassed = true;
 
   } else if (!strcmp(aTopic, kClearPrivateData) || !strcmp(aTopic, kPurge)) {
     // flush the TRR blacklist, both in-memory and on-disk
     if (mTRRBLStorage) {
       mTRRBLStorage->Clear();
     }
-  } else if (!strcmp(aTopic, NS_NETWORK_LINK_TOPIC)) {
-    mDNSSuffixDomains.Clear();
-    nsAutoCString data = NS_ConvertUTF16toUTF8(aData);
-    if (data.EqualsLiteral(NS_NETWORK_LINK_DATA_CHANGED)) {
-      nsCOMPtr<nsINetworkLinkService> link = do_QueryInterface(aSubject);
-      // The network link service notification normally passes itself as the
-      // subject, but some unit tests will sometimes pass a null subject.
-      if (link) {
-        nsTArray<nsCString> suffixList;
-        link->GetDnsSuffixList(suffixList);
-        for (const auto& item : suffixList) {
-          mDNSSuffixDomains.PutEntry(item);
-        }
-      }
-    }
   }
   return NS_OK;
 }
 
 void TRRService::MaybeConfirm() {
   MutexAutoLock lock(mLock);
   MaybeConfirm_locked();
 }
@@ -548,20 +531,16 @@ bool TRRService::IsTRRBlacklisted(const 
       aHost.Equals(NS_LITERAL_CSTRING("localhost"))) {
     return true;
   }
 
   if (mExcludedDomains.GetEntry(aHost)) {
     LOG(("Host [%s] is TRR blacklisted via pref\n", aHost.BeginReading()));
     return true;
   }
-  if (mDNSSuffixDomains.GetEntry(aHost)) {
-    LOG(("Host [%s] is TRR blacklisted dns suffix\n", aHost.BeginReading()));
-    return true;
-  }
 
   if (!Enabled()) {
     return true;
   }
 
   int32_t dot = aHost.FindChar('.');
   if ((dot == kNotFound) && aParentsToo) {
     // Only if a full host name. Domains can be dotless to be able to
@@ -621,21 +600,16 @@ bool TRRService::IsExcludedFromTRR(const
     nsDependentCSubstring subdomain =
         Substring(aHost, dot, aHost.Length() - dot);
 
     if (mExcludedDomains.GetEntry(subdomain)) {
       LOG(("Subdomain [%s] of host [%s] Is Excluded From TRR via pref\n",
            subdomain.BeginReading(), aHost.BeginReading()));
       return true;
     }
-    if (mDNSSuffixDomains.GetEntry(subdomain)) {
-      LOG(("Subdomain [%s] of host [%s] Is Excluded From TRR via pref\n",
-           subdomain.BeginReading(), aHost.BeginReading()));
-      return true;
-    }
 
     dot = aHost.FindChar('.', dot + 1);
     if (dot == kNotFound) {
       break;
     }
     dot++;
   }
 
--- a/netwerk/dns/TRRService.h
+++ b/netwerk/dns/TRRService.h
@@ -101,17 +101,16 @@ class TRRService : public nsIObserver,
   // mTRRBLStorage is only modified on the main thread, but we query whether it
   // is initialized or not off the main thread as well. Therefore we need to
   // lock while creating it and while accessing it off the main thread.
   RefPtr<DataStorage> mTRRBLStorage;
   Atomic<bool, Relaxed> mClearTRRBLStorage;
 
   // A set of domains that we should not use TRR for.
   nsTHashtable<nsCStringHashKey> mExcludedDomains;
-  nsTHashtable<nsCStringHashKey> mDNSSuffixDomains;
 
   enum ConfirmationState {
     CONFIRM_INIT = 0,
     CONFIRM_TRYING = 1,
     CONFIRM_OK = 2,
     CONFIRM_FAILED = 3
   };
   Atomic<ConfirmationState, Relaxed> mConfirmationState;
--- a/netwerk/test/unit/test_trr.js
+++ b/netwerk/test/unit/test_trr.js
@@ -1083,45 +1083,8 @@ add_task(async function test_clearCacheO
   Services.prefs.setCharPref(
     "network.trr.uri",
     `https://localhost:${h2Port}/doh?responseIP=8.8.8.8`
   );
 
   await new DNSListener("bar.example.com", "8.8.8.8");
   Services.prefs.setBoolPref("network.trr.clear-cache-on-pref-change", false);
 });
-
-add_task(async function test_dnsSuffix() {
-  async function checkDnsSuffixInMode(mode) {
-    dns.clearCache(true);
-    Services.prefs.setIntPref("network.trr.mode", mode);
-    Services.prefs.setCharPref(
-      "network.trr.uri",
-      `https://localhost:${h2Port}/doh?responseIP=1.2.3.4`
-    );
-    await new DNSListener("test.com", "1.2.3.4");
-    dns.clearCache(true);
-    Services.prefs.setIntPref("network.trr.mode", mode);
-
-    dns.clearCache(true);
-    let networkLinkService = {
-      dnsSuffixList: ["test.com"],
-      QueryInterface: ChromeUtils.generateQI([Ci.nsINetworkLinkService]),
-    };
-    Services.obs.notifyObservers(
-      networkLinkService,
-      "network:link-status-changed",
-      "changed"
-    );
-    await new DNSListener("test.com", "127.0.0.1");
-
-    // Attempt to clean up, just in case
-    networkLinkService.dnsSuffixList = [];
-    Services.obs.notifyObservers(
-      networkLinkService,
-      "network:link-status-changed",
-      "changed"
-    );
-  }
-
-  await checkDnsSuffixInMode(2);
-  await checkDnsSuffixInMode(3);
-});