Skip to content

Commit a8205bb

Browse files
committed
Linux: Support for "virtual" network interfaces (created by VirtualBox, etc)
1 parent 9285c61 commit a8205bb

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

backend/src/linux_platform.cpp

+11-6
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,18 @@ vector<InterfaceInfo> LinuxPlatform::interfaces()
105105
else
106106
continue;
107107

108-
/* Get parent physical device */
109-
string parent = device_get_property_string(context, devices[i], "net.originating_device", &error);
108+
/* device points to a 'network inteface', get parent (physical?) device */
109+
string parent = device_get_property_string(context, device, "net.originating_device", &error);
110110

111-
/* Originating_device of USB interfaces is an interface, the parent of that is the actual device */
112-
string parent_subsystem = device_get_property_string(context, parent, "info.subsystem", &error);
113-
if (parent_subsystem == "usb")
114-
parent = device_get_property_string(context, parent, "info.parent", &error);
111+
if (parent != "/org/freedesktop/Hal/devices/computer") {
112+
/* Might need to go up one more level to actually find physical device */
113+
string parent_subsystem = device_get_property_string(context, parent, "info.subsystem", &error);
114+
if (parent_subsystem == "usb")
115+
parent = device_get_property_string(context, parent, "info.parent", &error);
116+
} else {
117+
/* Some virtual network interfaces have no device parent. */
118+
parent = devices[i];
119+
}
115120

116121
/* Get device properties */
117122
string vendor = device_get_property_string(context, parent, "info.vendor", &error);

0 commit comments

Comments
 (0)