Commit 6cd55a88 authored by Lambros Lambrou's avatar Lambros Lambrou Committed by Commit Bot

[remoting host] Allow route-changes to have invalid IP addresses.

WebRTC sometimes provides selected-candidate-changed notifications with
invalid IP addresses. The host process normally records these in the
system event log, but only if both IPs are valid. With this CL,
route-change events are generated even if the local or peer IP address
is invalid. These appear in the event log as "unknown".

Bug: 1128667
Change-Id: I9329092bdb7f7e4cf6d845303f321bff3eb3177b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2485576
Commit-Queue: Lambros Lambrou <lambroslambrou@chromium.org>
Commit-Queue: Jamie Walch <jamiewalch@chromium.org>
Auto-Submit: Lambros Lambrou <lambroslambrou@chromium.org>
Reviewed-by: default avatarJamie Walch <jamiewalch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818770}
parent 0c2c26be
...@@ -88,8 +88,14 @@ void HostEventLoggerPosix::OnClientRouteChange( ...@@ -88,8 +88,14 @@ void HostEventLoggerPosix::OnClientRouteChange(
Log(base::StringPrintf( Log(base::StringPrintf(
"Channel IP for client: %s ip='%s' host_ip='%s' channel='%s' " "Channel IP for client: %s ip='%s' host_ip='%s' channel='%s' "
"connection='%s'", "connection='%s'",
jid.c_str(), route.remote_address.ToString().c_str(), jid.c_str(),
route.local_address.ToString().c_str(), channel_name.c_str(), route.remote_address.address().IsValid()
? route.remote_address.ToString().c_str()
: "unknown",
route.local_address.address().IsValid()
? route.local_address.ToString().c_str()
: "unknown",
channel_name.c_str(),
protocol::TransportRoute::GetTypeString(route.type).c_str())); protocol::TransportRoute::GetTypeString(route.type).c_str()));
} }
......
...@@ -96,8 +96,12 @@ void HostEventLoggerWin::OnClientRouteChange( ...@@ -96,8 +96,12 @@ void HostEventLoggerWin::OnClientRouteChange(
const protocol::TransportRoute& route) { const protocol::TransportRoute& route) {
std::vector<std::string> strings(5); std::vector<std::string> strings(5);
strings[0] = jid; strings[0] = jid;
strings[1] = route.remote_address.ToString(); strings[1] = route.remote_address.address().IsValid()
strings[2] = route.local_address.ToString(); ? route.remote_address.ToString()
: "unknown";
strings[2] = route.local_address.address().IsValid()
? route.local_address.ToString()
: "unknown";
strings[3] = channel_name; strings[3] = channel_name;
strings[4] = protocol::TransportRoute::GetTypeString(route.type); strings[4] = protocol::TransportRoute::GetTypeString(route.type);
Log(EVENTLOG_INFORMATION_TYPE, MSG_HOST_CLIENT_ROUTING_CHANGED, strings); Log(EVENTLOG_INFORMATION_TYPE, MSG_HOST_CLIENT_ROUTING_CHANGED, strings);
......
...@@ -58,10 +58,19 @@ void IpcHostEventLogger::OnClientRouteChange( ...@@ -58,10 +58,19 @@ void IpcHostEventLogger::OnClientRouteChange(
SerializedTransportRoute serialized_route; SerializedTransportRoute serialized_route;
serialized_route.type = route.type; serialized_route.type = route.type;
serialized_route.remote_ip =
route.remote_address.address().CopyBytesToVector(); // If the remote (or local) IP address is invalid, send it over IPC as an
// empty vector. The receiving process has a CHECK() that the address is
// either valid or empty.
if (route.remote_address.address().IsValid()) {
serialized_route.remote_ip =
route.remote_address.address().CopyBytesToVector();
}
serialized_route.remote_port = route.remote_address.port(); serialized_route.remote_port = route.remote_address.port();
serialized_route.local_ip = route.local_address.address().CopyBytesToVector(); if (route.local_address.address().IsValid()) {
serialized_route.local_ip =
route.local_address.address().CopyBytesToVector();
}
serialized_route.local_port = route.local_address.port(); serialized_route.local_port = route.local_address.port();
daemon_channel_->Send(new ChromotingNetworkDaemonMsg_ClientRouteChange( daemon_channel_->Send(new ChromotingNetworkDaemonMsg_ClientRouteChange(
jid, channel_name, serialized_route)); jid, channel_name, serialized_route));
......
...@@ -1076,15 +1076,18 @@ void WebrtcTransport::OnIceSelectedCandidatePairChanged( ...@@ -1076,15 +1076,18 @@ void WebrtcTransport::OnIceSelectedCandidatePairChanged(
VLOG(0) << " Remote IP = " << remote_candidate.address().ToString() VLOG(0) << " Remote IP = " << remote_candidate.address().ToString()
<< ", type = " << remote_candidate.type() << ", type = " << remote_candidate.type()
<< ", protocol = " << remote_candidate.protocol(); << ", protocol = " << remote_candidate.protocol();
// Try to convert local and peer addresses. These may sometimes be invalid,
// for example, a "relay" or "prflx" candidate from a relay connection
// might have the IP address stripped away by WebRTC - see
// http://crbug.com/1128667.
if (!jingle_glue::SocketAddressToIPEndPoint(remote_candidate.address(), if (!jingle_glue::SocketAddressToIPEndPoint(remote_candidate.address(),
&route.remote_address)) { &route.remote_address)) {
LOG(ERROR) << "Failed to convert peer IP address."; VLOG(0) << "Peer IP address is invalid.";
return;
} }
if (!jingle_glue::SocketAddressToIPEndPoint(local_candidate.address(), if (!jingle_glue::SocketAddressToIPEndPoint(local_candidate.address(),
&route.local_address)) { &route.local_address)) {
LOG(ERROR) << "Failed to convert local IP address."; VLOG(0) << "Local IP address is invalid.";
return;
} }
VLOG(0) << "Sending route-changed notification."; VLOG(0) << "Sending route-changed notification.";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment