mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-06 22:10:25 +01:00
platform/tests: test IP6TNL links
This commit is contained in:
parent
133724d958
commit
1a3448b43b
3 changed files with 77 additions and 0 deletions
|
|
@ -700,6 +700,50 @@ nmtstp_link_gre_add (gboolean external_command, const char *name, NMPlatformLnkG
|
|||
return success;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nmtstp_link_ip6tnl_add (gboolean external_command, const char *name, NMPlatformLnkIp6Tnl *lnk)
|
||||
{
|
||||
gboolean success;
|
||||
char buffer[INET6_ADDRSTRLEN];
|
||||
|
||||
external_command = nmtstp_run_command_check_external (external_command);
|
||||
|
||||
if (external_command) {
|
||||
gs_free char *dev = NULL;
|
||||
const char *mode;
|
||||
|
||||
if (lnk->parent_ifindex)
|
||||
dev = g_strdup_printf ("dev %s", nm_platform_link_get_name (NM_PLATFORM_GET, lnk->parent_ifindex));
|
||||
|
||||
switch (lnk->proto) {
|
||||
case IPPROTO_IPIP:
|
||||
mode = "ipip6";
|
||||
break;
|
||||
case IPPROTO_IPV6:
|
||||
mode = "ip6ip6";
|
||||
break;
|
||||
default:
|
||||
g_assert (FALSE);
|
||||
}
|
||||
|
||||
success = !nmtstp_run_command ("ip -6 tunnel add %s mode %s %s local %s remote %s ttl %u tclass %02x encaplimit %u flowlabel %x",
|
||||
name,
|
||||
mode,
|
||||
dev,
|
||||
nm_utils_inet6_ntop (&lnk->local, NULL),
|
||||
nm_utils_inet6_ntop (&lnk->remote, buffer),
|
||||
lnk->ttl,
|
||||
lnk->tclass,
|
||||
lnk->encap_limit,
|
||||
lnk->flow_label);
|
||||
if (success)
|
||||
nmtstp_assert_wait_for_link (name, NM_LINK_TYPE_IP6TNL, 100);
|
||||
} else
|
||||
success = nm_platform_link_ip6tnl_add (NM_PLATFORM_GET, name, lnk, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nmtstp_link_ipip_add (gboolean external_command, const char *name, NMPlatformLnkIpIp *lnk)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -138,6 +138,9 @@ void nmtstp_link_set_updown (gboolean external_command,
|
|||
gboolean nmtstp_link_gre_add (gboolean external_command,
|
||||
const char *name,
|
||||
NMPlatformLnkGre *lnk);
|
||||
gboolean nmtstp_link_ip6tnl_add (gboolean external_command,
|
||||
const char *name,
|
||||
NMPlatformLnkIp6Tnl *lnk);
|
||||
gboolean nmtstp_link_ipip_add (gboolean external_command,
|
||||
const char *name,
|
||||
NMPlatformLnkIpIp *lnk);
|
||||
|
|
|
|||
|
|
@ -703,6 +703,21 @@ test_software_detect (gconstpointer user_data)
|
|||
g_error ("Failed adding IPIP tunnel");
|
||||
break;
|
||||
}
|
||||
case NM_LINK_TYPE_IP6TNL: {
|
||||
NMPlatformLnkIp6Tnl lnk_ip6tnl = { };
|
||||
|
||||
inet_pton (AF_INET6, "fd01::15", &lnk_ip6tnl.local);
|
||||
inet_pton (AF_INET6, "fd01::16", &lnk_ip6tnl.remote);
|
||||
lnk_ip6tnl.parent_ifindex = ifindex_parent;
|
||||
lnk_ip6tnl.tclass = 20;
|
||||
lnk_ip6tnl.encap_limit = 6;
|
||||
lnk_ip6tnl.flow_label = 1337;
|
||||
lnk_ip6tnl.proto = IPPROTO_IPV6;
|
||||
|
||||
if (!nmtstp_link_ip6tnl_add (EX, DEVICE_NAME, &lnk_ip6tnl))
|
||||
g_error ("Failed adding IPv6 tunnel");
|
||||
break;
|
||||
}
|
||||
case NM_LINK_TYPE_MACVLAN:
|
||||
nmtstp_run_command_check ("ip link add name %s link %s type macvlan", DEVICE_NAME, PARENT_NAME);
|
||||
break;
|
||||
|
|
@ -799,6 +814,20 @@ test_software_detect (gconstpointer user_data)
|
|||
g_assert_cmpint (plnk->path_mtu_discovery, ==, TRUE);
|
||||
break;
|
||||
}
|
||||
case NM_LINK_TYPE_IP6TNL: {
|
||||
const NMPlatformLnkIp6Tnl *plnk = &lnk->lnk_ip6tnl;
|
||||
|
||||
g_assert (plnk == nm_platform_link_get_lnk_ip6tnl (NM_PLATFORM_GET, ifindex, NULL));
|
||||
g_assert_cmpint (plnk->parent_ifindex, ==, ifindex_parent);
|
||||
nmtst_assert_ip6_address (&plnk->local, "fd01::15");
|
||||
nmtst_assert_ip6_address (&plnk->remote, "fd01::16");
|
||||
g_assert_cmpint (plnk->ttl, ==, 0);
|
||||
g_assert_cmpint (plnk->tclass, ==, 20);
|
||||
g_assert_cmpint (plnk->encap_limit, ==, 6);
|
||||
g_assert_cmpint (plnk->flow_label, ==, 1337);
|
||||
g_assert_cmpint (plnk->proto, ==, IPPROTO_IPV6);
|
||||
break;
|
||||
}
|
||||
case NM_LINK_TYPE_IPIP: {
|
||||
const NMPlatformLnkIpIp *plnk = &lnk->lnk_ipip;
|
||||
|
||||
|
|
@ -1649,6 +1678,7 @@ setup_tests (void)
|
|||
g_test_add_func ("/link/external", test_external);
|
||||
|
||||
test_software_detect_add ("/link/software/detect/gre", NM_LINK_TYPE_GRE, 0);
|
||||
test_software_detect_add ("/link/software/detect/ip6tnl", NM_LINK_TYPE_IP6TNL, 0);
|
||||
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/sit", NM_LINK_TYPE_SIT, 0);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue