From 625efe6dfe5b5681a2d8d3d5ecaa0c5ac9edd6ee Mon Sep 17 00:00:00 2001 From: Qingsi Wang Date: Thu, 28 Jun 2018 19:15:33 -0700 Subject: [PATCH] Use also the related address in redundancy detection for candidates from the any-address/wildcard ports. A TURN server can allocate different IPs for different allocation requests from the same network interface, and a relayed candidate from a wildcard port is not considered duplicate with another relayed candidate using the same network interface in the current redundancy detection, if their mapped addresses (as the "related address" for relayed candidates) are different. Extra candidates would then be surfaced to the application unnecessarily. Bug: webrtc:9469 Change-Id: I504fde3b70cd727ef6ad4517072dcf37328a8380 Reviewed-on: https://webrtc-review.googlesource.com/86181 Commit-Queue: Qingsi Wang Reviewed-by: Steve Anton Reviewed-by: Qingsi Wang Cr-Commit-Position: refs/heads/master@{#24108} --- p2p/client/basicportallocator.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/p2p/client/basicportallocator.cc b/p2p/client/basicportallocator.cc index eb14a37758..ec9abb73dd 100644 --- a/p2p/client/basicportallocator.cc +++ b/p2p/client/basicportallocator.cc @@ -1191,6 +1191,11 @@ void BasicPortAllocatorSession:: // socket to this address, so ignore it. if (c.address().port() != DISCARD_PORT) { ips_from_non_any_address_ports.insert(c.address().ipaddr()); + if (port_data.port()->Type() == RELAY_PORT_TYPE) { + // The related address of a relay candidate is the server reflexive + // address obtained from the TURN allocation response. + ips_from_non_any_address_ports.insert(c.related_address().ipaddr()); + } } } } @@ -1204,7 +1209,8 @@ void BasicPortAllocatorSession:: bool port_signalable = false; for (const Candidate& c : port_data->port()->Candidates()) { if (!CandidatePairable(c, port_data->port()) || - ips_from_non_any_address_ports.count(c.address().ipaddr())) { + ips_from_non_any_address_ports.count(c.address().ipaddr()) || + ips_from_non_any_address_ports.count(c.related_address().ipaddr())) { continue; } // Even when a port is bound to the "any" address, it should normally