mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1689987 - P4: Add a telemetry probe to collect channel success rate when ODoH is used r=necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D105214
This commit is contained in:
parent
9795f890cc
commit
36d1df148d
@ -44,6 +44,7 @@ already_AddRefed<ChildDNSService> ChildDNSService::GetSingleton() {
|
||||
return nullptr;
|
||||
}
|
||||
gChildDNSService = new ChildDNSService();
|
||||
gChildDNSService->Init();
|
||||
ClearOnShutdown(&gChildDNSService);
|
||||
}
|
||||
|
||||
@ -53,9 +54,7 @@ already_AddRefed<ChildDNSService> ChildDNSService::GetSingleton() {
|
||||
NS_IMPL_ISUPPORTS(ChildDNSService, nsIDNSService, nsPIDNSService, nsIObserver)
|
||||
|
||||
ChildDNSService::ChildDNSService()
|
||||
: mFirstTime(true),
|
||||
mDisablePrefetch(false),
|
||||
mPendingRequestsLock("DNSPendingRequestsLock") {
|
||||
: mPendingRequestsLock("DNSPendingRequestsLock") {
|
||||
MOZ_ASSERT_IF(nsIOService::UseSocketProcess(),
|
||||
XRE_IsContentProcess() || XRE_IsParentProcess());
|
||||
MOZ_ASSERT_IF(!nsIOService::UseSocketProcess(),
|
||||
@ -332,6 +331,14 @@ ChildDNSService::GetMyHostName(nsACString& result) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ChildDNSService::GetODoHActivated(bool* aResult) {
|
||||
NS_ENSURE_ARG(aResult);
|
||||
|
||||
*aResult = mODoHActivated;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void ChildDNSService::NotifyRequestDone(DNSRequestSender* aDnsRequest) {
|
||||
// We need the original flags and listener for the pending requests hash.
|
||||
uint32_t originalFlags = aDnsRequest->mFlags & ~RESOLVE_OFFLINE;
|
||||
@ -385,6 +392,12 @@ nsresult ChildDNSService::Init() {
|
||||
// If a manual proxy is in use, disable prefetch implicitly
|
||||
prefs->AddObserver("network.proxy.type", this, false);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
if (observerService) {
|
||||
observerService->AddObserver(this, "odoh-service-activated", false);
|
||||
}
|
||||
}
|
||||
|
||||
mDisablePrefetch =
|
||||
@ -433,12 +446,13 @@ ChildDNSService::ResetExcludedSVCDomainName(const nsACString& aOwnerName) {
|
||||
NS_IMETHODIMP
|
||||
ChildDNSService::Observe(nsISupports* subject, const char* topic,
|
||||
const char16_t* data) {
|
||||
// we are only getting called if a preference has changed.
|
||||
NS_ASSERTION(strcmp(topic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) == 0,
|
||||
"unexpected observe call");
|
||||
if (!strcmp(topic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
|
||||
// Reread prefs
|
||||
Init();
|
||||
} else if (!strcmp(topic, "odoh-service-activated")) {
|
||||
mODoHActivated = u"true"_ns.Equals(data);
|
||||
}
|
||||
|
||||
// Reread prefs
|
||||
Init();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -53,8 +53,9 @@ class ChildDNSService final : public nsPIDNSService, public nsIObserver {
|
||||
nsIDNSResolverInfo* aResolver, nsIDNSListener* aListener,
|
||||
nsresult aReason, const OriginAttributes& aOriginAttributes);
|
||||
|
||||
bool mFirstTime;
|
||||
bool mDisablePrefetch;
|
||||
bool mFirstTime = true;
|
||||
bool mDisablePrefetch = false;
|
||||
bool mODoHActivated = false;
|
||||
|
||||
// We need to remember pending dns requests to be able to cancel them.
|
||||
nsClassHashtable<nsCStringHashKey, nsTArray<RefPtr<DNSRequestSender>>>
|
||||
|
@ -5,11 +5,13 @@
|
||||
|
||||
#include "ODoHService.h"
|
||||
|
||||
#include "mozilla/net/SocketProcessChild.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/StaticPrefs_network.h"
|
||||
#include "nsIDNSService.h"
|
||||
#include "nsIDNSByTypeRecord.h"
|
||||
#include "nsIOService.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "ODoH.h"
|
||||
#include "TRRService.h"
|
||||
#include "nsURLHelper.h"
|
||||
@ -241,6 +243,31 @@ ODoHService::OnLookupComplete(nsICancelable* aRequest, nsIDNSRecord* aRec,
|
||||
mODoHConfigs.reset();
|
||||
mODoHConfigs.emplace(std::move(configs));
|
||||
|
||||
// Let observers know whether ODoHService is activated or not.
|
||||
bool hasODoHConfigs = !mODoHConfigs->IsEmpty();
|
||||
auto task = [hasODoHConfigs]() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (XRE_IsSocketProcess()) {
|
||||
SocketProcessChild::GetSingleton()->SendODoHServiceActivated(
|
||||
hasODoHConfigs);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
|
||||
if (observerService) {
|
||||
observerService->NotifyObservers(nullptr, "odoh-service-activated",
|
||||
hasODoHConfigs ? u"true" : u"false");
|
||||
}
|
||||
};
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
task();
|
||||
} else {
|
||||
NS_DispatchToMainThread(
|
||||
NS_NewRunnableFunction("ODoHService::Activated", std::move(task)));
|
||||
}
|
||||
|
||||
if (!mPendingRequests.IsEmpty()) {
|
||||
nsTArray<RefPtr<ODoH>> requests = std::move(mPendingRequests);
|
||||
nsCOMPtr<nsIEventTarget> target = gTRRService->MainThreadOrTRRThread();
|
||||
|
@ -777,6 +777,7 @@ nsDNSService::Init() {
|
||||
observerService->AddObserver(this, "last-pb-context-exited", false);
|
||||
observerService->AddObserver(this, NS_NETWORK_LINK_TOPIC, false);
|
||||
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
||||
observerService->AddObserver(this, "odoh-service-activated", false);
|
||||
}
|
||||
|
||||
RefPtr<nsHostResolver> res;
|
||||
@ -1242,6 +1243,14 @@ nsDNSService::GetMyHostName(nsACString& result) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDNSService::GetODoHActivated(bool* aResult) {
|
||||
NS_ENSURE_ARG(aResult);
|
||||
|
||||
*aResult = mODoHActivated;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDNSService::Observe(nsISupports* subject, const char* topic,
|
||||
const char16_t* data) {
|
||||
@ -1262,6 +1271,8 @@ nsDNSService::Observe(nsISupports* subject, const char* topic,
|
||||
}
|
||||
} else if (!strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
|
||||
Shutdown();
|
||||
} else if (!strcmp(topic, "odoh-service-activated")) {
|
||||
mODoHActivated = u"true"_ns.Equals(data);
|
||||
}
|
||||
|
||||
if (flushCache && mResolver) {
|
||||
|
@ -103,6 +103,7 @@ class nsDNSService final : public nsPIDNSService,
|
||||
uint32_t mResCacheExpiration;
|
||||
uint32_t mResCacheGrace;
|
||||
bool mResolverPrefsUpdated;
|
||||
bool mODoHActivated = false;
|
||||
nsClassHashtable<nsCStringHashKey, nsTArray<nsCString>> mFailedSVCDomainNames;
|
||||
};
|
||||
|
||||
|
@ -243,6 +243,12 @@ interface nsIDNSService : nsISupports
|
||||
*/
|
||||
readonly attribute AUTF8String myHostName;
|
||||
|
||||
/**
|
||||
* Returns true when we have valid ODoHConfigs to encrypt/decrypt oblivious
|
||||
* DNS packets.
|
||||
*/
|
||||
readonly attribute boolean ODoHActivated;
|
||||
|
||||
/*************************************************************************
|
||||
* Listed below are the various flags that may be OR'd together to form
|
||||
* the aFlags parameter passed to asyncResolve() and resolve().
|
||||
|
@ -128,6 +128,7 @@ parent:
|
||||
OriginAttributes aOriginAttributes,
|
||||
nsCString aRequestString)
|
||||
returns (bool aAccepted);
|
||||
async ODoHServiceActivated(bool aActivated);
|
||||
|
||||
child:
|
||||
async Init(SocketPorcessInitAttributes aAttributes);
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "mozilla/TelemetryIPC.h"
|
||||
#include "nsIAppStartup.h"
|
||||
#include "nsIHttpActivityObserver.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsNSSIOLayer.h"
|
||||
#include "PSMIPCCommon.h"
|
||||
#include "secerr.h"
|
||||
@ -425,5 +426,17 @@ SocketProcessParent::RecvPRemoteLazyInputStreamConstructor(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult SocketProcessParent::RecvODoHServiceActivated(
|
||||
const bool& aActivated) {
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
|
||||
if (observerService) {
|
||||
observerService->NotifyObservers(nullptr, "odoh-service-activated",
|
||||
aActivated ? u"true" : u"false");
|
||||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
@ -119,6 +119,8 @@ class SocketProcessParent final
|
||||
PRemoteLazyInputStreamParent* aActor, const nsID& aID,
|
||||
const uint64_t& aSize);
|
||||
|
||||
mozilla::ipc::IPCResult RecvODoHServiceActivated(const bool& aActivated);
|
||||
|
||||
private:
|
||||
SocketProcessHost* mHost;
|
||||
UniquePtr<dom::MemoryReportRequestHost> mMemoryReportRequest;
|
||||
|
@ -7312,7 +7312,17 @@ nsHttpChannel::OnStartRequest(nsIRequest* request) {
|
||||
NS_SUCCEEDED(mStatus));
|
||||
}
|
||||
|
||||
if (gTRRService && gTRRService->IsConfirmed()) {
|
||||
if (StaticPrefs::network_trr_odoh_enabled()) {
|
||||
nsCOMPtr<nsIDNSService> dns = do_GetService(NS_DNSSERVICE_CONTRACTID);
|
||||
bool ODoHActivated = false;
|
||||
if (dns && NS_SUCCEEDED(dns->GetODoHActivated(&ODoHActivated)) &&
|
||||
ODoHActivated) {
|
||||
Telemetry::Accumulate(Telemetry::HTTP_CHANNEL_ONSTART_SUCCESS_ODOH,
|
||||
NS_SUCCEEDED(mStatus));
|
||||
}
|
||||
} else if (gTRRService && gTRRService->IsConfirmed()) {
|
||||
// Note this telemetry probe is not working when DNS resolution is done in
|
||||
// the socket process.
|
||||
Telemetry::Accumulate(Telemetry::HTTP_CHANNEL_ONSTART_SUCCESS_TRR,
|
||||
TRRService::AutoDetectedKey(), NS_SUCCEEDED(mStatus));
|
||||
}
|
||||
|
@ -171,6 +171,7 @@ add_task(async function testODoHQueryA() {
|
||||
inRecord.QueryInterface(Ci.nsIDNSAddrRecord);
|
||||
let answer = inRecord.getNextAddrAsString();
|
||||
Assert.equal(answer, expectedIP);
|
||||
Assert.ok(dns.ODoHActivated);
|
||||
});
|
||||
|
||||
add_task(async function testODoHQueryAAAA() {
|
||||
@ -199,4 +200,5 @@ add_task(async function testODoHQueryAAAA() {
|
||||
inRecord.QueryInterface(Ci.nsIDNSAddrRecord);
|
||||
let answer = inRecord.getNextAddrAsString();
|
||||
Assert.equal(answer, expectedIP);
|
||||
Assert.ok(dns.ODoHActivated);
|
||||
});
|
||||
|
@ -3159,6 +3159,15 @@
|
||||
"bug_numbers": [1682552],
|
||||
"alert_emails": ["necko@mozilla.com", "kershaw@mozilla.com"]
|
||||
},
|
||||
"HTTP_CHANNEL_ONSTART_SUCCESS_ODOH" : {
|
||||
"record_in_processes": ["main"],
|
||||
"products": ["firefox"],
|
||||
"expires_in_version": "never",
|
||||
"kind": "boolean",
|
||||
"description": "Successfully started HTTP channels when ODoH is enabled",
|
||||
"bug_numbers": [1689987],
|
||||
"alert_emails": ["necko@mozilla.com", "kershaw@mozilla.com"]
|
||||
},
|
||||
"HTTP_CONNECTION_ENTRY_CACHE_HIT_1" : {
|
||||
"record_in_processes": ["main", "content"],
|
||||
"products": ["firefox", "fennec"],
|
||||
|
Loading…
Reference in New Issue
Block a user