diff options
Diffstat (limited to 'src/core/platform/tests/test-link.c')
| -rw-r--r-- | src/core/platform/tests/test-link.c | 75 |
1 files changed, 69 insertions, 6 deletions
diff --git a/src/core/platform/tests/test-link.c b/src/core/platform/tests/test-link.c index 4cadfe4d..fab6bd2e 100644 --- a/src/core/platform/tests/test-link.c +++ b/src/core/platform/tests/test-link.c @@ -15,6 +15,7 @@ #include "libnm-base/nm-ethtool-base.h" #include "libnm-platform/nmp-object.h" #include "libnm-platform/nmp-netns.h" +#include "libnm-platform/nmp-ethtool-ioctl.h" #include "libnm-platform/nm-platform-utils.h" #include "test-common.h" @@ -2725,6 +2726,66 @@ test_link_set_properties(void) /*****************************************************************************/ static void +test_link_get_bridge_fdb(void) +{ + const NMPlatformLink *link; + nm_auto_freev NMEtherAddr **addrs = NULL; + int ifindex[2]; + guint8 expected[][6] = { + {0x00, 0x99, 0x00, 0x00, 0x00, 0x01}, + {0x00, 0x99, 0x00, 0x00, 0x00, 0x02}, + {0x00, 0x99, 0x00, 0x00, 0x00, 0x03}, + {0x00, 0x99, 0x00, 0x00, 0x00, 0x05}, + }; + guint i; + guint j; + + ifindex[0] = + nmtstp_link_bridge_add(NULL, -1, "br-test-1", &nm_platform_lnk_bridge_default)->ifindex; + ifindex[1] = + nmtstp_link_bridge_add(NULL, -1, "br-test-2", &nm_platform_lnk_bridge_default)->ifindex; + + link = nmtstp_link_get(NULL, ifindex[0], "br-test-1"); + g_assert(link); + link = nmtstp_link_get(NULL, ifindex[1], "br-test-2"); + g_assert(link); + + nmtstp_run_command_check("bridge fdb add dev br-test-1 00:99:00:00:00:01"); + nmtstp_run_command_check("bridge fdb add dev br-test-1 00:99:00:00:00:02"); + nmtstp_run_command_check("bridge fdb add dev br-test-1 00:99:00:00:00:03"); + nmtstp_run_command_check("bridge fdb add dev br-test-2 00:99:00:00:00:01"); + nmtstp_run_command_check("bridge fdb add dev br-test-2 00:99:00:00:00:05"); + + addrs = nm_linux_platform_get_bridge_fdb(NM_PLATFORM_GET, ifindex, 2); + g_assert(addrs); + + /* Check for expected entries */ + for (i = 0; i < G_N_ELEMENTS(expected); i++) { + gboolean found = FALSE; + + for (j = 0; addrs[j]; j++) { + if (memcmp(addrs[j], expected[i], ETH_ALEN) == 0) { + found = TRUE; + break; + } + } + g_assert(found); + } + + /* No dupes */ + for (i = 0; addrs[i]; i++) { + for (j = i + 1; addrs[j]; j++) { + g_assert_cmpint(memcmp(addrs[i], addrs[j], ETH_ALEN), !=, 0); + } + } + + nmtstp_link_delete(NULL, -1, ifindex[0], "br-test-1", TRUE); + nmtstp_link_delete(NULL, -1, ifindex[1], "br-test-2", TRUE); +} + +/*****************************************************************************/ + +static void test_create_many_links_do(guint n_devices) { gint64 time, start_time = nm_utils_get_monotonic_timestamp_nsec(); @@ -3183,10 +3244,10 @@ test_netns_general(gpointer fixture, gconstpointer test_data) * Work around that and skip asserts that are known to fail. */ ethtool_support = nmtstp_run_command("ethtool -i dummy1_ > /dev/null") == 0; if (ethtool_support) { - g_assert(nmp_utils_ethtool_get_driver_info( + g_assert(nmp_ethtool_ioctl_get_driver_info( nmtstp_link_get_typed(platform_1, 0, "dummy1_", NM_LINK_TYPE_DUMMY)->ifindex, &driver_info)); - g_assert(nmp_utils_ethtool_get_driver_info( + g_assert(nmp_ethtool_ioctl_get_driver_info( nmtstp_link_get_typed(platform_1, 0, "dummy2a", NM_LINK_TYPE_DUMMY)->ifindex, &driver_info)); g_assert_cmpint(nmtstp_run_command("ethtool -i dummy1_ > /dev/null"), ==, 0); @@ -3197,10 +3258,10 @@ test_netns_general(gpointer fixture, gconstpointer test_data) g_assert(nm_platform_netns_push(platform_2, &netns_tmp)); if (ethtool_support) { - g_assert(nmp_utils_ethtool_get_driver_info( + g_assert(nmp_ethtool_ioctl_get_driver_info( nmtstp_link_get_typed(platform_2, 0, "dummy1_", NM_LINK_TYPE_DUMMY)->ifindex, &driver_info)); - g_assert(nmp_utils_ethtool_get_driver_info( + g_assert(nmp_ethtool_ioctl_get_driver_info( nmtstp_link_get_typed(platform_2, 0, "dummy2b", NM_LINK_TYPE_DUMMY)->ifindex, &driver_info)); g_assert_cmpint(nmtstp_run_command("ethtool -i dummy1_ > /dev/null"), ==, 0); @@ -4031,7 +4092,7 @@ test_ethtool_features_get(void) _LOGT(">>> ethtool-features-get RUN %u (do-set=%s", i_run, do_set ? "set" : "reset"); - features = nmp_utils_ethtool_get_features(IFINDEX); + features = nmp_ethtool_ioctl_get_features(IFINDEX); g_ptr_array_add(gfree_keeper, features); ethtool_features_dump(features); @@ -4044,7 +4105,7 @@ test_ethtool_features_get(void) features = gfree_keeper->pdata[i_run * 2 - 1]; } - nmp_utils_ethtool_set_features(IFINDEX, features, requested, do_set); + nmp_ethtool_ioctl_set_features(IFINDEX, features, requested, do_set); } } @@ -4105,6 +4166,8 @@ _nmtstp_setup_tests(void) test_software_detect_add("/link/software/detect/wireguard/1", NM_LINK_TYPE_WIREGUARD, 1); test_software_detect_add("/link/software/detect/wireguard/2", NM_LINK_TYPE_WIREGUARD, 2); + g_test_add_func("/link/get-bridge-fdb", test_link_get_bridge_fdb); + g_test_add_func("/link/software/vlan/set-xgress", test_vlan_set_xgress); g_test_add_func("/link/set-properties", test_link_set_properties); |