From: Michael Biebl Date: Thu, 10 Jul 2014 03:38:42 +0200 Subject: Mark virtual ethernet interfaces as unmanaged We do not want to interfere with VBox and VMware network interfaces, so ignore any virtual ethernet interfaces and mark them as unmanaged. --- src/devices/nm-device-ethernet.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index ac408d3..116d4d3 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -250,6 +250,45 @@ out: g_object_unref (client); } +static void +nm_device_check_virtual (NMDeviceEthernet *self) +{ + GUdevDevice *dev = NULL; + GUdevClient *client = NULL; + const char *iface = NULL; + const char *subsystems[] = { "net", NULL }; + const char *sysfs_path; + const char *virtual = "/sys/devices/virtual/net"; + + iface = nm_device_get_iface (NM_DEVICE (self)); + + client = g_udev_client_new (subsystems); + if (!client) { + nm_log_warn (LOGD_DEVICE | LOGD_HW, "(%s): failed to initialize GUdev client", iface); + goto out; + } + + dev = g_udev_client_query_by_subsystem_and_name (client, "net", iface); + if (!dev) { + nm_log_warn (LOGD_DEVICE | LOGD_HW, "(%s): failed to find device with udev", iface); + goto out; + } + + sysfs_path = g_udev_device_get_sysfs_path (dev); + + if (g_ascii_strncasecmp (sysfs_path, virtual, strlen (virtual)) == 0) { + nm_log_info (LOGD_DEVICE | LOGD_HW, "(%s): device is virtual, marking as unmanaged", iface); + nm_device_set_initial_unmanaged_flag (NM_DEVICE (self), NM_UNMANAGED_DEFAULT, TRUE); + } + +out: + if (client) + g_object_unref (client); + if (dev) + g_object_unref (dev); +} + + static GObject* constructor (GType type, guint n_construct_params, @@ -272,6 +311,8 @@ constructor (GType type, /* s390 stuff */ _update_s390_subchannels (NM_DEVICE_ETHERNET (object)); + + nm_device_check_virtual (NM_DEVICE_ETHERNET (object)); } return object;