summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-04-07 16:31:54 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2023-04-19 23:31:28 +0200
commite720f2f0029b3a5ead65cf64d88a96f726a9681c (patch)
tree68df4ebaf48338050807e78a057f7127ad3cb959
parent7f8b73c0d02021ab884f9db5561133a57598661a (diff)
downloadNetworkManager-e720f2f0029b3a5ead65cf64d88a96f726a9681c.tar.gz
platform/tests: fix unit test creating ip6gre tunnel with old iproute2
Older versions of iproute2 don't support the "enclimit" argument. Work around that from the unit tests. Fixes: 1505ca3626b2 ('platform/tests: ip6gre & ip6gretap test cases (ip6 tunnel flags)') (cherry picked from commit 640c82710f9b4d0569594ffb970350f437905bda)
-rw-r--r--src/core/platform/tests/test-common.c18
-rw-r--r--src/core/platform/tests/test-link.c1
2 files changed, 16 insertions, 3 deletions
diff --git a/src/core/platform/tests/test-common.c b/src/core/platform/tests/test-common.c
index c32bff4511..65bdfeae08 100644
--- a/src/core/platform/tests/test-common.c
+++ b/src/core/platform/tests/test-common.c
@@ -2520,7 +2520,7 @@ nmtstp_link_ip6gre_add(NMPlatform *platform,
gboolean success;
char b1[NM_INET_ADDRSTRLEN];
char b2[NM_INET_ADDRSTRLEN];
- char encap[20];
+ char encap[100];
char tclass[20];
gboolean encap_ignore;
gboolean tclass_inherit;
@@ -2532,6 +2532,7 @@ nmtstp_link_ip6gre_add(NMPlatform *platform,
_init_platform(&platform, external_command);
+again:
if (external_command) {
gs_free char *dev = NULL;
@@ -2543,7 +2544,7 @@ nmtstp_link_ip6gre_add(NMPlatform *platform,
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 encaplimit %s "
+ "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",
@@ -2552,8 +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 ? "none" : nm_sprintf_buf(encap, "%u", lnk->encap_limit),
+ 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 8335aef1d4..9a1eaf890e 100644
--- a/src/core/platform/tests/test-link.c
+++ b/src/core/platform/tests/test-link.c
@@ -1496,6 +1496,7 @@ test_software_detect(gconstpointer user_data)
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;
}