mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-15 02:10:32 +01:00
platform/tests: test IPIP links
This commit is contained in:
parent
3063f40e9a
commit
133724d958
3 changed files with 59 additions and 0 deletions
|
|
@ -700,6 +700,36 @@ nmtstp_link_gre_add (gboolean external_command, const char *name, NMPlatformLnkG
|
|||
return success;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nmtstp_link_ipip_add (gboolean external_command, const char *name, NMPlatformLnkIpIp *lnk)
|
||||
{
|
||||
gboolean success;
|
||||
char buffer[INET_ADDRSTRLEN];
|
||||
|
||||
external_command = nmtstp_run_command_check_external (external_command);
|
||||
|
||||
if (external_command) {
|
||||
gs_free char *dev = NULL;
|
||||
|
||||
if (lnk->parent_ifindex)
|
||||
dev = g_strdup_printf ("dev %s", nm_platform_link_get_name (NM_PLATFORM_GET, lnk->parent_ifindex));
|
||||
|
||||
success = !nmtstp_run_command ("ip tunnel add %s mode ipip %s local %s remote %s ttl %u tos %02x %s",
|
||||
name,
|
||||
dev,
|
||||
nm_utils_inet4_ntop (lnk->local, NULL),
|
||||
nm_utils_inet4_ntop (lnk->remote, buffer),
|
||||
lnk->ttl,
|
||||
lnk->tos,
|
||||
lnk->path_mtu_discovery ? "pmtudisc" : "nopmtudisc");
|
||||
if (success)
|
||||
nmtstp_assert_wait_for_link (name, NM_LINK_TYPE_IPIP, 100);
|
||||
} else
|
||||
success = nm_platform_link_ipip_add (NM_PLATFORM_GET, name, lnk, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nmtstp_link_sit_add (gboolean external_command, const char *name, NMPlatformLnkSit *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_ipip_add (gboolean external_command,
|
||||
const char *name,
|
||||
NMPlatformLnkIpIp *lnk);
|
||||
gboolean nmtstp_link_sit_add (gboolean external_command,
|
||||
const char *name,
|
||||
NMPlatformLnkSit *lnk);
|
||||
|
|
|
|||
|
|
@ -690,6 +690,19 @@ test_software_detect (gconstpointer user_data)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case NM_LINK_TYPE_IPIP: {
|
||||
NMPlatformLnkIpIp lnk_ipip = { };
|
||||
|
||||
inet_pton (AF_INET, "1.2.3.4", &lnk_ipip.local);
|
||||
inet_pton (AF_INET, "5.6.7.8", &lnk_ipip.remote);
|
||||
lnk_ipip.parent_ifindex = ifindex_parent;
|
||||
lnk_ipip.tos = 32;
|
||||
lnk_ipip.path_mtu_discovery = FALSE;
|
||||
|
||||
if (!nmtstp_link_ipip_add (EX, DEVICE_NAME, &lnk_ipip))
|
||||
g_error ("Failed adding IPIP 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;
|
||||
|
|
@ -786,6 +799,18 @@ test_software_detect (gconstpointer user_data)
|
|||
g_assert_cmpint (plnk->path_mtu_discovery, ==, TRUE);
|
||||
break;
|
||||
}
|
||||
case NM_LINK_TYPE_IPIP: {
|
||||
const NMPlatformLnkIpIp *plnk = &lnk->lnk_ipip;
|
||||
|
||||
g_assert (plnk == nm_platform_link_get_lnk_ipip (NM_PLATFORM_GET, ifindex, NULL));
|
||||
g_assert_cmpint (plnk->parent_ifindex, ==, ifindex_parent);
|
||||
nmtst_assert_ip4_address (plnk->local, "1.2.3.4");
|
||||
nmtst_assert_ip4_address (plnk->remote, "5.6.7.8");
|
||||
g_assert_cmpint (plnk->ttl, ==, 0);
|
||||
g_assert_cmpint (plnk->tos, ==, 32);
|
||||
g_assert_cmpint (plnk->path_mtu_discovery, ==, FALSE);
|
||||
break;
|
||||
}
|
||||
case NM_LINK_TYPE_MACVLAN: {
|
||||
const NMPlatformLnkMacvlan *plnk = &lnk->lnk_macvlan;
|
||||
|
||||
|
|
@ -1624,6 +1649,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/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);
|
||||
test_software_detect_add ("/link/software/detect/vlan", NM_LINK_TYPE_VLAN, 0);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue