discovery: use a single server reflexive and relay local candidate
authorFabrice Bellet <fabrice@bellet.info>
Wed, 26 Feb 2020 19:46:56 +0000 (20:46 +0100)
committerOlivier CrĂȘte <olivier.crete@ocrete.ca>
Mon, 14 Dec 2020 19:13:21 +0000 (19:13 +0000)
The rationale with this patch is that an agent running on a multihomed
host have no gain to store multiple identical server reflexive and relay
local candidates (those obtained by a stun bind request sent from each
local interface). The stun requests that use the same default route are
all expected to provide the same answer.

This patch should keep intact the ICE conncheck versatility, and
drastically improve the conncheck time to completion, as the number of
checked pairs is reduced.

agent/discovery.c

index 0ca0041..823a50f 100644 (file)
@@ -423,7 +423,24 @@ static gboolean priv_add_local_candidate_pruned (NiceAgent *agent, guint stream_
     if (nice_address_equal (&c->base_addr, &candidate->base_addr) &&
         nice_address_equal (&c->addr, &candidate->addr) &&
         c->transport == candidate->transport) {
-      nice_debug ("Candidate %p (component-id %u) redundant, ignoring.", candidate, component->id);
+      nice_debug ("Agent %p : s%d/c%d : cand %p redundant, ignoring.",
+          agent, stream_id, component->id, candidate);
+      return FALSE;
+    }
+
+    if (c->type == NICE_CANDIDATE_TYPE_RELAYED &&
+        candidate->type == NICE_CANDIDATE_TYPE_RELAYED &&
+        nice_address_equal_no_port (&c->addr, &candidate->addr)) {
+      nice_debug ("Agent %p : s%d/c%d : relay cand %p redundant, ignoring.",
+          agent, stream_id, component->id, candidate);
+      return FALSE;
+    }
+
+    if (c->type == NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE &&
+        candidate->type == NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE &&
+        nice_address_equal_no_port (&c->addr, &candidate->addr)) {
+      nice_debug ("Agent %p : s%d/c%d : srflx cand %p redundant, ignoring.",
+          agent, stream_id, component->id, candidate);
       return FALSE;
     }
   }