tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 1984fd7905bb11bd4ed2fb0357134ab5aa309a8c
parent 12e4d8e30af263d4dad847a17fae817eace6887a
Author: Valentin Gosu <valentin.gosu@gmail.com>
Date:   Wed, 19 Nov 2025 12:32:55 +0000

Bug 1996813 - Change network.trr.retry_on_recoverable_errors to false and cycle connections when confirmation fails r=necko-reviewers,kershaw

This change does the following:
- Sets network.trr.retry_on_recoverable_errors to false, which means that failed TRR requests immediately fallback to native in mode 2.
- Makes it so a failed confirmation will trigger the use of a new connection for the next confirmation
- Triggers a confirmation for every TRR failure

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

Diffstat:
Mmodules/libpref/init/StaticPrefList.yaml | 2+-
Mnetwerk/dns/TRRService.cpp | 11++++++++---
Mnetwerk/dns/nsHostResolver.cpp | 3+++
3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml @@ -14756,7 +14756,7 @@ # If true, retry TRR for recoverable errors once. - name: network.trr.retry_on_recoverable_errors type: RelaxedAtomicBool - value: true + value: false mirror: always # If true, don't fallback to native DNS upon network errors. diff --git a/netwerk/dns/TRRService.cpp b/netwerk/dns/TRRService.cpp @@ -671,6 +671,7 @@ void TRRService::RebuildSuffixList(nsTArray<nsCString>&& aSuffixList) { void TRRService::ConfirmationContext::SetState( enum ConfirmationState aNewState) { + LOG(("ConfirmationContext::SetState %u", uint32_t(aNewState))); mState = aNewState; enum ConfirmationState state = mState; @@ -802,9 +803,11 @@ bool TRRService::ConfirmationContext::HandleEvent(ConfirmationEvent aEvent, MOZ_ASSERT(mode == nsIDNSService::MODE_TRRFIRST, "Should only confirm in TRR first mode"); - // Set aUseFreshConnection if TRR lookups are retried. + // Set aUseFreshConnection if TRR lookups are retried + // or if confirmation already failed. mTask = new TRR(service, service->mConfirmationNS, TRRTYPE_NS, ""_ns, false, - StaticPrefs::network_trr_retry_on_recoverable_errors()); + mState == CONFIRM_TRYING_FAILED || + StaticPrefs::network_trr_retry_on_recoverable_errors()); mTask->SetTimeout(StaticPrefs::network_trr_confirmation_timeout_ms()); mTask->SetPurpose(TRR::Confirmation); @@ -870,6 +873,8 @@ bool TRRService::ConfirmationContext::HandleEvent(ConfirmationEvent aEvent, } break; case ConfirmationEvent::ConfirmOK: + // Reset confirmation retry timeout to default + mRetryInterval = StaticPrefs::network_trr_retry_timeout_ms(); SetState(CONFIRM_OK); mTask = nullptr; break; @@ -879,7 +884,7 @@ bool TRRService::ConfirmationContext::HandleEvent(ConfirmationEvent aEvent, SetState(CONFIRM_FAILED); mTask = nullptr; // retry failed NS confirmation - + LOG(("Setting timer to reconfirm %u", uint32_t(mRetryInterval))); NS_NewTimerWithCallback(getter_AddRefs(mTimer), this, mRetryInterval, nsITimer::TYPE_ONE_SHOT); // double the interval up to this point diff --git a/netwerk/dns/nsHostResolver.cpp b/netwerk/dns/nsHostResolver.cpp @@ -1381,6 +1381,9 @@ bool nsHostResolver::MaybeRetryTRRLookup( MOZ_ASSERT(!aAddrRec->mResolving); if (!StaticPrefs::network_trr_retry_on_recoverable_errors()) { LOG(("nsHostResolver::MaybeRetryTRRLookup retrying with native")); + + // Trigger a confirmation retry, in order to cycle connection if needed + TRRService::Get()->RetryTRRConfirm(); return NS_SUCCEEDED(NativeLookup(aAddrRec, aLock)); }