Commit 62c1f2c6 authored by Beniamino Galvani's avatar Beniamino Galvani

platform/tests: test macvlans also using platform code

parent 27c0f8de
......@@ -774,6 +774,39 @@ nmtstp_link_ipip_add (gboolean external_command, const char *name, NMPlatformLnk
return success;
}
gboolean
nmtstp_link_macvlan_add (gboolean external_command, const char *name, int parent, NMPlatformLnkMacvlan *lnk)
{
gboolean success;
external_command = nmtstp_run_command_check_external (external_command);
if (external_command) {
const char *dev;
char *modes[] = {
[MACVLAN_MODE_BRIDGE] = "bridge",
[MACVLAN_MODE_VEPA] = "vepa",
[MACVLAN_MODE_PRIVATE] = "private",
[MACVLAN_MODE_PASSTHRU] = "passthru",
};
dev = nm_platform_link_get_name (NM_PLATFORM_GET, parent);
g_assert (dev);
g_assert_cmpint (lnk->mode, <, G_N_ELEMENTS (modes));
success = !nmtstp_run_command ("ip link add name %s link %s type macvlan mode %s %s",
name,
dev,
modes[lnk->mode],
lnk->no_promisc ? "nopromisc" : "");
if (success)
nmtstp_assert_wait_for_link (name, NM_LINK_TYPE_MACVLAN, 100);
} else
success = nm_platform_link_macvlan_add (NM_PLATFORM_GET, name, parent, lnk, NULL) == NM_PLATFORM_ERROR_SUCCESS;
return success;
}
gboolean
nmtstp_link_sit_add (gboolean external_command, const char *name, NMPlatformLnkSit *lnk)
{
......
......@@ -144,6 +144,9 @@ gboolean nmtstp_link_ip6tnl_add (gboolean external_command,
gboolean nmtstp_link_ipip_add (gboolean external_command,
const char *name,
NMPlatformLnkIpIp *lnk);
gboolean nmtstp_link_macvlan_add (gboolean external_command,
const char *name,
int parent, NMPlatformLnkMacvlan *lnk);
gboolean nmtstp_link_sit_add (gboolean external_command,
const char *name,
NMPlatformLnkSit *lnk);
......
......@@ -740,9 +740,16 @@ test_software_detect (gconstpointer user_data)
}
break;
}
case NM_LINK_TYPE_MACVLAN:
nmtstp_run_command_check ("ip link add name %s link %s type macvlan", DEVICE_NAME, PARENT_NAME);
case NM_LINK_TYPE_MACVLAN: {
NMPlatformLnkMacvlan lnk_macvlan = { };
lnk_macvlan.mode = MACVLAN_MODE_BRIDGE;
lnk_macvlan.no_promisc = FALSE;
if (!nmtstp_link_macvlan_add (EX, DEVICE_NAME, ifindex_parent, &lnk_macvlan))
g_error ("Failed adding MACVLAN interface");
break;
}
case NM_LINK_TYPE_SIT: {
NMPlatformLnkSit lnk_sit = { };
gboolean gracefully_skip = FALSE;
......@@ -867,7 +874,7 @@ test_software_detect (gconstpointer user_data)
g_assert (plnk == nm_platform_link_get_lnk_macvlan (NM_PLATFORM_GET, ifindex, NULL));
g_assert_cmpint (plnk->no_promisc, ==, FALSE);
g_assert_cmpint (plnk->mode, ==, MACVLAN_MODE_VEPA);
g_assert_cmpint (plnk->mode, ==, MACVLAN_MODE_BRIDGE);
break;
}
case NM_LINK_TYPE_SIT: {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment