summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2017-03-09 18:53:03 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2017-03-09 19:01:59 +0100
commit686fea656221d2e54b33969965f93e13516ae4c7 (patch)
tree2db89336f46d5e22a84aed91d276310196a322b2
parent74f62d21ce58301957b93424104cdc3bd1087419 (diff)
downloadNetworkManager-686fea656221d2e54b33969965f93e13516ae4c7.tar.gz
platform: tests: wait for non-tentative address before adding route
Wait that the address becomes non-tentative before adding the route with RTA_PREFSRC. Dummy interfaces are NOARP and thus don't do DAD, but the kernel sets the address as tentative for a small amount of time, which prevents the immediate addition of the route with preferred source. Fixes: 36d9e252d2733f43765597d54bcdd9efa750531d
-rw-r--r--src/platform/tests/test-route.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/platform/tests/test-route.c b/src/platform/tests/test-route.c
index fc080e0c62..58822734fd 100644
--- a/src/platform/tests/test-route.c
+++ b/src/platform/tests/test-route.c
@@ -250,6 +250,8 @@ test_ip6_route (void)
/* Choose a high metric so that we hopefully don't conflict. */
int metric = 22987;
int mss = 1000;
+ const NMPlatformIP6Address *plt_addr;
+ gint64 time_start;
inet_pton (AF_INET6, "2001:db8:a:b:0:0:0:0", &network);
inet_pton (AF_INET6, "2001:db8:c:d:1:2:3:4", &gateway);
@@ -259,6 +261,21 @@ test_ip6_route (void)
NM_PLATFORM_LIFETIME_PERMANENT, NM_PLATFORM_LIFETIME_PERMANENT, 0));
accept_signals (route_added, 0, 1);
+ /* Wait that the address becomes non-tentative. Dummy interfaces are NOARP
+ * and thus don't do DAD, but the kernel sets the address as tentative for a
+ * small amount of time, which prevents the immediate addition of the route
+ * with RTA_PREFSRC */
+ time_start = nm_utils_get_monotonic_timestamp_ms ();
+ while (TRUE) {
+ nm_platform_process_events (NM_PLATFORM_GET);
+ plt_addr = nm_platform_ip6_address_get (NM_PLATFORM_GET, ifindex, pref_src, 128);
+ if (plt_addr && !NM_FLAGS_HAS (plt_addr->n_ifa_flags, IFA_F_TENTATIVE))
+ break;
+ if (nm_utils_get_monotonic_timestamp_ms() - time_start > 2000)
+ g_assert_not_reached();
+ g_usleep (100);
+ }
+
/* Add route to gateway */
nmtstp_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway, 128, in6addr_any, in6addr_any, metric, mss);
accept_signal (route_added);