Bug 1686421 - Add probes to understand how HTTPS RR is used r=necko-reviewers,dragana

Differential Revision: https://phabricator.services.mozilla.com/D101631
This commit is contained in:
Kershaw Chang 2021-02-09 09:11:45 +00:00
Родитель 1db98eae92
Коммит 3555325696
3 изменённых файлов: 61 добавлений и 5 удалений

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

@ -627,7 +627,7 @@ nsresult nsHttpChannel::MaybeUseHTTPSRRForUpgrade(bool aShouldUpgrade,
this)); this));
StoreWaitHTTPSSVCRecord(false); StoreWaitHTTPSSVCRecord(false);
bool hasHTTPSRR = (mHTTPSSVCRecord.ref() != nullptr); bool hasHTTPSRR = (mHTTPSSVCRecord.ref() != nullptr);
return ContinueOnBeforeConnect(hasHTTPSRR, aStatus); return ContinueOnBeforeConnect(hasHTTPSRR, aStatus, hasHTTPSRR);
} }
LOG(("nsHttpChannel::MaybeUseHTTPSRRForUpgrade [%p] wait for HTTPS RR", LOG(("nsHttpChannel::MaybeUseHTTPSRRForUpgrade [%p] wait for HTTPS RR",
@ -637,7 +637,8 @@ nsresult nsHttpChannel::MaybeUseHTTPSRRForUpgrade(bool aShouldUpgrade,
} }
nsresult nsHttpChannel::ContinueOnBeforeConnect(bool aShouldUpgrade, nsresult nsHttpChannel::ContinueOnBeforeConnect(bool aShouldUpgrade,
nsresult aStatus) { nsresult aStatus,
bool aUpgradeWithHTTPSRR) {
LOG( LOG(
("nsHttpChannel::ContinueOnBeforeConnect " ("nsHttpChannel::ContinueOnBeforeConnect "
"[this=%p aShouldUpgrade=%d rv=%" PRIx32 "]\n", "[this=%p aShouldUpgrade=%d rv=%" PRIx32 "]\n",
@ -650,6 +651,8 @@ nsresult nsHttpChannel::ContinueOnBeforeConnect(bool aShouldUpgrade,
} }
if (aShouldUpgrade) { if (aShouldUpgrade) {
Telemetry::Accumulate(Telemetry::HTTPS_UPGRADE_WITH_HTTPS_RR,
aUpgradeWithHTTPSRR);
return AsyncCall(&nsHttpChannel::HandleAsyncRedirectChannelToHttps); return AsyncCall(&nsHttpChannel::HandleAsyncRedirectChannelToHttps);
} }
@ -7563,6 +7566,26 @@ nsresult nsHttpChannel::ContinueOnStartRequest4(nsresult result) {
return CallOnStartRequest(); return CallOnStartRequest();
} }
static void ReportHTTPSRRTelemetry(
const Maybe<nsCOMPtr<nsIDNSHTTPSSVCRecord>>& aMaybeRecord) {
bool hasHTTPSRR = aMaybeRecord && (aMaybeRecord.ref() != nullptr);
Telemetry::Accumulate(Telemetry::HTTPS_RR_PRESENTED, hasHTTPSRR);
if (!hasHTTPSRR) {
return;
}
const nsCOMPtr<nsIDNSHTTPSSVCRecord>& record = aMaybeRecord.ref();
nsCOMPtr<nsISVCBRecord> svcbRecord;
if (NS_SUCCEEDED(record->GetServiceModeRecord(false, false,
getter_AddRefs(svcbRecord)))) {
MOZ_ASSERT(svcbRecord);
Maybe<Tuple<nsCString, bool>> alpn = svcbRecord->GetAlpn();
bool isHttp3 = alpn ? Get<1>(*alpn) : false;
Telemetry::Accumulate(Telemetry::HTTPS_RR_WITH_HTTP3_PRESENTED, isHttp3);
}
}
NS_IMETHODIMP NS_IMETHODIMP
nsHttpChannel::OnStopRequest(nsIRequest* request, nsresult status) { nsHttpChannel::OnStopRequest(nsIRequest* request, nsresult status) {
AUTO_PROFILER_LABEL("nsHttpChannel::OnStopRequest", NETWORK); AUTO_PROFILER_LABEL("nsHttpChannel::OnStopRequest", NETWORK);
@ -7580,6 +7603,12 @@ nsHttpChannel::OnStopRequest(nsIRequest* request, nsresult status) {
return NS_OK; return NS_OK;
} }
// It's possible that LoadUseHTTPSSVC() is false, but we already have
// mHTTPSSVCRecord.
if (LoadUseHTTPSSVC() || mHTTPSSVCRecord) {
ReportHTTPSRRTelemetry(mHTTPSSVCRecord);
}
// If this load failed because of a security error, it may be because we // If this load failed because of a security error, it may be because we
// are in a captive portal - trigger an async check to make sure. // are in a captive portal - trigger an async check to make sure.
int32_t nsprError = -1 * NS_ERROR_GET_CODE(status); int32_t nsprError = -1 * NS_ERROR_GET_CODE(status);
@ -9000,7 +9029,7 @@ void nsHttpChannel::OnHTTPSRRAvailable(nsIDNSHTTPSSVCRecord* aRecord) {
MOZ_ASSERT(mURI->SchemeIs("http")); MOZ_ASSERT(mURI->SchemeIs("http"));
StoreWaitHTTPSSVCRecord(false); StoreWaitHTTPSSVCRecord(false);
nsresult rv = ContinueOnBeforeConnect(!!httprr, mStatus); nsresult rv = ContinueOnBeforeConnect(!!httprr, mStatus, !!httprr);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
CloseCacheEntry(false); CloseCacheEntry(false);
Unused << AsyncAbort(rv); Unused << AsyncAbort(rv);

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

@ -332,8 +332,8 @@ class nsHttpChannel final : public HttpBaseChannel,
[[nodiscard]] nsresult PrepareToConnect(); [[nodiscard]] nsresult PrepareToConnect();
void HandleOnBeforeConnect(); void HandleOnBeforeConnect();
[[nodiscard]] nsresult OnBeforeConnect(); [[nodiscard]] nsresult OnBeforeConnect();
[[nodiscard]] nsresult ContinueOnBeforeConnect(bool aShouldUpgrade, [[nodiscard]] nsresult ContinueOnBeforeConnect(
nsresult aStatus); bool aShouldUpgrade, nsresult aStatus, bool aUpgradeWithHTTPSRR = false);
nsresult MaybeUseHTTPSRRForUpgrade(bool aShouldUpgrade, nsresult aStatus); nsresult MaybeUseHTTPSRRForUpgrade(bool aShouldUpgrade, nsresult aStatus);
void OnHTTPSRRAvailable(nsIDNSHTTPSSVCRecord* aRecord); void OnHTTPSRRAvailable(nsIDNSHTTPSSVCRecord* aRecord);
void OnBeforeConnectContinue(); void OnBeforeConnectContinue();

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

@ -16455,5 +16455,32 @@
"description": "TLS handshake with and without EchConfig success rate.", "description": "TLS handshake with and without EchConfig success rate.",
"alert_emails": ["necko@mozilla.com", "kershaw@mozilla.com"], "alert_emails": ["necko@mozilla.com", "kershaw@mozilla.com"],
"bug_numbers": [1682555] "bug_numbers": [1682555]
},
"HTTPS_RR_PRESENTED": {
"record_in_processes": ["main"],
"products": ["firefox"],
"alert_emails": ["necko@mozilla.com", "kershaw@mozilla.com"],
"bug_numbers": [1686421],
"expires_in_version": "never",
"kind": "boolean",
"description": "HTTPS RR is presented or not."
},
"HTTPS_RR_WITH_HTTP3_PRESENTED": {
"record_in_processes": ["main"],
"products": ["firefox"],
"alert_emails": ["necko@mozilla.com", "kershaw@mozilla.com"],
"bug_numbers": [1686421],
"expires_in_version": "never",
"kind": "boolean",
"description": "Whether an HTTPS RR indicates that HTTP3 should be used."
},
"HTTPS_UPGRADE_WITH_HTTPS_RR": {
"record_in_processes": ["main"],
"products": ["firefox"],
"alert_emails": ["necko@mozilla.com", "kershaw@mozilla.com"],
"bug_numbers": [1686421],
"expires_in_version": "never",
"kind": "boolean",
"description": "Whether an HTTP request gets upgraded to HTTPS because HTTPS RR is presented"
} }
} }