Commit e1486f20 authored by Philip Withnall's avatar Philip Withnall

agent: Use provided CandidatePair rather than re-finding a pair

In priv_update_selected_pair(), commit 57393333 changed the code to
re-find a CandidatePair matching the given lfoundation and rfoundation.
However, the foundation does not uniquely identify candidate pairs,
and if we’re aiming to set a specific candidate pair as the selected
pair, this could result in the wrong pair being selected.

This can happen when handling multiple similar candidate pairs, such as
when generating peer reflexive candidates from multiple sources.

See https://tools.ietf.org/html/rfc5245#section-2.4.

Originally spotted by Fabrice Bellet in
https://phabricator.freedesktop.org/T3557.

Differential Revision: https://phabricator.freedesktop.org/D742
parent 41ab61de
......@@ -1207,17 +1207,20 @@ static void priv_limit_conn_check_list_size (GSList *conncheck_list, guint upper
*/
static gboolean priv_update_selected_pair (NiceAgent *agent, NiceComponent *component, CandidateCheckPair *pair)
{
CandidatePair cpair;
CandidatePair cpair = { 0, };
g_assert (component);
g_assert (pair);
if (pair->priority > component->selected_pair.priority &&
nice_component_find_pair (component, agent, pair->local->foundation,
pair->remote->foundation, &cpair)) {
if (pair->priority > component->selected_pair.priority) {
nice_debug ("Agent %p : changing SELECTED PAIR for component %u: %s:%s "
"(prio:%" G_GUINT64_FORMAT ").", agent, component->id,
pair->local->foundation, pair->remote->foundation, pair->priority);
cpair.local = pair->local;
cpair.remote = pair->remote;
cpair.priority = pair->priority;
/* cpair.keepalive is not used by nice_component_update_selected_pair() */
nice_component_update_selected_pair (component, &cpair);
priv_conn_keepalive_tick_unlocked (agent);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment