summary refs log tree commit diff
path: root/src/core/platform
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/platform')
-rw-r--r--src/core/platform/nm-fake-platform.c2
-rw-r--r--src/core/platform/tests/test-common.c4
-rw-r--r--src/core/platform/tests/test-link.c75
-rw-r--r--src/core/platform/tests/test-route.c33
4 files changed, 89 insertions, 25 deletions
diff --git a/src/core/platform/nm-fake-platform.c b/src/core/platform/nm-fake-platform.c
index 10c69f63..e0d51b70 100644
--- a/src/core/platform/nm-fake-platform.c
+++ b/src/core/platform/nm-fake-platform.c
@@ -117,7 +117,7 @@ ip6_address_delete(NMPlatform *platform, int ifindex, struct in6_addr addr, guin
         const int         _dirfd  = (dirfd);                                                     \
         const char *const _path   = (path);                                                      \
                                                                                                  \
-        g_assert(_path &&_path[0]);                                                              \
+        g_assert(_path && _path[0]);                                                             \
         g_assert(!strstr(_path, "/../"));                                                        \
         if (_dirfd < 0) {                                                                        \
             g_assert(!_pathid);                                                                  \
diff --git a/src/core/platform/tests/test-common.c b/src/core/platform/tests/test-common.c
index 26f8b26b..91445b30 100644
--- a/src/core/platform/tests/test-common.c
+++ b/src/core/platform/tests/test-common.c
@@ -1356,7 +1356,7 @@ nmtstp_check_platform_full(NMPlatform *platform, guint32 obj_type_flags, gboolea
                     /* For IPv4, it also does not reliably always work. This may
                      * be a bug we want to fix. For now, ignore the check.
                      *
-                     * a) Kernel can wrongly allow to configure the same route twice.
+                     * a) Kernel can wrongly allow one to configure the same route twice.
                      * That means, the same route is visible in `ip route` output,
                      * meaning, it would be added twice to the platform cache.
                      * At least due to that problem, may the weak-id not be properly sorted.
@@ -1364,7 +1364,7 @@ nmtstp_check_platform_full(NMPlatform *platform, guint32 obj_type_flags, gboolea
                      * a bug of kernel allowing to configure the exact same route twice.
                      *
                      * b) See https://bugzilla.redhat.com/show_bug.cgi?id=2162315 which is
-                     * a bug where kernel does allow to configure single-hop routes that differ by
+                     * a bug where kernel does allow one to configure single-hop routes that differ by
                      * their next-hop weight, but on the netlink API those routes look the same.
                      *
                      * Due to a) and b), the platform cache may contain only one instance
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);
diff --git a/src/core/platform/tests/test-route.c b/src/core/platform/tests/test-route.c
index a05362f2..f8f7070b 100644
--- a/src/core/platform/tests/test-route.c
+++ b/src/core/platform/tests/test-route.c
@@ -640,22 +640,23 @@ test_ip4_route_options(gconstpointer test_data)
     switch (TEST_IDX) {
     case 1:
         rts_add[rts_n++] = ((NMPlatformIP4Route) {
-            .ifindex    = IFINDEX,
-            .rt_source  = NM_IP_CONFIG_SOURCE_USER,
-            .network    = nmtst_inet4_from_string("172.16.1.0"),
-            .plen       = 24,
-            .metric     = 20,
-            .tos        = 0x28,
-            .window     = 10000,
-            .cwnd       = 16,
-            .initcwnd   = 30,
-            .initrwnd   = 50,
-            .mtu        = 1350,
-            .lock_cwnd  = TRUE,
-            .mss        = 1300,
-            .quickack   = TRUE,
-            .rto_min    = 1000,
-            .n_nexthops = 1,
+            .ifindex     = IFINDEX,
+            .rt_source   = NM_IP_CONFIG_SOURCE_USER,
+            .network     = nmtst_inet4_from_string("172.16.1.0"),
+            .plen        = 24,
+            .metric      = 20,
+            .tos         = 0x28,
+            .window      = 10000,
+            .cwnd        = 16,
+            .initcwnd    = 30,
+            .initrwnd    = 50,
+            .mtu         = 1350,
+            .lock_cwnd   = TRUE,
+            .mss         = 1300,
+            .quickack    = TRUE,
+            .rto_min     = 1000,
+            .rto_min_set = TRUE,
+            .n_nexthops  = 1,
         });
         break;
     case 2: