diff options
author | Fabrice Bellet <fabrice@bellet.info> | 2017-11-21 15:12:45 +0100 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2017-11-27 15:27:13 -0500 |
commit | 02216a6766caccb652387d5ee19686149eedbc93 (patch) | |
tree | e8e0bd033a1718fc070b5936ea186c5efb16a153 /tests/test-restart.c | |
parent | fbdccf0c2787ebdc65fe13ac64bd25c829ea7972 (diff) | |
download | libnice-02216a6766caccb652387d5ee19686149eedbc93.tar.gz |
agent: prevent external role change while conncheck is running
With this patch, we stash the controlling mode property change, and
apply it safely, when it won't interfere with an ongoing conncheck
running. According to RFC5245, sect 5.2. "Determining Role", the role
is determined for a session, and persists unless an ICE is restarted.
Differential Revision: https://phabricator.freedesktop.org/D1887
Diffstat (limited to 'tests/test-restart.c')
-rw-r--r-- | tests/test-restart.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test-restart.c b/tests/test-restart.c index c2cbe9a..afc51b6 100644 --- a/tests/test-restart.c +++ b/tests/test-restart.c @@ -301,6 +301,11 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress * nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP, cands); cdes.addr = laddr_rtcp; nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP, cands); + /* This role switch request will be effective after restart. We test + * here that the role cannot be externally modified after conncheck + * has started. */ + g_object_set (G_OBJECT (ragent), "controlling-mode", TRUE, NULL); + g_assert (ragent->controlling_mode == FALSE); g_debug ("test-restart: Set properties, next running mainloop until connectivity checks succeed..."); @@ -329,10 +334,18 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress * global_ragent_read = 0; g_assert (nice_agent_send (lagent, ls_id, 1, 16, "1234567812345678") == 16); + /* Both agent have a distinct role at the end of the conncheck */ + g_assert (lagent->controlling_mode == TRUE); + g_assert (ragent->controlling_mode == FALSE); /* step: restart agents, exchange updated credentials */ tie_breaker = ragent->tie_breaker; nice_agent_restart (ragent); g_assert (tie_breaker != ragent->tie_breaker); + /* This role switch of ragent should be done now, and both agents + * have now the same role, which should generate a role conflict + * resolution situation */ + g_assert (lagent->controlling_mode == TRUE); + g_assert (ragent->controlling_mode == TRUE); nice_agent_restart (lagent); { gchar *ufrag = NULL, *password = NULL; @@ -375,6 +388,8 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress * /* note: verify binding requests were resent after restart */ g_assert (global_lagent_ibr_received == TRUE); g_assert (global_ragent_ibr_received == TRUE); + /* note: verify that a role switch occured for one of the agents */ + g_assert (ragent->controlling_mode != lagent->controlling_mode); g_debug ("test-restart: Ran mainloop, removing streams..."); |