conncheck: add missing cases when pruning pending checks
authorFabrice Bellet <fabrice@bellet.info>
Thu, 9 Apr 2020 14:47:17 +0000 (16:47 +0200)
committerOlivier CrĂȘte <olivier.crete@collabora.com>
Wed, 6 May 2020 01:12:20 +0000 (21:12 -0400)
When pruning pending checks (after at least one nominated pair has been
obtained), some supplementary cases need to be handled, to ensure that
the property "all pairs and only the pairs having a higher priority than
the nominated pair should have the stun retransmit flag set" remains
true during the whole conncheck:

- a pair "not to be retransmitted" must be removed from the triggered check
  list (because a triggered check would create a new stun request, that
  would defacto ignore the retransmit flag)

- an in-progress pair "not to be retransmitted", for which no stun
  request has been sent (p->stun_transactions == NULL, a transient
  state) must be removed from the conncheck list, just like a waiting
  pair.

- a failed pair must have its flag "retransmit" updated too, just like
  another pair, since a failed pair could match an inbound check, and
  generate a triggered check, based on retransmit flag value : ie only
  if this pair has a chance to become a better nominated pair. See
  NICE_CHECK_FAILED case in priv_schedule_triggered_check().

agent/conncheck.c

index abaf5f2..41d8c92 100644 (file)
@@ -3140,10 +3140,17 @@ static guint priv_prune_pending_checks (NiceAgent *agent, NiceStream *stream, Ni
     /* note: a SHOULD level req. in ICE 8.1.2. "Updating States" (ID-19) */
     else if (p->state == NICE_CHECK_IN_PROGRESS) {
       if (p->priority < priority) {
+        priv_remove_pair_from_triggered_check_queue (agent, p);
         if (p->retransmit && p->stun_transactions) {
           p->retransmit  = FALSE;
           nice_debug ("Agent %p : pair %p will not be retransmitted.",
               agent, p);
+        } else if (p->retransmit) {
+          /* Pair in-progress, but stun request not yet sent */
+          nice_debug ("Agent %p : pair %p removed.", agent, p);
+          candidate_check_pair_free (agent, p);
+          stream->conncheck_list = g_slist_delete_link(stream->conncheck_list,
+              i);
         }
       } else {
         /* We must keep the higher priority pairs running because if a udp
@@ -3161,6 +3168,12 @@ static guint priv_prune_pending_checks (NiceAgent *agent, NiceStream *stream, Ni
         in_progress++;
       }
     }
+    /* A triggered check on a failed pair will depend on the retransmit
+     * flag, so on the relative priority of this pair and the nominated
+     * pair.
+     */
+    else if (p->state == NICE_CHECK_FAILED)
+      p->retransmit = (p->priority > priority ? TRUE : FALSE);
     i = next;
   }