NetworkManager/src/platform
Thomas Haller f41b4cacd4 platform: support weakly tracked routing rules in NMPRulesManager
Policy routing rules are global, and unlike routes not tied to an interface by ifindex.
That means, while we take full control over all routes of an interface during a sync,
we need to consider that multiple parties can contribute to the global set of rules.
That might be muliple connection profiles providing the same rule, or rules that are added
externally by the user. NMPRulesManager mediates for that.

This is done by NMPRulesManager "tracking" rules.

Rules that are not tracked by NMPRulesManager are completely ignored (and
considered externally added).

When tracking a rule, the caller provides a track-priority. If multiple
parties track a rule, then the highest (absolute value of the) priority
wins.

If the highest track-priority is positive, NMPRulesManager will add the rule if
it's not present.

When the highest track-priority is negative, then NMPRulesManager will remove the
rule if it's present (enforce its absence).

The complicated part is, when a rule that was previously tracked becomes no
longer tracked. In that case, we need to restore the previous state.

If NetworkManager added the rule earlier, then untracking the rule
NMPRulesManager will remove the rule again (restore its previous absent
state).

By default, if NetworkManager had a negative tracking-priority and removed the
rule earlier (enforced it to be absent), then when the rule becomes no
longer tracked, NetworkManager will not restore the rule.
Consider: the user adds a rule externally, and then activates a profile that
enforces the absence of the rule (causing NetworkManager to remove it).
When deactivating the profile, by default NetworkManager will not
restore such a rule! It's unclear whether that is a good idea, but it's
also unclear why the rule is there and whether NetworkManager should
really restore it.

Add weakly tracked rules to account for that. A tracking-priority of
zero indicates such weakly tracked rules. The only difference between an untracked
rule and a weakly tracked rule is, that when NetworkManager earlier removed the
rule (due to a negative tracking-priority), it *will* restore weakly
tracked rules when the rules becomes no longer (negatively) tracked.
And it attmpts to do that only once.

Likewise, if the rule is weakly tracked and already exists when
NMPRulesManager starts posively tracking the rule, then it would not
remove again, when no longer positively tracking it.
2019-04-13 18:22:58 +02:00
..
linux platform: import nl82154.h 2018-06-26 16:21:54 +02:00
tests platform: drop track_default argument from nmp_rules_manager_new() 2019-04-13 18:17:16 +02:00
wifi platform/wifi: don't use __u32 type in "nm-wifi-utils-nl80211.c" 2019-02-22 10:05:00 +01:00
wpan platform/netlink: cleanup nla_parse*() code by using safer macros 2019-02-22 09:58:09 +01:00
nm-fake-platform.c platform: set errno to ENOENT for nm_platform_sysctl_get() 2019-04-04 15:35:13 +02:00
nm-fake-platform.h core: refactor private data in "src" 2016-10-04 09:50:56 +02:00
nm-linux-platform.c libnm,core: enable "onlink" flags also for IPv6 routes 2019-04-10 09:02:35 +02:00
nm-linux-platform.h platform: use NMDedupMultiIndex for routes in NMPCache 2017-07-05 18:37:38 +02:00
nm-netlink.c platform/netlink: cleanup nlmsg_append() and add nlmsg_append_struct() macro 2019-02-22 09:58:09 +01:00
nm-netlink.h platform/netlink: cleanup nlmsg_append() and add nlmsg_append_struct() macro 2019-02-22 09:58:09 +01:00
nm-platform-private.h platform: expose emit-signal function from platform 2017-07-05 18:37:39 +02:00
nm-platform-utils.c all: replace strerror() calls with nm_strerror_native() 2019-02-12 08:50:28 +01:00
nm-platform-utils.h platform/ethtool: add code to get/set offload features via ethtool 2018-08-10 10:38:19 +02:00
nm-platform.c platform: set errno to ENOENT for nm_platform_sysctl_get() 2019-04-04 15:35:13 +02:00
nm-platform.h libnm,core: enable "onlink" flags also for IPv6 routes 2019-04-10 09:02:35 +02:00
nmp-netns.c all: replace g_strerror() calls with nm_strerror_native() 2019-02-12 08:50:28 +01:00
nmp-netns.h core: cleanup implementation of nm_auto* macros to use nm_auto() 2017-10-11 08:43:40 +02:00
nmp-object.c platform: add support for routing-rule objects and cache them in platform 2019-03-13 09:03:59 +01:00
nmp-object.h platform: add support for routing-rule objects and cache them in platform 2019-03-13 09:03:59 +01:00
nmp-rules-manager.c platform: support weakly tracked routing rules in NMPRulesManager 2019-04-13 18:22:58 +02:00
nmp-rules-manager.h platform: add nmp_rules_manager_track_from_platform() 2019-04-13 18:17:16 +02:00