From 3dc202579e691c6cc6c4847e3b4229ea53afeb2c Mon Sep 17 00:00:00 2001 From: Fernando Fernandez Mancera Date: Tue, 1 Dec 2020 18:38:41 +0100 Subject: [PATCH] libnm: NMDeviceEthernet uses PRIO_20 instead of PRIO_30 As NMDeviceVeth has a NMDeviceEthernet as parent, it should use PRIO_20 in order to report NMDeviceVeth when configured and do not report NMDeviceEthernet. An unit test case has been added. Signed-off-by: Fernando Fernandez Mancera --- libnm/NetworkManager.h | 1 + libnm/nm-device-ethernet.c | 2 +- libnm/nm-device-veth.c | 2 +- libnm/nm-libnm-utils.h | 6 ++++++ libnm/tests/test-libnm.c | 5 +++++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libnm/NetworkManager.h b/libnm/NetworkManager.h index c94f093e66..ba83647afa 100644 --- a/libnm/NetworkManager.h +++ b/libnm/NetworkManager.h @@ -34,6 +34,7 @@ #include "nm-device-ppp.h" #include "nm-device-team.h" #include "nm-device-tun.h" +#include "nm-device-veth.h" #include "nm-device-vlan.h" #include "nm-device-vxlan.h" #include "nm-device-wifi-p2p.h" diff --git a/libnm/nm-device-ethernet.c b/libnm/nm-device-ethernet.c index bf4a36fee0..6513e7b7da 100644 --- a/libnm/nm-device-ethernet.c +++ b/libnm/nm-device-ethernet.c @@ -315,7 +315,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_wired = NML_DBUS_META_IFACE_INIT_PROP( NM_DBUS_INTERFACE_DEVICE_WIRED, nm_device_ethernet_get_type, - NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30, + NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_20, NML_DBUS_META_IFACE_DBUS_PROPERTIES( NML_DBUS_META_PROPERTY_INIT_B("Carrier", PROP_CARRIER, NMDeviceEthernetPrivate, carrier), NML_DBUS_META_PROPERTY_INIT_FCN("HwAddress", diff --git a/libnm/nm-device-veth.c b/libnm/nm-device-veth.c index 9f00cd8a6e..c19250d6c0 100644 --- a/libnm/nm-device-veth.c +++ b/libnm/nm-device-veth.c @@ -84,7 +84,7 @@ nm_device_veth_init(NMDeviceVeth *device) const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_veth = NML_DBUS_META_IFACE_INIT_PROP(NM_DBUS_INTERFACE_DEVICE_VETH, nm_device_veth_get_type, - NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_20, + NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30, NML_DBUS_META_IFACE_DBUS_PROPERTIES( NML_DBUS_META_PROPERTY_INIT_O_PROP("Peer", PROP_PEER, diff --git a/libnm/nm-libnm-utils.h b/libnm/nm-libnm-utils.h index 86e7b304b1..ae9c5c25d0 100644 --- a/libnm/nm-libnm-utils.h +++ b/libnm/nm-libnm-utils.h @@ -527,6 +527,12 @@ struct _NMLDBusMetaIface { * %NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_10, and depending on whether there is * a "org.freedesktop.NetworkManager.VPN.Connection" (with high priority), we create * one or the other type. + * + * Another exception is "org.freedesktop.NetworkManager.Device.Veth". It is a NMDeviceVeth + * and the parent is NMDeviceEthernet. Therefore it contains "org.freedesktop.NetworkManager.Device.Wired" + * as it should be registered as NMDeviceVeth, the profile has priority + * %NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_20. + * */ NMLDBusMetaInteracePrio interface_prio : 3; }; diff --git a/libnm/tests/test-libnm.c b/libnm/tests/test-libnm.c index 27f0a7cc01..976b98e722 100644 --- a/libnm/tests/test-libnm.c +++ b/libnm/tests/test-libnm.c @@ -3232,6 +3232,11 @@ test_dbus_meta_types(void) { NM_DBUS_INTERFACE_DEVICE_WIRED, NM_TYPE_DEVICE_ETHERNET, + NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_20, + }, + { + NM_DBUS_INTERFACE_DEVICE_VETH, + NM_TYPE_DEVICE_VETH, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30, }, {