Bug 1727173 - Make h3/h2 excluded list synced between socket process and parent process, r=necko-reviewers,dragana

Differential Revision: https://phabricator.services.mozilla.com/D123376
This commit is contained in:
Kershaw Chang 2021-09-03 20:14:39 +00:00
Родитель ed29500ab4
Коммит 95f5b8933d
7 изменённых файлов: 74 добавлений и 21 удалений

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

@ -134,6 +134,8 @@ parent:
returns (bool aAccepted);
async ODoHServiceActivated(bool aActivated);
async ExcludeHttp2OrHttp3(HttpConnectionInfoCloneArgs aArgs);
child:
async Init(SocketPorcessInitAttributes aAttributes);
async PreferenceUpdate(Pref pref);

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

@ -439,5 +439,22 @@ mozilla::ipc::IPCResult SocketProcessParent::RecvODoHServiceActivated(
return IPC_OK();
}
mozilla::ipc::IPCResult SocketProcessParent::RecvExcludeHttp2OrHttp3(
const HttpConnectionInfoCloneArgs& aArgs) {
RefPtr<nsHttpConnectionInfo> cinfo =
nsHttpConnectionInfo::DeserializeHttpConnectionInfoCloneArgs(aArgs);
if (!cinfo) {
MOZ_ASSERT(false, "failed to deserizlize http connection info");
return IPC_OK();
}
if (cinfo->IsHttp3()) {
gHttpHandler->ExcludeHttp3(cinfo);
} else {
gHttpHandler->ExcludeHttp2(cinfo);
}
return IPC_OK();
}
} // namespace net
} // namespace mozilla

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

@ -121,6 +121,9 @@ class SocketProcessParent final
mozilla::ipc::IPCResult RecvODoHServiceActivated(const bool& aActivated);
mozilla::ipc::IPCResult RecvExcludeHttp2OrHttp3(
const HttpConnectionInfoCloneArgs& aArgs);
private:
SocketProcessHost* mHost;
UniquePtr<dom::MemoryReportRequestHost> mMemoryReportRequest;

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

@ -240,11 +240,11 @@ nsresult HttpConnectionMgrParent::VerifyTraffic() {
}
void HttpConnectionMgrParent::ExcludeHttp2(const nsHttpConnectionInfo* ci) {
MOZ_ASSERT_UNREACHABLE("ExcludeHttp2 should not be called");
// Do nothing.
}
void HttpConnectionMgrParent::ExcludeHttp3(const nsHttpConnectionInfo* ci) {
MOZ_ASSERT_UNREACHABLE("ExcludeHttp3 should not be called");
// Do nothing.
}
nsresult HttpConnectionMgrParent::ClearConnectionHistory() {

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

@ -64,6 +64,7 @@
#include "mozilla/net/NeckoParent.h"
#include "mozilla/net/RequestContextService.h"
#include "mozilla/net/SocketProcessParent.h"
#include "mozilla/net/SocketProcessChild.h"
#include "mozilla/ipc/URIUtils.h"
#include "mozilla/Telemetry.h"
#include "mozilla/Unused.h"
@ -2650,14 +2651,48 @@ bool nsHttpHandler::IsBeforeLastActiveTabLoadOptimization(
when <= mLastActiveTabLoadOptimizationHit;
}
void nsHttpHandler::ExcludeHttp2(const nsHttpConnectionInfo* ci) {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
void nsHttpHandler::ExcludeHttp2OrHttp3Internal(
const nsHttpConnectionInfo* ci) {
LOG(("nsHttpHandler::ExcludeHttp2OrHttp3Internal ci=%s",
ci->HashKey().get()));
// The excluded list needs to be stayed synced between parent process and
// socket process, so we send this information to the parent process here.
if (XRE_IsSocketProcess()) {
MOZ_ASSERT(OnSocketThread());
mConnMgr->ExcludeHttp2(ci);
if (!mExcludedHttp2Origins.Contains(ci->GetOrigin())) {
MutexAutoLock lock(mHttpExclusionLock);
mExcludedHttp2Origins.Insert(ci->GetOrigin());
RefPtr<nsHttpConnectionInfo> cinfo = ci->Clone();
NS_DispatchToMainThread(NS_NewRunnableFunction(
"nsHttpHandler::ExcludeHttp2OrHttp3Internal",
[cinfo{std::move(cinfo)}]() {
HttpConnectionInfoCloneArgs connInfoArgs;
nsHttpConnectionInfo::SerializeHttpConnectionInfo(cinfo,
connInfoArgs);
Unused << SocketProcessChild::GetSingleton()->SendExcludeHttp2OrHttp3(
connInfoArgs);
}));
}
MOZ_ASSERT_IF(nsIOService::UseSocketProcess() && XRE_IsParentProcess(),
NS_IsMainThread());
MOZ_ASSERT_IF(!nsIOService::UseSocketProcess(), OnSocketThread());
if (ci->IsHttp3()) {
if (!mExcludedHttp3Origins.Contains(ci->GetRoutedHost())) {
MutexAutoLock lock(mHttpExclusionLock);
mExcludedHttp3Origins.Insert(ci->GetRoutedHost());
}
mConnMgr->ExcludeHttp3(ci);
} else {
if (!mExcludedHttp2Origins.Contains(ci->GetOrigin())) {
MutexAutoLock lock(mHttpExclusionLock);
mExcludedHttp2Origins.Insert(ci->GetOrigin());
}
mConnMgr->ExcludeHttp2(ci);
}
}
void nsHttpHandler::ExcludeHttp2(const nsHttpConnectionInfo* ci) {
ExcludeHttp2OrHttp3Internal(ci);
}
bool nsHttpHandler::IsHttp2Excluded(const nsHttpConnectionInfo* ci) {
@ -2666,13 +2701,8 @@ bool nsHttpHandler::IsHttp2Excluded(const nsHttpConnectionInfo* ci) {
}
void nsHttpHandler::ExcludeHttp3(const nsHttpConnectionInfo* ci) {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
if (!mExcludedHttp3Origins.Contains(ci->GetRoutedHost())) {
MutexAutoLock lock(mHttpExclusionLock);
mExcludedHttp3Origins.Insert(ci->GetRoutedHost());
}
mConnMgr->ExcludeHttp3(ci);
MOZ_ASSERT(ci->IsHttp3());
ExcludeHttp2OrHttp3Internal(ci);
}
bool nsHttpHandler::IsHttp3Excluded(const nsACString& aRoutedHost) {

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

@ -802,6 +802,7 @@ class nsHttpHandler final : public nsIHttpProtocolHandler,
[[nodiscard]] nsresult SpeculativeConnectInternal(
nsIURI* aURI, nsIPrincipal* aPrincipal, nsIInterfaceRequestor* aCallbacks,
bool anonymous);
void ExcludeHttp2OrHttp3Internal(const nsHttpConnectionInfo* ci);
// State for generating channelIds
uint32_t mProcessId{0};

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

@ -479,18 +479,18 @@ skip-if =
os =='android'
run-sequentially = http3server
[test_http3_fatal_stream_error.js]
skip-if = tsan || os =='android' || socketprocess_networking
skip-if = tsan || os =='android'
run-sequentially = node server exceptions dont replay well
[test_http3_large_post.js]
skip-if = tsan || os == 'win' || os =='android'
[test_http3_error_before_connect.js]
skip-if = tsan || os =='android' || socketprocess_networking
skip-if = tsan || os =='android'
run-sequentially = node server exceptions dont replay well
[test_http3_server_not_existing.js]
skip-if = tsan || os =='android' || socketprocess_networking
skip-if = tsan || os =='android'
run-sequentially = node server exceptions dont replay well
[test_http3_fast_fallback.js]
skip-if = tsan || os == 'win' || os =='android' || socketprocess_networking
skip-if = tsan || os == 'win' || os =='android'
run-sequentially = node server exceptions dont replay well
[test_cookie_ipv6.js]
[test_httpssvc_retry_with_ech.js]
@ -519,7 +519,7 @@ skip-if =
socketprocess_networking # server on a local ipv6 is not started on mac
run-sequentially = node server exceptions dont replay well
[test_http3_version1.js]
skip-if = tsan || os == 'win' || os =='android' || socketprocess_networking
skip-if = tsan || os == 'win' || os =='android'
[test_trr_domain.js]
[test_http3_progress.js]
skip-if = tsan || os == 'win' || os =='android'
@ -535,5 +535,5 @@ skip-if = tsan || os =='android' || (verify && (os == 'win')) || socketprocess_n
run-sequentially = node server exceptions dont replay well
[test_304_headers.js]
[test_http3_direct_proxy.js]
skip-if = tsan || os =='android' || socketprocess_networking
skip-if = tsan || os =='android'
run-sequentially = node server exceptions dont replay well