Bug 1552438 - Remove TRR mode 1 (MODE_PARALLEL) r=agrover

Differential Revision: https://phabricator.services.mozilla.com/D32996

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Valentin Gosu 2019-06-01 09:44:06 +00:00
Родитель e9e8848ea1
Коммит 4882c4f4ea
4 изменённых файлов: 17 добавлений и 10 удалений

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

@ -125,13 +125,16 @@ void TRRService::GetPrefBranch(nsIPrefBranch** result) {
nsresult TRRService::ReadPrefs(const char* name) { nsresult TRRService::ReadPrefs(const char* name) {
MOZ_ASSERT(NS_IsMainThread(), "wrong thread"); MOZ_ASSERT(NS_IsMainThread(), "wrong thread");
if (!name || !strcmp(name, TRR_PREF("mode"))) { if (!name || !strcmp(name, TRR_PREF("mode"))) {
// 0 - off, 1 - parallel, 2 - TRR first, 3 - TRR only, 4 - shadow, // 0 - off, 1 - reserved, 2 - TRR first, 3 - TRR only, 4 - shadow,
// 5 - explicit off // 5 - explicit off
uint32_t tmp; uint32_t tmp;
if (NS_SUCCEEDED(Preferences::GetUint(TRR_PREF("mode"), &tmp))) { if (NS_SUCCEEDED(Preferences::GetUint(TRR_PREF("mode"), &tmp))) {
if (tmp > MODE_TRROFF) { if (tmp > MODE_TRROFF) {
tmp = MODE_TRROFF; tmp = MODE_TRROFF;
} }
if (tmp == MODE_RESERVED1) {
tmp = MODE_TRROFF;
}
mMode = tmp; mMode = tmp;
} }
} }

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

@ -469,8 +469,7 @@ void AddrHostRecord::ResolveComplete() {
} }
} }
if (mTRRUsed && mNativeUsed && if (mTRRUsed && mNativeUsed && ((mResolverMode == MODE_SHADOW))) {
((mResolverMode == MODE_SHADOW) || (mResolverMode == MODE_PARALLEL))) {
// both were used, accumulate comparative success // both were used, accumulate comparative success
AccumulateCategorical( AccumulateCategorical(
mNativeSuccess && mTRRSuccess mNativeSuccess && mTRRSuccess
@ -505,9 +504,6 @@ void AddrHostRecord::ResolveComplete() {
case MODE_TRROFF: case MODE_TRROFF:
AccumulateCategorical(Telemetry::LABELS_DNS_LOOKUP_ALGORITHM::nativeOnly); AccumulateCategorical(Telemetry::LABELS_DNS_LOOKUP_ALGORITHM::nativeOnly);
break; break;
case MODE_PARALLEL:
AccumulateCategorical(Telemetry::LABELS_DNS_LOOKUP_ALGORITHM::trrRace);
break;
case MODE_TRRFIRST: case MODE_TRRFIRST:
AccumulateCategorical(Telemetry::LABELS_DNS_LOOKUP_ALGORITHM::trrFirst); AccumulateCategorical(Telemetry::LABELS_DNS_LOOKUP_ALGORITHM::trrFirst);
break; break;
@ -517,6 +513,9 @@ void AddrHostRecord::ResolveComplete() {
case MODE_SHADOW: case MODE_SHADOW:
AccumulateCategorical(Telemetry::LABELS_DNS_LOOKUP_ALGORITHM::trrShadow); AccumulateCategorical(Telemetry::LABELS_DNS_LOOKUP_ALGORITHM::trrShadow);
break; break;
case MODE_RESERVED1:
MOZ_DIAGNOSTIC_ASSERT(false, "MODE_RESERVED1 should not be used");
break;
} }
if (mTRRUsed && !mTRRSuccess && mNativeSuccess && gTRRService) { if (mTRRUsed && !mTRRSuccess && mNativeSuccess && gTRRService) {
@ -1414,6 +1413,7 @@ nsresult nsHostResolver::NameLookup(nsHostRecord* rec) {
} }
ResolverMode mode = rec->mResolverMode = Mode(); ResolverMode mode = rec->mResolverMode = Mode();
MOZ_ASSERT(mode != MODE_RESERVED1);
if (rec->IsAddrRecord()) { if (rec->IsAddrRecord()) {
RefPtr<AddrHostRecord> addrRec = do_QueryObject(rec); RefPtr<AddrHostRecord> addrRec = do_QueryObject(rec);
@ -1448,7 +1448,7 @@ nsresult nsHostResolver::NameLookup(nsHostRecord* rec) {
rv = TrrLookup(rec); rv = TrrLookup(rec);
} }
if ((mode == MODE_PARALLEL) || TRR_DISABLED(mode) || (mode == MODE_SHADOW) || if (TRR_DISABLED(mode) || (mode == MODE_SHADOW) ||
((mode == MODE_TRRFIRST) && NS_FAILED(rv)) || ((mode == MODE_TRRFIRST) && NS_FAILED(rv)) ||
(mode == MODE_TRRONLY && skipTRR)) { (mode == MODE_TRRONLY && skipTRR)) {
if (!rec->IsAddrRecord()) { if (!rec->IsAddrRecord()) {

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

@ -32,7 +32,7 @@ namespace net {
class TRR; class TRR;
enum ResolverMode { enum ResolverMode {
MODE_NATIVEONLY, // 0 - TRR OFF (by default) MODE_NATIVEONLY, // 0 - TRR OFF (by default)
MODE_PARALLEL, // 1 - race and use the first response MODE_RESERVED1, // 1 - Reserved value. Used to be parallel resolve.
MODE_TRRFIRST, // 2 - fallback to native on TRR failure MODE_TRRFIRST, // 2 - fallback to native on TRR failure
MODE_TRRONLY, // 3 - don't even fallback MODE_TRRONLY, // 3 - don't even fallback
MODE_SHADOW, // 4 - race for stats, but always use native result MODE_SHADOW, // 4 - race for stats, but always use native result

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

@ -343,12 +343,16 @@ add_task(async function test18() {
Assert.ok(!Components.isSuccessCode(inStatus), `${inStatus} should be an error code`); Assert.ok(!Components.isSuccessCode(inStatus), `${inStatus} should be an error code`);
}); });
// TRR-race and a CNAME loop // Test that MODE_RESERVED1 (previously MODE_PARALLEL) is treated as TRR off.
add_task(async function test19() { add_task(async function test19() {
dns.clearCache(true); dns.clearCache(true);
Services.prefs.setIntPref("network.trr.mode", 1); // Race them! Services.prefs.setIntPref("network.trr.mode", 1); // MODE_RESERVED1. Interpreted as TRR off.
Services.prefs.setCharPref("network.trr.uri", `https://foo.example.com:${h2Port}/doh?responseIP=none&cnameloop=true`); Services.prefs.setCharPref("network.trr.uri", `https://foo.example.com:${h2Port}/doh?responseIP=none&cnameloop=true`);
await new DNSListener("test19.example.com", "127.0.0.1"); await new DNSListener("test19.example.com", "127.0.0.1");
Services.prefs.setIntPref("network.trr.mode", 1); // MODE_RESERVED1. Interpreted as TRR off.
Services.prefs.setCharPref("network.trr.uri", `https://foo.example.com:${h2Port}/doh?responseIP=2.2.2.2`);
await new DNSListener("bar.example.com", "127.0.0.1");
}); });
// TRR-first and a CNAME loop // TRR-first and a CNAME loop