NetworkManager/src/libnm-core-impl
Thomas Haller 71454ae4cd
libnm: make ref counting of immutable types thread safe
The types NMBridgeVlan, NMIPRoutingRule, NMRange, NMWireGuardPeer
are immutable (or immutable, after the seal() function is called).

Immutable types are great, as it means a reference to them can be shared
without doing a full clone. Hence the G_DEFINE_BOXED_TYPE() for these
types prefers to take a reference instead of cloning the objects. Except
for sealable types, where it will prefer to clone unsealed values.
Likewise, nm_simple_connection_new_clone() probably will just take
another reference to the value, instead of doing a deep clone.

libnm is not a thread-safe library in the sense that you could pass a
NMConnection or NMClient instance to multiple threads and access them
without your own synchronization. However, it should be possible that
multiple threads access (seemingly) distinct objects.

As the copy function of these boxed types (and nm_simple_connection_new_clone()
and similar) prefers to share the references to immutable types, it is important
that the ref function is thread-safe too. Otherwise you cannot just clone a
NMConnection on thread1, hand the clone to thread2 and operate on the
clone and the original independently. If you do before this patch, you would
hit a subtle race condition.

Avoid that. While atomic operations have a runtime overhead, being safe
is more important. Also, we already save a full malloc()/free() by
having immutable, ref-counted types. We just need to make it safe to use
in order to fully benefit from it.
2022-12-20 10:35:02 +01:00
..
tests all: fix various "-Wcast-align=strict" warnings 2022-12-09 09:15:56 +01:00
gen-metadata-nm-settings-libnm-core.c libnm/trivial: fix style 2022-11-10 14:41:38 +01:00
gen-metadata-nm-settings-libnm-core.xml.in libnm,nmcli: add vlan.protocol property 2022-12-14 11:33:03 +01:00
meson.build support loopback interface 2022-11-23 20:51:22 +01:00
nm-connection-private.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-connection.c libnm: add ovs-port.trunks property 2022-11-25 14:15:41 +01:00
nm-default-libnm-core.h libnm: move nm-errors.h include away from nm-connection.h 2022-11-13 23:36:37 +01:00
nm-errors.c libnm: don't depend nm-crypto on "nm-error.h" 2022-03-29 11:56:03 +02:00
nm-keyfile-utils.c glib-aux: drop nm_str_buf_init() for NM_STR_BUF_INIT() 2022-05-09 19:18:30 +02:00
nm-keyfile.c all: fix "-Wcast-align=strict" warnings for GArray casts 2022-12-09 09:15:55 +01:00
nm-meta-setting-base-impl.c support loopback interface 2022-11-23 20:51:22 +01:00
nm-property-compare.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-property-compare.h clang-format: use "IndentPPDirectives:None" instead of "BeforeHash" 2021-07-09 08:49:06 +02:00
nm-setting-6lowpan.c libnm: actually export a lot of routines that were supposed to be public 2022-11-08 11:43:00 +01:00
nm-setting-8021x.c setting-8021x: fix "PKCS#11" string in gtk-doc 2022-11-13 23:35:56 +01:00
nm-setting-adsl.c core: move rerequest decision of secrets to NMSetting 2022-10-25 08:40:09 +02:00
nm-setting-bluetooth.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-setting-bond-port.c libnm-core: allow empty slave-type with a NMSettingBondPort 2022-09-21 13:24:14 +02:00
nm-setting-bond.c libnm: fix a handful of misformatted gtk-doc blocks 2022-11-13 23:36:37 +01:00
nm-setting-bridge-port.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-setting-bridge.c libnm: make ref counting of immutable types thread safe 2022-12-20 10:35:02 +01:00
nm-setting-cdma.c core: move rerequest decision of secrets to NMSetting 2022-10-25 08:40:09 +02:00
nm-setting-connection.c libnm: actually export a lot of routines that were supposed to be public 2022-11-08 11:43:00 +01:00
nm-setting-dcb.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-setting-dummy.c libnm: extend NMSettInfoSetting with an offset to the private data 2021-07-12 13:34:40 +02:00
nm-setting-ethtool.c setting-ethtool: fix malformed doc comments 2022-11-13 23:36:37 +01:00
nm-setting-generic.c libnm: extend NMSettInfoSetting with an offset to the private data 2021-07-12 13:34:40 +02:00
nm-setting-gsm.c libnm: mark deprecated D-Bus properties in meta data 2022-10-27 09:11:23 +02:00
nm-setting-hostname.c libnm: actually export a lot of routines that were supposed to be public 2022-11-08 11:43:00 +01:00
nm-setting-infiniband.c libnm: style cleanups for property annotations 2022-09-02 19:03:35 +02:00
nm-setting-ip-config.c libnm: make ref counting of immutable types thread safe 2022-12-20 10:35:02 +01:00
nm-setting-ip-tunnel.c libnm: actually export a lot of routines that were supposed to be public 2022-11-08 11:43:00 +01:00
nm-setting-ip4-config.c libnm: actually export a lot of routines that were supposed to be public 2022-11-08 11:43:00 +01:00
nm-setting-ip6-config.c libnm: fix comparing "ipv[46].dns" properties 2022-10-28 17:54:15 +02:00
nm-setting-loopback.c loopback: reject setting "slave-type"/"master" for "loopback" profiles 2022-12-01 13:24:18 +01:00
nm-setting-macsec.c macsec: document the format of CAK and CKN properties 2022-11-16 10:36:39 +01:00
nm-setting-macvlan.c libnm: refactor some NMSetting to use direct properties for string 2022-01-18 16:22:28 +01:00
nm-setting-match.c libnm: rework strv properties of NMSetting as "direct" properties 2022-02-10 22:30:27 +01:00
nm-setting-olpc-mesh.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-setting-ovs-bridge.c libnm: actually export a lot of routines that were supposed to be public 2022-11-08 11:43:00 +01:00
nm-setting-ovs-dpdk.c libnm: refactor some NMSetting to use direct properties for string 2022-01-18 16:22:28 +01:00
nm-setting-ovs-external-ids.c libnm: fix a large amount of Since tags 2022-11-08 11:40:18 +01:00
nm-setting-ovs-interface.c ovs: add ofport_request option to ovs interface 2022-09-02 08:46:36 +00:00
nm-setting-ovs-patch.c libnm: refactor some NMSetting to use direct properties for string 2022-01-18 16:22:28 +01:00
nm-setting-ovs-port.c libnm: accept "dot1q-tunnel" as vlan mode for ovs-ports 2022-11-25 14:15:41 +01:00
nm-setting-ppp.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-setting-pppoe.c core: move rerequest decision of secrets to NMSetting 2022-10-25 08:40:09 +02:00
nm-setting-private.h libnm: make ref counting of immutable types thread safe 2022-12-20 10:35:02 +01:00
nm-setting-proxy.c libnm/docs: fix documentation for "proxy.pac-script" 2022-03-21 15:21:37 +01:00
nm-setting-serial.c libnm: style cleanups for property annotations 2022-09-02 19:03:35 +02:00
nm-setting-sriov.c libnm: actually export a lot of routines that were supposed to be public 2022-11-08 11:43:00 +01:00
nm-setting-tc-config.c libnm: actually export a lot of routines that were supposed to be public 2022-11-08 11:43:00 +01:00
nm-setting-team-port.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-setting-team.c libnm: document nm_team_link_watcher_{ref,unref}() as thread-safe 2022-12-20 10:35:02 +01:00
nm-setting-tun.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-setting-user.c libnm: fix a large amount of Since tags 2022-11-08 11:40:18 +01:00
nm-setting-veth.c libnm: refactor some NMSetting to use direct properties for string 2022-01-18 16:22:28 +01:00
nm-setting-vlan.c ifcfg-rh: support the vlan.protocol property 2022-12-14 11:33:03 +01:00
nm-setting-vpn.c libnm: fix a handful of misformatted gtk-doc blocks 2022-11-13 23:36:37 +01:00
nm-setting-vrf.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-setting-vxlan.c glib-aux: rename IP address related helpers from "nm-inet-utils.h" 2022-08-25 19:05:51 +02:00
nm-setting-wifi-p2p.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-setting-wimax.c libnm: mark deprecated D-Bus properties in meta data 2022-10-27 09:11:23 +02:00
nm-setting-wired.c all: fix "-Wcast-align=strict" warnings for GArray casts 2022-12-09 09:15:55 +01:00
nm-setting-wireguard.c libnm: make ref counting of immutable types thread safe 2022-12-20 10:35:02 +01:00
nm-setting-wireless-security.c libnm: fix a large amount of Since tags 2022-11-08 11:40:18 +01:00
nm-setting-wireless.c all: fix "-Wcast-align=strict" warnings for GArray casts 2022-12-09 09:15:55 +01:00
nm-setting-wpan.c libnm: actually export a lot of routines that were supposed to be public 2022-11-08 11:43:00 +01:00
nm-setting.c all: fix "-Wcast-align=strict" warnings for GArray casts 2022-12-09 09:15:55 +01:00
nm-simple-connection.c libnm: use NMRefString for nm_connection_get_path() 2022-10-06 13:43:33 +02:00
nm-team-utils.c clang-format: reformat code with clang-format 15.0.4-1.fc37 2022-11-23 09:17:21 +01:00
nm-team-utils.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-utils-private.h libnm: unify IPv4/IPv6 forms of DNS to GVariant helper 2022-10-27 09:11:40 +02:00
nm-utils.c libnm: workaround compiler warning in nm_sock_addr_endpoint_new() 2022-11-30 08:49:07 +01:00
nm-vpn-editor-plugin.c libnm: workaround crash in nm_vpn_editor_plugin_import() for plugin requiring GError 2022-11-16 13:05:55 +01:00
nm-vpn-plugin-info.c libnm: actually export a lot of routines that were supposed to be public 2022-11-08 11:43:00 +01:00
README.md build: move "libnm-core/" to "src/" and split it 2021-02-18 19:46:51 +01:00

libnm-core-impl

NetworkManager provides a client library libnm. NetworkManager core does not (dynamically) link against all of libnm. Instead, it statically links against a part of it. That part is the static helper library libnm-core-impl.

libnm-core-impl implements (and provides) the API from libnm-core-public, which is part of the public API of libnm. In this form, libnm-core-impl is part of the implementation of libnm. It also implements (and provides) an internal API libnm-core-intern which can only be used by those who link statically against libnm-core-impl.

Only NetworkManager core and libnm are allowed to statically link with libnm-core-impl. Consequently, only those are allowed to include libnm-core-intern.

This directory should not be added to the include search path of other components as they are only allowed to include libnm-core-public and libnm-core-intern.