conncheck: discard new pair creation when priority is too low
authorFabrice Bellet <fabrice@bellet.info>
Wed, 8 Apr 2020 15:16:30 +0000 (17:16 +0200)
committerOlivier CrĂȘte <olivier.crete@collabora.com>
Wed, 6 May 2020 01:12:20 +0000 (21:12 -0400)
It is possible to ignore the creation of a new pair whose priority is
lower than the priority of the selected pair, ie the nominated pair with
the highest priority. Such pair would be discarded by a call to
prune_pending_checks(), and if checked, there state would break the
assumption that all pairs with lower priority than the nominated pair
are not retransmitted.

agent/conncheck.c

index 526269c..617ec3f 100644 (file)
@@ -2450,10 +2450,26 @@ static CandidateCheckPair *priv_add_new_check_pair (NiceAgent *agent,
 {
   NiceStream *stream;
   CandidateCheckPair *pair;
+  guint64 priority;
 
   g_assert (local != NULL);
   g_assert (remote != NULL);
 
+  priority = agent_candidate_pair_priority (agent, local, remote);
+
+  if (component->selected_pair.priority &&
+      priority < component->selected_pair.priority) {
+    gchar prio1[NICE_CANDIDATE_PAIR_PRIORITY_MAX_SIZE];
+    gchar prio2[NICE_CANDIDATE_PAIR_PRIORITY_MAX_SIZE];
+
+    nice_candidate_pair_priority_to_string (priority, prio1);
+    nice_candidate_pair_priority_to_string (component->selected_pair.priority,
+        prio2);
+    nice_debug ("Agent %p : do not create a pair that would have a priority "
+        "%s lower than selected pair priority %s.", agent, prio1, prio2);
+    return NULL;
+  }
+
   stream = agent_find_stream (agent, stream_id);
   pair = g_slice_new0 (CandidateCheckPair);