libnm: adjust nm_device_get_type_description for Veth

Veth interfaces should be shown as Ethernet from
nm_device_get_type_description in order to provide backward
compatibility.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
This commit is contained in:
Fernando Fernandez Mancera 2020-12-14 11:29:59 +01:00
parent 3dc202579e
commit b19b800c95
2 changed files with 8 additions and 2 deletions

View file

@ -1223,8 +1223,11 @@ nm_device_get_type_description(NMDevice *device)
}
typename = G_OBJECT_TYPE_NAME(device);
if (g_str_has_prefix(typename, "NMDevice"))
if (g_str_has_prefix(typename, "NMDevice")) {
typename += 8;
if (nm_streq(typename, "Veth"))
typename = "Ethernet";
}
priv->type_description = g_ascii_strdown(typename, -1);
return _nml_coerce_property_str_not_empty(priv->type_description);

View file

@ -3778,8 +3778,11 @@ get_type_description(NMDevice *self)
gs_free char *s = NULL;
typename = G_OBJECT_TYPE_NAME(self);
if (g_str_has_prefix(typename, "NMDevice"))
if (g_str_has_prefix(typename, "NMDevice")) {
typename += 8;
if (nm_streq(typename, "Veth"))
typename = "Ethernet";
}
s = g_ascii_strdown(typename, -1);
klass->default_type_description = g_intern_string(s);
klass->default_type_description_klass = klass;