core: improve handling of NPAR/SR-IOV devices (rh #804527)

Use the new kernel physical_port_id interface property to recognize
when two devices are just virtual devices sharing the same physical
port, and refuse to bond/team multiple slaves on the same port.
This commit is contained in:
Dan Winship
2013-10-11 14:59:26 -04:00
parent a4dcd66698
commit b7300bbe5a
10 changed files with 142 additions and 1 deletions

View File

@@ -1725,6 +1725,26 @@ link_get_mtu (NMPlatform *platform, int ifindex)
return rtnllink ? rtnl_link_get_mtu (rtnllink) : 0;
}
static char *
link_get_physical_port_id (NMPlatform *platform, int ifindex)
{
const char *ifname;
char *path, *id;
ifname = nm_platform_link_get_name (ifindex);
if (!ifname)
return NULL;
path = g_strdup_printf ("/sys/class/net/%s/physical_port_id", ifname);
if (g_file_test (path, G_FILE_TEST_EXISTS))
id = sysctl_get (platform, path);
else
id = NULL;
g_free (path);
return id;
}
static int
vlan_add (NMPlatform *platform, const char *name, int parent, int vlan_id, guint32 vlan_flags)
{
@@ -2719,6 +2739,8 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
platform_class->link_get_mtu = link_get_mtu;
platform_class->link_set_mtu = link_set_mtu;
platform_class->link_get_physical_port_id = link_get_physical_port_id;
platform_class->link_supports_carrier_detect = link_supports_carrier_detect;
platform_class->link_supports_vlans = link_supports_vlans;