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.c19
-rw-r--r--src/core/platform/tests/test-link.c133
3 files changed, 119 insertions, 35 deletions
diff --git a/src/core/platform/nm-fake-platform.c b/src/core/platform/nm-fake-platform.c
index c92d9aef..86d6bc5f 100644
--- a/src/core/platform/nm-fake-platform.c
+++ b/src/core/platform/nm-fake-platform.c
@@ -835,7 +835,7 @@ wifi_set_mode(NMPlatform *platform, int ifindex, _NM80211Mode mode)
 }
 
 static guint32
-wifi_find_frequency(NMPlatform *platform, int ifindex, const guint32 *freqs)
+wifi_find_frequency(NMPlatform *platform, int ifindex, const guint32 *freqs, gboolean ap)
 {
     return freqs[0];
 }
diff --git a/src/core/platform/tests/test-common.c b/src/core/platform/tests/test-common.c
index 571fedfe..65bdfeae 100644
--- a/src/core/platform/tests/test-common.c
+++ b/src/core/platform/tests/test-common.c
@@ -2520,7 +2520,9 @@ nmtstp_link_ip6gre_add(NMPlatform                *platform,
     gboolean              success;
     char                  b1[NM_INET_ADDRSTRLEN];
     char                  b2[NM_INET_ADDRSTRLEN];
+    char                  encap[100];
     char                  tclass[20];
+    gboolean              encap_ignore;
     gboolean              tclass_inherit;
 
     g_assert(nm_utils_ifname_valid_kernel(name, NULL));
@@ -2530,6 +2532,7 @@ nmtstp_link_ip6gre_add(NMPlatform                *platform,
 
     _init_platform(&platform, external_command);
 
+again:
     if (external_command) {
         gs_free char *dev = NULL;
 
@@ -2538,9 +2541,11 @@ nmtstp_link_ip6gre_add(NMPlatform                *platform,
                 g_strdup_printf("dev %s", nm_platform_link_get_name(platform, lnk->parent_ifindex));
 
         tclass_inherit = NM_FLAGS_HAS(lnk->flags, IP6_TNL_F_USE_ORIG_TCLASS);
+        encap_ignore   = NM_FLAGS_HAS(lnk->flags, IP6_TNL_F_IGN_ENCAP_LIMIT);
 
         success = !nmtstp_run_command(
-            "ip link add %s type %s%s%s local %s remote %s ttl %u tclass %s flowlabel %x",
+            "ip link add %s type %s%s%s local %s remote %s ttl %u tclass %s%s "
+            "flowlabel %x",
             name,
             lnk->is_tap ? "ip6gretap" : "ip6gre",
             NM_PRINT_FMT_QUOTED2(dev, " ", dev, ""),
@@ -2548,7 +2553,19 @@ nmtstp_link_ip6gre_add(NMPlatform                *platform,
             nm_inet6_ntop(&lnk->remote, b2),
             lnk->ttl,
             tclass_inherit ? "inherit" : nm_sprintf_buf(tclass, "%02x", lnk->tclass),
+            encap_ignore
+                ? "encaplimit none"
+                : (lnk->encap_limit != 4 ? nm_sprintf_buf(encap, "encaplimit %u", lnk->encap_limit)
+                                         : ""),
             lnk->flow_label);
+
+        if (!success && (encap_ignore || lnk->encap_limit != 4)) {
+            /* The command failed. That might be because iproute2 does not support the
+             * encaplimit parameter yet. Retry, now with platform code. */
+            external_command = FALSE;
+            goto again;
+        }
+
         if (success) {
             pllink = nmtstp_assert_wait_for_link(platform,
                                                  name,
diff --git a/src/core/platform/tests/test-link.c b/src/core/platform/tests/test-link.c
index cc1ec6d1..9a1eaf89 100644
--- a/src/core/platform/tests/test-link.c
+++ b/src/core/platform/tests/test-link.c
@@ -1439,12 +1439,25 @@ test_software_detect(gconstpointer user_data)
 
         module_loaded = nmtstp_ensure_module("ip6_gre");
 
-        lnk_ip6tnl.local          = nmtst_inet6_from_string("fd01::42");
-        lnk_ip6tnl.remote         = nmtst_inet6_from_string("fd01::aaaa");
-        lnk_ip6tnl.parent_ifindex = ifindex_parent;
-        lnk_ip6tnl.tclass         = 21;
-        lnk_ip6tnl.flow_label     = 1338;
-        lnk_ip6tnl.is_gre         = TRUE;
+        switch (test_data->test_mode) {
+        case 0:
+            lnk_ip6tnl.local          = nmtst_inet6_from_string("fd01::43");
+            lnk_ip6tnl.remote         = nmtst_inet6_from_string("fd01::aaaa");
+            lnk_ip6tnl.parent_ifindex = ifindex_parent;
+            lnk_ip6tnl.tclass         = 21;
+            lnk_ip6tnl.flow_label     = 1338;
+            lnk_ip6tnl.is_gre         = TRUE;
+            break;
+        case 1:
+            lnk_ip6tnl.local          = nmtst_inet6_from_string("fd01::44");
+            lnk_ip6tnl.remote         = nmtst_inet6_from_string("fd01::aaab");
+            lnk_ip6tnl.parent_ifindex = ifindex_parent;
+            lnk_ip6tnl.tclass         = 0;
+            lnk_ip6tnl.flow_label     = 1339;
+            lnk_ip6tnl.is_gre         = TRUE;
+            lnk_ip6tnl.flags          = IP6_TNL_F_IGN_ENCAP_LIMIT | IP6_TNL_F_USE_ORIG_TCLASS;
+            break;
+        }
 
         if (!nmtstp_link_ip6gre_add(NULL, ext, DEVICE_NAME, &lnk_ip6tnl)) {
             if (!module_loaded) {
@@ -1463,14 +1476,30 @@ test_software_detect(gconstpointer user_data)
 
         module_loaded = nmtstp_ensure_module("ip6_gre");
 
-        lnk_ip6tnl.local          = nmtst_inet6_from_string("fe80::abcd");
-        lnk_ip6tnl.remote         = nmtst_inet6_from_string("fc01::bbbb");
-        lnk_ip6tnl.parent_ifindex = ifindex_parent;
-        lnk_ip6tnl.ttl            = 10;
-        lnk_ip6tnl.tclass         = 22;
-        lnk_ip6tnl.flow_label     = 1339;
-        lnk_ip6tnl.is_gre         = TRUE;
-        lnk_ip6tnl.is_tap         = TRUE;
+        switch (test_data->test_mode) {
+        case 0:
+            lnk_ip6tnl.local          = nmtst_inet6_from_string("fe80::abcd");
+            lnk_ip6tnl.remote         = nmtst_inet6_from_string("fc01::bbbb");
+            lnk_ip6tnl.parent_ifindex = ifindex_parent;
+            lnk_ip6tnl.ttl            = 10;
+            lnk_ip6tnl.tclass         = 23;
+            lnk_ip6tnl.flow_label     = 1340;
+            lnk_ip6tnl.is_gre         = TRUE;
+            lnk_ip6tnl.is_tap         = TRUE;
+            break;
+        case 1:
+            lnk_ip6tnl.local          = nmtst_inet6_from_string("fe80::abce");
+            lnk_ip6tnl.remote         = nmtst_inet6_from_string("fc01::bbbc");
+            lnk_ip6tnl.parent_ifindex = ifindex_parent;
+            lnk_ip6tnl.ttl            = 10;
+            lnk_ip6tnl.tclass         = 0;
+            lnk_ip6tnl.flow_label     = 1341;
+            lnk_ip6tnl.is_gre         = TRUE;
+            lnk_ip6tnl.is_tap         = TRUE;
+            lnk_ip6tnl.encap_limit    = 4;
+            lnk_ip6tnl.flags          = IP6_TNL_F_IGN_ENCAP_LIMIT | IP6_TNL_F_USE_ORIG_TCLASS;
+            break;
+        }
 
         if (!nmtstp_link_ip6gre_add(NULL, ext, DEVICE_NAME, &lnk_ip6tnl)) {
             if (!module_loaded) {
@@ -1851,29 +1880,65 @@ test_software_detect(gconstpointer user_data)
         {
             const NMPlatformLnkIp6Tnl *plnk = &lnk->lnk_ip6tnl;
 
-            g_assert(plnk == nm_platform_link_get_lnk_ip6gre(NM_PLATFORM_GET, ifindex, NULL));
-            g_assert_cmpint(plnk->parent_ifindex, ==, ifindex_parent);
-            nmtst_assert_ip6_address(&plnk->local, "fd01::42");
-            nmtst_assert_ip6_address(&plnk->remote, "fd01::aaaa");
-            g_assert_cmpint(plnk->tclass, ==, 21);
-            g_assert_cmpint(plnk->flow_label, ==, 1338);
-            g_assert_cmpint(plnk->is_gre, ==, TRUE);
-            g_assert_cmpint(plnk->is_tap, ==, FALSE);
+            switch (test_data->test_mode) {
+            case 0:
+                g_assert(plnk == nm_platform_link_get_lnk_ip6gre(NM_PLATFORM_GET, ifindex, NULL));
+                g_assert_cmpint(plnk->parent_ifindex, ==, ifindex_parent);
+                nmtst_assert_ip6_address(&plnk->local, "fd01::43");
+                nmtst_assert_ip6_address(&plnk->remote, "fd01::aaaa");
+                g_assert_cmpint(plnk->tclass, ==, 21);
+                g_assert_cmpint(plnk->flow_label, ==, 1338);
+                g_assert_cmpint(plnk->is_gre, ==, TRUE);
+                g_assert_cmpint(plnk->is_tap, ==, FALSE);
+                break;
+            case 1:
+                g_assert(plnk == nm_platform_link_get_lnk_ip6gre(NM_PLATFORM_GET, ifindex, NULL));
+                g_assert_cmpint(plnk->parent_ifindex, ==, ifindex_parent);
+                nmtst_assert_ip6_address(&plnk->local, "fd01::44");
+                nmtst_assert_ip6_address(&plnk->remote, "fd01::aaab");
+                g_assert_cmpint(plnk->flow_label, ==, 1339);
+                g_assert_cmpint(plnk->is_gre, ==, TRUE);
+                g_assert_cmpint(plnk->is_tap, ==, FALSE);
+                g_assert_cmpint(plnk->flags & 0xFFFF, /* ignore kernel internal flags */
+                                ==,
+                                IP6_TNL_F_IGN_ENCAP_LIMIT | IP6_TNL_F_USE_ORIG_TCLASS);
+                break;
+            }
+
             break;
         }
         case NM_LINK_TYPE_IP6GRETAP:
         {
             const NMPlatformLnkIp6Tnl *plnk = &lnk->lnk_ip6tnl;
 
-            g_assert(plnk == nm_platform_link_get_lnk_ip6gretap(NM_PLATFORM_GET, ifindex, NULL));
-            g_assert_cmpint(plnk->parent_ifindex, ==, ifindex_parent);
-            nmtst_assert_ip6_address(&plnk->local, "fe80::abcd");
-            nmtst_assert_ip6_address(&plnk->remote, "fc01::bbbb");
-            g_assert_cmpint(plnk->ttl, ==, 10);
-            g_assert_cmpint(plnk->tclass, ==, 22);
-            g_assert_cmpint(plnk->flow_label, ==, 1339);
-            g_assert_cmpint(plnk->is_gre, ==, TRUE);
-            g_assert_cmpint(plnk->is_tap, ==, TRUE);
+            switch (test_data->test_mode) {
+            case 0:
+                g_assert(plnk
+                         == nm_platform_link_get_lnk_ip6gretap(NM_PLATFORM_GET, ifindex, NULL));
+                g_assert_cmpint(plnk->parent_ifindex, ==, ifindex_parent);
+                nmtst_assert_ip6_address(&plnk->local, "fe80::abcd");
+                nmtst_assert_ip6_address(&plnk->remote, "fc01::bbbb");
+                g_assert_cmpint(plnk->ttl, ==, 10);
+                g_assert_cmpint(plnk->tclass, ==, 23);
+                g_assert_cmpint(plnk->flow_label, ==, 1340);
+                g_assert_cmpint(plnk->is_gre, ==, TRUE);
+                g_assert_cmpint(plnk->is_tap, ==, TRUE);
+                break;
+            case 1:
+                g_assert(plnk
+                         == nm_platform_link_get_lnk_ip6gretap(NM_PLATFORM_GET, ifindex, NULL));
+                g_assert_cmpint(plnk->parent_ifindex, ==, ifindex_parent);
+                nmtst_assert_ip6_address(&plnk->local, "fe80::abce");
+                nmtst_assert_ip6_address(&plnk->remote, "fc01::bbbc");
+                g_assert_cmpint(plnk->ttl, ==, 10);
+                g_assert_cmpint(plnk->flow_label, ==, 1341);
+                g_assert_cmpint(plnk->is_gre, ==, TRUE);
+                g_assert_cmpint(plnk->is_tap, ==, TRUE);
+                g_assert_cmpint(plnk->flags & 0xFFFF, /* ignore kernel internal flags */
+                                ==,
+                                IP6_TNL_F_IGN_ENCAP_LIMIT | IP6_TNL_F_USE_ORIG_TCLASS);
+                break;
+            }
             break;
         }
         case NM_LINK_TYPE_IPIP:
@@ -3888,8 +3953,10 @@ _nmtstp_setup_tests(void)
         test_software_detect_add("/link/software/detect/gretap", NM_LINK_TYPE_GRETAP, 0);
         test_software_detect_add("/link/software/detect/ip6tnl/0", NM_LINK_TYPE_IP6TNL, 0);
         test_software_detect_add("/link/software/detect/ip6tnl/1", NM_LINK_TYPE_IP6TNL, 1);
-        test_software_detect_add("/link/software/detect/ip6gre", NM_LINK_TYPE_IP6GRE, 0);
-        test_software_detect_add("/link/software/detect/ip6gretap", NM_LINK_TYPE_IP6GRETAP, 0);
+        test_software_detect_add("/link/software/detect/ip6gre/0", NM_LINK_TYPE_IP6GRE, 0);
+        test_software_detect_add("/link/software/detect/ip6gre/1", NM_LINK_TYPE_IP6GRE, 1);
+        test_software_detect_add("/link/software/detect/ip6gretap/0", NM_LINK_TYPE_IP6GRETAP, 0);
+        test_software_detect_add("/link/software/detect/ip6gretap/1", NM_LINK_TYPE_IP6GRETAP, 1);
         test_software_detect_add("/link/software/detect/ipip", NM_LINK_TYPE_IPIP, 0);
         test_software_detect_add("/link/software/detect/macvlan", NM_LINK_TYPE_MACVLAN, 0);
         test_software_detect_add("/link/software/detect/macvtap", NM_LINK_TYPE_MACVTAP, 0);