From 6a898fc0a29f7f8835da2d4c071bdbf94a83c3cc Mon Sep 17 00:00:00 2001 From: Fernando Fernandez Mancera Date: Thu, 19 Sep 2024 14:38:15 +0200 Subject: [PATCH 1/3] ipvlan: fix libnm unit test for ipvlan setting and dbus Fixes: d238ff487b29 ('ipvlan: add support to IPVLAN interface') --- src/libnm-client-impl/tests/test-libnm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libnm-client-impl/tests/test-libnm.c b/src/libnm-client-impl/tests/test-libnm.c index f677ad8e6..4d3652ebe 100644 --- a/src/libnm-client-impl/tests/test-libnm.c +++ b/src/libnm-client-impl/tests/test-libnm.c @@ -2692,6 +2692,7 @@ test_types(void) G(nm_device_get_type), G(nm_device_infiniband_get_type), G(nm_device_ip_tunnel_get_type), + G(nm_device_ipvlan_get_type), G(nm_device_macsec_get_type), G(nm_device_macvlan_get_type), G(nm_device_modem_capabilities_get_type), @@ -2769,6 +2770,8 @@ test_types(void) G(nm_setting_ip6_config_privacy_get_type), G(nm_setting_ip_config_get_type), G(nm_setting_ip_tunnel_get_type), + G(nm_setting_ipvlan_get_type), + G(nm_setting_ipvlan_mode_get_type), G(nm_setting_mac_randomization_get_type), G(nm_setting_macsec_get_type), G(nm_setting_macsec_mode_get_type), @@ -3393,6 +3396,11 @@ test_dbus_meta_types(void) NM_TYPE_DEVICE_IP_TUNNEL, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30, }, + { + NM_DBUS_INTERFACE_DEVICE_IPVLAN, + NM_TYPE_DEVICE_IPVLAN, + NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30, + }, { NM_DBUS_INTERFACE_DEVICE_MACSEC, NM_TYPE_DEVICE_MACSEC, From 1e70f2437861d391c6a357931dbbed2b7d192c8f Mon Sep 17 00:00:00 2001 From: Fernando Fernandez Mancera Date: Mon, 23 Sep 2024 16:53:32 +0200 Subject: [PATCH 2/3] hsr: fix initialization of port1 and port2 DBus Object property This was causing test_nml_dbus_meta() unit test to fail and also it was affecting the notification when the object changed. Fixes: 5426bdf4a122 ('HSR: add support to HSR/PRP interface') --- src/libnm-client-impl/nm-device-hsr.c | 22 ++++++++++++++-------- src/libnm-client-impl/tests/test-libnm.c | 7 +++++++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/libnm-client-impl/nm-device-hsr.c b/src/libnm-client-impl/nm-device-hsr.c index 7160bf6d9..fd4da41bf 100644 --- a/src/libnm-client-impl/nm-device-hsr.c +++ b/src/libnm-client-impl/nm-device-hsr.c @@ -20,10 +20,15 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PORT1, PROP_MULTICAST_SPEC, PROP_PRP, ); +enum { + PROPERTY_O_IDX_PORT1, + PROPERTY_O_IDX_PORT2, + _PROPERTY_O_IDX_NUM, +}; + typedef struct { char *supervision_address; - NMLDBusPropertyO port1; - NMLDBusPropertyO port2; + NMLDBusPropertyO property_o[_PROPERTY_O_IDX_NUM]; guint8 multicast_spec; bool prp; } NMDeviceHsrPrivate; @@ -57,7 +62,8 @@ nm_device_hsr_get_port1(NMDeviceHsr *device) { g_return_val_if_fail(NM_IS_DEVICE_HSR(device), NULL); - return nml_dbus_property_o_get_obj(&NM_DEVICE_HSR_GET_PRIVATE(device)->port1); + return nml_dbus_property_o_get_obj( + &NM_DEVICE_HSR_GET_PRIVATE(device)->property_o[PROPERTY_O_IDX_PORT1]); } /** @@ -73,7 +79,8 @@ nm_device_hsr_get_port2(NMDeviceHsr *device) { g_return_val_if_fail(NM_IS_DEVICE_HSR(device), NULL); - return nml_dbus_property_o_get_obj(&NM_DEVICE_HSR_GET_PRIVATE(device)->port2); + return nml_dbus_property_o_get_obj( + &NM_DEVICE_HSR_GET_PRIVATE(device)->property_o[PROPERTY_O_IDX_PORT2]); } /** @@ -179,12 +186,12 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_hsr = NML_DBUS_META_IFACE_ NML_DBUS_META_PROPERTY_INIT_O_PROP("Port1", PROP_PORT1, NMDeviceHsr, - _priv.port1, + _priv.property_o[PROPERTY_O_IDX_PORT1], nm_device_get_type), NML_DBUS_META_PROPERTY_INIT_O_PROP("Port2", PROP_PORT2, NMDeviceHsr, - _priv.port2, + _priv.property_o[PROPERTY_O_IDX_PORT2], nm_device_get_type), NML_DBUS_META_PROPERTY_INIT_B("Prp", PROP_PRP, NMDeviceHsr, _priv.prp), NML_DBUS_META_PROPERTY_INIT_S("SupervisionAddress", @@ -203,8 +210,7 @@ nm_device_hsr_class_init(NMDeviceHsrClass *klass) _NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT(nm_object_class, NMDeviceHsr); - _NM_OBJECT_CLASS_INIT_PROPERTY_O_FIELDS_1(nm_object_class, NMDeviceHsrPrivate, port1); - _NM_OBJECT_CLASS_INIT_PROPERTY_O_FIELDS_1(nm_object_class, NMDeviceHsrPrivate, port2); + _NM_OBJECT_CLASS_INIT_PROPERTY_O_FIELDS_N(nm_object_class, NMDeviceHsrPrivate, property_o); /** * NMDeviceHsr:port1: diff --git a/src/libnm-client-impl/tests/test-libnm.c b/src/libnm-client-impl/tests/test-libnm.c index 4d3652ebe..951559469 100644 --- a/src/libnm-client-impl/tests/test-libnm.c +++ b/src/libnm-client-impl/tests/test-libnm.c @@ -2690,6 +2690,7 @@ test_types(void) G(nm_device_ethernet_get_type), G(nm_device_generic_get_type), G(nm_device_get_type), + G(nm_device_hsr_get_type), G(nm_device_infiniband_get_type), G(nm_device_ip_tunnel_get_type), G(nm_device_ipvlan_get_type), @@ -2763,6 +2764,7 @@ test_types(void) G(nm_setting_generic_get_type), G(nm_setting_get_type), G(nm_setting_gsm_get_type), + G(nm_setting_hsr_get_type), G(nm_setting_infiniband_get_type), G(nm_setting_ip4_config_get_type), G(nm_setting_ip6_config_addr_gen_mode_get_type), @@ -3386,6 +3388,11 @@ test_dbus_meta_types(void) NM_TYPE_DEVICE_GENERIC, NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30, }, + { + NM_DBUS_INTERFACE_DEVICE_HSR, + NM_TYPE_DEVICE_HSR, + NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30, + }, { NM_DBUS_INTERFACE_DEVICE_INFINIBAND, NM_TYPE_DEVICE_INFINIBAND, From 5e360638932da270999d6f0d0b8f60d417f4b4c4 Mon Sep 17 00:00:00 2001 From: Fernando Fernandez Mancera Date: Mon, 23 Sep 2024 17:13:23 +0200 Subject: [PATCH 3/3] test-libnm: add comment explaining one assertion --- src/libnm-client-impl/tests/test-libnm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libnm-client-impl/tests/test-libnm.c b/src/libnm-client-impl/tests/test-libnm.c index 951559469..4a59f6eca 100644 --- a/src/libnm-client-impl/tests/test-libnm.c +++ b/src/libnm-client-impl/tests/test-libnm.c @@ -3004,8 +3004,13 @@ test_nml_dbus_meta(void) g_assert(NM_IS_OBJECT_CLASS(p->klass)); g_assert(g_type_is_a(gtype, G_TYPE_FROM_CLASS(p->klass))); if (ii == 0) + /* If there is more than one NMLDBusPropertyO needed in the struct + * associated to the DBus object, they must be all in the same struct field + * as an array. This is later used on nm-object.c to perform operations on + * all the object properties at once. */ g_assert(p->klass->property_o_info == p); else + /* Same check than above if branch but for NMLDBusPropertyAO. */ g_assert(p->klass->property_ao_info == p); g_assert_cmpint(p->klass->priv_ptr_offset, >, 0); if (p_prev) {