libnm: rework setting metadata for property handling

System Internals / NetworkManager - Thomas Haller [redhat.com] - 10 August 2018 08:38 EDT

NMSetting internally already tracked a list of all proper GObject properties and D-Bus-only properties.

Rework the tracking of the list, so that:

- instead of attaching the data to the GType of the setting via g_type_set_qdata(), it is tracked in a static array indexed by NMMetaSettingType. This allows to find the setting-data by simple pointer arithmetic, instead of taking a look and iterating (like g_type_set_qdata() does).

Note, that this is still thread safe, because the static table entry is initialized in the class-init function with _nm_setting_class_commit(). And it only accessed by following a NMSettingClass instance, thus the class constructor already ran (maybe not for all setting classes, but for the particular one that we look up).

I think this makes initialization of the metadata simpler to understand. Previously, in a first phase each class would attach the metadata to the GType as setting_property_overrides_quark(). Then during nm_setting_class_ensure_properties() it would merge them and set as setting_properties_quark(). Now, during the first phase, we only incrementally build a properties_override GArray, which we finally hand over during nm_setting_class_commit().

- sort the property infos by name and do binary search.

Also expose this meta data types as internal API in nm-setting-private.h. While not accessed yet, it can prove beneficial, to have direct (internal) access to these structures.

Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct naming scheme. We already have 40+ subclasses of NMSetting that are called NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a new, distinct name.

379380431 libnm: rework setting metadata for property handling
libnm-core/nm-core-internal.h | 53 ++++
libnm-core/nm-setting-6lowpan.c | 5 +-
libnm-core/nm-setting-8021x.c | 3 +-
libnm-core/nm-setting-adsl.c | 3 +-
libnm-core/nm-setting-bluetooth.c | 16 +-
libnm-core/nm-setting-bond.c | 25 +-
libnm-core/nm-setting-bridge-port.c | 5 +-
libnm-core/nm-setting-bridge.c | 27 +-
libnm-core/nm-setting-cdma.c | 2 +-
libnm-core/nm-setting-connection.c | 18 +-
libnm-core/nm-setting-dcb.c | 73 ++++--
libnm-core/nm-setting-dummy.c | 5 +-
libnm-core/nm-setting-generic.c | 2 +-
libnm-core/nm-setting-gsm.c | 22 +-
libnm-core/nm-setting-infiniband.c | 17 +-
libnm-core/nm-setting-ip-config.c | 24 +-
libnm-core/nm-setting-ip-tunnel.c | 5 +-
libnm-core/nm-setting-ip4-config.c | 77 +++---
libnm-core/nm-setting-ip6-config.c | 64 ++---
libnm-core/nm-setting-macsec.c | 3 +-
libnm-core/nm-setting-macvlan.c | 5 +-
libnm-core/nm-setting-olpc-mesh.c | 18 +-
libnm-core/nm-setting-ovs-bridge.c | 5 +-
libnm-core/nm-setting-ovs-interface.c | 5 +-
libnm-core/nm-setting-ovs-patch.c | 5 +-
libnm-core/nm-setting-ovs-port.c | 5 +-
libnm-core/nm-setting-ppp.c | 5 +-
libnm-core/nm-setting-pppoe.c | 3 +-
libnm-core/nm-setting-private.h | 103 +++++---
libnm-core/nm-setting-proxy.c | 5 +-
libnm-core/nm-setting-serial.c | 18 +-
libnm-core/nm-setting-sriov.c | 18 +-
libnm-core/nm-setting-tc-config.c | 31 ++-
libnm-core/nm-setting-team-port.c | 16 +-
libnm-core/nm-setting-team.c | 26 +-
libnm-core/nm-setting-tun.c | 5 +-
libnm-core/nm-setting-user.c | 15 +-
libnm-core/nm-setting-vlan.c | 29 ++-
libnm-core/nm-setting-vpn.c | 27 +-
libnm-core/nm-setting-vxlan.c | 5 +-
libnm-core/nm-setting-wimax.c | 18 +-
libnm-core/nm-setting-wired.c | 57 +++--
libnm-core/nm-setting-wireless-security.c | 17 +-
libnm-core/nm-setting-wireless.c | 59 +++--
libnm-core/nm-setting-wpan.c | 5 +-
libnm-core/nm-setting.c | 396 +++++++++++++++---------------
46 files changed, 810 insertions(+), 540 deletions(-)

Upstream: cgit.freedesktop.org


  • Share