Skip to content

Commit

Permalink
Disable fallback path to WebRTC platform sockets
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=235402

Reviewed by Eric Carlson.

We should not fallback to the legacy WebRTC socket code path in Cocoa ports.
Instead, if we cannot create the corresponding sockets (in case of ssltcp candidates for instance),
we mark the socket as closed.
Minor refactoring to show that NetworkRTCUDPSocketCocoa code path should always be successful.

Manually tested on meet.google.com which can make use of ssltcp candidates.

* NetworkProcess/webrtc/NetworkRTCProvider.cpp:
* NetworkProcess/webrtc/NetworkRTCProvider.h:
* NetworkProcess/webrtc/NetworkRTCTCPSocketCocoa.mm:
* NetworkProcess/webrtc/NetworkRTCUDPSocketCocoa.mm:



Canonical link: https://commits.webkit.org/246218@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288296 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
youennf committed Jan 20, 2022
1 parent 976a8df commit 8897fde
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 17 deletions.
19 changes: 19 additions & 0 deletions Source/WebKit/ChangeLog
@@ -1,3 +1,22 @@
2022-01-20 Youenn Fablet <youenn@apple.com>

Disable fallback path to WebRTC platform sockets
https://bugs.webkit.org/show_bug.cgi?id=235402

Reviewed by Eric Carlson.

We should not fallback to the legacy WebRTC socket code path in Cocoa ports.
Instead, if we cannot create the corresponding sockets (in case of ssltcp candidates for instance),
we mark the socket as closed.
Minor refactoring to show that NetworkRTCUDPSocketCocoa code path should always be successful.

Manually tested on meet.google.com which can make use of ssltcp candidates.

* NetworkProcess/webrtc/NetworkRTCProvider.cpp:
* NetworkProcess/webrtc/NetworkRTCProvider.h:
* NetworkProcess/webrtc/NetworkRTCTCPSocketCocoa.mm:
* NetworkProcess/webrtc/NetworkRTCUDPSocketCocoa.mm:

2022-01-20 Elliott Williams <emw@apple.com>

Prevent empty folders being created during install builds
Expand Down
24 changes: 15 additions & 9 deletions Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp
Expand Up @@ -168,10 +168,9 @@ void NetworkRTCProvider::createUDPSocket(LibWebRTCSocketIdentifier identifier, c

#if PLATFORM(COCOA)
if (m_platformUDPSocketsEnabled) {
if (auto socket = NetworkRTCUDPSocketCocoa::createUDPSocket(identifier, *this, address.value, minPort, maxPort, m_ipcConnection.copyRef(), String(attributedBundleIdentifierFromPageIdentifier(pageIdentifier)), isFirstParty, isRelayDisabled, WTFMove(domain))) {
addSocket(identifier, WTFMove(socket));
return;
}
auto socket = makeUnique<NetworkRTCUDPSocketCocoa>(identifier, *this, address.value, m_ipcConnection.copyRef(), String(attributedBundleIdentifierFromPageIdentifier(pageIdentifier)), isFirstParty, isRelayDisabled, WTFMove(domain));
addSocket(identifier, WTFMove(socket));
return;
}
#endif

Expand All @@ -187,7 +186,7 @@ void NetworkRTCProvider::createServerTCPSocket(LibWebRTCSocketIdentifier identif
return;

if (!m_isListeningSocketAuthorized) {
m_connection->connection().send(Messages::LibWebRTCNetwork::SignalClose(identifier, 1), 0);
signalSocketIsClosed(identifier);
return;
}

Expand All @@ -211,10 +210,12 @@ void NetworkRTCProvider::createClientTCPSocket(LibWebRTCSocketIdentifier identif

#if PLATFORM(COCOA)
if (m_platformTCPSocketsEnabled) {
if (auto socket = NetworkRTCTCPSocketCocoa::createClientTCPSocket(identifier, *this, remoteAddress.value, options, attributedBundleIdentifierFromPageIdentifier(pageIdentifier), isFirstParty, isRelayDisabled, domain, m_ipcConnection.copyRef())) {
auto socket = NetworkRTCTCPSocketCocoa::createClientTCPSocket(identifier, *this, remoteAddress.value, options, attributedBundleIdentifierFromPageIdentifier(pageIdentifier), isFirstParty, isRelayDisabled, domain, m_ipcConnection.copyRef());
if (socket)
addSocket(identifier, WTFMove(socket));
return;
}
else
signalSocketIsClosed(identifier);
return;
}
#endif

Expand All @@ -224,7 +225,7 @@ void NetworkRTCProvider::createClientTCPSocket(LibWebRTCSocketIdentifier identif

auto* session = m_connection->networkSession();
if (!session) {
m_connection->connection().send(Messages::LibWebRTCNetwork::SignalClose(identifier, 1), 0);
signalSocketIsClosed(identifier);
return;
}
callOnRTCNetworkThread([this, identifier, localAddress = RTCNetwork::isolatedCopy(localAddress.value), remoteAddress = RTCNetwork::isolatedCopy(remoteAddress.value), proxyInfo = proxyInfoFromSession(remoteAddress, *session), userAgent = WTFMove(userAgent).isolatedCopy(), options]() mutable {
Expand Down Expand Up @@ -429,6 +430,11 @@ void NetworkRTCProvider::callOnRTCNetworkThread(Function<void()>&& callback)
m_rtcNetworkThread.Post(RTC_FROM_HERE, this, 1, new NetworkMessageData(*this, WTFMove(callback)));
}

void NetworkRTCProvider::signalSocketIsClosed(LibWebRTCSocketIdentifier identifier)
{
m_connection->connection().send(Messages::LibWebRTCNetwork::SignalClose(identifier, 1), 0);
}

#undef RTC_RELEASE_LOG
#undef RTC_RELEASE_LOG_ERROR

Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.h
Expand Up @@ -149,6 +149,7 @@ class NetworkRTCProvider : public rtc::MessageHandler, public IPC::Connection::T
#if PLATFORM(COCOA)
const String& attributedBundleIdentifierFromPageIdentifier(WebPageProxyIdentifier);
#endif
void signalSocketIsClosed(WebCore::LibWebRTCSocketIdentifier);

static constexpr size_t maxSockets { 256 };

Expand Down
Expand Up @@ -53,9 +53,7 @@ static dispatch_queue_t tcpSocketQueue()

std::unique_ptr<NetworkRTCProvider::Socket> NetworkRTCTCPSocketCocoa::createClientTCPSocket(LibWebRTCSocketIdentifier identifier, NetworkRTCProvider& rtcProvider, const rtc::SocketAddress& remoteAddress, int tcpOptions, const String& attributedBundleIdentifier, bool isFirstParty, bool isRelayDisabled, const WebCore::RegistrableDomain& domain, Ref<IPC::Connection>&& connection)
{
// FIXME: We should migrate ssltcp candidates, maybe support OPT_TLS_INSECURE as well.
if ((tcpOptions & rtc::PacketSocketFactory::OPT_TLS_FAKE) || (tcpOptions & rtc::PacketSocketFactory::OPT_TLS_INSECURE))
return nullptr;
// FIXME: We should support ssltcp candidates, maybe support OPT_TLS_INSECURE as well.
return makeUnique<NetworkRTCTCPSocketCocoa>(identifier, rtcProvider, remoteAddress, tcpOptions, attributedBundleIdentifier, isFirstParty, isRelayDisabled, domain, WTFMove(connection));
}

Expand Down
Expand Up @@ -102,11 +102,6 @@ static dispatch_queue_t udpSocketQueue()
return queue;
}

std::unique_ptr<NetworkRTCProvider::Socket> NetworkRTCUDPSocketCocoa::createUDPSocket(WebCore::LibWebRTCSocketIdentifier identifier, NetworkRTCProvider& rtcProvider, const rtc::SocketAddress& address, uint16_t minPort, uint16_t maxPort, Ref<IPC::Connection>&& connection, String&& attributedBundleIdentifier, bool isFirstParty, bool isRelayDisabled, const WebCore::RegistrableDomain& domain)
{
return makeUnique<NetworkRTCUDPSocketCocoa>(identifier, rtcProvider, address, WTFMove(connection), WTFMove(attributedBundleIdentifier), isFirstParty, isRelayDisabled, domain);
}

NetworkRTCUDPSocketCocoa::NetworkRTCUDPSocketCocoa(WebCore::LibWebRTCSocketIdentifier identifier, NetworkRTCProvider& rtcProvider, const rtc::SocketAddress& address, Ref<IPC::Connection>&& connection, String&& attributedBundleIdentifier, bool isFirstParty, bool isRelayDisabled, const WebCore::RegistrableDomain& domain)
: m_rtcProvider(rtcProvider)
, m_identifier(identifier)
Expand Down

0 comments on commit 8897fde

Please sign in to comment.