Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(610)

Unified Diff: webrtc/p2p/client/basicportallocator.cc

Issue 2983213002: Relanding: Move "max IPv6 networks" logic to BasicPortAllocator, and fix sorting. (Closed)
Patch Set: Fixing P2PTransportChannelMultihomedTest (was relying on ordering assumptions it shouldn't have beeā€¦ Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/base/portallocator.h ('k') | webrtc/p2p/client/basicportallocator_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/client/basicportallocator.cc
diff --git a/webrtc/p2p/client/basicportallocator.cc b/webrtc/p2p/client/basicportallocator.cc
index 2970987900b1390c956e45a5b775cc008ecbc9b3..091819ac43f1d0e1420bcd123bb6c6384fd67291 100644
--- a/webrtc/p2p/client/basicportallocator.cc
+++ b/webrtc/p2p/client/basicportallocator.cc
@@ -588,13 +588,14 @@ std::vector<rtc::Network*> BasicPortAllocatorSession::GetNetworks() {
network_manager->GetAnyAddressNetworks(&networks);
}
}
+ // Do some more filtering, depending on the network ignore mask and "disable
+ // costly networks" flag.
networks.erase(std::remove_if(networks.begin(), networks.end(),
[this](rtc::Network* network) {
return allocator_->network_ignore_mask() &
network->type();
}),
networks.end());
-
if (flags() & PORTALLOCATOR_DISABLE_COSTLY_NETWORKS) {
uint16_t lowest_cost = rtc::kNetworkCostMax;
for (rtc::Network* network : networks) {
@@ -607,6 +608,26 @@ std::vector<rtc::Network*> BasicPortAllocatorSession::GetNetworks() {
}),
networks.end());
}
+ // 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;
}
« no previous file with comments | « webrtc/p2p/base/portallocator.h ('k') | webrtc/p2p/client/basicportallocator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698