webrtc_m130/p2p/client/basic_port_allocator.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

1719 lines
61 KiB
C++
Raw Normal View History

/*
* Copyright 2004 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "p2p/client/basic_port_allocator.h"
#include <algorithm>
#include <functional>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "absl/algorithm/container.h"
#include "absl/memory/memory.h"
#include "p2p/base/basic_packet_socket_factory.h"
#include "p2p/base/port.h"
#include "p2p/base/stun_port.h"
#include "p2p/base/tcp_port.h"
#include "p2p/base/turn_port.h"
#include "p2p/base/udp_port.h"
#include "rtc_base/checks.h"
#include "rtc_base/helpers.h"
#include "rtc_base/logging.h"
#include "rtc_base/task_utils/to_queued_task.h"
#include "rtc_base/trace_event.h"
#include "system_wrappers/include/field_trial.h"
Reland "Reland "Replace the usage of MetricsObserverInterface by RTC_HISTOGRAM_*."" This is a reland of 1a2cc0acba6a66f89249455d8e5775849b56f755 Original change's description: > Reland "Replace the usage of MetricsObserverInterface by RTC_HISTOGRAM_*." > > This is a reland of 870bca1f418a1abf445169a638a61f9a649d557f > > Original change's description: > > Replace the usage of MetricsObserverInterface by RTC_HISTOGRAM_*. > > > > We now use RTC_HISTOGRAM_* macros in system_wrappers/include/metrics.h > > to report the metrics in pc/ and p2p/ that are currently been reported > > using MetricsObserverInterface. > > > > TBR=tommi@webrtc.org > > > > Bug: webrtc:9409 > > Change-Id: I47c9975402293c72250203fa1ec19eb1668766f6 > > Reviewed-on: https://webrtc-review.googlesource.com/83782 > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > > Reviewed-by: Taylor (left Google) <deadbeef@webrtc.org> > > Reviewed-by: Steve Anton <steveanton@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#23914} > > TBR=steveanton@webrtc.org,hta@webrtc.org,tommi@webrtc.org > > Bug: webrtc:9409 > Change-Id: I37fc95ced60dea25aa9b4f5ad44bdf7174c8bd5c > Reviewed-on: https://webrtc-review.googlesource.com/88060 > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > Commit-Queue: Qingsi Wang <qingsi@google.com> > Cr-Commit-Position: refs/heads/master@{#23919} TBR=steveanton@webrtc.org,tommi@webrtc.org Bug: webrtc:9409 Change-Id: Ib55f0b6c9bcb9d9585924a4dfac5cf643ff4d76b Reviewed-on: https://webrtc-review.googlesource.com/88343 Commit-Queue: Qingsi Wang <qingsi@google.com> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23957}
2018-07-12 12:54:53 -07:00
#include "system_wrappers/include/metrics.h"
using rtc::CreateRandomId;
Reland "Surface ICE candidates that match an updated candidate filter." This is a reland of cd8d1cf68e4eeed71fba51c97006a91bfd41813d Original change's description: > Surface ICE candidates that match an updated candidate filter. > > After this change an ICE agent can surface candidates that do not match > the previous filter but are allowed by the updated one. The candidate > filter, as part of the internal implementation in the ICE transport, > manifests the RTCIceTransportPolicy field in RTCConfiguration. > > This new feature would allow an ICE agent to gather new candidates when > the transport policy changes from e.g. 'relay' to 'all' without an ICE > restart. > > A caveat in the current implementation remains, and a candidate can > surface multiple times if the transport policy, or the candidate filter > directly, performs multiple transitions from a value that disallows to > one that allows the underlying candidate type. For example, if the > transport policy is updated by 'all' -> 'relay' -> 'all', the same host > candidate can surface after the second update. > > > Bug: webrtc:8939 > Change-Id: I92c2e07dafab225c702c5de28f47958a0d3270cc > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132282 > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> > Reviewed-by: Seth Hampson <shampson@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27674} Bug: webrtc:8939 Change-Id: I9c32b1ea05028ecd937ab4912779dd958faf734f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133582 Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27694}
2019-04-18 10:41:58 -07:00
namespace cricket {
namespace {
const int PHASE_UDP = 0;
const int PHASE_RELAY = 1;
const int PHASE_TCP = 2;
const int kNumPhases = 3;
// Gets protocol priority: UDP > TCP > SSLTCP == TLS.
int GetProtocolPriority(cricket::ProtocolType protocol) {
switch (protocol) {
case cricket::PROTO_UDP:
return 2;
case cricket::PROTO_TCP:
return 1;
case cricket::PROTO_SSLTCP:
case cricket::PROTO_TLS:
return 0;
default:
RTC_NOTREACHED();
return 0;
}
}
// Gets address family priority: IPv6 > IPv4 > Unspecified.
int GetAddressFamilyPriority(int ip_family) {
switch (ip_family) {
case AF_INET6:
return 2;
case AF_INET:
return 1;
default:
RTC_NOTREACHED();
return 0;
}
}
// Returns positive if a is better, negative if b is better, and 0 otherwise.
int ComparePort(const cricket::Port* a, const cricket::Port* b) {
int a_protocol = GetProtocolPriority(a->GetProtocol());
int b_protocol = GetProtocolPriority(b->GetProtocol());
int cmp_protocol = a_protocol - b_protocol;
if (cmp_protocol != 0) {
return cmp_protocol;
}
int a_family = GetAddressFamilyPriority(a->Network()->GetBestIP().family());
int b_family = GetAddressFamilyPriority(b->Network()->GetBestIP().family());
return a_family - b_family;
}
struct NetworkFilter {
using Predicate = std::function<bool(rtc::Network*)>;
NetworkFilter(Predicate pred, const std::string& description)
: predRemain([pred](rtc::Network* network) { return !pred(network); }),
description(description) {}
Predicate predRemain;
const std::string description;
};
using NetworkList = rtc::NetworkManager::NetworkList;
void FilterNetworks(NetworkList* networks, NetworkFilter filter) {
auto start_to_remove =
std::partition(networks->begin(), networks->end(), filter.predRemain);
if (start_to_remove == networks->end()) {
return;
}
RTC_LOG(INFO) << "Filtered out " << filter.description << " networks:";
for (auto it = start_to_remove; it != networks->end(); ++it) {
RTC_LOG(INFO) << (*it)->ToString();
}
networks->erase(start_to_remove, networks->end());
}
Reland "Surface ICE candidates that match an updated candidate filter." This is a reland of cd8d1cf68e4eeed71fba51c97006a91bfd41813d Original change's description: > Surface ICE candidates that match an updated candidate filter. > > After this change an ICE agent can surface candidates that do not match > the previous filter but are allowed by the updated one. The candidate > filter, as part of the internal implementation in the ICE transport, > manifests the RTCIceTransportPolicy field in RTCConfiguration. > > This new feature would allow an ICE agent to gather new candidates when > the transport policy changes from e.g. 'relay' to 'all' without an ICE > restart. > > A caveat in the current implementation remains, and a candidate can > surface multiple times if the transport policy, or the candidate filter > directly, performs multiple transitions from a value that disallows to > one that allows the underlying candidate type. For example, if the > transport policy is updated by 'all' -> 'relay' -> 'all', the same host > candidate can surface after the second update. > > > Bug: webrtc:8939 > Change-Id: I92c2e07dafab225c702c5de28f47958a0d3270cc > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132282 > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> > Reviewed-by: Seth Hampson <shampson@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27674} Bug: webrtc:8939 Change-Id: I9c32b1ea05028ecd937ab4912779dd958faf734f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133582 Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27694}
2019-04-18 10:41:58 -07:00
bool IsAllowedByCandidateFilter(const Candidate& c, uint32_t filter) {
// When binding to any address, before sending packets out, the getsockname
// returns all 0s, but after sending packets, it'll be the NIC used to
// send. All 0s is not a valid ICE candidate address and should be filtered
// out.
if (c.address().IsAnyIP()) {
return false;
}
if (c.type() == RELAY_PORT_TYPE) {
return ((filter & CF_RELAY) != 0);
} else if (c.type() == STUN_PORT_TYPE) {
return ((filter & CF_REFLEXIVE) != 0);
} else if (c.type() == LOCAL_PORT_TYPE) {
if ((filter & CF_REFLEXIVE) && !c.address().IsPrivateIP()) {
// We allow host candidates if the filter allows server-reflexive
// candidates and the candidate is a public IP. Because we don't generate
// server-reflexive candidates if they have the same IP as the host
// candidate (i.e. when the host candidate is a public IP), filtering to
// only server-reflexive candidates won't work right when the host
// candidates have public IPs.
return true;
}
return ((filter & CF_HOST) != 0);
}
return false;
}
} // namespace
const uint32_t DISABLE_ALL_PHASES =
PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_TCP |
PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY;
// BasicPortAllocator
BasicPortAllocator::BasicPortAllocator(
rtc::NetworkManager* network_manager,
rtc::PacketSocketFactory* socket_factory,
webrtc::TurnCustomizer* customizer,
RelayPortFactoryInterface* relay_port_factory)
Revert of Add logging of host lookups made by TurnPort to the RtcEventLog. (patchset #11 id:200001 of https://codereview.webrtc.org/2996933003/ ) Reason for revert: Breaks Chromium build due to the changed constructor in webrtc/p2p/client/basicportallocator.h. Build (example): https://build.chromium.org/p/chromium.webrtc.fyi/builders/Linux%20Builder/builds/19739. Log: FAILED: obj/remoting/protocol/protocol/port_allocator.o /b/c/goma_client/gomacc ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/remoting/protocol/protocol/port_allocator.o.d -DV8_DEPRECATION_WARNINGS -DUSE_UDEV -DUSE_AURA=1 -DUSE_PANGO=1 -DUSE_CAIRO=1 -DUSE_GLIB=1 -DUSE_NSS_CERTS=1 -DUSE_X11=1 -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -DFIELDTRIAL_TESTING_ENABLED -DCR_CLANG_REVISION=\"310694-2\" -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DCOMPONENT_BUILD -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DWTF_USE_DYNAMIC_ANNOTATIONS=1 -D_GLIBCXX_DEBUG=1 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26 -DEXPAT_RELATIVE_PATH -DGL_GLEXT_PROTOTYPES -DUSE_GLX -DUSE_EGL -DGOOGLE_PROTOBUF_NO_RTTI -DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER -DHAVE_PTHREAD -DPROTOBUF_USE_DLLS -DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0 -DFEATURE_ENABLE_VOICEMAIL -DGTEST_RELATIVE_PATH -DWEBRTC_CHROMIUM_BUILD -DWEBRTC_POSIX -DWEBRTC_LINUX -DBORINGSSL_SHARED_LIBRARY -I../.. -Igen -I../../build/linux/debian_jessie_amd64-sysroot/usr/include/glib-2.0 -I../../build/linux/debian_jessie_amd64-sysroot/usr/lib/x86_64-linux-gnu/glib-2.0/include -I../../third_party/libwebp/src -I../../third_party/khronos -I../../gpu -I../../third_party/protobuf/src -Igen/protoc_out -I../../third_party/protobuf/src -I../../third_party/webrtc_overrides -I../../testing/gtest/include -I../../third_party -I../../third_party/webrtc_overrides -I../../third_party -I../../third_party/boringssl/src/include -I../../build/linux/debian_jessie_amd64-sysroot/usr/include/nss -I../../build/linux/debian_jessie_amd64-sysroot/usr/include/nspr -I../../third_party/libyuv/include -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -funwind-tables -fPIC -pipe -B../../third_party/binutils/Linux_x64/Release/bin -pthread -fcolor-diagnostics -fdebug-prefix-map=/b/c/b/Linux_Builder__dbg_/src=. -m64 -march=x86-64 -Wall -Werror -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-covered-switch-default -Wno-unneeded-internal-declaration -Wno-inconsistent-missing-override -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-address-of-packed-member -Wno-unused-lambda-capture -Wno-user-defined-warnings -Wno-enum-compare-switch -O0 -fno-omit-frame-pointer -g2 -gsplit-dwarf -fvisibility=hidden -Xclang -load -Xclang ../../third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.so -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang check-auto-raw-pointer -Xclang -plugin-arg-find-bad-constructs -Xclang check-ipc -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wexit-time-destructors -Wno-header-guard -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -std=gnu++14 -fno-rtti -nostdinc++ -isystem../../buildtools/third_party/libc++/trunk/include -isystem../../buildtools/third_party/libc++abi/trunk/include --sysroot=../../build/linux/debian_jessie_amd64-sysroot -fno-exceptions -fvisibility-inlines-hidden -c ../../remoting/protocol/port_allocator.cc -o obj/remoting/protocol/protocol/port_allocator.o ../../remoting/protocol/port_allocator.cc:48:7: error: no matching constructor for initialization of 'cricket::BasicPortAllocator' : BasicPortAllocator(network_manager.get(), socket_factory.get()), ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../third_party/webrtc/p2p/client/basicportallocator.h:35:12: note: candidate constructor not viable: requires single argument 'network_manager', but 2 arguments were provided explicit BasicPortAllocator(rtc::NetworkManager* network_manager); ^ ../../third_party/webrtc/p2p/client/basicportallocator.h:30:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided class BasicPortAllocator : public PortAllocator { ^ ../../third_party/webrtc/p2p/client/basicportallocator.h:32:3: note: candidate constructor not viable: requires 3 arguments, but 2 were provided BasicPortAllocator(rtc::NetworkManager* network_manager, ^ ../../third_party/webrtc/p2p/client/basicportallocator.h:36:3: note: candidate constructor not viable: requires 3 arguments, but 2 were provided BasicPortAllocator(rtc::NetworkManager* network_manager, ^ ../../third_party/webrtc/p2p/client/basicportallocator.h:39:3: note: candidate constructor not viable: requires 5 arguments, but 2 were provided BasicPortAllocator(rtc::NetworkManager* network_manager, ^ 1 error generated. Original issue's description: > Add logging host lookups made by TurnPort to the RtcEventLog. > > The following fields are logged: > - error, if there was an error. > - elapsed time in milliseconds > > BUG=webrtc:8100 > > Review-Url: https://codereview.webrtc.org/2996933003 > Cr-Commit-Position: refs/heads/master@{#19574} > Committed: https://chromium.googlesource.com/external/webrtc/+/c251cb13c08aba710ba3a12588beb4aa172c7323 TBR=terelius@webrtc.org,pthatcher@webrtc.org,jonaso@google.com,pthatcher@google.com,solenberg@webrtc.org,deadbeef@webrtc.org,jonaso@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:8100 Review-Url: https://codereview.webrtc.org/3012473002 Cr-Commit-Position: refs/heads/master@{#19578}
2017-08-29 04:49:00 -07:00
: network_manager_(network_manager), socket_factory_(socket_factory) {
InitRelayPortFactory(relay_port_factory);
RTC_DCHECK(relay_port_factory_ != nullptr);
RTC_DCHECK(network_manager_ != nullptr);
RTC_DCHECK(socket_factory_ != nullptr);
SetConfiguration(ServerAddresses(), std::vector<RelayServerConfig>(), 0,
webrtc::NO_PRUNE, customizer);
}
BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager)
Revert of Add logging of host lookups made by TurnPort to the RtcEventLog. (patchset #11 id:200001 of https://codereview.webrtc.org/2996933003/ ) Reason for revert: Breaks Chromium build due to the changed constructor in webrtc/p2p/client/basicportallocator.h. Build (example): https://build.chromium.org/p/chromium.webrtc.fyi/builders/Linux%20Builder/builds/19739. Log: FAILED: obj/remoting/protocol/protocol/port_allocator.o /b/c/goma_client/gomacc ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/remoting/protocol/protocol/port_allocator.o.d -DV8_DEPRECATION_WARNINGS -DUSE_UDEV -DUSE_AURA=1 -DUSE_PANGO=1 -DUSE_CAIRO=1 -DUSE_GLIB=1 -DUSE_NSS_CERTS=1 -DUSE_X11=1 -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -DFIELDTRIAL_TESTING_ENABLED -DCR_CLANG_REVISION=\"310694-2\" -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DCOMPONENT_BUILD -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DWTF_USE_DYNAMIC_ANNOTATIONS=1 -D_GLIBCXX_DEBUG=1 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26 -DEXPAT_RELATIVE_PATH -DGL_GLEXT_PROTOTYPES -DUSE_GLX -DUSE_EGL -DGOOGLE_PROTOBUF_NO_RTTI -DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER -DHAVE_PTHREAD -DPROTOBUF_USE_DLLS -DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0 -DFEATURE_ENABLE_VOICEMAIL -DGTEST_RELATIVE_PATH -DWEBRTC_CHROMIUM_BUILD -DWEBRTC_POSIX -DWEBRTC_LINUX -DBORINGSSL_SHARED_LIBRARY -I../.. -Igen -I../../build/linux/debian_jessie_amd64-sysroot/usr/include/glib-2.0 -I../../build/linux/debian_jessie_amd64-sysroot/usr/lib/x86_64-linux-gnu/glib-2.0/include -I../../third_party/libwebp/src -I../../third_party/khronos -I../../gpu -I../../third_party/protobuf/src -Igen/protoc_out -I../../third_party/protobuf/src -I../../third_party/webrtc_overrides -I../../testing/gtest/include -I../../third_party -I../../third_party/webrtc_overrides -I../../third_party -I../../third_party/boringssl/src/include -I../../build/linux/debian_jessie_amd64-sysroot/usr/include/nss -I../../build/linux/debian_jessie_amd64-sysroot/usr/include/nspr -I../../third_party/libyuv/include -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -funwind-tables -fPIC -pipe -B../../third_party/binutils/Linux_x64/Release/bin -pthread -fcolor-diagnostics -fdebug-prefix-map=/b/c/b/Linux_Builder__dbg_/src=. -m64 -march=x86-64 -Wall -Werror -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-covered-switch-default -Wno-unneeded-internal-declaration -Wno-inconsistent-missing-override -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-address-of-packed-member -Wno-unused-lambda-capture -Wno-user-defined-warnings -Wno-enum-compare-switch -O0 -fno-omit-frame-pointer -g2 -gsplit-dwarf -fvisibility=hidden -Xclang -load -Xclang ../../third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.so -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang check-auto-raw-pointer -Xclang -plugin-arg-find-bad-constructs -Xclang check-ipc -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wexit-time-destructors -Wno-header-guard -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -std=gnu++14 -fno-rtti -nostdinc++ -isystem../../buildtools/third_party/libc++/trunk/include -isystem../../buildtools/third_party/libc++abi/trunk/include --sysroot=../../build/linux/debian_jessie_amd64-sysroot -fno-exceptions -fvisibility-inlines-hidden -c ../../remoting/protocol/port_allocator.cc -o obj/remoting/protocol/protocol/port_allocator.o ../../remoting/protocol/port_allocator.cc:48:7: error: no matching constructor for initialization of 'cricket::BasicPortAllocator' : BasicPortAllocator(network_manager.get(), socket_factory.get()), ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../third_party/webrtc/p2p/client/basicportallocator.h:35:12: note: candidate constructor not viable: requires single argument 'network_manager', but 2 arguments were provided explicit BasicPortAllocator(rtc::NetworkManager* network_manager); ^ ../../third_party/webrtc/p2p/client/basicportallocator.h:30:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided class BasicPortAllocator : public PortAllocator { ^ ../../third_party/webrtc/p2p/client/basicportallocator.h:32:3: note: candidate constructor not viable: requires 3 arguments, but 2 were provided BasicPortAllocator(rtc::NetworkManager* network_manager, ^ ../../third_party/webrtc/p2p/client/basicportallocator.h:36:3: note: candidate constructor not viable: requires 3 arguments, but 2 were provided BasicPortAllocator(rtc::NetworkManager* network_manager, ^ ../../third_party/webrtc/p2p/client/basicportallocator.h:39:3: note: candidate constructor not viable: requires 5 arguments, but 2 were provided BasicPortAllocator(rtc::NetworkManager* network_manager, ^ 1 error generated. Original issue's description: > Add logging host lookups made by TurnPort to the RtcEventLog. > > The following fields are logged: > - error, if there was an error. > - elapsed time in milliseconds > > BUG=webrtc:8100 > > Review-Url: https://codereview.webrtc.org/2996933003 > Cr-Commit-Position: refs/heads/master@{#19574} > Committed: https://chromium.googlesource.com/external/webrtc/+/c251cb13c08aba710ba3a12588beb4aa172c7323 TBR=terelius@webrtc.org,pthatcher@webrtc.org,jonaso@google.com,pthatcher@google.com,solenberg@webrtc.org,deadbeef@webrtc.org,jonaso@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:8100 Review-Url: https://codereview.webrtc.org/3012473002 Cr-Commit-Position: refs/heads/master@{#19578}
2017-08-29 04:49:00 -07:00
: network_manager_(network_manager), socket_factory_(nullptr) {
InitRelayPortFactory(nullptr);
RTC_DCHECK(relay_port_factory_ != nullptr);
RTC_DCHECK(network_manager_ != nullptr);
}
BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager,
const ServerAddresses& stun_servers)
: BasicPortAllocator(network_manager,
/*socket_factory=*/nullptr,
stun_servers) {}
BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager,
rtc::PacketSocketFactory* socket_factory,
const ServerAddresses& stun_servers)
Revert of Add logging of host lookups made by TurnPort to the RtcEventLog. (patchset #11 id:200001 of https://codereview.webrtc.org/2996933003/ ) Reason for revert: Breaks Chromium build due to the changed constructor in webrtc/p2p/client/basicportallocator.h. Build (example): https://build.chromium.org/p/chromium.webrtc.fyi/builders/Linux%20Builder/builds/19739. Log: FAILED: obj/remoting/protocol/protocol/port_allocator.o /b/c/goma_client/gomacc ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/remoting/protocol/protocol/port_allocator.o.d -DV8_DEPRECATION_WARNINGS -DUSE_UDEV -DUSE_AURA=1 -DUSE_PANGO=1 -DUSE_CAIRO=1 -DUSE_GLIB=1 -DUSE_NSS_CERTS=1 -DUSE_X11=1 -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -DFIELDTRIAL_TESTING_ENABLED -DCR_CLANG_REVISION=\"310694-2\" -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DCOMPONENT_BUILD -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DWTF_USE_DYNAMIC_ANNOTATIONS=1 -D_GLIBCXX_DEBUG=1 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26 -DEXPAT_RELATIVE_PATH -DGL_GLEXT_PROTOTYPES -DUSE_GLX -DUSE_EGL -DGOOGLE_PROTOBUF_NO_RTTI -DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER -DHAVE_PTHREAD -DPROTOBUF_USE_DLLS -DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0 -DFEATURE_ENABLE_VOICEMAIL -DGTEST_RELATIVE_PATH -DWEBRTC_CHROMIUM_BUILD -DWEBRTC_POSIX -DWEBRTC_LINUX -DBORINGSSL_SHARED_LIBRARY -I../.. -Igen -I../../build/linux/debian_jessie_amd64-sysroot/usr/include/glib-2.0 -I../../build/linux/debian_jessie_amd64-sysroot/usr/lib/x86_64-linux-gnu/glib-2.0/include -I../../third_party/libwebp/src -I../../third_party/khronos -I../../gpu -I../../third_party/protobuf/src -Igen/protoc_out -I../../third_party/protobuf/src -I../../third_party/webrtc_overrides -I../../testing/gtest/include -I../../third_party -I../../third_party/webrtc_overrides -I../../third_party -I../../third_party/boringssl/src/include -I../../build/linux/debian_jessie_amd64-sysroot/usr/include/nss -I../../build/linux/debian_jessie_amd64-sysroot/usr/include/nspr -I../../third_party/libyuv/include -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -funwind-tables -fPIC -pipe -B../../third_party/binutils/Linux_x64/Release/bin -pthread -fcolor-diagnostics -fdebug-prefix-map=/b/c/b/Linux_Builder__dbg_/src=. -m64 -march=x86-64 -Wall -Werror -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-covered-switch-default -Wno-unneeded-internal-declaration -Wno-inconsistent-missing-override -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-address-of-packed-member -Wno-unused-lambda-capture -Wno-user-defined-warnings -Wno-enum-compare-switch -O0 -fno-omit-frame-pointer -g2 -gsplit-dwarf -fvisibility=hidden -Xclang -load -Xclang ../../third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.so -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang check-auto-raw-pointer -Xclang -plugin-arg-find-bad-constructs -Xclang check-ipc -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wexit-time-destructors -Wno-header-guard -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -std=gnu++14 -fno-rtti -nostdinc++ -isystem../../buildtools/third_party/libc++/trunk/include -isystem../../buildtools/third_party/libc++abi/trunk/include --sysroot=../../build/linux/debian_jessie_amd64-sysroot -fno-exceptions -fvisibility-inlines-hidden -c ../../remoting/protocol/port_allocator.cc -o obj/remoting/protocol/protocol/port_allocator.o ../../remoting/protocol/port_allocator.cc:48:7: error: no matching constructor for initialization of 'cricket::BasicPortAllocator' : BasicPortAllocator(network_manager.get(), socket_factory.get()), ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../third_party/webrtc/p2p/client/basicportallocator.h:35:12: note: candidate constructor not viable: requires single argument 'network_manager', but 2 arguments were provided explicit BasicPortAllocator(rtc::NetworkManager* network_manager); ^ ../../third_party/webrtc/p2p/client/basicportallocator.h:30:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided class BasicPortAllocator : public PortAllocator { ^ ../../third_party/webrtc/p2p/client/basicportallocator.h:32:3: note: candidate constructor not viable: requires 3 arguments, but 2 were provided BasicPortAllocator(rtc::NetworkManager* network_manager, ^ ../../third_party/webrtc/p2p/client/basicportallocator.h:36:3: note: candidate constructor not viable: requires 3 arguments, but 2 were provided BasicPortAllocator(rtc::NetworkManager* network_manager, ^ ../../third_party/webrtc/p2p/client/basicportallocator.h:39:3: note: candidate constructor not viable: requires 5 arguments, but 2 were provided BasicPortAllocator(rtc::NetworkManager* network_manager, ^ 1 error generated. Original issue's description: > Add logging host lookups made by TurnPort to the RtcEventLog. > > The following fields are logged: > - error, if there was an error. > - elapsed time in milliseconds > > BUG=webrtc:8100 > > Review-Url: https://codereview.webrtc.org/2996933003 > Cr-Commit-Position: refs/heads/master@{#19574} > Committed: https://chromium.googlesource.com/external/webrtc/+/c251cb13c08aba710ba3a12588beb4aa172c7323 TBR=terelius@webrtc.org,pthatcher@webrtc.org,jonaso@google.com,pthatcher@google.com,solenberg@webrtc.org,deadbeef@webrtc.org,jonaso@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:8100 Review-Url: https://codereview.webrtc.org/3012473002 Cr-Commit-Position: refs/heads/master@{#19578}
2017-08-29 04:49:00 -07:00
: network_manager_(network_manager), socket_factory_(socket_factory) {
InitRelayPortFactory(nullptr);
RTC_DCHECK(relay_port_factory_ != nullptr);
SetConfiguration(stun_servers, std::vector<RelayServerConfig>(), 0,
webrtc::NO_PRUNE, nullptr);
}
void BasicPortAllocator::OnIceRegathering(PortAllocatorSession* session,
IceRegatheringReason reason) {
// If the session has not been taken by an active channel, do not report the
// metric.
for (auto& allocator_session : pooled_sessions()) {
if (allocator_session.get() == session) {
return;
}
}
Reland "Reland "Replace the usage of MetricsObserverInterface by RTC_HISTOGRAM_*."" This is a reland of 1a2cc0acba6a66f89249455d8e5775849b56f755 Original change's description: > Reland "Replace the usage of MetricsObserverInterface by RTC_HISTOGRAM_*." > > This is a reland of 870bca1f418a1abf445169a638a61f9a649d557f > > Original change's description: > > Replace the usage of MetricsObserverInterface by RTC_HISTOGRAM_*. > > > > We now use RTC_HISTOGRAM_* macros in system_wrappers/include/metrics.h > > to report the metrics in pc/ and p2p/ that are currently been reported > > using MetricsObserverInterface. > > > > TBR=tommi@webrtc.org > > > > Bug: webrtc:9409 > > Change-Id: I47c9975402293c72250203fa1ec19eb1668766f6 > > Reviewed-on: https://webrtc-review.googlesource.com/83782 > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > > Reviewed-by: Taylor (left Google) <deadbeef@webrtc.org> > > Reviewed-by: Steve Anton <steveanton@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#23914} > > TBR=steveanton@webrtc.org,hta@webrtc.org,tommi@webrtc.org > > Bug: webrtc:9409 > Change-Id: I37fc95ced60dea25aa9b4f5ad44bdf7174c8bd5c > Reviewed-on: https://webrtc-review.googlesource.com/88060 > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > Commit-Queue: Qingsi Wang <qingsi@google.com> > Cr-Commit-Position: refs/heads/master@{#23919} TBR=steveanton@webrtc.org,tommi@webrtc.org Bug: webrtc:9409 Change-Id: Ib55f0b6c9bcb9d9585924a4dfac5cf643ff4d76b Reviewed-on: https://webrtc-review.googlesource.com/88343 Commit-Queue: Qingsi Wang <qingsi@google.com> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23957}
2018-07-12 12:54:53 -07:00
RTC_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.IceRegatheringReason",
static_cast<int>(reason),
static_cast<int>(IceRegatheringReason::MAX_VALUE));
}
BasicPortAllocator::~BasicPortAllocator() {
CheckRunOnValidThreadIfInitialized();
// Our created port allocator sessions depend on us, so destroy our remaining
// pooled sessions before anything else.
DiscardCandidatePool();
}
void BasicPortAllocator::SetNetworkIgnoreMask(int network_ignore_mask) {
// TODO(phoglund): implement support for other types than loopback.
// See https://code.google.com/p/webrtc/issues/detail?id=4288.
// Then remove set_network_ignore_list from NetworkManager.
CheckRunOnValidThreadIfInitialized();
network_ignore_mask_ = network_ignore_mask;
}
PortAllocatorSession* BasicPortAllocator::CreateSessionInternal(
const std::string& content_name,
int component,
const std::string& ice_ufrag,
const std::string& ice_pwd) {
CheckRunOnValidThreadAndInitialized();
PortAllocatorSession* session = new BasicPortAllocatorSession(
this, content_name, component, ice_ufrag, ice_pwd);
session->SignalIceRegathering.connect(this,
&BasicPortAllocator::OnIceRegathering);
return session;
}
void BasicPortAllocator::AddTurnServer(const RelayServerConfig& turn_server) {
CheckRunOnValidThreadAndInitialized();
std::vector<RelayServerConfig> new_turn_servers = turn_servers();
new_turn_servers.push_back(turn_server);
SetConfiguration(stun_servers(), new_turn_servers, candidate_pool_size(),
turn_port_prune_policy(), turn_customizer());
}
void BasicPortAllocator::InitRelayPortFactory(
RelayPortFactoryInterface* relay_port_factory) {
if (relay_port_factory != nullptr) {
relay_port_factory_ = relay_port_factory;
} else {
default_relay_port_factory_.reset(new TurnPortFactory());
relay_port_factory_ = default_relay_port_factory_.get();
}
}
// BasicPortAllocatorSession
BasicPortAllocatorSession::BasicPortAllocatorSession(
BasicPortAllocator* allocator,
const std::string& content_name,
int component,
const std::string& ice_ufrag,
const std::string& ice_pwd)
: PortAllocatorSession(content_name,
component,
ice_ufrag,
ice_pwd,
allocator->flags()),
allocator_(allocator),
network_thread_(rtc::Thread::Current()),
socket_factory_(allocator->socket_factory()),
allocation_started_(false),
network_manager_started_(false),
allocation_sequences_created_(false),
turn_port_prune_policy_(allocator->turn_port_prune_policy()) {
TRACE_EVENT0("webrtc",
"BasicPortAllocatorSession::BasicPortAllocatorSession");
allocator_->network_manager()->SignalNetworksChanged.connect(
this, &BasicPortAllocatorSession::OnNetworksChanged);
allocator_->network_manager()->StartUpdating();
}
BasicPortAllocatorSession::~BasicPortAllocatorSession() {
TRACE_EVENT0("webrtc",
"BasicPortAllocatorSession::~BasicPortAllocatorSession");
RTC_DCHECK_RUN_ON(network_thread_);
allocator_->network_manager()->StopUpdating();
for (uint32_t i = 0; i < sequences_.size(); ++i) {
// AllocationSequence should clear it's map entry for turn ports before
// ports are destroyed.
sequences_[i]->Clear();
}
std::vector<PortData>::iterator it;
for (it = ports_.begin(); it != ports_.end(); it++)
delete it->port();
configs_.clear();
for (uint32_t i = 0; i < sequences_.size(); ++i)
delete sequences_[i];
}
BasicPortAllocator* BasicPortAllocatorSession::allocator() {
RTC_DCHECK_RUN_ON(network_thread_);
return allocator_;
}
void BasicPortAllocatorSession::SetCandidateFilter(uint32_t filter) {
RTC_DCHECK_RUN_ON(network_thread_);
if (filter == candidate_filter_) {
return;
}
Reland "Surface ICE candidates that match an updated candidate filter." This is a reland of cd8d1cf68e4eeed71fba51c97006a91bfd41813d Original change's description: > Surface ICE candidates that match an updated candidate filter. > > After this change an ICE agent can surface candidates that do not match > the previous filter but are allowed by the updated one. The candidate > filter, as part of the internal implementation in the ICE transport, > manifests the RTCIceTransportPolicy field in RTCConfiguration. > > This new feature would allow an ICE agent to gather new candidates when > the transport policy changes from e.g. 'relay' to 'all' without an ICE > restart. > > A caveat in the current implementation remains, and a candidate can > surface multiple times if the transport policy, or the candidate filter > directly, performs multiple transitions from a value that disallows to > one that allows the underlying candidate type. For example, if the > transport policy is updated by 'all' -> 'relay' -> 'all', the same host > candidate can surface after the second update. > > > Bug: webrtc:8939 > Change-Id: I92c2e07dafab225c702c5de28f47958a0d3270cc > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132282 > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> > Reviewed-by: Seth Hampson <shampson@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27674} Bug: webrtc:8939 Change-Id: I9c32b1ea05028ecd937ab4912779dd958faf734f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133582 Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27694}
2019-04-18 10:41:58 -07:00
uint32_t prev_filter = candidate_filter_;
candidate_filter_ = filter;
Reland "Surface ICE candidates that match an updated candidate filter." This is a reland of cd8d1cf68e4eeed71fba51c97006a91bfd41813d Original change's description: > Surface ICE candidates that match an updated candidate filter. > > After this change an ICE agent can surface candidates that do not match > the previous filter but are allowed by the updated one. The candidate > filter, as part of the internal implementation in the ICE transport, > manifests the RTCIceTransportPolicy field in RTCConfiguration. > > This new feature would allow an ICE agent to gather new candidates when > the transport policy changes from e.g. 'relay' to 'all' without an ICE > restart. > > A caveat in the current implementation remains, and a candidate can > surface multiple times if the transport policy, or the candidate filter > directly, performs multiple transitions from a value that disallows to > one that allows the underlying candidate type. For example, if the > transport policy is updated by 'all' -> 'relay' -> 'all', the same host > candidate can surface after the second update. > > > Bug: webrtc:8939 > Change-Id: I92c2e07dafab225c702c5de28f47958a0d3270cc > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132282 > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> > Reviewed-by: Seth Hampson <shampson@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27674} Bug: webrtc:8939 Change-Id: I9c32b1ea05028ecd937ab4912779dd958faf734f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133582 Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27694}
2019-04-18 10:41:58 -07:00
for (PortData& port_data : ports_) {
if (port_data.error() || port_data.pruned()) {
continue;
}
Reland "Surface ICE candidates that match an updated candidate filter." This is a reland of cd8d1cf68e4eeed71fba51c97006a91bfd41813d Original change's description: > Surface ICE candidates that match an updated candidate filter. > > After this change an ICE agent can surface candidates that do not match > the previous filter but are allowed by the updated one. The candidate > filter, as part of the internal implementation in the ICE transport, > manifests the RTCIceTransportPolicy field in RTCConfiguration. > > This new feature would allow an ICE agent to gather new candidates when > the transport policy changes from e.g. 'relay' to 'all' without an ICE > restart. > > A caveat in the current implementation remains, and a candidate can > surface multiple times if the transport policy, or the candidate filter > directly, performs multiple transitions from a value that disallows to > one that allows the underlying candidate type. For example, if the > transport policy is updated by 'all' -> 'relay' -> 'all', the same host > candidate can surface after the second update. > > > Bug: webrtc:8939 > Change-Id: I92c2e07dafab225c702c5de28f47958a0d3270cc > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132282 > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> > Reviewed-by: Seth Hampson <shampson@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27674} Bug: webrtc:8939 Change-Id: I9c32b1ea05028ecd937ab4912779dd958faf734f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133582 Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27694}
2019-04-18 10:41:58 -07:00
PortData::State cur_state = port_data.state();
bool found_signalable_candidate = false;
bool found_pairable_candidate = false;
cricket::Port* port = port_data.port();
for (const auto& c : port->Candidates()) {
if (!IsStopped() && !IsAllowedByCandidateFilter(c, prev_filter) &&
IsAllowedByCandidateFilter(c, filter)) {
// This candidate was not signaled because of not matching the previous
// filter (see OnCandidateReady below). Let the Port to fire the signal
// again.
//
// Note that
// 1) we would need the Port to enter the state of in-progress of
// gathering to have candidates signaled;
//
// 2) firing the signal would also let the session set the port ready
// if needed, so that we could form candidate pairs with candidates
// from this port;
//
// * See again OnCandidateReady below for 1) and 2).
//
// 3) we only try to resurface candidates if we have not stopped
// getting ports, which is always true for the continual gathering.
if (!found_signalable_candidate) {
found_signalable_candidate = true;
port_data.set_state(PortData::STATE_INPROGRESS);
}
port->SignalCandidateReady(port, c);
}
if (CandidatePairable(c, port)) {
found_pairable_candidate = true;
}
}
// Restore the previous state.
port_data.set_state(cur_state);
// Setting a filter may cause a ready port to become non-ready
// if it no longer has any pairable candidates.
Reland "Surface ICE candidates that match an updated candidate filter." This is a reland of cd8d1cf68e4eeed71fba51c97006a91bfd41813d Original change's description: > Surface ICE candidates that match an updated candidate filter. > > After this change an ICE agent can surface candidates that do not match > the previous filter but are allowed by the updated one. The candidate > filter, as part of the internal implementation in the ICE transport, > manifests the RTCIceTransportPolicy field in RTCConfiguration. > > This new feature would allow an ICE agent to gather new candidates when > the transport policy changes from e.g. 'relay' to 'all' without an ICE > restart. > > A caveat in the current implementation remains, and a candidate can > surface multiple times if the transport policy, or the candidate filter > directly, performs multiple transitions from a value that disallows to > one that allows the underlying candidate type. For example, if the > transport policy is updated by 'all' -> 'relay' -> 'all', the same host > candidate can surface after the second update. > > > Bug: webrtc:8939 > Change-Id: I92c2e07dafab225c702c5de28f47958a0d3270cc > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132282 > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> > Reviewed-by: Seth Hampson <shampson@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27674} Bug: webrtc:8939 Change-Id: I9c32b1ea05028ecd937ab4912779dd958faf734f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133582 Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27694}
2019-04-18 10:41:58 -07:00
//
// Note that we only set for the negative case here, since a port would be
// set to have pairable candidates when it signals a ready candidate, which
// requires the port is still in the progress of gathering/surfacing
// candidates, and would be done in the firing of the signal above.
if (!found_pairable_candidate) {
port_data.set_has_pairable_candidate(false);
}
}
}
void BasicPortAllocatorSession::StartGettingPorts() {
RTC_DCHECK_RUN_ON(network_thread_);
state_ = SessionState::GATHERING;
if (!socket_factory_) {
owned_socket_factory_.reset(
new rtc::BasicPacketSocketFactory(network_thread_));
socket_factory_ = owned_socket_factory_.get();
}
network_thread_->PostTask(webrtc::ToQueuedTask(
network_safety_, [this] { GetPortConfigurations(); }));
RTC_LOG(LS_INFO) << "Start getting ports with turn_port_prune_policy "
<< turn_port_prune_policy_;
}
void BasicPortAllocatorSession::StopGettingPorts() {
RTC_DCHECK_RUN_ON(network_thread_);
ClearGettingPorts();
// Note: this must be called after ClearGettingPorts because both may set the
// session state and we should set the state to STOPPED.
state_ = SessionState::STOPPED;
}
void BasicPortAllocatorSession::ClearGettingPorts() {
RTC_DCHECK_RUN_ON(network_thread_);
++allocation_epoch_;
for (uint32_t i = 0; i < sequences_.size(); ++i) {
sequences_[i]->Stop();
}
network_thread_->PostTask(
webrtc::ToQueuedTask(network_safety_, [this] { OnConfigStop(); }));
state_ = SessionState::CLEARED;
}
bool BasicPortAllocatorSession::IsGettingPorts() {
RTC_DCHECK_RUN_ON(network_thread_);
return state_ == SessionState::GATHERING;
}
bool BasicPortAllocatorSession::IsCleared() const {
RTC_DCHECK_RUN_ON(network_thread_);
return state_ == SessionState::CLEARED;
}
bool BasicPortAllocatorSession::IsStopped() const {
RTC_DCHECK_RUN_ON(network_thread_);
return state_ == SessionState::STOPPED;
}
std::vector<rtc::Network*> BasicPortAllocatorSession::GetFailedNetworks() {
RTC_DCHECK_RUN_ON(network_thread_);
std::vector<rtc::Network*> networks = GetNetworks();
// A network interface may have both IPv4 and IPv6 networks. Only if
// neither of the networks has any connections, the network interface
// is considered failed and need to be regathered on.
std::set<std::string> networks_with_connection;
for (const PortData& data : ports_) {
Port* port = data.port();
if (!port->connections().empty()) {
networks_with_connection.insert(port->Network()->name());
}
}
networks.erase(
std::remove_if(networks.begin(), networks.end(),
[networks_with_connection](rtc::Network* network) {
// If a network does not have any connection, it is
// considered failed.
return networks_with_connection.find(network->name()) !=
networks_with_connection.end();
}),
networks.end());
return networks;
}
void BasicPortAllocatorSession::RegatherOnFailedNetworks() {
RTC_DCHECK_RUN_ON(network_thread_);
// Find the list of networks that have no connection.
std::vector<rtc::Network*> failed_networks = GetFailedNetworks();
if (failed_networks.empty()) {
return;
}
RTC_LOG(LS_INFO) << "Regather candidates on failed networks";
// Mark a sequence as "network failed" if its network is in the list of failed
// networks, so that it won't be considered as equivalent when the session
// regathers ports and candidates.
for (AllocationSequence* sequence : sequences_) {
if (!sequence->network_failed() &&
absl::c_linear_search(failed_networks, sequence->network())) {
sequence->set_network_failed();
}
}
bool disable_equivalent_phases = true;
Regather(failed_networks, disable_equivalent_phases,
IceRegatheringReason::NETWORK_FAILURE);
}
void BasicPortAllocatorSession::Regather(
const std::vector<rtc::Network*>& networks,
bool disable_equivalent_phases,
IceRegatheringReason reason) {
RTC_DCHECK_RUN_ON(network_thread_);
// Remove ports from being used locally and send signaling to remove
// the candidates on the remote side.
std::vector<PortData*> ports_to_prune = GetUnprunedPorts(networks);
if (!ports_to_prune.empty()) {
RTC_LOG(LS_INFO) << "Prune " << ports_to_prune.size() << " ports";
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
PrunePortsAndRemoveCandidates(ports_to_prune);
}
if (allocation_started_ && network_manager_started_ && !IsStopped()) {
SignalIceRegathering(this, reason);
DoAllocate(disable_equivalent_phases);
}
}
void BasicPortAllocatorSession::GetCandidateStatsFromReadyPorts(
CandidateStatsList* candidate_stats_list) const {
auto ports = ReadyPorts();
for (auto* port : ports) {
auto candidates = port->Candidates();
for (const auto& candidate : candidates) {
absl::optional<StunStats> stun_stats;
port->GetStunStats(&stun_stats);
CandidateStats candidate_stats(allocator_->SanitizeCandidate(candidate),
std::move(stun_stats));
candidate_stats_list->push_back(std::move(candidate_stats));
}
}
}
void BasicPortAllocatorSession::SetStunKeepaliveIntervalForReadyPorts(
const absl::optional<int>& stun_keepalive_interval) {
RTC_DCHECK_RUN_ON(network_thread_);
auto ports = ReadyPorts();
for (PortInterface* port : ports) {
// The port type and protocol can be used to identify different subclasses
// of Port in the current implementation. Note that a TCPPort has the type
// LOCAL_PORT_TYPE but uses the protocol PROTO_TCP.
if (port->Type() == STUN_PORT_TYPE ||
(port->Type() == LOCAL_PORT_TYPE && port->GetProtocol() == PROTO_UDP)) {
static_cast<UDPPort*>(port)->set_stun_keepalive_delay(
stun_keepalive_interval);
}
}
}
std::vector<PortInterface*> BasicPortAllocatorSession::ReadyPorts() const {
RTC_DCHECK_RUN_ON(network_thread_);
std::vector<PortInterface*> ret;
for (const PortData& data : ports_) {
if (data.ready()) {
ret.push_back(data.port());
}
}
return ret;
}
std::vector<Candidate> BasicPortAllocatorSession::ReadyCandidates() const {
RTC_DCHECK_RUN_ON(network_thread_);
std::vector<Candidate> candidates;
for (const PortData& data : ports_) {
if (!data.ready()) {
continue;
}
GetCandidatesFromPort(data, &candidates);
}
return candidates;
}
void BasicPortAllocatorSession::GetCandidatesFromPort(
const PortData& data,
std::vector<Candidate>* candidates) const {
RTC_DCHECK_RUN_ON(network_thread_);
RTC_CHECK(candidates != nullptr);
for (const Candidate& candidate : data.port()->Candidates()) {
if (!CheckCandidateFilter(candidate)) {
continue;
}
candidates->push_back(allocator_->SanitizeCandidate(candidate));
}
}
bool BasicPortAllocator::MdnsObfuscationEnabled() const {
return network_manager()->GetMdnsResponder() != nullptr;
}
bool BasicPortAllocatorSession::CandidatesAllocationDone() const {
RTC_DCHECK_RUN_ON(network_thread_);
// Done only if all required AllocationSequence objects
// are created.
if (!allocation_sequences_created_) {
return false;
}
// Check that all port allocation sequences are complete (not running).
if (absl::c_any_of(sequences_, [](const AllocationSequence* sequence) {
return sequence->state() == AllocationSequence::kRunning;
})) {
return false;
}
// If all allocated ports are no longer gathering, session must have got all
// expected candidates. Session will trigger candidates allocation complete
// signal.
return absl::c_none_of(
ports_, [](const PortData& port) { return port.inprogress(); });
}
void BasicPortAllocatorSession::UpdateIceParametersInternal() {
RTC_DCHECK_RUN_ON(network_thread_);
for (PortData& port : ports_) {
port.port()->set_content_name(content_name());
port.port()->SetIceParameters(component(), ice_ufrag(), ice_pwd());
}
}
void BasicPortAllocatorSession::GetPortConfigurations() {
RTC_DCHECK_RUN_ON(network_thread_);
Reland "Surface ICE candidates that match an updated candidate filter." This is a reland of cd8d1cf68e4eeed71fba51c97006a91bfd41813d Original change's description: > Surface ICE candidates that match an updated candidate filter. > > After this change an ICE agent can surface candidates that do not match > the previous filter but are allowed by the updated one. The candidate > filter, as part of the internal implementation in the ICE transport, > manifests the RTCIceTransportPolicy field in RTCConfiguration. > > This new feature would allow an ICE agent to gather new candidates when > the transport policy changes from e.g. 'relay' to 'all' without an ICE > restart. > > A caveat in the current implementation remains, and a candidate can > surface multiple times if the transport policy, or the candidate filter > directly, performs multiple transitions from a value that disallows to > one that allows the underlying candidate type. For example, if the > transport policy is updated by 'all' -> 'relay' -> 'all', the same host > candidate can surface after the second update. > > > Bug: webrtc:8939 > Change-Id: I92c2e07dafab225c702c5de28f47958a0d3270cc > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132282 > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> > Reviewed-by: Seth Hampson <shampson@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27674} Bug: webrtc:8939 Change-Id: I9c32b1ea05028ecd937ab4912779dd958faf734f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133582 Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27694}
2019-04-18 10:41:58 -07:00
auto config = std::make_unique<PortConfiguration>(allocator_->stun_servers(),
username(), password());
for (const RelayServerConfig& turn_server : allocator_->turn_servers()) {
config->AddRelay(turn_server);
}
ConfigReady(std::move(config));
}
void BasicPortAllocatorSession::ConfigReady(PortConfiguration* config) {
RTC_DCHECK_RUN_ON(network_thread_);
ConfigReady(absl::WrapUnique(config));
}
void BasicPortAllocatorSession::ConfigReady(
std::unique_ptr<PortConfiguration> config) {
RTC_DCHECK_RUN_ON(network_thread_);
network_thread_->PostTask(webrtc::ToQueuedTask(
network_safety_, [this, config = std::move(config)]() mutable {
OnConfigReady(std::move(config));
}));
}
// Adds a configuration to the list.
void BasicPortAllocatorSession::OnConfigReady(
std::unique_ptr<PortConfiguration> config) {
RTC_DCHECK_RUN_ON(network_thread_);
if (config)
configs_.push_back(std::move(config));
AllocatePorts();
}
void BasicPortAllocatorSession::OnConfigStop() {
RTC_DCHECK_RUN_ON(network_thread_);
// If any of the allocated ports have not completed the candidates allocation,
// mark those as error. Since session doesn't need any new candidates
// at this stage of the allocation, it's safe to discard any new candidates.
bool send_signal = false;
for (std::vector<PortData>::iterator it = ports_.begin(); it != ports_.end();
++it) {
if (it->inprogress()) {
// Updating port state to error, which didn't finish allocating candidates
// yet.
Reland "Surface ICE candidates that match an updated candidate filter." This is a reland of cd8d1cf68e4eeed71fba51c97006a91bfd41813d Original change's description: > Surface ICE candidates that match an updated candidate filter. > > After this change an ICE agent can surface candidates that do not match > the previous filter but are allowed by the updated one. The candidate > filter, as part of the internal implementation in the ICE transport, > manifests the RTCIceTransportPolicy field in RTCConfiguration. > > This new feature would allow an ICE agent to gather new candidates when > the transport policy changes from e.g. 'relay' to 'all' without an ICE > restart. > > A caveat in the current implementation remains, and a candidate can > surface multiple times if the transport policy, or the candidate filter > directly, performs multiple transitions from a value that disallows to > one that allows the underlying candidate type. For example, if the > transport policy is updated by 'all' -> 'relay' -> 'all', the same host > candidate can surface after the second update. > > > Bug: webrtc:8939 > Change-Id: I92c2e07dafab225c702c5de28f47958a0d3270cc > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132282 > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> > Reviewed-by: Seth Hampson <shampson@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27674} Bug: webrtc:8939 Change-Id: I9c32b1ea05028ecd937ab4912779dd958faf734f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133582 Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27694}
2019-04-18 10:41:58 -07:00
it->set_state(PortData::STATE_ERROR);
send_signal = true;
}
}
// Did we stop any running sequences?
for (std::vector<AllocationSequence*>::iterator it = sequences_.begin();
it != sequences_.end() && !send_signal; ++it) {
if ((*it)->state() == AllocationSequence::kStopped) {
send_signal = true;
}
}
// If we stopped anything that was running, send a done signal now.
if (send_signal) {
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
MaybeSignalCandidatesAllocationDone();
}
}
void BasicPortAllocatorSession::AllocatePorts() {
RTC_DCHECK_RUN_ON(network_thread_);
network_thread_->PostTask(webrtc::ToQueuedTask(
network_safety_, [this, allocation_epoch = allocation_epoch_] {
OnAllocate(allocation_epoch);
}));
}
void BasicPortAllocatorSession::OnAllocate(int allocation_epoch) {
RTC_DCHECK_RUN_ON(network_thread_);
if (allocation_epoch != allocation_epoch_)
return;
if (network_manager_started_ && !IsStopped()) {
bool disable_equivalent_phases = true;
DoAllocate(disable_equivalent_phases);
}
allocation_started_ = true;
}
std::vector<rtc::Network*> BasicPortAllocatorSession::GetNetworks() {
RTC_DCHECK_RUN_ON(network_thread_);
std::vector<rtc::Network*> networks;
rtc::NetworkManager* network_manager = allocator_->network_manager();
RTC_DCHECK(network_manager != nullptr);
// If the network permission state is BLOCKED, we just act as if the flag has
// been passed in.
if (network_manager->enumeration_permission() ==
rtc::NetworkManager::ENUMERATION_BLOCKED) {
set_flags(flags() | PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION);
}
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
// If the adapter enumeration is disabled, we'll just bind to any address
// instead of specific NIC. This is to ensure the same routing for http
// traffic by OS is also used here to avoid any local or public IP leakage
// during stun process.
if (flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) {
network_manager->GetAnyAddressNetworks(&networks);
} else {
network_manager->GetNetworks(&networks);
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
// If network enumeration fails, use the ANY address as a fallback, so we
// can at least try gathering candidates using the default route chosen by
// the OS. Or, if the PORTALLOCATOR_ENABLE_ANY_ADDRESS_PORTS flag is
// set, we'll use ANY address candidates either way.
if (networks.empty() || flags() & PORTALLOCATOR_ENABLE_ANY_ADDRESS_PORTS) {
network_manager->GetAnyAddressNetworks(&networks);
}
}
// Filter out link-local networks if needed.
if (flags() & PORTALLOCATOR_DISABLE_LINK_LOCAL_NETWORKS) {
NetworkFilter link_local_filter(
[](rtc::Network* network) { return IPIsLinkLocal(network->prefix()); },
"link-local");
FilterNetworks(&networks, link_local_filter);
}
Relanding: Move "max IPv6 networks" logic to BasicPortAllocator, and fix sorting. Relanding because the broken chromium test has been fixed: https://chromium-review.googlesource.com/582196 This CL moves the responsibility for restricting the number of IPv6 interfaces used for ICE to BasicPortAllocator. This is the right place to do it in the first place; it's where all the rest of the filtering occurs. And NetworkManager shouldn't need to know about ICE limitations; only the ICE classes should. Part of the reason I'm doing this is that I want to add a "max_ipv6_networks" API to RTCConfiguration, so that applications can override the default easily (see linked bug). But that means that PeerConnection would need to be able to call "set_max_ipv6_networks" on the underlying object that does the filtering, and that method isn't available on the "NetworkManager" base class. So rather than adding another method to a place it doesn't belong, I'm moving it to the place it does belong. In the process, I noticed that "CompareNetworks" is inconsistent with "SortNetworks"; the former orders interfaces alphabetically, and the latter reverse-alphabetically. I believe this was unintentional, and results in undesirable behavior (like "eth1" being preferred over "eth0"), so I'm fixing it and adding a test. BUG=webrtc:7703 Review-Url: https://codereview.webrtc.org/2983213002 Cr-Original-Commit-Position: refs/heads/master@{#19112} Committed: https://chromium.googlesource.com/external/webrtc/+/ad9561404c0cc007574eaedade581928aa3d24ef Review-Url: https://codereview.webrtc.org/2983213002 Cr-Commit-Position: refs/heads/master@{#19159}
2017-07-26 16:09:33 -07:00
// Do some more filtering, depending on the network ignore mask and "disable
// costly networks" flag.
NetworkFilter ignored_filter(
[this](rtc::Network* network) {
return allocator_->network_ignore_mask() & network->type();
},
"ignored");
FilterNetworks(&networks, ignored_filter);
if (flags() & PORTALLOCATOR_DISABLE_COSTLY_NETWORKS) {
uint16_t lowest_cost = rtc::kNetworkCostMax;
for (rtc::Network* network : networks) {
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
// Don't determine the lowest cost from a link-local network.
// On iOS, a device connected to the computer will get a link-local
// network for communicating with the computer, however this network can't
// be used to connect to a peer outside the network.
if (rtc::IPIsLinkLocal(network->GetBestIP())) {
continue;
}
lowest_cost = std::min<uint16_t>(lowest_cost, network->GetCost());
}
NetworkFilter costly_filter(
[lowest_cost](rtc::Network* network) {
return network->GetCost() > lowest_cost + rtc::kNetworkCostLow;
},
"costly");
FilterNetworks(&networks, costly_filter);
}
Relanding: Move "max IPv6 networks" logic to BasicPortAllocator, and fix sorting. Relanding because the broken chromium test has been fixed: https://chromium-review.googlesource.com/582196 This CL moves the responsibility for restricting the number of IPv6 interfaces used for ICE to BasicPortAllocator. This is the right place to do it in the first place; it's where all the rest of the filtering occurs. And NetworkManager shouldn't need to know about ICE limitations; only the ICE classes should. Part of the reason I'm doing this is that I want to add a "max_ipv6_networks" API to RTCConfiguration, so that applications can override the default easily (see linked bug). But that means that PeerConnection would need to be able to call "set_max_ipv6_networks" on the underlying object that does the filtering, and that method isn't available on the "NetworkManager" base class. So rather than adding another method to a place it doesn't belong, I'm moving it to the place it does belong. In the process, I noticed that "CompareNetworks" is inconsistent with "SortNetworks"; the former orders interfaces alphabetically, and the latter reverse-alphabetically. I believe this was unintentional, and results in undesirable behavior (like "eth1" being preferred over "eth0"), so I'm fixing it and adding a test. BUG=webrtc:7703 Review-Url: https://codereview.webrtc.org/2983213002 Cr-Original-Commit-Position: refs/heads/master@{#19112} Committed: https://chromium.googlesource.com/external/webrtc/+/ad9561404c0cc007574eaedade581928aa3d24ef Review-Url: https://codereview.webrtc.org/2983213002 Cr-Commit-Position: refs/heads/master@{#19159}
2017-07-26 16:09:33 -07:00
// Lastly, if we have a limit for the number of IPv6 network interfaces (by
// default, it's 5), remove networks to ensure that limit is satisfied.
//
// TODO(deadbeef): Instead of just taking the first N arbitrary IPv6
// networks, we could try to choose a set that's "most likely to work". It's
// hard to define what that means though; it's not just "lowest cost".
// Alternatively, we could just focus on making our ICE pinging logic smarter
// such that this filtering isn't necessary in the first place.
int ipv6_networks = 0;
for (auto it = networks.begin(); it != networks.end();) {
if ((*it)->prefix().family() == AF_INET6) {
if (ipv6_networks >= allocator_->max_ipv6_networks()) {
it = networks.erase(it);
continue;
} else {
++ipv6_networks;
}
}
++it;
}
return networks;
}
// For each network, see if we have a sequence that covers it already. If not,
// create a new sequence to create the appropriate ports.
void BasicPortAllocatorSession::DoAllocate(bool disable_equivalent) {
RTC_DCHECK_RUN_ON(network_thread_);
bool done_signal_needed = false;
std::vector<rtc::Network*> networks = GetNetworks();
if (networks.empty()) {
RTC_LOG(LS_WARNING)
<< "Machine has no networks; no ports will be allocated";
done_signal_needed = true;
} else {
RTC_LOG(LS_INFO) << "Allocate ports on " << networks.size() << " networks";
PortConfiguration* config =
configs_.empty() ? nullptr : configs_.back().get();
for (uint32_t i = 0; i < networks.size(); ++i) {
uint32_t sequence_flags = flags();
if ((sequence_flags & DISABLE_ALL_PHASES) == DISABLE_ALL_PHASES) {
// If all the ports are disabled we should just fire the allocation
// done event and return.
done_signal_needed = true;
break;
}
if (!config || config->relays.empty()) {
// No relay ports specified in this config.
sequence_flags |= PORTALLOCATOR_DISABLE_RELAY;
}
if (!(sequence_flags & PORTALLOCATOR_ENABLE_IPV6) &&
networks[i]->GetBestIP().family() == AF_INET6) {
// Skip IPv6 networks unless the flag's been set.
continue;
}
if (!(sequence_flags & PORTALLOCATOR_ENABLE_IPV6_ON_WIFI) &&
networks[i]->GetBestIP().family() == AF_INET6 &&
networks[i]->type() == rtc::ADAPTER_TYPE_WIFI) {
// Skip IPv6 Wi-Fi networks unless the flag's been set.
continue;
}
if (disable_equivalent) {
// Disable phases that would only create ports equivalent to
// ones that we have already made.
DisableEquivalentPhases(networks[i], config, &sequence_flags);
if ((sequence_flags & DISABLE_ALL_PHASES) == DISABLE_ALL_PHASES) {
// New AllocationSequence would have nothing to do, so don't make it.
continue;
}
}
AllocationSequence* sequence =
new AllocationSequence(this, networks[i], config, sequence_flags,
[this, safety_flag = network_safety_.flag()] {
if (safety_flag->alive())
OnPortAllocationComplete();
});
sequence->Init();
sequence->Start();
sequences_.push_back(sequence);
done_signal_needed = true;
}
}
if (done_signal_needed) {
network_thread_->PostTask(webrtc::ToQueuedTask(
network_safety_, [this] { OnAllocationSequenceObjectsCreated(); }));
}
}
void BasicPortAllocatorSession::OnNetworksChanged() {
RTC_DCHECK_RUN_ON(network_thread_);
std::vector<rtc::Network*> networks = GetNetworks();
std::vector<rtc::Network*> failed_networks;
for (AllocationSequence* sequence : sequences_) {
// Mark the sequence as "network failed" if its network is not in
// `networks`.
if (!sequence->network_failed() &&
!absl::c_linear_search(networks, sequence->network())) {
sequence->OnNetworkFailed();
failed_networks.push_back(sequence->network());
}
}
std::vector<PortData*> ports_to_prune = GetUnprunedPorts(failed_networks);
if (!ports_to_prune.empty()) {
RTC_LOG(LS_INFO) << "Prune " << ports_to_prune.size()
<< " ports because their networks were gone";
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
PrunePortsAndRemoveCandidates(ports_to_prune);
}
if (allocation_started_ && !IsStopped()) {
if (network_manager_started_) {
// If the network manager has started, it must be regathering.
SignalIceRegathering(this, IceRegatheringReason::NETWORK_CHANGE);
}
bool disable_equivalent_phases = true;
DoAllocate(disable_equivalent_phases);
}
if (!network_manager_started_) {
RTC_LOG(LS_INFO) << "Network manager has started";
network_manager_started_ = true;
}
}
void BasicPortAllocatorSession::DisableEquivalentPhases(
rtc::Network* network,
PortConfiguration* config,
uint32_t* flags) {
RTC_DCHECK_RUN_ON(network_thread_);
for (uint32_t i = 0; i < sequences_.size() &&
(*flags & DISABLE_ALL_PHASES) != DISABLE_ALL_PHASES;
++i) {
sequences_[i]->DisableEquivalentPhases(network, config, flags);
}
}
void BasicPortAllocatorSession::AddAllocatedPort(Port* port,
AllocationSequence* seq,
bool prepare_address) {
RTC_DCHECK_RUN_ON(network_thread_);
if (!port)
return;
RTC_LOG(LS_INFO) << "Adding allocated port for " << content_name();
port->set_content_name(content_name());
port->set_component(component());
port->set_generation(generation());
if (allocator_->proxy().type != rtc::PROXY_NONE)
port->set_proxy(allocator_->user_agent(), allocator_->proxy());
port->set_send_retransmit_count_attribute(
(flags() & PORTALLOCATOR_ENABLE_STUN_RETRANSMIT_ATTRIBUTE) != 0);
PortData data(port, seq);
ports_.push_back(data);
port->SignalCandidateReady.connect(
this, &BasicPortAllocatorSession::OnCandidateReady);
port->SignalCandidateError.connect(
this, &BasicPortAllocatorSession::OnCandidateError);
port->SignalPortComplete.connect(this,
&BasicPortAllocatorSession::OnPortComplete);
port->SubscribePortDestroyed(
[this](PortInterface* port) { OnPortDestroyed(port); });
port->SignalPortError.connect(this, &BasicPortAllocatorSession::OnPortError);
RTC_LOG(LS_INFO) << port->ToString() << ": Added port to allocator";
if (prepare_address)
port->PrepareAddress();
}
void BasicPortAllocatorSession::OnAllocationSequenceObjectsCreated() {
RTC_DCHECK_RUN_ON(network_thread_);
allocation_sequences_created_ = true;
// Send candidate allocation complete signal if we have no sequences.
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
MaybeSignalCandidatesAllocationDone();
}
void BasicPortAllocatorSession::OnCandidateReady(Port* port,
const Candidate& c) {
RTC_DCHECK_RUN_ON(network_thread_);
PortData* data = FindPort(port);
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
RTC_DCHECK(data != NULL);
RTC_LOG(LS_INFO) << port->ToString()
<< ": Gathered candidate: " << c.ToSensitiveString();
// Discarding any candidate signal if port allocation status is
// already done with gathering.
if (!data->inprogress()) {
RTC_LOG(LS_WARNING)
<< "Discarding candidate because port is already done gathering.";
return;
}
// Mark that the port has a pairable candidate, either because we have a
// usable candidate from the port, or simply because the port is bound to the
// any address and therefore has no host candidate. This will trigger the port
// to start creating candidate pairs (connections) and issue connectivity
// checks. If port has already been marked as having a pairable candidate,
// do nothing here.
// Note: We should check whether any candidates may become ready after this
// because there we will check whether the candidate is generated by the ready
// ports, which may include this port.
bool pruned = false;
if (CandidatePairable(c, port) && !data->has_pairable_candidate()) {
data->set_has_pairable_candidate(true);
if (port->Type() == RELAY_PORT_TYPE) {
if (turn_port_prune_policy_ == webrtc::KEEP_FIRST_READY) {
pruned = PruneNewlyPairableTurnPort(data);
} else if (turn_port_prune_policy_ == webrtc::PRUNE_BASED_ON_PRIORITY) {
pruned = PruneTurnPorts(port);
}
}
// If the current port is not pruned yet, SignalPortReady.
if (!data->pruned()) {
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
RTC_LOG(LS_INFO) << port->ToString() << ": Port ready.";
SignalPortReady(this, port);
port->KeepAliveUntilPruned();
}
}
if (data->ready() && CheckCandidateFilter(c)) {
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
std::vector<Candidate> candidates;
candidates.push_back(allocator_->SanitizeCandidate(c));
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
SignalCandidatesReady(this, candidates);
} else {
RTC_LOG(LS_INFO) << "Discarding candidate because it doesn't match filter.";
}
// If we have pruned any port, maybe need to signal port allocation done.
if (pruned) {
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
MaybeSignalCandidatesAllocationDone();
}
}
void BasicPortAllocatorSession::OnCandidateError(
Port* port,
const IceCandidateErrorEvent& event) {
RTC_DCHECK_RUN_ON(network_thread_);
RTC_DCHECK(FindPort(port));
if (event.address.empty()) {
candidate_error_events_.push_back(event);
} else {
SignalCandidateError(this, event);
}
}
Port* BasicPortAllocatorSession::GetBestTurnPortForNetwork(
const std::string& network_name) const {
RTC_DCHECK_RUN_ON(network_thread_);
Port* best_turn_port = nullptr;
for (const PortData& data : ports_) {
if (data.port()->Network()->name() == network_name &&
data.port()->Type() == RELAY_PORT_TYPE && data.ready() &&
(!best_turn_port || ComparePort(data.port(), best_turn_port) > 0)) {
best_turn_port = data.port();
}
}
return best_turn_port;
}
bool BasicPortAllocatorSession::PruneNewlyPairableTurnPort(
PortData* newly_pairable_port_data) {
RTC_DCHECK_RUN_ON(network_thread_);
RTC_DCHECK(newly_pairable_port_data->port()->Type() == RELAY_PORT_TYPE);
// If an existing turn port is ready on the same network, prune the newly
// pairable port.
const std::string& network_name =
newly_pairable_port_data->port()->Network()->name();
for (PortData& data : ports_) {
if (data.port()->Network()->name() == network_name &&
data.port()->Type() == RELAY_PORT_TYPE && data.ready() &&
&data != newly_pairable_port_data) {
RTC_LOG(LS_INFO) << "Port pruned: "
<< newly_pairable_port_data->port()->ToString();
newly_pairable_port_data->Prune();
return true;
}
}
return false;
}
bool BasicPortAllocatorSession::PruneTurnPorts(Port* newly_pairable_turn_port) {
RTC_DCHECK_RUN_ON(network_thread_);
// Note: We determine the same network based only on their network names. So
// if an IPv4 address and an IPv6 address have the same network name, they
// are considered the same network here.
const std::string& network_name = newly_pairable_turn_port->Network()->name();
Port* best_turn_port = GetBestTurnPortForNetwork(network_name);
// `port` is already in the list of ports, so the best port cannot be nullptr.
RTC_CHECK(best_turn_port != nullptr);
bool pruned = false;
std::vector<PortData*> ports_to_prune;
for (PortData& data : ports_) {
if (data.port()->Network()->name() == network_name &&
data.port()->Type() == RELAY_PORT_TYPE && !data.pruned() &&
ComparePort(data.port(), best_turn_port) < 0) {
pruned = true;
if (data.port() != newly_pairable_turn_port) {
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
// These ports will be pruned in PrunePortsAndRemoveCandidates.
ports_to_prune.push_back(&data);
} else {
data.Prune();
}
}
}
if (!ports_to_prune.empty()) {
RTC_LOG(LS_INFO) << "Prune " << ports_to_prune.size()
<< " low-priority TURN ports";
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
PrunePortsAndRemoveCandidates(ports_to_prune);
}
return pruned;
}
void BasicPortAllocatorSession::PruneAllPorts() {
RTC_DCHECK_RUN_ON(network_thread_);
for (PortData& data : ports_) {
data.Prune();
}
}
void BasicPortAllocatorSession::OnPortComplete(Port* port) {
RTC_DCHECK_RUN_ON(network_thread_);
RTC_LOG(LS_INFO) << port->ToString()
<< ": Port completed gathering candidates.";
PortData* data = FindPort(port);
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
RTC_DCHECK(data != NULL);
// Ignore any late signals.
if (!data->inprogress()) {
return;
}
// Moving to COMPLETE state.
Reland "Surface ICE candidates that match an updated candidate filter." This is a reland of cd8d1cf68e4eeed71fba51c97006a91bfd41813d Original change's description: > Surface ICE candidates that match an updated candidate filter. > > After this change an ICE agent can surface candidates that do not match > the previous filter but are allowed by the updated one. The candidate > filter, as part of the internal implementation in the ICE transport, > manifests the RTCIceTransportPolicy field in RTCConfiguration. > > This new feature would allow an ICE agent to gather new candidates when > the transport policy changes from e.g. 'relay' to 'all' without an ICE > restart. > > A caveat in the current implementation remains, and a candidate can > surface multiple times if the transport policy, or the candidate filter > directly, performs multiple transitions from a value that disallows to > one that allows the underlying candidate type. For example, if the > transport policy is updated by 'all' -> 'relay' -> 'all', the same host > candidate can surface after the second update. > > > Bug: webrtc:8939 > Change-Id: I92c2e07dafab225c702c5de28f47958a0d3270cc > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132282 > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> > Reviewed-by: Seth Hampson <shampson@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27674} Bug: webrtc:8939 Change-Id: I9c32b1ea05028ecd937ab4912779dd958faf734f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133582 Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27694}
2019-04-18 10:41:58 -07:00
data->set_state(PortData::STATE_COMPLETE);
// Send candidate allocation complete signal if this was the last port.
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
MaybeSignalCandidatesAllocationDone();
}
void BasicPortAllocatorSession::OnPortError(Port* port) {
RTC_DCHECK_RUN_ON(network_thread_);
RTC_LOG(LS_INFO) << port->ToString()
<< ": Port encountered error while gathering candidates.";
PortData* data = FindPort(port);
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
RTC_DCHECK(data != NULL);
// We might have already given up on this port and stopped it.
if (!data->inprogress()) {
return;
}
// SignalAddressError is currently sent from StunPort/TurnPort.
// But this signal itself is generic.
Reland "Surface ICE candidates that match an updated candidate filter." This is a reland of cd8d1cf68e4eeed71fba51c97006a91bfd41813d Original change's description: > Surface ICE candidates that match an updated candidate filter. > > After this change an ICE agent can surface candidates that do not match > the previous filter but are allowed by the updated one. The candidate > filter, as part of the internal implementation in the ICE transport, > manifests the RTCIceTransportPolicy field in RTCConfiguration. > > This new feature would allow an ICE agent to gather new candidates when > the transport policy changes from e.g. 'relay' to 'all' without an ICE > restart. > > A caveat in the current implementation remains, and a candidate can > surface multiple times if the transport policy, or the candidate filter > directly, performs multiple transitions from a value that disallows to > one that allows the underlying candidate type. For example, if the > transport policy is updated by 'all' -> 'relay' -> 'all', the same host > candidate can surface after the second update. > > > Bug: webrtc:8939 > Change-Id: I92c2e07dafab225c702c5de28f47958a0d3270cc > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132282 > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> > Reviewed-by: Seth Hampson <shampson@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27674} Bug: webrtc:8939 Change-Id: I9c32b1ea05028ecd937ab4912779dd958faf734f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133582 Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27694}
2019-04-18 10:41:58 -07:00
data->set_state(PortData::STATE_ERROR);
// Send candidate allocation complete signal if this was the last port.
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
MaybeSignalCandidatesAllocationDone();
}
bool BasicPortAllocatorSession::CheckCandidateFilter(const Candidate& c) const {
RTC_DCHECK_RUN_ON(network_thread_);
Reland "Surface ICE candidates that match an updated candidate filter." This is a reland of cd8d1cf68e4eeed71fba51c97006a91bfd41813d Original change's description: > Surface ICE candidates that match an updated candidate filter. > > After this change an ICE agent can surface candidates that do not match > the previous filter but are allowed by the updated one. The candidate > filter, as part of the internal implementation in the ICE transport, > manifests the RTCIceTransportPolicy field in RTCConfiguration. > > This new feature would allow an ICE agent to gather new candidates when > the transport policy changes from e.g. 'relay' to 'all' without an ICE > restart. > > A caveat in the current implementation remains, and a candidate can > surface multiple times if the transport policy, or the candidate filter > directly, performs multiple transitions from a value that disallows to > one that allows the underlying candidate type. For example, if the > transport policy is updated by 'all' -> 'relay' -> 'all', the same host > candidate can surface after the second update. > > > Bug: webrtc:8939 > Change-Id: I92c2e07dafab225c702c5de28f47958a0d3270cc > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132282 > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> > Reviewed-by: Seth Hampson <shampson@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27674} Bug: webrtc:8939 Change-Id: I9c32b1ea05028ecd937ab4912779dd958faf734f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133582 Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27694}
2019-04-18 10:41:58 -07:00
return IsAllowedByCandidateFilter(c, candidate_filter_);
}
bool BasicPortAllocatorSession::CandidatePairable(const Candidate& c,
const Port* port) const {
RTC_DCHECK_RUN_ON(network_thread_);
bool candidate_signalable = CheckCandidateFilter(c);
// When device enumeration is disabled (to prevent non-default IP addresses
// from leaking), we ping from some local candidates even though we don't
// signal them. However, if host candidates are also disabled (for example, to
// prevent even default IP addresses from leaking), we still don't want to
// ping from them, even if device enumeration is disabled. Thus, we check for
// both device enumeration and host candidates being disabled.
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
bool network_enumeration_disabled = c.address().IsAnyIP();
bool can_ping_from_candidate =
(port->SharedSocket() || c.protocol() == TCP_PROTOCOL_NAME);
bool host_candidates_disabled = !(candidate_filter_ & CF_HOST);
return candidate_signalable ||
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
(network_enumeration_disabled && can_ping_from_candidate &&
!host_candidates_disabled);
}
void BasicPortAllocatorSession::OnPortAllocationComplete() {
RTC_DCHECK_RUN_ON(network_thread_);
// Send candidate allocation complete signal if all ports are done.
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
MaybeSignalCandidatesAllocationDone();
}
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
void BasicPortAllocatorSession::MaybeSignalCandidatesAllocationDone() {
RTC_DCHECK_RUN_ON(network_thread_);
if (CandidatesAllocationDone()) {
if (pooled()) {
RTC_LOG(LS_INFO) << "All candidates gathered for pooled session.";
} else {
RTC_LOG(LS_INFO) << "All candidates gathered for " << content_name()
<< ":" << component() << ":" << generation();
}
for (const auto& event : candidate_error_events_) {
SignalCandidateError(this, event);
}
candidate_error_events_.clear();
SignalCandidatesAllocationDone(this);
}
}
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
void BasicPortAllocatorSession::OnPortDestroyed(PortInterface* port) {
RTC_DCHECK_RUN_ON(network_thread_);
for (std::vector<PortData>::iterator iter = ports_.begin();
iter != ports_.end(); ++iter) {
if (port == iter->port()) {
ports_.erase(iter);
RTC_LOG(LS_INFO) << port->ToString() << ": Removed port from allocator ("
<< static_cast<int>(ports_.size()) << " remaining)";
return;
}
}
RTC_NOTREACHED();
}
BasicPortAllocatorSession::PortData* BasicPortAllocatorSession::FindPort(
Port* port) {
RTC_DCHECK_RUN_ON(network_thread_);
for (std::vector<PortData>::iterator it = ports_.begin(); it != ports_.end();
++it) {
if (it->port() == port) {
return &*it;
}
}
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
return NULL;
}
std::vector<BasicPortAllocatorSession::PortData*>
BasicPortAllocatorSession::GetUnprunedPorts(
const std::vector<rtc::Network*>& networks) {
RTC_DCHECK_RUN_ON(network_thread_);
std::vector<PortData*> unpruned_ports;
for (PortData& port : ports_) {
if (!port.pruned() &&
absl::c_linear_search(networks, port.sequence()->network())) {
unpruned_ports.push_back(&port);
}
}
return unpruned_ports;
}
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
void BasicPortAllocatorSession::PrunePortsAndRemoveCandidates(
const std::vector<PortData*>& port_data_list) {
RTC_DCHECK_RUN_ON(network_thread_);
std::vector<PortInterface*> pruned_ports;
std::vector<Candidate> removed_candidates;
for (PortData* data : port_data_list) {
// Prune the port so that it may be destroyed.
data->Prune();
pruned_ports.push_back(data->port());
if (data->has_pairable_candidate()) {
GetCandidatesFromPort(*data, &removed_candidates);
// Mark the port as having no pairable candidates so that its candidates
// won't be removed multiple times.
data->set_has_pairable_candidate(false);
}
}
if (!pruned_ports.empty()) {
SignalPortsPruned(this, pruned_ports);
}
if (!removed_candidates.empty()) {
RTC_LOG(LS_INFO) << "Removed " << removed_candidates.size()
<< " candidates";
SignalCandidatesRemoved(this, removed_candidates);
}
}
// AllocationSequence
AllocationSequence::AllocationSequence(
BasicPortAllocatorSession* session,
rtc::Network* network,
PortConfiguration* config,
uint32_t flags,
std::function<void()> port_allocation_complete_callback)
: session_(session),
network_(network),
config_(config),
state_(kInit),
flags_(flags),
udp_socket_(),
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
udp_port_(NULL),
phase_(0),
port_allocation_complete_callback_(
std::move(port_allocation_complete_callback)) {}
void AllocationSequence::Init() {
if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) {
udp_socket_.reset(session_->socket_factory()->CreateUdpSocket(
Make Port (and subclasses) fully "Network"-based, instead of IP-based. For ICE, we want sockets that are bound to specific network interfaces, rather than to specific IP addresses. So, a while ago, we added a "Network" class that gets passed into the Port constructor, in addition to the IP address as before. But we never finished the job of removing the IP address field, such that a Port only guarantees something about the network interface it's associated with, and not the specific IP address it ends up with. This CL does that, and as a consequence, if a port ends up bound to an IP address other than the "best" one (returned by Network::GetBestIP), this *won't* be treated as an error. This is relevant to Android, where even though we pass an IP address into "Bind" as a way of identifying the network, the socket actually gets bound using "android_setsocknetwork", which doesn't provide any guarantees about the IP address. So, if a network interface has multiple IPv6 addresses (for instance), we may not correctly predict the one the OS will choose, and that's ok. This CL also moves "SetAlternateLocalAddress" from VirtualSocket to VirtualSocketServer, which makes for much more readable test code. The next step, if there is one, is to pass along the Network class all the way to SocketServer::Bind. Then the socket server could do smart things with the network information. We could even stick a platform- specific network handle in the Network object, such that the socket server could use it for the binding, or for "sendmsg", for example. See bug 7026 for more context about the sendmsg idea. BUG=webrtc:7715 Review-Url: https://codereview.webrtc.org/2989303002 Cr-Commit-Position: refs/heads/master@{#19251}
2017-08-04 15:01:57 -07:00
rtc::SocketAddress(network_->GetBestIP(), 0),
session_->allocator()->min_port(), session_->allocator()->max_port()));
if (udp_socket_) {
udp_socket_->SignalReadPacket.connect(this,
&AllocationSequence::OnReadPacket);
}
// Continuing if `udp_socket_` is NULL, as local TCP and RelayPort using TCP
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
// are next available options to setup a communication channel.
}
}
void AllocationSequence::Clear() {
TRACE_EVENT0("webrtc", "AllocationSequence::Clear");
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
udp_port_ = NULL;
relay_ports_.clear();
}
void AllocationSequence::OnNetworkFailed() {
RTC_DCHECK(!network_failed_);
network_failed_ = true;
// Stop the allocation sequence if its network failed.
Stop();
}
void AllocationSequence::DisableEquivalentPhases(rtc::Network* network,
PortConfiguration* config,
uint32_t* flags) {
if (network_failed_) {
// If the network of this allocation sequence has ever become failed,
// it won't be equivalent to the new network.
return;
}
Make Port (and subclasses) fully "Network"-based, instead of IP-based. For ICE, we want sockets that are bound to specific network interfaces, rather than to specific IP addresses. So, a while ago, we added a "Network" class that gets passed into the Port constructor, in addition to the IP address as before. But we never finished the job of removing the IP address field, such that a Port only guarantees something about the network interface it's associated with, and not the specific IP address it ends up with. This CL does that, and as a consequence, if a port ends up bound to an IP address other than the "best" one (returned by Network::GetBestIP), this *won't* be treated as an error. This is relevant to Android, where even though we pass an IP address into "Bind" as a way of identifying the network, the socket actually gets bound using "android_setsocknetwork", which doesn't provide any guarantees about the IP address. So, if a network interface has multiple IPv6 addresses (for instance), we may not correctly predict the one the OS will choose, and that's ok. This CL also moves "SetAlternateLocalAddress" from VirtualSocket to VirtualSocketServer, which makes for much more readable test code. The next step, if there is one, is to pass along the Network class all the way to SocketServer::Bind. Then the socket server could do smart things with the network information. We could even stick a platform- specific network handle in the Network object, such that the socket server could use it for the binding, or for "sendmsg", for example. See bug 7026 for more context about the sendmsg idea. BUG=webrtc:7715 Review-Url: https://codereview.webrtc.org/2989303002 Cr-Commit-Position: refs/heads/master@{#19251}
2017-08-04 15:01:57 -07:00
if (!((network == network_) && (previous_best_ip_ == network->GetBestIP()))) {
// Different network setup; nothing is equivalent.
return;
}
// Else turn off the stuff that we've already got covered.
// Every config implicitly specifies local, so turn that off right away if we
// already have a port of the corresponding type. Look for a port that
// matches this AllocationSequence's network, is the right protocol, and
// hasn't encountered an error.
// TODO(deadbeef): This doesn't take into account that there may be another
// AllocationSequence that's ABOUT to allocate a UDP port, but hasn't yet.
// This can happen if, say, there's a network change event right before an
// application-triggered ICE restart. Hopefully this problem will just go
// away if we get rid of the gathering "phases" though, which is planned.
Reland "Surface ICE candidates that match an updated candidate filter." This is a reland of cd8d1cf68e4eeed71fba51c97006a91bfd41813d Original change's description: > Surface ICE candidates that match an updated candidate filter. > > After this change an ICE agent can surface candidates that do not match > the previous filter but are allowed by the updated one. The candidate > filter, as part of the internal implementation in the ICE transport, > manifests the RTCIceTransportPolicy field in RTCConfiguration. > > This new feature would allow an ICE agent to gather new candidates when > the transport policy changes from e.g. 'relay' to 'all' without an ICE > restart. > > A caveat in the current implementation remains, and a candidate can > surface multiple times if the transport policy, or the candidate filter > directly, performs multiple transitions from a value that disallows to > one that allows the underlying candidate type. For example, if the > transport policy is updated by 'all' -> 'relay' -> 'all', the same host > candidate can surface after the second update. > > > Bug: webrtc:8939 > Change-Id: I92c2e07dafab225c702c5de28f47958a0d3270cc > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132282 > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> > Reviewed-by: Seth Hampson <shampson@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27674} Bug: webrtc:8939 Change-Id: I9c32b1ea05028ecd937ab4912779dd958faf734f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133582 Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27694}
2019-04-18 10:41:58 -07:00
//
//
// PORTALLOCATOR_DISABLE_UDP is used to disable a Port from gathering the host
// candidate (and srflx candidate if Port::SharedSocket()), and we do not want
// to disable the gathering of these candidates just becaue of an existing
// Port over PROTO_UDP, namely a TurnPort over UDP.
if (absl::c_any_of(session_->ports_,
[this](const BasicPortAllocatorSession::PortData& p) {
Reland "Surface ICE candidates that match an updated candidate filter." This is a reland of cd8d1cf68e4eeed71fba51c97006a91bfd41813d Original change's description: > Surface ICE candidates that match an updated candidate filter. > > After this change an ICE agent can surface candidates that do not match > the previous filter but are allowed by the updated one. The candidate > filter, as part of the internal implementation in the ICE transport, > manifests the RTCIceTransportPolicy field in RTCConfiguration. > > This new feature would allow an ICE agent to gather new candidates when > the transport policy changes from e.g. 'relay' to 'all' without an ICE > restart. > > A caveat in the current implementation remains, and a candidate can > surface multiple times if the transport policy, or the candidate filter > directly, performs multiple transitions from a value that disallows to > one that allows the underlying candidate type. For example, if the > transport policy is updated by 'all' -> 'relay' -> 'all', the same host > candidate can surface after the second update. > > > Bug: webrtc:8939 > Change-Id: I92c2e07dafab225c702c5de28f47958a0d3270cc > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132282 > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> > Reviewed-by: Seth Hampson <shampson@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27674} Bug: webrtc:8939 Change-Id: I9c32b1ea05028ecd937ab4912779dd958faf734f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133582 Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27694}
2019-04-18 10:41:58 -07:00
return !p.pruned() && p.port()->Network() == network_ &&
p.port()->GetProtocol() == PROTO_UDP &&
Reland "Surface ICE candidates that match an updated candidate filter." This is a reland of cd8d1cf68e4eeed71fba51c97006a91bfd41813d Original change's description: > Surface ICE candidates that match an updated candidate filter. > > After this change an ICE agent can surface candidates that do not match > the previous filter but are allowed by the updated one. The candidate > filter, as part of the internal implementation in the ICE transport, > manifests the RTCIceTransportPolicy field in RTCConfiguration. > > This new feature would allow an ICE agent to gather new candidates when > the transport policy changes from e.g. 'relay' to 'all' without an ICE > restart. > > A caveat in the current implementation remains, and a candidate can > surface multiple times if the transport policy, or the candidate filter > directly, performs multiple transitions from a value that disallows to > one that allows the underlying candidate type. For example, if the > transport policy is updated by 'all' -> 'relay' -> 'all', the same host > candidate can surface after the second update. > > > Bug: webrtc:8939 > Change-Id: I92c2e07dafab225c702c5de28f47958a0d3270cc > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132282 > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> > Reviewed-by: Seth Hampson <shampson@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27674} Bug: webrtc:8939 Change-Id: I9c32b1ea05028ecd937ab4912779dd958faf734f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133582 Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27694}
2019-04-18 10:41:58 -07:00
p.port()->Type() == LOCAL_PORT_TYPE && !p.error();
})) {
*flags |= PORTALLOCATOR_DISABLE_UDP;
}
Reland "Surface ICE candidates that match an updated candidate filter." This is a reland of cd8d1cf68e4eeed71fba51c97006a91bfd41813d Original change's description: > Surface ICE candidates that match an updated candidate filter. > > After this change an ICE agent can surface candidates that do not match > the previous filter but are allowed by the updated one. The candidate > filter, as part of the internal implementation in the ICE transport, > manifests the RTCIceTransportPolicy field in RTCConfiguration. > > This new feature would allow an ICE agent to gather new candidates when > the transport policy changes from e.g. 'relay' to 'all' without an ICE > restart. > > A caveat in the current implementation remains, and a candidate can > surface multiple times if the transport policy, or the candidate filter > directly, performs multiple transitions from a value that disallows to > one that allows the underlying candidate type. For example, if the > transport policy is updated by 'all' -> 'relay' -> 'all', the same host > candidate can surface after the second update. > > > Bug: webrtc:8939 > Change-Id: I92c2e07dafab225c702c5de28f47958a0d3270cc > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132282 > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> > Reviewed-by: Seth Hampson <shampson@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27674} Bug: webrtc:8939 Change-Id: I9c32b1ea05028ecd937ab4912779dd958faf734f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133582 Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27694}
2019-04-18 10:41:58 -07:00
// Similarly we need to check both the protocol used by an existing Port and
// its type.
if (absl::c_any_of(session_->ports_,
[this](const BasicPortAllocatorSession::PortData& p) {
Reland "Surface ICE candidates that match an updated candidate filter." This is a reland of cd8d1cf68e4eeed71fba51c97006a91bfd41813d Original change's description: > Surface ICE candidates that match an updated candidate filter. > > After this change an ICE agent can surface candidates that do not match > the previous filter but are allowed by the updated one. The candidate > filter, as part of the internal implementation in the ICE transport, > manifests the RTCIceTransportPolicy field in RTCConfiguration. > > This new feature would allow an ICE agent to gather new candidates when > the transport policy changes from e.g. 'relay' to 'all' without an ICE > restart. > > A caveat in the current implementation remains, and a candidate can > surface multiple times if the transport policy, or the candidate filter > directly, performs multiple transitions from a value that disallows to > one that allows the underlying candidate type. For example, if the > transport policy is updated by 'all' -> 'relay' -> 'all', the same host > candidate can surface after the second update. > > > Bug: webrtc:8939 > Change-Id: I92c2e07dafab225c702c5de28f47958a0d3270cc > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132282 > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> > Reviewed-by: Seth Hampson <shampson@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27674} Bug: webrtc:8939 Change-Id: I9c32b1ea05028ecd937ab4912779dd958faf734f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133582 Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27694}
2019-04-18 10:41:58 -07:00
return !p.pruned() && p.port()->Network() == network_ &&
p.port()->GetProtocol() == PROTO_TCP &&
Reland "Surface ICE candidates that match an updated candidate filter." This is a reland of cd8d1cf68e4eeed71fba51c97006a91bfd41813d Original change's description: > Surface ICE candidates that match an updated candidate filter. > > After this change an ICE agent can surface candidates that do not match > the previous filter but are allowed by the updated one. The candidate > filter, as part of the internal implementation in the ICE transport, > manifests the RTCIceTransportPolicy field in RTCConfiguration. > > This new feature would allow an ICE agent to gather new candidates when > the transport policy changes from e.g. 'relay' to 'all' without an ICE > restart. > > A caveat in the current implementation remains, and a candidate can > surface multiple times if the transport policy, or the candidate filter > directly, performs multiple transitions from a value that disallows to > one that allows the underlying candidate type. For example, if the > transport policy is updated by 'all' -> 'relay' -> 'all', the same host > candidate can surface after the second update. > > > Bug: webrtc:8939 > Change-Id: I92c2e07dafab225c702c5de28f47958a0d3270cc > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132282 > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> > Reviewed-by: Seth Hampson <shampson@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27674} Bug: webrtc:8939 Change-Id: I9c32b1ea05028ecd937ab4912779dd958faf734f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133582 Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27694}
2019-04-18 10:41:58 -07:00
p.port()->Type() == LOCAL_PORT_TYPE && !p.error();
})) {
*flags |= PORTALLOCATOR_DISABLE_TCP;
}
if (config_ && config) {
Reland "Surface ICE candidates that match an updated candidate filter." This is a reland of cd8d1cf68e4eeed71fba51c97006a91bfd41813d Original change's description: > Surface ICE candidates that match an updated candidate filter. > > After this change an ICE agent can surface candidates that do not match > the previous filter but are allowed by the updated one. The candidate > filter, as part of the internal implementation in the ICE transport, > manifests the RTCIceTransportPolicy field in RTCConfiguration. > > This new feature would allow an ICE agent to gather new candidates when > the transport policy changes from e.g. 'relay' to 'all' without an ICE > restart. > > A caveat in the current implementation remains, and a candidate can > surface multiple times if the transport policy, or the candidate filter > directly, performs multiple transitions from a value that disallows to > one that allows the underlying candidate type. For example, if the > transport policy is updated by 'all' -> 'relay' -> 'all', the same host > candidate can surface after the second update. > > > Bug: webrtc:8939 > Change-Id: I92c2e07dafab225c702c5de28f47958a0d3270cc > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132282 > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> > Reviewed-by: Seth Hampson <shampson@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27674} Bug: webrtc:8939 Change-Id: I9c32b1ea05028ecd937ab4912779dd958faf734f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133582 Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27694}
2019-04-18 10:41:58 -07:00
// We need to regather srflx candidates if either of the following
// conditions occurs:
// 1. The STUN servers are different from the previous gathering.
// 2. We will regather host candidates, hence possibly inducing new NAT
// bindings.
if (config_->StunServers() == config->StunServers() &&
(*flags & PORTALLOCATOR_DISABLE_UDP)) {
// Already got this STUN servers covered.
*flags |= PORTALLOCATOR_DISABLE_STUN;
}
if (!config_->relays.empty()) {
// Already got relays covered.
// NOTE: This will even skip a _different_ set of relay servers if we
// were to be given one, but that never happens in our codebase. Should
// probably get rid of the list in PortConfiguration and just keep a
// single relay server in each one.
*flags |= PORTALLOCATOR_DISABLE_RELAY;
}
}
}
void AllocationSequence::Start() {
state_ = kRunning;
session_->network_thread()->PostTask(webrtc::ToQueuedTask(
safety_, [this, epoch = epoch_] { Process(epoch); }));
Make Port (and subclasses) fully "Network"-based, instead of IP-based. For ICE, we want sockets that are bound to specific network interfaces, rather than to specific IP addresses. So, a while ago, we added a "Network" class that gets passed into the Port constructor, in addition to the IP address as before. But we never finished the job of removing the IP address field, such that a Port only guarantees something about the network interface it's associated with, and not the specific IP address it ends up with. This CL does that, and as a consequence, if a port ends up bound to an IP address other than the "best" one (returned by Network::GetBestIP), this *won't* be treated as an error. This is relevant to Android, where even though we pass an IP address into "Bind" as a way of identifying the network, the socket actually gets bound using "android_setsocknetwork", which doesn't provide any guarantees about the IP address. So, if a network interface has multiple IPv6 addresses (for instance), we may not correctly predict the one the OS will choose, and that's ok. This CL also moves "SetAlternateLocalAddress" from VirtualSocket to VirtualSocketServer, which makes for much more readable test code. The next step, if there is one, is to pass along the Network class all the way to SocketServer::Bind. Then the socket server could do smart things with the network information. We could even stick a platform- specific network handle in the Network object, such that the socket server could use it for the binding, or for "sendmsg", for example. See bug 7026 for more context about the sendmsg idea. BUG=webrtc:7715 Review-Url: https://codereview.webrtc.org/2989303002 Cr-Commit-Position: refs/heads/master@{#19251}
2017-08-04 15:01:57 -07:00
// Take a snapshot of the best IP, so that when DisableEquivalentPhases is
// called next time, we enable all phases if the best IP has since changed.
previous_best_ip_ = network_->GetBestIP();
}
void AllocationSequence::Stop() {
// If the port is completed, don't set it to stopped.
if (state_ == kRunning) {
state_ = kStopped;
// Cause further Process calls in the previous epoch to be ignored.
++epoch_;
}
}
void AllocationSequence::Process(int epoch) {
RTC_DCHECK(rtc::Thread::Current() == session_->network_thread());
const char* const PHASE_NAMES[kNumPhases] = {"Udp", "Relay", "Tcp"};
if (epoch != epoch_)
return;
// Perform all of the phases in the current step.
RTC_LOG(LS_INFO) << network_->ToString()
<< ": Allocation Phase=" << PHASE_NAMES[phase_];
switch (phase_) {
case PHASE_UDP:
CreateUDPPorts();
CreateStunPorts();
break;
case PHASE_RELAY:
CreateRelayPorts();
break;
case PHASE_TCP:
CreateTCPPorts();
state_ = kCompleted;
break;
default:
RTC_NOTREACHED();
}
if (state() == kRunning) {
++phase_;
session_->network_thread()->PostDelayedTask(
webrtc::ToQueuedTask(safety_,
[this, epoch = epoch_] { Process(epoch); }),
session_->allocator()->step_delay());
} else {
// No allocation steps needed further if all phases in AllocationSequence
// are completed. Cause further Process calls in the previous epoch to be
// ignored.
++epoch_;
port_allocation_complete_callback_();
}
}
void AllocationSequence::CreateUDPPorts() {
if (IsFlagSet(PORTALLOCATOR_DISABLE_UDP)) {
RTC_LOG(LS_VERBOSE) << "AllocationSequence: UDP ports disabled, skipping.";
return;
}
// TODO(mallinath) - Remove UDPPort creating socket after shared socket
// is enabled completely.
std::unique_ptr<UDPPort> port;
bool emit_local_candidate_for_anyaddress =
!IsFlagSet(PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE);
if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET) && udp_socket_) {
port = UDPPort::Create(
session_->network_thread(), session_->socket_factory(), network_,
udp_socket_.get(), session_->username(), session_->password(),
session_->allocator()->origin(), emit_local_candidate_for_anyaddress,
session_->allocator()->stun_candidate_keepalive_interval());
} else {
port = UDPPort::Create(
Make Port (and subclasses) fully "Network"-based, instead of IP-based. For ICE, we want sockets that are bound to specific network interfaces, rather than to specific IP addresses. So, a while ago, we added a "Network" class that gets passed into the Port constructor, in addition to the IP address as before. But we never finished the job of removing the IP address field, such that a Port only guarantees something about the network interface it's associated with, and not the specific IP address it ends up with. This CL does that, and as a consequence, if a port ends up bound to an IP address other than the "best" one (returned by Network::GetBestIP), this *won't* be treated as an error. This is relevant to Android, where even though we pass an IP address into "Bind" as a way of identifying the network, the socket actually gets bound using "android_setsocknetwork", which doesn't provide any guarantees about the IP address. So, if a network interface has multiple IPv6 addresses (for instance), we may not correctly predict the one the OS will choose, and that's ok. This CL also moves "SetAlternateLocalAddress" from VirtualSocket to VirtualSocketServer, which makes for much more readable test code. The next step, if there is one, is to pass along the Network class all the way to SocketServer::Bind. Then the socket server could do smart things with the network information. We could even stick a platform- specific network handle in the Network object, such that the socket server could use it for the binding, or for "sendmsg", for example. See bug 7026 for more context about the sendmsg idea. BUG=webrtc:7715 Review-Url: https://codereview.webrtc.org/2989303002 Cr-Commit-Position: refs/heads/master@{#19251}
2017-08-04 15:01:57 -07:00
session_->network_thread(), session_->socket_factory(), network_,
session_->allocator()->min_port(), session_->allocator()->max_port(),
session_->username(), session_->password(),
session_->allocator()->origin(), emit_local_candidate_for_anyaddress,
session_->allocator()->stun_candidate_keepalive_interval());
}
if (port) {
// If shared socket is enabled, STUN candidate will be allocated by the
// UDPPort.
if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) {
udp_port_ = port.get();
port->SubscribePortDestroyed(
[this](PortInterface* port) { OnPortDestroyed(port); });
// If STUN is not disabled, setting stun server address to port.
if (!IsFlagSet(PORTALLOCATOR_DISABLE_STUN)) {
if (config_ && !config_->StunServers().empty()) {
RTC_LOG(LS_INFO)
<< "AllocationSequence: UDPPort will be handling the "
"STUN candidate generation.";
port->set_server_addresses(config_->StunServers());
}
}
}
session_->AddAllocatedPort(port.release(), this, true);
}
}
void AllocationSequence::CreateTCPPorts() {
if (IsFlagSet(PORTALLOCATOR_DISABLE_TCP)) {
RTC_LOG(LS_VERBOSE) << "AllocationSequence: TCP ports disabled, skipping.";
return;
}
std::unique_ptr<Port> port = TCPPort::Create(
Make Port (and subclasses) fully "Network"-based, instead of IP-based. For ICE, we want sockets that are bound to specific network interfaces, rather than to specific IP addresses. So, a while ago, we added a "Network" class that gets passed into the Port constructor, in addition to the IP address as before. But we never finished the job of removing the IP address field, such that a Port only guarantees something about the network interface it's associated with, and not the specific IP address it ends up with. This CL does that, and as a consequence, if a port ends up bound to an IP address other than the "best" one (returned by Network::GetBestIP), this *won't* be treated as an error. This is relevant to Android, where even though we pass an IP address into "Bind" as a way of identifying the network, the socket actually gets bound using "android_setsocknetwork", which doesn't provide any guarantees about the IP address. So, if a network interface has multiple IPv6 addresses (for instance), we may not correctly predict the one the OS will choose, and that's ok. This CL also moves "SetAlternateLocalAddress" from VirtualSocket to VirtualSocketServer, which makes for much more readable test code. The next step, if there is one, is to pass along the Network class all the way to SocketServer::Bind. Then the socket server could do smart things with the network information. We could even stick a platform- specific network handle in the Network object, such that the socket server could use it for the binding, or for "sendmsg", for example. See bug 7026 for more context about the sendmsg idea. BUG=webrtc:7715 Review-Url: https://codereview.webrtc.org/2989303002 Cr-Commit-Position: refs/heads/master@{#19251}
2017-08-04 15:01:57 -07:00
session_->network_thread(), session_->socket_factory(), network_,
session_->allocator()->min_port(), session_->allocator()->max_port(),
session_->username(), session_->password(),
session_->allocator()->allow_tcp_listen());
if (port) {
session_->AddAllocatedPort(port.release(), this, true);
// Since TCPPort is not created using shared socket, `port` will not be
// added to the dequeue.
}
}
void AllocationSequence::CreateStunPorts() {
if (IsFlagSet(PORTALLOCATOR_DISABLE_STUN)) {
RTC_LOG(LS_VERBOSE) << "AllocationSequence: STUN ports disabled, skipping.";
return;
}
if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) {
return;
}
if (!(config_ && !config_->StunServers().empty())) {
RTC_LOG(LS_WARNING)
<< "AllocationSequence: No STUN server configured, skipping.";
return;
}
std::unique_ptr<StunPort> port = StunPort::Create(
Make Port (and subclasses) fully "Network"-based, instead of IP-based. For ICE, we want sockets that are bound to specific network interfaces, rather than to specific IP addresses. So, a while ago, we added a "Network" class that gets passed into the Port constructor, in addition to the IP address as before. But we never finished the job of removing the IP address field, such that a Port only guarantees something about the network interface it's associated with, and not the specific IP address it ends up with. This CL does that, and as a consequence, if a port ends up bound to an IP address other than the "best" one (returned by Network::GetBestIP), this *won't* be treated as an error. This is relevant to Android, where even though we pass an IP address into "Bind" as a way of identifying the network, the socket actually gets bound using "android_setsocknetwork", which doesn't provide any guarantees about the IP address. So, if a network interface has multiple IPv6 addresses (for instance), we may not correctly predict the one the OS will choose, and that's ok. This CL also moves "SetAlternateLocalAddress" from VirtualSocket to VirtualSocketServer, which makes for much more readable test code. The next step, if there is one, is to pass along the Network class all the way to SocketServer::Bind. Then the socket server could do smart things with the network information. We could even stick a platform- specific network handle in the Network object, such that the socket server could use it for the binding, or for "sendmsg", for example. See bug 7026 for more context about the sendmsg idea. BUG=webrtc:7715 Review-Url: https://codereview.webrtc.org/2989303002 Cr-Commit-Position: refs/heads/master@{#19251}
2017-08-04 15:01:57 -07:00
session_->network_thread(), session_->socket_factory(), network_,
session_->allocator()->min_port(), session_->allocator()->max_port(),
session_->username(), session_->password(), config_->StunServers(),
session_->allocator()->origin(),
session_->allocator()->stun_candidate_keepalive_interval());
if (port) {
session_->AddAllocatedPort(port.release(), this, true);
// Since StunPort is not created using shared socket, `port` will not be
// added to the dequeue.
}
}
void AllocationSequence::CreateRelayPorts() {
if (IsFlagSet(PORTALLOCATOR_DISABLE_RELAY)) {
RTC_LOG(LS_VERBOSE)
<< "AllocationSequence: Relay ports disabled, skipping.";
return;
}
// If BasicPortAllocatorSession::OnAllocate left relay ports enabled then we
// ought to have a relay list for them here.
RTC_DCHECK(config_);
RTC_DCHECK(!config_->relays.empty());
if (!(config_ && !config_->relays.empty())) {
RTC_LOG(LS_WARNING)
<< "AllocationSequence: No relay server configured, skipping.";
return;
}
for (RelayServerConfig& relay : config_->relays) {
CreateTurnPort(relay);
}
}
void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) {
PortList::const_iterator relay_port;
for (relay_port = config.ports.begin(); relay_port != config.ports.end();
++relay_port) {
// Skip UDP connections to relay servers if it's disallowed.
if (IsFlagSet(PORTALLOCATOR_DISABLE_UDP_RELAY) &&
relay_port->proto == PROTO_UDP) {
continue;
}
// Do not create a port if the server address family is known and does
// not match the local IP address family.
int server_ip_family = relay_port->address.ipaddr().family();
Make Port (and subclasses) fully "Network"-based, instead of IP-based. For ICE, we want sockets that are bound to specific network interfaces, rather than to specific IP addresses. So, a while ago, we added a "Network" class that gets passed into the Port constructor, in addition to the IP address as before. But we never finished the job of removing the IP address field, such that a Port only guarantees something about the network interface it's associated with, and not the specific IP address it ends up with. This CL does that, and as a consequence, if a port ends up bound to an IP address other than the "best" one (returned by Network::GetBestIP), this *won't* be treated as an error. This is relevant to Android, where even though we pass an IP address into "Bind" as a way of identifying the network, the socket actually gets bound using "android_setsocknetwork", which doesn't provide any guarantees about the IP address. So, if a network interface has multiple IPv6 addresses (for instance), we may not correctly predict the one the OS will choose, and that's ok. This CL also moves "SetAlternateLocalAddress" from VirtualSocket to VirtualSocketServer, which makes for much more readable test code. The next step, if there is one, is to pass along the Network class all the way to SocketServer::Bind. Then the socket server could do smart things with the network information. We could even stick a platform- specific network handle in the Network object, such that the socket server could use it for the binding, or for "sendmsg", for example. See bug 7026 for more context about the sendmsg idea. BUG=webrtc:7715 Review-Url: https://codereview.webrtc.org/2989303002 Cr-Commit-Position: refs/heads/master@{#19251}
2017-08-04 15:01:57 -07:00
int local_ip_family = network_->GetBestIP().family();
if (server_ip_family != AF_UNSPEC && server_ip_family != local_ip_family) {
RTC_LOG(LS_INFO)
<< "Server and local address families are not compatible. "
"Server address: "
<< relay_port->address.ipaddr().ToSensitiveString()
<< " Local address: " << network_->GetBestIP().ToSensitiveString();
continue;
}
CreateRelayPortArgs args;
args.network_thread = session_->network_thread();
args.socket_factory = session_->socket_factory();
args.network = network_;
args.username = session_->username();
args.password = session_->password();
args.server_address = &(*relay_port);
args.config = &config;
args.origin = session_->allocator()->origin();
args.turn_customizer = session_->allocator()->turn_customizer();
std::unique_ptr<cricket::Port> port;
// Shared socket mode must be enabled only for UDP based ports. Hence
// don't pass shared socket for ports which will create TCP sockets.
// TODO(mallinath) - Enable shared socket mode for TURN ports. Disabled
// due to webrtc bug https://code.google.com/p/webrtc/issues/detail?id=3537
if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET) &&
relay_port->proto == PROTO_UDP && udp_socket_) {
port = session_->allocator()->relay_port_factory()->Create(
args, udp_socket_.get());
if (!port) {
RTC_LOG(LS_WARNING) << "Failed to create relay port with "
<< args.server_address->address.ToSensitiveString();
continue;
}
relay_ports_.push_back(port.get());
// Listen to the port destroyed signal, to allow AllocationSequence to
// remove the entry from it's map.
port->SubscribePortDestroyed(
[this](PortInterface* port) { OnPortDestroyed(port); });
} else {
port = session_->allocator()->relay_port_factory()->Create(
args, session_->allocator()->min_port(),
session_->allocator()->max_port());
if (!port) {
RTC_LOG(LS_WARNING) << "Failed to create relay port with "
<< args.server_address->address.ToSensitiveString();
continue;
}
}
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
RTC_DCHECK(port != NULL);
session_->AddAllocatedPort(port.release(), this, true);
}
}
void AllocationSequence::OnReadPacket(rtc::AsyncPacketSocket* socket,
const char* data,
size_t size,
const rtc::SocketAddress& remote_addr,
const int64_t& packet_time_us) {
RTC_DCHECK(socket == udp_socket_.get());
bool turn_port_found = false;
// Try to find the TurnPort that matches the remote address. Note that the
// message could be a STUN binding response if the TURN server is also used as
// a STUN server. We don't want to parse every message here to check if it is
// a STUN binding response, so we pass the message to TurnPort regardless of
// the message type. The TurnPort will just ignore the message since it will
// not find any request by transaction ID.
for (auto* port : relay_ports_) {
if (port->CanHandleIncomingPacketsFrom(remote_addr)) {
if (port->HandleIncomingPacket(socket, data, size, remote_addr,
packet_time_us)) {
return;
}
turn_port_found = true;
}
}
if (udp_port_) {
const ServerAddresses& stun_servers = udp_port_->server_addresses();
// Pass the packet to the UdpPort if there is no matching TurnPort, or if
// the TURN server is also a STUN server.
if (!turn_port_found ||
stun_servers.find(remote_addr) != stun_servers.end()) {
RTC_DCHECK(udp_port_->SharedSocket());
udp_port_->HandleIncomingPacket(socket, data, size, remote_addr,
packet_time_us);
}
}
}
void AllocationSequence::OnPortDestroyed(PortInterface* port) {
if (udp_port_ == port) {
Revert "Reland "Enable any address ports by default."" This reverts commit b89ac622f3f5a7bb065a08cb1efba10a0e8cae23. Reason for revert: Speculative revert. Original change's description: > Reland "Enable any address ports by default." > > This reverts commit 1165949341b6f61c5d728999bfbdaf68fd5c15aa. > > Reason for revert: Speculative reland (the revert breaks a downstream project). > > Original change's description: > > Revert "Reland "Enable any address ports by default."" > > > > This reverts commit ac5bbd940ed31f8a58095952f4dcdcbb1b58203c. > > > > Reason for revert: Speculative revert, possibly breaking downstream projects > > > > Original change's description: > > > Reland "Enable any address ports by default." > > > > > > This reverts commit 056a68da896d9a578b9ea83e56d261648ea0adc6. > > > > > > Reason for revert: Trying to reland. > > > > > > Original change's description: > > > > Revert "Enable any address ports by default." > > > > > > > > This reverts commit f04148c810aad2a0809dc8978650c55308381c47. > > > > > > > > Reason for revert: Speculative revert. I suspect this is breaking a > > > > downstream test (I'll reland if it is not the culprit). > > > > > > > > Original change's description: > > > > > Enable any address ports by default. > > > > > > > > > > Ports not bound to any specific network interface are allocated by > > > > > default. These any address ports are pruned after allocation, > > > > > conditional on the allocation results of normal ports that are bound to > > > > > the enumerated interfaces. > > > > > > > > > > Bug: webrtc:9313 > > > > > Change-Id: I3ce12eeab0cf3547224e5f8c188d061fc530e145 > > > > > Reviewed-on: https://webrtc-review.googlesource.com/78383 > > > > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > > > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#23673} > > > > > > > > TBR=deadbeef@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > > > Change-Id: I3b3dc42c7de46d198d4b9c270020dcf1100dd907 > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: webrtc:9313 > > > > Reviewed-on: https://webrtc-review.googlesource.com/84300 > > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#23678} > > > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com > > > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > > > Bug: webrtc:9313 > > > Change-Id: I98442346babb5d8953d37dc5825efaf79804ed7f > > > Reviewed-on: https://webrtc-review.googlesource.com/85000 > > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > > Commit-Queue: Qingsi Wang <qingsi@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#23720} > > > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9313 > > Change-Id: Ie5da4133a371532f717af144f183e299e759f152 > > Reviewed-on: https://webrtc-review.googlesource.com/95340 > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#24374} > > TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org > > Change-Id: I52bf487d441ce8ccedee7e348b9ed9ade0fd9d1c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9313 > Reviewed-on: https://webrtc-review.googlesource.com/95440 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#24379} TBR=deadbeef@webrtc.org,mbonadei@webrtc.org,pthatcher@webrtc.org,qingsi@google.com,qingsi@webrtc.org Change-Id: I6db41f092c55be74f6594eb729ad5f15c718fe34 Bug: webrtc:9313 Reviewed-on: https://webrtc-review.googlesource.com/95520 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24412}
2018-08-22 17:41:22 +00:00
udp_port_ = NULL;
return;
}
auto it = absl::c_find(relay_ports_, port);
if (it != relay_ports_.end()) {
relay_ports_.erase(it);
} else {
RTC_LOG(LS_ERROR) << "Unexpected OnPortDestroyed for nonexistent port.";
RTC_NOTREACHED();
}
}
// PortConfiguration
PortConfiguration::PortConfiguration(const rtc::SocketAddress& stun_address,
const std::string& username,
const std::string& password)
: stun_address(stun_address), username(username), password(password) {
if (!stun_address.IsNil())
stun_servers.insert(stun_address);
}
PortConfiguration::PortConfiguration(const ServerAddresses& stun_servers,
const std::string& username,
const std::string& password)
: stun_servers(stun_servers), username(username), password(password) {
if (!stun_servers.empty())
stun_address = *(stun_servers.begin());
// Note that this won't change once the config is initialized.
use_turn_server_as_stun_server_disabled =
webrtc::field_trial::IsDisabled("WebRTC-UseTurnServerAsStunServer");
}
ServerAddresses PortConfiguration::StunServers() {
if (!stun_address.IsNil() &&
stun_servers.find(stun_address) == stun_servers.end()) {
stun_servers.insert(stun_address);
}
if (!stun_servers.empty() && use_turn_server_as_stun_server_disabled) {
return stun_servers;
}
// Every UDP TURN server should also be used as a STUN server if
// use_turn_server_as_stun_server is not disabled or the stun servers are
// empty.
ServerAddresses turn_servers = GetRelayServerAddresses(PROTO_UDP);
for (const rtc::SocketAddress& turn_server : turn_servers) {
if (stun_servers.find(turn_server) == stun_servers.end()) {
stun_servers.insert(turn_server);
}
}
return stun_servers;
}
void PortConfiguration::AddRelay(const RelayServerConfig& config) {
relays.push_back(config);
}
bool PortConfiguration::SupportsProtocol(const RelayServerConfig& relay,
ProtocolType type) const {
PortList::const_iterator relay_port;
for (relay_port = relay.ports.begin(); relay_port != relay.ports.end();
++relay_port) {
if (relay_port->proto == type)
return true;
}
return false;
}
bool PortConfiguration::SupportsProtocol(ProtocolType type) const {
for (size_t i = 0; i < relays.size(); ++i) {
if (SupportsProtocol(relays[i], type))
return true;
}
return false;
}
ServerAddresses PortConfiguration::GetRelayServerAddresses(
ProtocolType type) const {
ServerAddresses servers;
for (size_t i = 0; i < relays.size(); ++i) {
if (SupportsProtocol(relays[i], type)) {
servers.insert(relays[i].ports.front().address);
}
}
return servers;
}
} // namespace cricket