From 29c293728dfd37505b6dc8f6d7d21b05597bab64 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 26 Nov 2015 12:02:29 +0100 Subject: [PATCH] platform/tests: add test for missing netlink notification for IFA_LINK_NETNSID The related bug rh#1262908 in kernel causes missing netlink notifications when moving a IFA_LINK interface to another netns. Add a test for our workaround. Related: https://bugzilla.redhat.com/show_bug.cgi?id=1262908 --- src/platform/nm-linux-platform.c | 3 ++- src/platform/tests/test-link.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 4f9d712e2e..7cc90b6790 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -2738,7 +2738,8 @@ cache_pre_hook (NMPCache *cache, const NMPObject *old, const NMPObject *new, NMP /* removal of a link could be caused by moving the link to another netns. * In this case, we potentially have to update other links that have this link as parent. - * Currently, kernel misses to sent us a notification in this case (rh #1262908). */ + * Currently, kernel misses to sent us a notification in this case + * (https://bugzilla.redhat.com/show_bug.cgi?id=1262908). */ if ( ops_type == NMP_CACHE_OPS_REMOVED && old /* <-- nonsensical, make coverity happy */ diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c index 8dd68ecb5f..ac574da216 100644 --- a/src/platform/tests/test-link.c +++ b/src/platform/tests/test-link.c @@ -1,5 +1,7 @@ #include "config.h" +#include + #include "nmp-object.h" #include "test-common.h" @@ -1379,6 +1381,8 @@ test_nl_bugs_veth (void) int ifindex_veth0, ifindex_veth1; int i; const NMPlatformLink *pllink_veth0, *pllink_veth1; + gs_free_error GError *error = NULL; + NMTstpNamespaceHandle *ns_handle = NULL; /* create veth pair. */ nmtstp_run_command_check ("ip link add dev %s type veth peer name %s", IFACE_VETH0, IFACE_VETH1); @@ -1409,9 +1413,32 @@ test_nl_bugs_veth (void) g_assert (pllink_veth1); g_assert_cmpint (pllink_veth1->parent, ==, ifindex_veth0); + + /* move one veth peer to another namespace and check that the + * parent/IFLA_LINK of the remaining peer properly updates + * (https://bugzilla.redhat.com/show_bug.cgi?id=1262908). */ + ns_handle = nmtstp_namespace_create (CLONE_NEWNET, &error); + g_assert_no_error (error); + g_assert (ns_handle); + + nmtstp_run_command_check ("ip link set %s netns %ld", IFACE_VETH1, (long) nmtstp_namespace_handle_get_pid (ns_handle)); + NMTST_WAIT_ASSERT (100, { + nmtstp_wait_for_signal (50); + nm_platform_process_events (NM_PLATFORM_GET); + + pllink_veth1 = nm_platform_link_get (NM_PLATFORM_GET, ifindex_veth1); + pllink_veth0 = nm_platform_link_get (NM_PLATFORM_GET, ifindex_veth0); + if ( !pllink_veth1 + && pllink_veth0 + && pllink_veth0->parent == NM_PLATFORM_LINK_OTHER_NETNS) { + break; + } + }); + out: - g_assert (nm_platform_link_delete (NM_PLATFORM_GET, ifindex_veth0)); + nm_platform_link_delete (NM_PLATFORM_GET, ifindex_veth0); nm_platform_link_delete (NM_PLATFORM_GET, ifindex_veth1); + nmtstp_namespace_handle_release (ns_handle); } /*****************************************************************************/