From 88c227d90a6b7b388c5c85d72802a0ca8f05ed5c Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Thu, 13 Jan 2022 22:30:39 +0100 Subject: New upstream version 1.34.0 --- src/libnm-client-impl/libnm.pc.in | 2 + src/libnm-client-impl/libnm.ver | 18 + src/libnm-client-impl/nm-client.c | 25 +- src/libnm-client-impl/nm-dbus-helpers.h | 2 +- src/libnm-client-impl/nm-device-bond.c | 34 +- src/libnm-client-impl/nm-device-bridge.c | 22 +- src/libnm-client-impl/nm-device-ovs-bridge.c | 44 +-- src/libnm-client-impl/nm-device-ovs-port.c | 44 +-- src/libnm-client-impl/nm-device-team.c | 24 +- src/libnm-client-impl/nm-device-wifi.c | 2 +- src/libnm-client-impl/nm-device.c | 120 +++++- src/libnm-client-impl/nm-dhcp4-config.h | 2 +- src/libnm-client-impl/nm-dhcp6-config.h | 2 +- src/libnm-client-impl/nm-dns-manager.h | 2 +- src/libnm-client-impl/nm-ip-config.c | 2 +- src/libnm-client-impl/nm-ip4-config.h | 2 +- src/libnm-client-impl/nm-ip6-config.h | 2 +- src/libnm-client-impl/nm-libnm-utils.c | 2 +- src/libnm-client-impl/nm-libnm-utils.h | 125 +++--- src/libnm-client-impl/nm-object-private.h | 2 +- src/libnm-client-impl/nm-object.c | 29 +- src/libnm-client-impl/nm-property-infos-dbus.xml | 2 + .../nm-property-infos-ifcfg-rh.xml | 4 + .../nm-property-infos-keyfile.xml | 2 + src/libnm-client-impl/nm-property-infos-nmcli.xml | 439 +++++++++++++++++++++ .../nm-remote-connection-private.h | 2 +- src/libnm-client-impl/nm-settings-docs-gir.xml | 12 +- src/libnm-client-impl/tests/test-libnm.c | 13 +- src/libnm-client-impl/tests/test-nm-client.c | 20 +- 29 files changed, 800 insertions(+), 201 deletions(-) (limited to 'src/libnm-client-impl') diff --git a/src/libnm-client-impl/libnm.pc.in b/src/libnm-client-impl/libnm.pc.in index afc5e4d9..c65b80df 100644 --- a/src/libnm-client-impl/libnm.pc.in +++ b/src/libnm-client-impl/libnm.pc.in @@ -3,6 +3,8 @@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ vpnservicedir=@nmlibdir@/VPN +plugindir=@libdir@/NetworkManager +configdir=@sysconfdir@/NetworkManager Name: libnm Description: Convenience library for clients of NetworkManager diff --git a/src/libnm-client-impl/libnm.ver b/src/libnm-client-impl/libnm.ver index 89a99af8..ce07a876 100644 --- a/src/libnm-client-impl/libnm.ver +++ b/src/libnm-client-impl/libnm.ver @@ -1785,6 +1785,12 @@ global: nm_utils_print; } libnm_1_28_0; +libnm_1_30_8 { + #nm_ip_address_dup@libnm_1_30_8; + #nm_ip_route_dup@libnm_1_30_8; + #nm_setting_ip_config_get_required_timeout@libnm_1_30_8; +} libnm_1_30_0; + libnm_1_32_0 { global: nm_ethtool_optname_is_pause; @@ -1798,3 +1804,15 @@ libnm_1_32_4 { global: nm_setting_ip_config_get_required_timeout; } libnm_1_32_0; + +libnm_1_34_0 { +global: + nm_device_get_ports; + nm_ip_routing_rule_get_uid_range; + nm_ip_routing_rule_set_uid_range; + nm_setting_bond_port_get_queue_id; + nm_setting_bond_port_get_type; + nm_setting_bond_port_new; + nm_setting_connection_get_dns_over_tls; + nm_setting_connection_dns_over_tls_get_type; +} libnm_1_32_4; diff --git a/src/libnm-client-impl/nm-client.c b/src/libnm-client-impl/nm-client.c index 4cbd56dc..0f9d8fe1 100644 --- a/src/libnm-client-impl/nm-client.c +++ b/src/libnm-client-impl/nm-client.c @@ -2118,7 +2118,7 @@ nml_dbus_property_ao_notify_watch_cb(NMClient *self, gpointer obj_watcher) _ASSERT_pr_ao(pr_ao); } -static NMLDBusNotifyUpdatePropFlags +NMLDBusNotifyUpdatePropFlags nml_dbus_property_ao_notify(NMClient * self, NMLDBusPropertyAO * pr_ao, NMLDBusObject * dbobj, @@ -2266,9 +2266,11 @@ nml_dbus_property_ao_notify(NMClient * self, return NML_DBUS_NOTIFY_UPDATE_PROP_FLAGS_NONE; } -void +gboolean nml_dbus_property_ao_clear(NMLDBusPropertyAO *pr_ao, NMClient *self) { + gboolean changed_prop = FALSE; + _ASSERT_pr_ao(pr_ao); if (!pr_ao->owner_dbobj) { @@ -2281,7 +2283,6 @@ nml_dbus_property_ao_clear(NMLDBusPropertyAO *pr_ao, NMClient *self) nm_assert(!pr_ao->is_changed); } else { PropertyAOData *pr_ao_data; - gboolean changed_prop = FALSE; nm_assert(NM_IS_CLIENT(self)); nm_assert(pr_ao->data_lst_head.next); @@ -2329,6 +2330,8 @@ nml_dbus_property_ao_clear(NMLDBusPropertyAO *pr_ao, NMClient *self) } nm_clear_pointer(&pr_ao->arr, g_ptr_array_unref); + + return changed_prop; } void @@ -2404,7 +2407,7 @@ _obj_handle_dbus_prop_changes(NMClient * self, value = NULL; } - if (meta_property->use_notify_update_prop) { + if (meta_property->notify_update_prop) { notify_update_prop_flags = meta_property->notify_update_prop(self, dbobj, meta_iface, dbus_property_idx, value); if (notify_update_prop_flags == NML_DBUS_NOTIFY_UPDATE_PROP_FLAGS_NONE) @@ -8832,3 +8835,17 @@ NM_BACKPORT_SYMBOL(libnm_1_10_14, (NMSettingConnection * setting), (setting)); NM_BACKPORT_SYMBOL(libnm_1_10_14, GType, nm_setting_connection_mdns_get_type, (void), ()); + +NM_BACKPORT_SYMBOL(libnm_1_30_8, + int, + nm_setting_ip_config_get_required_timeout, + (NMSettingIPConfig * setting), + (setting)); + +NM_BACKPORT_SYMBOL(libnm_1_30_8, + NMIPAddress *, + nm_ip_address_dup, + (NMIPAddress * address), + (address)); + +NM_BACKPORT_SYMBOL(libnm_1_30_8, NMIPRoute *, nm_ip_route_dup, (NMIPRoute * route), (route)); diff --git a/src/libnm-client-impl/nm-dbus-helpers.h b/src/libnm-client-impl/nm-dbus-helpers.h index e519f733..5a6b2d62 100644 --- a/src/libnm-client-impl/nm-dbus-helpers.h +++ b/src/libnm-client-impl/nm-dbus-helpers.h @@ -7,7 +7,7 @@ #define __NM_DBUS_HELPERS_PRIVATE_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #include "libnm-std-aux/nm-dbus-compat.h" diff --git a/src/libnm-client-impl/nm-device-bond.c b/src/libnm-client-impl/nm-device-bond.c index 48dfd9b2..add54639 100644 --- a/src/libnm-client-impl/nm-device-bond.c +++ b/src/libnm-client-impl/nm-device-bond.c @@ -18,9 +18,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_CARRIER, PROP_SLAVES, ); typedef struct { - NMLDBusPropertyAO slaves; - char * hw_address; - bool carrier; + bool carrier; } NMDeviceBondPrivate; struct _NMDeviceBond { @@ -83,13 +81,13 @@ nm_device_bond_get_carrier(NMDeviceBond *device) * Returns: (element-type NMDevice): the #GPtrArray containing * #NMDevices that are slaves of @device. This is the internal * copy used by the device, and must not be modified. + * + * Deprecated: 1.34 Use nm_device_get_ports() instead. **/ const GPtrArray * nm_device_bond_get_slaves(NMDeviceBond *device) { - g_return_val_if_fail(NM_IS_DEVICE_BOND(device), FALSE); - - return nml_dbus_property_ao_get_objs_as_ptrarray(&NM_DEVICE_BOND_GET_PRIVATE(device)->slaves); + return nm_device_get_ports(NM_DEVICE(device)); } static gboolean @@ -124,16 +122,6 @@ static void nm_device_bond_init(NMDeviceBond *device) {} -static void -finalize(GObject *object) -{ - NMDeviceBondPrivate *priv = NM_DEVICE_BOND_GET_PRIVATE(object); - - g_free(priv->hw_address); - - G_OBJECT_CLASS(nm_device_bond_parent_class)->finalize(object); -} - static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { @@ -162,11 +150,10 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_bond = NML_DBUS_META_IFACE 0, "s", _nm_device_notify_update_prop_hw_address), - NML_DBUS_META_PROPERTY_INIT_AO_PROP("Slaves", - PROP_SLAVES, - NMDeviceBond, - _priv.slaves, - nm_device_get_type), ), ); + NML_DBUS_META_PROPERTY_INIT_FCN("Slaves", + PROP_SLAVES, + "ao", + _nm_device_notify_update_prop_ports), ), ); static void nm_device_bond_class_init(NMDeviceBondClass *klass) @@ -176,12 +163,9 @@ nm_device_bond_class_init(NMDeviceBondClass *klass) NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->get_property = get_property; - object_class->finalize = finalize; _NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT(nm_object_class, NMDeviceBond); - _NM_OBJECT_CLASS_INIT_PROPERTY_AO_FIELDS_1(nm_object_class, NMDeviceBondPrivate, slaves); - device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; @@ -208,4 +192,6 @@ nm_device_bond_class_init(NMDeviceBondClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); _nml_dbus_meta_class_init_with_properties(object_class, &_nml_dbus_meta_iface_nm_device_bond); + + device_class->slaves_param_spec = obj_properties[PROP_SLAVES]; } diff --git a/src/libnm-client-impl/nm-device-bridge.c b/src/libnm-client-impl/nm-device-bridge.c index 9bc41ac8..fb0ad873 100644 --- a/src/libnm-client-impl/nm-device-bridge.c +++ b/src/libnm-client-impl/nm-device-bridge.c @@ -18,8 +18,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_CARRIER, PROP_SLAVES, ); typedef struct { - NMLDBusPropertyAO slaves; - bool carrier; + bool carrier; } NMDeviceBridgePrivate; struct _NMDeviceBridge { @@ -82,13 +81,13 @@ nm_device_bridge_get_carrier(NMDeviceBridge *device) * Returns: (element-type NMDevice): the #GPtrArray containing * #NMDevices that are slaves of @device. This is the internal * copy used by the device, and must not be modified. + * + * Deprecated: 1.34 Use nm_device_get_ports() instead. **/ const GPtrArray * nm_device_bridge_get_slaves(NMDeviceBridge *device) { - g_return_val_if_fail(NM_IS_DEVICE_BRIDGE(device), FALSE); - - return nml_dbus_property_ao_get_objs_as_ptrarray(&NM_DEVICE_BRIDGE_GET_PRIVATE(device)->slaves); + return nm_device_get_ports(NM_DEVICE(device)); } static gboolean @@ -156,11 +155,10 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_bridge = NML_DBUS_META_IFA 0, "s", _nm_device_notify_update_prop_hw_address), - NML_DBUS_META_PROPERTY_INIT_AO_PROP("Slaves", - PROP_SLAVES, - NMDeviceBridge, - _priv.slaves, - nm_device_get_type), ), ); + NML_DBUS_META_PROPERTY_INIT_FCN("Slaves", + PROP_SLAVES, + "ao", + _nm_device_notify_update_prop_ports), ), ); static void nm_device_bridge_class_init(NMDeviceBridgeClass *klass) @@ -173,8 +171,6 @@ nm_device_bridge_class_init(NMDeviceBridgeClass *klass) _NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT(nm_object_class, NMDeviceBridge); - _NM_OBJECT_CLASS_INIT_PROPERTY_AO_FIELDS_1(nm_object_class, NMDeviceBridgePrivate, slaves); - device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; @@ -201,4 +197,6 @@ nm_device_bridge_class_init(NMDeviceBridgeClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); _nml_dbus_meta_class_init_with_properties(object_class, &_nml_dbus_meta_iface_nm_device_bridge); + + device_class->slaves_param_spec = obj_properties[PROP_SLAVES]; } diff --git a/src/libnm-client-impl/nm-device-ovs-bridge.c b/src/libnm-client-impl/nm-device-ovs-bridge.c index 898a41fa..465957c4 100644 --- a/src/libnm-client-impl/nm-device-ovs-bridge.c +++ b/src/libnm-client-impl/nm-device-ovs-bridge.c @@ -17,13 +17,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_SLAVES, ); -typedef struct { - NMLDBusPropertyAO slaves; -} NMDeviceOvsBridgePrivate; - struct _NMDeviceOvsBridge { - NMDevice parent; - NMDeviceOvsBridgePrivate _priv; + NMDevice parent; }; struct _NMDeviceOvsBridgeClass { @@ -48,14 +43,13 @@ G_DEFINE_TYPE(NMDeviceOvsBridge, nm_device_ovs_bridge, NM_TYPE_DEVICE) * copy used by the device, and must not be modified. * * Since: 1.14 + * + * Deprecated: 1.34 Use nm_device_get_ports() instead. **/ const GPtrArray * nm_device_ovs_bridge_get_slaves(NMDeviceOvsBridge *device) { - g_return_val_if_fail(NM_IS_DEVICE_OVS_BRIDGE(device), FALSE); - - return nml_dbus_property_ao_get_objs_as_ptrarray( - &NM_DEVICE_OVS_BRIDGE_GET_PRIVATE(device)->slaves); + return nm_device_get_ports(NM_DEVICE(device)); } static const char * @@ -123,30 +117,24 @@ static void nm_device_ovs_bridge_init(NMDeviceOvsBridge *device) {} -const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_ovsbridge = - NML_DBUS_META_IFACE_INIT_PROP(NM_DBUS_INTERFACE_DEVICE_OVS_BRIDGE, - nm_device_ovs_bridge_get_type, - NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30, - NML_DBUS_META_IFACE_DBUS_PROPERTIES( - NML_DBUS_META_PROPERTY_INIT_AO_PROP("Slaves", - PROP_SLAVES, - NMDeviceOvsBridge, - _priv.slaves, - nm_device_get_type), ), ); +const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_ovsbridge = NML_DBUS_META_IFACE_INIT_PROP( + NM_DBUS_INTERFACE_DEVICE_OVS_BRIDGE, + nm_device_ovs_bridge_get_type, + NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30, + NML_DBUS_META_IFACE_DBUS_PROPERTIES( + NML_DBUS_META_PROPERTY_INIT_FCN("Slaves", + PROP_SLAVES, + "ao", + _nm_device_notify_update_prop_ports), ), ); static void nm_device_ovs_bridge_class_init(NMDeviceOvsBridgeClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); - NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); + GObjectClass * object_class = G_OBJECT_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->get_property = get_property; - _NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT(nm_object_class, NMDeviceOvsBridge); - - _NM_OBJECT_CLASS_INIT_PROPERTY_AO_FIELDS_1(nm_object_class, NMDeviceOvsBridgePrivate, slaves); - device_class->get_type_description = get_type_description; device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; @@ -166,4 +154,6 @@ nm_device_ovs_bridge_class_init(NMDeviceOvsBridgeClass *klass) _nml_dbus_meta_class_init_with_properties(object_class, &_nml_dbus_meta_iface_nm_device_ovsbridge); + + device_class->slaves_param_spec = obj_properties[PROP_SLAVES]; } diff --git a/src/libnm-client-impl/nm-device-ovs-port.c b/src/libnm-client-impl/nm-device-ovs-port.c index db30e1c7..76ae7a58 100644 --- a/src/libnm-client-impl/nm-device-ovs-port.c +++ b/src/libnm-client-impl/nm-device-ovs-port.c @@ -17,13 +17,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_SLAVES, ); -typedef struct { - NMLDBusPropertyAO slaves; -} NMDeviceOvsPortPrivate; - struct _NMDeviceOvsPort { - NMDevice parent; - NMDeviceOvsPortPrivate _priv; + NMDevice parent; }; struct _NMDeviceOvsPortClass { @@ -48,14 +43,13 @@ G_DEFINE_TYPE(NMDeviceOvsPort, nm_device_ovs_port, NM_TYPE_DEVICE) * copy used by the device, and must not be modified. * * Since: 1.14 + * + * Deprecated: 1.34 Use nm_device_get_ports() instead. **/ const GPtrArray * nm_device_ovs_port_get_slaves(NMDeviceOvsPort *device) { - g_return_val_if_fail(NM_IS_DEVICE_OVS_PORT(device), FALSE); - - return nml_dbus_property_ao_get_objs_as_ptrarray( - &NM_DEVICE_OVS_PORT_GET_PRIVATE(device)->slaves); + return nm_device_get_ports(NM_DEVICE(device)); } static const char * @@ -123,30 +117,24 @@ static void nm_device_ovs_port_init(NMDeviceOvsPort *device) {} -const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_ovsport = - NML_DBUS_META_IFACE_INIT_PROP(NM_DBUS_INTERFACE_DEVICE_OVS_PORT, - nm_device_ovs_port_get_type, - NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30, - NML_DBUS_META_IFACE_DBUS_PROPERTIES( - NML_DBUS_META_PROPERTY_INIT_AO_PROP("Slaves", - PROP_SLAVES, - NMDeviceOvsPort, - _priv.slaves, - nm_device_get_type), ), ); +const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_ovsport = NML_DBUS_META_IFACE_INIT_PROP( + NM_DBUS_INTERFACE_DEVICE_OVS_PORT, + nm_device_ovs_port_get_type, + NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30, + NML_DBUS_META_IFACE_DBUS_PROPERTIES( + NML_DBUS_META_PROPERTY_INIT_FCN("Slaves", + PROP_SLAVES, + "ao", + _nm_device_notify_update_prop_ports), ), ); static void nm_device_ovs_port_class_init(NMDeviceOvsPortClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); - NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); + GObjectClass * object_class = G_OBJECT_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->get_property = get_property; - _NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT(nm_object_class, NMDeviceOvsPort); - - _NM_OBJECT_CLASS_INIT_PROPERTY_AO_FIELDS_1(nm_object_class, NMDeviceOvsPortPrivate, slaves); - device_class->get_type_description = get_type_description; device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; @@ -166,4 +154,6 @@ nm_device_ovs_port_class_init(NMDeviceOvsPortClass *klass) _nml_dbus_meta_class_init_with_properties(object_class, &_nml_dbus_meta_iface_nm_device_ovsport); + + device_class->slaves_param_spec = obj_properties[PROP_SLAVES]; } diff --git a/src/libnm-client-impl/nm-device-team.c b/src/libnm-client-impl/nm-device-team.c index ca29c9f7..9f7fe768 100644 --- a/src/libnm-client-impl/nm-device-team.c +++ b/src/libnm-client-impl/nm-device-team.c @@ -18,9 +18,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_CARRIER, PROP_SLAVES, PROP_CONFIG, ); typedef struct { - NMLDBusPropertyAO slaves; - char * config; - bool carrier; + char *config; + bool carrier; } NMDeviceTeamPrivate; struct _NMDeviceTeam { @@ -83,13 +82,13 @@ nm_device_team_get_carrier(NMDeviceTeam *device) * Returns: (element-type NMDevice): the #GPtrArray containing * #NMDevices that are slaves of @device. This is the internal * copy used by the device, and must not be modified. + * + * Deprecated: 1.34 Use nm_device_get_ports() instead. **/ const GPtrArray * nm_device_team_get_slaves(NMDeviceTeam *device) { - g_return_val_if_fail(NM_IS_DEVICE_TEAM(device), FALSE); - - return nml_dbus_property_ao_get_objs_as_ptrarray(&NM_DEVICE_TEAM_GET_PRIVATE(device)->slaves); + return nm_device_get_ports(NM_DEVICE(device)); } /** @@ -185,11 +184,10 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_team = NML_DBUS_META_IFACE 0, "s", _nm_device_notify_update_prop_hw_address), - NML_DBUS_META_PROPERTY_INIT_AO_PROP("Slaves", - PROP_SLAVES, - NMDeviceTeam, - _priv.slaves, - nm_device_get_type), ), ); + NML_DBUS_META_PROPERTY_INIT_FCN("Slaves", + PROP_SLAVES, + "ao", + _nm_device_notify_update_prop_ports), ), ); static void nm_device_team_class_init(NMDeviceTeamClass *klass) @@ -203,8 +201,6 @@ nm_device_team_class_init(NMDeviceTeamClass *klass) _NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT(nm_object_class, NMDeviceTeam); - _NM_OBJECT_CLASS_INIT_PROPERTY_AO_FIELDS_1(nm_object_class, NMDeviceTeamPrivate, slaves); - device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; @@ -244,4 +240,6 @@ nm_device_team_class_init(NMDeviceTeamClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); _nml_dbus_meta_class_init_with_properties(object_class, &_nml_dbus_meta_iface_nm_device_team); + + device_class->slaves_param_spec = obj_properties[PROP_SLAVES]; } diff --git a/src/libnm-client-impl/nm-device-wifi.c b/src/libnm-client-impl/nm-device-wifi.c index fee7e8a2..cfbbea23 100644 --- a/src/libnm-client-impl/nm-device-wifi.c +++ b/src/libnm-client-impl/nm-device-wifi.c @@ -242,7 +242,7 @@ nm_device_wifi_get_access_point_by_path(NMDeviceWifi *device, const char *path) * Use nm_utils_get_timestamp_msec() to obtain current time value suitable for * comparing to this value. * - * Returns: the last scan time in seconds + * Returns: the last scan time in milliseconds (in clock_gettime(CLOCK_BOOTTIME) scale). * * Since: 1.12 **/ diff --git a/src/libnm-client-impl/nm-device.c b/src/libnm-client-impl/nm-device.c index 4d097935..a680a05f 100644 --- a/src/libnm-client-impl/nm-device.c +++ b/src/libnm-client-impl/nm-device.c @@ -61,7 +61,8 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMDevice, PROP_IP4_CONNECTIVITY, PROP_IP6_CONNECTIVITY, PROP_INTERFACE_FLAGS, - PROP_HW_ADDRESS, ); + PROP_HW_ADDRESS, + PROP_PORTS, ); enum { STATE_CHANGED, @@ -80,9 +81,15 @@ enum { _PROPERTY_O_IDX_NUM, }; +enum { + PROPERTY_AO_IDX_AVAILABLE_CONNECTIONS, + PROPERTY_AO_IDX_PORTS, + _PROPERTY_AO_IDX_NUM, +}; + typedef struct _NMDevicePrivate { NMLDBusPropertyO property_o[_PROPERTY_O_IDX_NUM]; - NMLDBusPropertyAO available_connections; + NMLDBusPropertyAO property_ao[_PROPERTY_AO_IDX_NUM]; GPtrArray * lldp_neighbors; char * driver; char * driver_version; @@ -109,6 +116,7 @@ typedef struct _NMDevicePrivate { bool real; bool hw_address_is_new : 1; + bool ports_is_new : 1; guint32 old_state; @@ -457,6 +465,9 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) case PROP_HW_ADDRESS: g_value_set_string(value, nm_device_get_hw_address(device)); break; + case PROP_PORTS: + g_value_take_boxed(value, _nm_utils_copy_object_array(nm_device_get_ports(device))); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -509,7 +520,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device = NML_DBUS_META_IFACE_INIT NML_DBUS_META_PROPERTY_INIT_AO_PROP("AvailableConnections", PROP_AVAILABLE_CONNECTIONS, NMDevicePrivate, - available_connections, + property_ao[PROPERTY_AO_IDX_AVAILABLE_CONNECTIONS], nm_remote_connection_get_type, .is_always_ready = TRUE), NML_DBUS_META_PROPERTY_INIT_U("Capabilities", @@ -588,6 +599,15 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device = NML_DBUS_META_IFACE_INIT PROP_PHYSICAL_PORT_ID, NMDevicePrivate, physical_port_id), + NML_DBUS_META_PROPERTY_INIT_FCN( + "Ports", + PROP_PORTS, + "ao", + _nm_device_notify_update_prop_ports, + .prop_struct_offset = + G_STRUCT_OFFSET(NMDevicePrivate, property_ao[PROPERTY_AO_IDX_PORTS]), + .extra.property_vtable_ao = + &((const NMLDBusPropertVTableAO){.get_o_type_fcn = (nm_device_get_type)})), NML_DBUS_META_PROPERTY_INIT_B("Real", PROP_REAL, NMDevicePrivate, real), NML_DBUS_META_PROPERTY_INIT_IGNORE("State", "u"), NML_DBUS_META_PROPERTY_INIT_FCN("StateReason", @@ -595,6 +615,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device = NML_DBUS_META_IFACE_INIT "(uu)", _notify_update_prop_state_reason), NML_DBUS_META_PROPERTY_INIT_S("Udi", PROP_UDI, NMDevicePrivate, udi), ), + .base_struct_offset = G_STRUCT_OFFSET(NMDevice, _priv), ); static void @@ -614,9 +635,7 @@ nm_device_class_init(NMDeviceClass *klass) _NM_OBJECT_CLASS_INIT_PRIV_PTR_INDIRECT(nm_object_class, NMDevice); _NM_OBJECT_CLASS_INIT_PROPERTY_O_FIELDS_N(nm_object_class, NMDevicePrivate, property_o); - _NM_OBJECT_CLASS_INIT_PROPERTY_AO_FIELDS_1(nm_object_class, - NMDevicePrivate, - available_connections); + _NM_OBJECT_CLASS_INIT_PROPERTY_AO_FIELDS_N(nm_object_class, NMDevicePrivate, property_ao); klass->connection_compatible = connection_compatible; @@ -1034,6 +1053,20 @@ nm_device_class_init(NMDeviceClass *klass) NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + /** + * NMDevice:ports: + * + * The port devices of the controller device. For devices that cannot be + * controllers this is likely to be always empty. + * + * Since: 1.34 + **/ + obj_properties[PROP_PORTS] = g_param_spec_boxed(NM_DEVICE_PORTS, + "", + "", + G_TYPE_PTR_ARRAY, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + _nml_dbus_meta_class_init_with_properties(object_class, &_nml_dbus_meta_iface_nm_device); /** @@ -1241,6 +1274,27 @@ nm_device_get_type_description(NMDevice *device) return _nml_coerce_property_str_not_empty(priv->type_description); } +/** + * nm_device_get_ports: + * @device: a #NMDevice + * + * Gets the devices currently set as port of @device. + * + * Returns: (element-type NMDevice): the #GPtrArray containing #NMDevices that + * are slaves of @device. This is the internal copy used by the device and + * must not be modified. + * + * Since: 1.34 + **/ +const GPtrArray * +nm_device_get_ports(NMDevice *device) +{ + g_return_val_if_fail(NM_IS_DEVICE(device), NULL); + + return nml_dbus_property_ao_get_objs_as_ptrarray( + &NM_DEVICE_GET_PRIVATE(device)->property_ao[PROPERTY_AO_IDX_PORTS]); +} + NMLDBusNotifyUpdatePropFlags _nm_device_notify_update_prop_hw_address(NMClient * client, NMLDBusObject * dbobj, @@ -1267,8 +1321,8 @@ _nm_device_notify_update_prop_hw_address(NMClient * client, priv->hw_address_is_new = is_new; - nm_utils_strdup_reset(&priv->hw_address, - _nml_coerce_property_str_not_empty(g_variant_get_string(value, NULL))); + nm_strdup_reset(&priv->hw_address, + _nml_coerce_property_str_not_empty(g_variant_get_string(value, NULL))); /* always emit a changed signal here, even if "priv->hw_address" might be unchanged. * We want to emit the signal because we received a PropertiesChanged signal on D-Bus, @@ -1305,6 +1359,48 @@ nm_device_get_hw_address(NMDevice *device) return priv->hw_address; } +NMLDBusNotifyUpdatePropFlags +_nm_device_notify_update_prop_ports(NMClient * client, + NMLDBusObject * dbobj, + const NMLDBusMetaIface *meta_iface, + guint dbus_property_idx, + GVariant * value) +{ + const NMLDBusMetaProperty *meta_property = + &_nml_dbus_meta_iface_nm_device.dbus_properties[_NML_DEVICE_META_PROPERTY_INDEX_PORTS]; + NMLDBusNotifyUpdatePropFlags notify_update_prop_flags; + NMDevice * self = NM_DEVICE(dbobj->nmobj); + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDeviceClass * klass; + gboolean is_new = (meta_iface == &_nml_dbus_meta_iface_nm_device); + + nm_assert(nm_streq(meta_property->dbus_property_name, "Ports")); + + if (!is_new && priv->ports_is_new) { + /* once the instance is marked to honor the new property, the + * changed signal for the old variant gets ignored. */ + goto out; + } + priv->ports_is_new = is_new; + + notify_update_prop_flags = + nml_dbus_property_ao_notify(client, + &priv->property_ao[PROPERTY_AO_IDX_PORTS], + dbobj, + &_nml_dbus_meta_iface_nm_device, + _NML_DEVICE_META_PROPERTY_INDEX_PORTS, + value); + if (notify_update_prop_flags == NML_DBUS_NOTIFY_UPDATE_PROP_FLAGS_NONE) + goto out; + nm_assert(notify_update_prop_flags == NML_DBUS_NOTIFY_UPDATE_PROP_FLAGS_NOTIFY); + + klass = NM_DEVICE_GET_CLASS(self); + if (klass->slaves_param_spec) + _nm_client_queue_notify_object(client, self, klass->slaves_param_spec); +out: + return NML_DBUS_NOTIFY_UPDATE_PROP_FLAGS_NONE; +} + /** * nm_device_get_capabilities: * @device: a #NMDevice @@ -1652,7 +1748,7 @@ nm_device_get_available_connections(NMDevice *device) g_return_val_if_fail(NM_IS_DEVICE(device), NULL); return nml_dbus_property_ao_get_objs_as_ptrarray( - &NM_DEVICE_GET_PRIVATE(device)->available_connections); + &NM_DEVICE_GET_PRIVATE(device)->property_ao[PROPERTY_AO_IDX_AVAILABLE_CONNECTIONS]); } static const char * @@ -2770,7 +2866,7 @@ connection_compatible(NMDevice *device, NMConnection *connection, GError **error g_set_error(error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, - _("The interface names of the device and the connection didn't match.")); + _("The interface names of the device and the connection didn't match")); return FALSE; } @@ -2999,9 +3095,9 @@ nm_lldp_neighbor_get_attr_names(NMLldpNeighbor *neighbor) g_return_val_if_fail(NM_IS_LLDP_NEIGHBOR(neighbor), NULL); - keys = nm_utils_strdict_get_keys(neighbor->attrs, TRUE, NULL); + keys = nm_strdict_get_keys(neighbor->attrs, TRUE, NULL); - return nm_utils_strv_make_deep_copied_nonnull(keys); + return nm_strv_make_deep_copied_nonnull(keys); } /** diff --git a/src/libnm-client-impl/nm-dhcp4-config.h b/src/libnm-client-impl/nm-dhcp4-config.h index d0ea2b46..135720f0 100644 --- a/src/libnm-client-impl/nm-dhcp4-config.h +++ b/src/libnm-client-impl/nm-dhcp4-config.h @@ -7,7 +7,7 @@ #define __NM_DHCP4_CONFIG_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #include "nm-dhcp-config.h" diff --git a/src/libnm-client-impl/nm-dhcp6-config.h b/src/libnm-client-impl/nm-dhcp6-config.h index 253594e6..adaa5050 100644 --- a/src/libnm-client-impl/nm-dhcp6-config.h +++ b/src/libnm-client-impl/nm-dhcp6-config.h @@ -7,7 +7,7 @@ #define __NM_DHCP6_CONFIG_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #include "nm-dhcp-config.h" diff --git a/src/libnm-client-impl/nm-dns-manager.h b/src/libnm-client-impl/nm-dns-manager.h index 8053b243..e6159e61 100644 --- a/src/libnm-client-impl/nm-dns-manager.h +++ b/src/libnm-client-impl/nm-dns-manager.h @@ -7,7 +7,7 @@ #define __NM_DNS_MANAGER_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #include "nm-client.h" diff --git a/src/libnm-client-impl/nm-ip-config.c b/src/libnm-client-impl/nm-ip-config.c index 099dd088..5666888c 100644 --- a/src/libnm-client-impl/nm-ip-config.c +++ b/src/libnm-client-impl/nm-ip-config.c @@ -190,7 +190,7 @@ next: g_variant_iter_free(iter_v); } if (arr && arr->len > 0) - nameservers_new = nm_utils_strv_dup((char **) arr->pdata, arr->len, FALSE); + nameservers_new = nm_strv_dup((char **) arr->pdata, arr->len, FALSE); else nameservers_new = g_new0(char *, 1); } diff --git a/src/libnm-client-impl/nm-ip4-config.h b/src/libnm-client-impl/nm-ip4-config.h index b9297dc0..db82a0a5 100644 --- a/src/libnm-client-impl/nm-ip4-config.h +++ b/src/libnm-client-impl/nm-ip4-config.h @@ -8,7 +8,7 @@ #define __NM_IP4_CONFIG_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #include "nm-ip-config.h" diff --git a/src/libnm-client-impl/nm-ip6-config.h b/src/libnm-client-impl/nm-ip6-config.h index 0c7c2a9f..94386691 100644 --- a/src/libnm-client-impl/nm-ip6-config.h +++ b/src/libnm-client-impl/nm-ip6-config.h @@ -8,7 +8,7 @@ #define __NM_IP6_CONFIG_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #include "nm-ip-config.h" diff --git a/src/libnm-client-impl/nm-libnm-utils.c b/src/libnm-client-impl/nm-libnm-utils.c index 671466cf..4543eaa1 100644 --- a/src/libnm-client-impl/nm-libnm-utils.c +++ b/src/libnm-client-impl/nm-libnm-utils.c @@ -208,7 +208,7 @@ _fixup_string(const char * desc, if (eow) *eow = '\0'; - if (nm_utils_strv_find_first((char **) ignored_words, -1, p) >= 0) + if (nm_strv_find_first(ignored_words, -1, p) >= 0) goto next; l = strlen(p); diff --git a/src/libnm-client-impl/nm-libnm-utils.h b/src/libnm-client-impl/nm-libnm-utils.h index 3fd3b679..75e87064 100644 --- a/src/libnm-client-impl/nm-libnm-utils.h +++ b/src/libnm-client-impl/nm-libnm-utils.h @@ -303,7 +303,7 @@ const GPtrArray *nml_dbus_property_ao_get_objs_as_ptrarray(NMLDBusPropertyAO *pr gboolean nml_dbus_property_ao_is_ready(const NMLDBusPropertyAO *pr_ao); -void nml_dbus_property_ao_clear(NMLDBusPropertyAO *pr_ao, NMClient *client); +gboolean nml_dbus_property_ao_clear(NMLDBusPropertyAO *pr_ao, NMClient *client); void nml_dbus_property_ao_clear_many(NMLDBusPropertyAO *pr_ao, guint len, NMClient *self); @@ -328,30 +328,33 @@ NMLDBusNotifyUpdatePropFlags _nml_dbus_notify_update_prop_o(NMClient * guint dbus_property_idx, GVariant *value); +NMLDBusNotifyUpdatePropFlags nml_dbus_property_ao_notify(NMClient * self, + NMLDBusPropertyAO * pr_ao, + NMLDBusObject * dbobj, + const NMLDBusMetaIface *meta_iface, + guint dbus_property_idx, + GVariant * value); + typedef struct { const char * dbus_property_name; const GVariantType *dbus_type; + NMLDBusNotifyUpdatePropFlags (*notify_update_prop)(NMClient * client, + NMLDBusObject * dbobj, + const NMLDBusMetaIface *meta_iface, + guint dbus_property_idx, + GVariant * value); + guint16 prop_struct_offset; guint8 obj_properties_idx; - bool use_notify_update_prop : 1; - bool obj_property_no_reverse_idx : 1; union { - union { - const NMLDBusPropertVTableO * property_vtable_o; - const NMLDBusPropertVTableAO *property_vtable_ao; - } extra; - - NMLDBusNotifyUpdatePropFlags (*notify_update_prop)(NMClient * client, - NMLDBusObject * dbobj, - const NMLDBusMetaIface *meta_iface, - guint dbus_property_idx, - GVariant *value); - }; + const NMLDBusPropertVTableO * property_vtable_o; + const NMLDBusPropertVTableAO *property_vtable_ao; + } extra; } NMLDBusMetaProperty; @@ -395,17 +398,16 @@ typedef struct { #define NML_DBUS_META_PROPERTY_INIT_AY(...) \ _NML_DBUS_META_PROPERTY_INIT_DEFAULT("ay", GBytes *, __VA_ARGS__) -#define NML_DBUS_META_PROPERTY_INIT_O(v_dbus_property_name, \ - v_obj_properties_idx, \ - v_container, \ - v_field) \ - NML_DBUS_META_PROPERTY_INIT( \ - v_dbus_property_name, \ - "o", \ - v_obj_properties_idx, \ - .prop_struct_offset = NM_STRUCT_OFFSET_ENSURE_TYPE(NMRefString *, v_container, v_field), \ - .use_notify_update_prop = TRUE, \ - .notify_update_prop = _nml_dbus_notify_update_prop_o) +#define NML_DBUS_META_PROPERTY_INIT_O(v_dbus_property_name, \ + v_obj_properties_idx, \ + v_container, \ + v_field) \ + NML_DBUS_META_PROPERTY_INIT( \ + v_dbus_property_name, \ + "o", \ + v_obj_properties_idx, \ + .prop_struct_offset = NM_STRUCT_OFFSET_ENSURE_TYPE(NMRefString *, v_container, v_field), \ + .notify_update_prop = _nml_dbus_notify_update_prop_o) #define NML_DBUS_META_PROPERTY_INIT_O_PROP(v_dbus_property_name, \ v_obj_properties_idx, \ @@ -437,24 +439,22 @@ typedef struct { .extra.property_vtable_ao = &( \ (const NMLDBusPropertVTableAO){.get_o_type_fcn = (v_get_o_type_fcn), ##__VA_ARGS__})) -#define NML_DBUS_META_PROPERTY_INIT_FCN(v_dbus_property_name, \ - v_obj_properties_idx, \ - v_dbus_type, \ - v_notify_update_prop, \ - ...) \ - NML_DBUS_META_PROPERTY_INIT(v_dbus_property_name, \ - v_dbus_type, \ - v_obj_properties_idx, \ - .use_notify_update_prop = TRUE, \ - .notify_update_prop = (v_notify_update_prop), \ +#define NML_DBUS_META_PROPERTY_INIT_FCN(v_dbus_property_name, \ + v_obj_properties_idx, \ + v_dbus_type, \ + v_notify_update_prop, \ + ...) \ + NML_DBUS_META_PROPERTY_INIT(v_dbus_property_name, \ + v_dbus_type, \ + v_obj_properties_idx, \ + .notify_update_prop = (v_notify_update_prop), \ ##__VA_ARGS__) #define NML_DBUS_META_PROPERTY_INIT_IGNORE(v_dbus_property_name, v_dbus_type) \ NML_DBUS_META_PROPERTY_INIT(v_dbus_property_name, \ v_dbus_type, \ 0, \ - .use_notify_update_prop = TRUE, \ - .notify_update_prop = _nml_dbus_notify_update_prop_ignore) + .notify_update_prop = _nml_dbus_notify_update_prop_ignore) /* "TODO" is like "IGNORE". The difference is that we don't plan to ever implement "IGNORE", but * "TODO" is something we should add support for. */ @@ -758,21 +758,29 @@ struct _NMObjectClass { } \ G_STMT_END -#define _NM_OBJECT_CLASS_INIT_FIELD_INFO(_nm_object_class, _field_name, _offset, _num) \ - G_STMT_START \ - { \ - (_nm_object_class)->_field_name = ({ \ - static _NMObjectClassFieldInfo _f; \ - \ - _f = (_NMObjectClassFieldInfo){ \ - .parent = (_nm_object_class)->_field_name, \ - .klass = (_nm_object_class), \ - .offset = _offset, \ - .num = _num, \ - }; \ - &_f; \ - }); \ - } \ +#define _NM_OBJECT_CLASS_INIT_FIELD_INFO(nm_object_class, field_name, _offset, _num) \ + G_STMT_START \ + { \ + NMObjectClass *const _klass = (nm_object_class); \ + \ + _klass->field_name = ({ \ + static _NMObjectClassFieldInfo _f; \ + \ + /* this code is called inside a _class_init() function, it thus + * is only executed once, so we are fine to initialize a static + * variable here. */ \ + nm_assert(!_f.klass); \ + \ + _f = (_NMObjectClassFieldInfo){ \ + .parent = _klass->field_name, \ + .klass = _klass, \ + .offset = (_offset), \ + .num = (_num), \ + }; \ + \ + &_f; \ + }); \ + } \ G_STMT_END #define _NM_OBJECT_CLASS_INIT_PROPERTY_O_FIELDS_1(nm_object_class, type_name, field_name) \ @@ -820,8 +828,15 @@ struct _NMDeviceClass { const char *(*get_type_description)(NMDevice *device); GType (*get_setting_type)(NMDevice *device); + + /* Slaves was originally part of some subtypes of NMDevice. It was deprecated and + * a new NMDevice::ports property was added. When that property changes, we need + * to notify about the subclass' respective property. This is the property. */ + const GParamSpec *slaves_param_spec; }; +#define _NML_DEVICE_META_PROPERTY_INDEX_PORTS 27 + /*****************************************************************************/ struct _NMDeviceEthernetPrivate; @@ -1025,6 +1040,12 @@ _nm_device_notify_update_prop_hw_address(NMClient * client, guint dbus_property_idx, GVariant * value); +NMLDBusNotifyUpdatePropFlags _nm_device_notify_update_prop_ports(NMClient * client, + NMLDBusObject * dbobj, + const NMLDBusMetaIface *meta_iface, + guint dbus_property_idx, + GVariant *value); + /*****************************************************************************/ #endif /* __NM_LIBNM_UTILS_H__ */ diff --git a/src/libnm-client-impl/nm-object-private.h b/src/libnm-client-impl/nm-object-private.h index 9f78304d..11afc639 100644 --- a/src/libnm-client-impl/nm-object-private.h +++ b/src/libnm-client-impl/nm-object-private.h @@ -7,7 +7,7 @@ #define __NM_OBJECT_PRIVATE_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #include "nm-object.h" diff --git a/src/libnm-client-impl/nm-object.c b/src/libnm-client-impl/nm-object.c index 2e7de8c2..ae48853b 100644 --- a/src/libnm-client-impl/nm-object.c +++ b/src/libnm-client-impl/nm-object.c @@ -21,7 +21,7 @@ /*****************************************************************************/ -NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PATH, ); +NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PATH, PROP_CLIENT, ); typedef struct _NMObjectPrivate { NMClient * client; @@ -215,6 +215,8 @@ unregister_client(NMObject *self, NMClient *client, NMLDBusObject *dbobj) nm_assert(priv->client == client); priv->client = NULL; + _nm_client_queue_notify_object(client, self, obj_properties[PROP_CLIENT]); + clear_properties(self, client); } @@ -229,6 +231,9 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) case PROP_PATH: g_value_set_string(value, nm_object_get_path(self)); break; + case PROP_CLIENT: + g_value_set_object(value, nm_object_get_client(self)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -300,6 +305,10 @@ nm_object_class_init(NMObjectClass *klass) * NMObject:path: * * The D-Bus object path. + * + * The D-Bus path of an object instance never changes, even if the object + * gets removed from the cache. To see whether the object is still in the + * cache, check NMObject:client. **/ obj_properties[PROP_PATH] = g_param_spec_string(NM_OBJECT_PATH, "", @@ -307,5 +316,23 @@ nm_object_class_init(NMObjectClass *klass) NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + /** + * NMObject:client: + * + * The NMClient instance as returned by nm_object_get_client(). + * + * When an NMObject gets removed from the NMClient cache, + * the NMObject:path property stays unchanged, but this client + * instance gets reset to %NULL. You can use this property to + * track removal of the object from the cache. + * + * Since: 1.34 + **/ + obj_properties[PROP_CLIENT] = g_param_spec_object(NM_OBJECT_CLIENT, + "", + "", + NM_TYPE_CLIENT, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); } diff --git a/src/libnm-client-impl/nm-property-infos-dbus.xml b/src/libnm-client-impl/nm-property-infos-dbus.xml index 216ed1e7..009e1274 100644 --- a/src/libnm-client-impl/nm-property-infos-dbus.xml +++ b/src/libnm-client-impl/nm-property-infos-dbus.xml @@ -7,6 +7,8 @@ + + diff --git a/src/libnm-client-impl/nm-property-infos-ifcfg-rh.xml b/src/libnm-client-impl/nm-property-infos-ifcfg-rh.xml index df38ca79..15950eb8 100644 --- a/src/libnm-client-impl/nm-property-infos-ifcfg-rh.xml +++ b/src/libnm-client-impl/nm-property-infos-ifcfg-rh.xml @@ -45,6 +45,9 @@ + + + @@ -106,6 +109,7 @@ + diff --git a/src/libnm-client-impl/nm-property-infos-keyfile.xml b/src/libnm-client-impl/nm-property-infos-keyfile.xml index 486d61e9..78a7fc0b 100644 --- a/src/libnm-client-impl/nm-property-infos-keyfile.xml +++ b/src/libnm-client-impl/nm-property-infos-keyfile.xml @@ -7,6 +7,8 @@ + + diff --git a/src/libnm-client-impl/nm-property-infos-nmcli.xml b/src/libnm-client-impl/nm-property-infos-nmcli.xml index d6aa8a80..a234f3ce 100644 --- a/src/libnm-client-impl/nm-property-infos-nmcli.xml +++ b/src/libnm-client-impl/nm-property-infos-nmcli.xml @@ -7,6 +7,8 @@ + + @@ -71,6 +73,443 @@ + + + +Array of TC queueing disciplines. qdisc is a basic block in the +Linux traffic control subsystem + + +Each qdisc can be specified by the following attributes: + + + + +handle HANDLE + + + +specifies the qdisc handle. A qdisc, which potentially can have children, gets +assigned a major number, called a 'handle', leaving the minor number namespace +available for classes. The handle is expressed as '10:'. It is customary to +explicitly assign a handle to qdiscs expected to have children. + + + + + +parent HANDLE + + + +specifies the handle of the parent qdisc the current qdisc must be +attached to. + + + + + +root + + + +specifies that the qdisc is attached to the root of device. + + + + + +KIND + + + +this is the qdisc kind. NetworkManager currently supports the +following kinds: fq_codel, sfq, tbf. Each qdisc kind has a +different set of parameters, described below. There are also some +kinds like pfifo, pfifo_fast, prio supported by NetworkManager +but their parameters are not supported by NetworkManager. + + + + + +Parameters for 'fq_codel': + + + + +limit U32 + + + +the hard limit on the real queue size. When this limit is +reached, incoming packets are dropped. Default is 10240 packets. + + + + + +memory_limit U32 + + + +sets a limit on the total number of bytes that can be queued in +this FQ-CoDel instance. The lower of the packet limit of the +limit parameter and the memory limit will be enforced. Default is +32 MB. + + + + + +flows U32 + + + +the number of flows into which the incoming packets are +classified. Due to the stochastic nature of hashing, multiple +flows may end up being hashed into the same slot. Newer flows +have priority over older ones. This parameter can be set only at +load time since memory has to be allocated for the hash table. +Default value is 1024. + + + + + +target U32 + + + +the acceptable minimum standing/persistent queue delay. This minimum +delay is identified by tracking the local minimum queue delay that packets +experience. The unit of measurement is microsecond(us). Default value is 5ms. + + + + + +interval U32 + + + +used to ensure that the measured minimum delay does not become too stale. +The minimum delay must be experienced in the last epoch of length .B +interval. It should be set on the order of the worst-case RTT +through the bottleneck to give endpoints sufficient time to +react. Default value is 100ms. + + + + + +quantum U32 + + + +the number of bytes used as 'deficit' in the fair queuing +algorithm. Default is set to 1514 bytes which corresponds to the +Ethernet MTU plus the hardware header length of 14 bytes. + + + + + +ecn BOOL + + + +can be used to mark packets instead of dropping them. ecn is turned +on by default. + + + + + +ce_threshold U32 + + + +sets a threshold above which all packets are marked with ECN +Congestion Experienced. This is useful for DCTCP-style congestion +control algorithms that require marking at very shallow queueing +thresholds. + + + + + +Parameters for 'sfq': + + + + +divisor U32 + + + +can be used to set a different hash table size, available +from kernel 2.6.39 onwards. The specified divisor must be +a power of two and cannot be larger than 65536. Default +value: 1024. + + + + + +limit U32 + + + +Upper limit of the SFQ. Can be used to reduce the default +length of 127 packets. + + + + + +depth U32 + + + +Limit of packets per flow. Default to +127 and can be lowered. + + + + + +perturb_period U32 + + + +Interval in seconds for queue algorithm perturbation. +Defaults to 0, which means that no perturbation occurs. Do +not set too low for each perturbation may cause some +packet reordering or losses. Advised value: 60 This value +has no effect when external flow classification is used. +Its better to increase divisor value to lower risk of hash +collisions. + + + + + +quantum U32 + + + +Amount of bytes a flow is allowed to dequeue during a +round of the round robin process. Defaults to the MTU of +the interface which is also the advised value and the +minimum value. + + + + + +flows U32 + + + +Default value is 127. + + + + + +Parameters for 'tbf': + + + + +rate U64 + + + +Bandwidth or rate. These parameters accept a floating +point number, possibly followed by either a unit (both SI +and IEC units supported), or a float followed by a percent +character to specify the rate as a percentage of the +device's speed. + + + + + +burst U32 + + + +Also known as buffer or maxburst. Size of the bucket, in +bytes. This is the maximum amount of bytes that tokens can +be available for instantaneously. In general, larger +shaping rates require a larger buffer. For 10mbit/s on +Intel, you need at least 10kbyte buffer if you want to +reach your configured rate! + + +If your buffer is too small, packets may be dropped +because more tokens arrive per timer tick than fit in your +bucket. The minimum buffer size can be calculated by +dividing the rate by HZ. + + +Token usage calculations are performed using a table which +by default has a resolution of 8 packets. This resolution +can be changed by specifying the cell size with the burst. +For example, to specify a 6000 byte buffer with a 16 byte +cell size, set a burst of 6000/16. You will probably never +have to set this. Must be an integral power of 2. + + + + + +limit U32 + + + +Limit is the number of bytes that can be queued waiting +for tokens to become available. + + + + + +latency U32 + + + +specifies the maximum amount of time a packet can +sit in the TBF. The latency calculation takes into account +the size of the bucket, the rate and possibly the peakrate +(if set). The latency and limit are mutually exclusive. + + + + + + + + + +Array of TC traffic filters. Traffic control can manage the packet content during +classification by using filters. + + +Each tfilters can be specified by the following attributes: + + + + +handle HANDLE + + + +specifies the tfilters handle. A filter is used by a classful qdisc to determine in which class +a packet will be enqueued. It is important to notice that filters reside within qdiscs. Therefore, +see qdiscs handle for detailed information. + + + + + +parent HANDLE + + + +specifies the handle of the parent qdisc the current qdisc must be +attached to. + + + + + +root + + + +specifies that the qdisc is attached to the root of device. + + + + + +KIND + + + +this is the tfilters kind. NetworkManager currently supports +following kinds: mirred, simple. Each filter kind has a +different set of actions, described below. There are also some +other kinds like matchall, basic, u32 supported by NetworkManager. + + + + + +Actions for 'mirred': + + + + +egress bool + + + +Define whether the packet should exit from the interface. + + + + + +ingress bool + + + +Define whether the packet should come into the interface. + + + + + +mirror bool + + + +Define whether the packet should be copied to the destination space. + + + + + +redirect bool + + + +Define whether the packet should be moved to the destination space. + + + + + +Action for 'simple': + + + + +sdata char[32] + + + +The actual string to print. + + + + + + diff --git a/src/libnm-client-impl/nm-remote-connection-private.h b/src/libnm-client-impl/nm-remote-connection-private.h index 3ca934bf..f0869347 100644 --- a/src/libnm-client-impl/nm-remote-connection-private.h +++ b/src/libnm-client-impl/nm-remote-connection-private.h @@ -7,7 +7,7 @@ #define __NM_REMOTE_CONNECTION_PRIVATE_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #define NM_REMOTE_CONNECTION_INIT_RESULT "init-result" diff --git a/src/libnm-client-impl/nm-settings-docs-gir.xml b/src/libnm-client-impl/nm-settings-docs-gir.xml index cbbae7b6..b916ee04 100644 --- a/src/libnm-client-impl/nm-settings-docs-gir.xml +++ b/src/libnm-client-impl/nm-settings-docs-gir.xml @@ -5,10 +5,11 @@ - - + + + @@ -98,6 +99,9 @@ + + + @@ -142,7 +146,7 @@ - + @@ -464,7 +468,7 @@ - + diff --git a/src/libnm-client-impl/tests/test-libnm.c b/src/libnm-client-impl/tests/test-libnm.c index e470c63e..29ffde97 100644 --- a/src/libnm-client-impl/tests/test-libnm.c +++ b/src/libnm-client-impl/tests/test-libnm.c @@ -6,7 +6,7 @@ #include "libnm-client-impl/nm-default-libnm.h" #if defined(HAVE_DECL_MEMFD_CREATE) && HAVE_DECL_MEMFD_CREATE - #include +#include #endif #include @@ -2758,7 +2758,7 @@ test_types(void) for (i_type = 0; i_type < G_N_ELEMENTS(get_type_fcns); i_type++) { nm_auto_unref_gtypeclass GObjectClass *klass_unref = NULL; - GType gtype = (get_type_fcns[i_type]) (); + GType gtype = (get_type_fcns[i_type])(); GObjectClass * klass; g_assert(g_str_has_prefix(g_type_name(gtype), "NM")); @@ -2837,6 +2837,11 @@ test_nml_dbus_meta(void) g_assert((mif->n_dbus_properties > 0) == (!!mif->dbus_properties)); + if (nm_streq(mif->dbus_iface_name, "org.freedesktop.NetworkManager.Device")) + g_assert(nm_streq( + mif->dbus_properties[_NML_DEVICE_META_PROPERTY_INDEX_PORTS].dbus_property_name, + "Ports")); + if (mif->interface_prio == NML_DBUS_META_INTERFACE_PRIO_NONE) { g_assert(!mif->get_type_fcn); g_assert(!mif->obj_properties); @@ -3068,7 +3073,7 @@ check_dbus_properties: pspec = mif->obj_properties[mpr->obj_properties_idx]; } - if (mpr->use_notify_update_prop) { + if (mpr->notify_update_prop) { g_assert(mpr->notify_update_prop); } else { if (klass) @@ -3129,7 +3134,7 @@ check_dbus_properties: g_assert_cmpstr(expected_property_name, ==, pspec->name); - if (!mpr->use_notify_update_prop) { + if (!mpr->notify_update_prop) { for (p_expected_type_2 = &expected_types[0]; p_expected_type_2 < &expected_types[G_N_ELEMENTS(expected_types)]; p_expected_type_2++) { diff --git a/src/libnm-client-impl/tests/test-nm-client.c b/src/libnm-client-impl/tests/test-nm-client.c index 55b886a0..a3fc5847 100644 --- a/src/libnm-client-impl/tests/test-nm-client.c +++ b/src/libnm-client-impl/tests/test-nm-client.c @@ -62,7 +62,7 @@ test_device_added(void) devices = nm_client_get_devices(client); g_assert(devices->len == 0); - g_signal_connect(client, "notify::devices", (GCallback) devices_notify_cb, ¬ified); + g_signal_connect(client, "notify::devices", G_CALLBACK(devices_notify_cb), ¬ified); /* Tell the test service to add a new device */ nmtstc_service_add_device(sinfo, client, "AddWiredDevice", "eth0"); @@ -149,11 +149,11 @@ test_device_added_signal_after_init(void) devices = nm_client_get_devices(client); g_assert(devices->len == 0); - g_signal_connect(client, NM_CLIENT_DEVICE_ADDED, (GCallback) device_sai_added_cb, &result); + g_signal_connect(client, NM_CLIENT_DEVICE_ADDED, G_CALLBACK(device_sai_added_cb), &result); g_signal_connect(client, "notify::" NM_CLIENT_DEVICES, - (GCallback) devices_sai_notify_cb, + G_CALLBACK(devices_sai_notify_cb), &result); /* Tell the test service to add a new device */ @@ -307,10 +307,10 @@ test_wifi_ap_added_removed(void) g_variant_get(ret, "(o)", &expected_path); g_variant_unref(ret); - g_signal_connect(wifi, "access-point-added", (GCallback) wifi_ap_added_cb, &info); + g_signal_connect(wifi, "access-point-added", G_CALLBACK(wifi_ap_added_cb), &info); info.quit_count = 1; - g_signal_connect(wifi, "notify::access-points", (GCallback) wifi_ap_add_notify_cb, &info); + g_signal_connect(wifi, "notify::access-points", G_CALLBACK(wifi_ap_add_notify_cb), &info); info.quit_count++; /* Wait for libnm to find the AP */ @@ -340,10 +340,10 @@ test_wifi_ap_added_removed(void) g_assert_no_error(error); nm_clear_pointer(&ret, g_variant_unref); - g_signal_connect(wifi, "access-point-removed", (GCallback) wifi_ap_removed_cb, &info); + g_signal_connect(wifi, "access-point-removed", G_CALLBACK(wifi_ap_removed_cb), &info); info.quit_count = 1; - g_signal_connect(wifi, "notify::access-points", (GCallback) wifi_ap_remove_notify_cb, &info); + g_signal_connect(wifi, "notify::access-points", G_CALLBACK(wifi_ap_remove_notify_cb), &info); info.quit_count++; /* Wait for libnm to find the AP */ @@ -463,9 +463,9 @@ test_devices_array(void) g_assert(ret); g_variant_unref(ret); - g_signal_connect(client, "device-removed", (GCallback) da_device_removed_cb, &info); + g_signal_connect(client, "device-removed", G_CALLBACK(da_device_removed_cb), &info); - g_signal_connect(client, "notify::devices", (GCallback) da_devices_notify_cb, &info); + g_signal_connect(client, "notify::devices", G_CALLBACK(da_devices_notify_cb), &info); info.quit_count = 2; /* Wait for libnm to notice the changes */ @@ -948,7 +948,7 @@ _test_connection_invalid_find_connections(gpointer element, gpointer needle, gpo static void test_connection_invalid(void) { - NMTSTC_SERVICE_INFO_SETUP(my_sinfo) + NMTSTC_SERVICE_INFO_SETUP(my_sinfo); gs_unref_object NMConnection *connection = NULL; NMSettingConnection * s_con; gs_unref_object NMClient *client = NULL; -- cgit 1.3.0-6-gf8a5