diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index edd8ef5f13..6c9f93808c 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -5399,6 +5399,24 @@ nm_device_get_type_desc(NMDevice *self) return NM_DEVICE_GET_PRIVATE(self)->type_desc; } +const char * +nm_device_get_type_desc_for_log(NMDevice *self) +{ + const char *type; + + type = nm_device_get_type_desc(self); + + /* Some OVS device types (ports and bridges) are not backed by a kernel link, and + * they can have the same name of another device of a different type. In fact, it's + * quite common to assign the same name to the OVS bridge, the OVS port and the OVS + * interface. For this reason, also log the type in case of OVS devices to make the + * log message unambiguous. */ + if (NM_STR_HAS_PREFIX(type, "Open vSwitch")) + return type; + + return NULL; +} + const char * nm_device_get_type_description(NMDevice *self) { diff --git a/src/core/devices/nm-device.h b/src/core/devices/nm-device.h index e22dbd07a9..35a8d1cd49 100644 --- a/src/core/devices/nm-device.h +++ b/src/core/devices/nm-device.h @@ -463,6 +463,7 @@ int nm_device_get_ip_ifindex(const NMDevice *dev); const char *nm_device_get_driver(NMDevice *dev); const char *nm_device_get_driver_version(NMDevice *dev); const char *nm_device_get_type_desc(NMDevice *dev); +const char *nm_device_get_type_desc_for_log(NMDevice *dev); const char *nm_device_get_type_description(NMDevice *dev); NMDeviceType nm_device_get_device_type(NMDevice *dev); NMLinkType nm_device_get_link_type(NMDevice *dev);