NetworkManager/src/libnm-platform
Thomas Haller 02ff8b2730
platform: fix tracking similar objects in NMPGlobalTracker
NMPGlobalTracker allows to track objects for independent users/callers.
That is, callers that are not aware whether another caller tracks the
same/similar object. It thus groups all objects by their nmp_object_id_equal()
(as `TrackObjData` struct), while keeping a list of each individually tracked
object (as `TrackData` struct which honors the object and the user-tag parameter).

When the same caller (based on the user-tag) tracks the same object again, then
NMPGlobalTracker will only track it once and combine the objects. That is done by
also having a dictionary for the `TrackData` entries (`self->by_data`).

This latter dictionary lookup wrongly considered nmp_object_id_equal().
Instead, it needs to consider all minor differences of the objects, and
use nmp_object_equal().

For example, for NMPlatformMptcpAddress, only the "address" is part of
the ID. Other fields, like the MPTCP flags are not. Imagine a profile is
active with MPTCP endpoints configured with flags "subflow". During reapply,
the user can only update the MPTCP flags (e.g. to "signal"). When that happens,
the caller (NML3Cfg) would track a new NMPlatformMptcpAddress instance, that only
differs by MPTCP flags. In this case, we need to track the new address for the
differences that it has according to nmp_object_equal(), and not
nmp_object_id_equal().

Due to this bug, reapply might not work correctly. For other supported types (routing
rules and routes) this bug may have been harder to reproduce, because most attributes
of rules/routes are also part of the ID and because it's uncommon to reapply a minor
change to a rule/route.

https://bugzilla.redhat.com/show_bug.cgi?id=2120471

Fixes: b8398b9e79 ('platform: add NMPRulesManager for syncing routing rules')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1375
(cherry picked from commit d8aacba3b2)
(cherry picked from commit c456bfa7c4)
(cherry picked from commit 06e720f7b2)
2022-09-29 10:53:03 +02:00
..
tests platform: clear all BASE types when setting advertised modes for ethernet autoneg 2021-09-06 10:07:15 +02:00
wifi wifi: fix find_freq() implementation 2022-02-21 19:56:13 +01:00
wpan format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
meson.build platform: rename "nmp-route-manager.h" to "nmp-rules-manager.h" 2022-02-10 08:41:17 +01:00
nm-linux-platform.c all: avoid using global string buffer for to-string methods 2022-06-14 12:55:43 +02:00
nm-linux-platform.h platform: allow disabling caching of tc objects 2021-09-20 13:27:16 +02:00
nm-netlink.c platform: no need to initialize nla sockaddr parameter to nl_recv() 2022-02-03 13:11:17 +01:00
nm-netlink.h platform/netlink: accept pre-allocated receive buffer for nl_recv() 2022-02-03 13:08:47 +01:00
nm-platform-private.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-platform-utils.c platform: make "now" timestamp an in/out parameter to nmp_utils_lifetime_get() 2022-05-12 10:46:33 +02:00
nm-platform-utils.h platform: make "now" timestamp an in/out parameter to nmp_utils_lifetime_get() 2022-05-12 10:46:33 +02:00
nm-platform.c platform: ensure the platform cache is up to date during nm_platform_ip_address_sync() 2022-06-14 12:55:46 +02:00
nm-platform.h platform: add nm_platform_ip_address_get() helper 2022-06-14 12:55:43 +02:00
nmp-base.h platform: make NMPlatformVTableAddress struct smaller and pack NMPObjectType 2022-05-12 10:46:39 +02:00
nmp-netns.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nmp-netns.h build: move "shared/nm-platform" to "src/libnm-platform" 2021-02-24 12:48:17 +01:00
nmp-object.c all: use "NM_UTILS_TO_STRING_BUFFER_SIZE" macro 2022-06-14 12:55:43 +02:00
nmp-object.h l3cfg: drop NM_L3_CFG_COMMIT_TYPE_ASSUME and assume_config_once 2022-05-12 10:46:52 +02:00
nmp-route-manager.c platform: fix tracking similar objects in NMPGlobalTracker 2022-09-29 10:53:03 +02:00
nmp-route-manager.h platform: improve way to prune dirty route-manager entries 2022-02-10 08:41:18 +01:00
README.md platform: support IPv6 mulitpath routes and fix cache inconsistency 2022-02-16 10:06:58 +01:00

libnm-platform

A static helper library that provides NMPlatform and other utils. This is NetworkManager's internal netlink library, but also contains helpers for sysfs, ethtool and other kernel APIs.

NMPlaform is also a cache of objects of the netlink API: NMPCache and NMPObject. These objects are used throughout NetworkManager also for generally tracking information about these types. For example, NMPlatformIP4Address (the public part of a certain type of NMPObject) is not only used to track platform addresses from netlink in the cache, but to track information about IPv4 addresses in general.

This depends on the following helper libraries