diff options
author | Thomas Haller <thaller@redhat.com> | 2019-04-10 13:47:52 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-04-10 15:44:15 +0200 |
commit | 99dd794998ce8b95281e512f9ed027671892a643 (patch) | |
tree | 3df6843e26c7aab6620a86a644006b1343413b82 /src/nm-act-request.c | |
parent | 98b2e9df61e142047e78047339bcb5328697962c (diff) | |
download | NetworkManager-th/platform-rules-cleanup.tar.gz |
platform: support weakly tracked routing rules in NMPRulesManagerth/platform-rules-cleanup
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.
For that, NMPRulesManager "track" can track rules.
Rules that are not tracked by NMPRulesManager are 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 best track-priority is positive, NMPRulesManager will add the rule if
it's not present.
When the best 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, when untracking the rule
NMPRulesManager will remove the rule again (restore its prevous absence).
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!
Add weakly tracked rules to account for that. A tracking-priority of
zero indicates 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.
Diffstat (limited to 'src/nm-act-request.c')
0 files changed, 0 insertions, 0 deletions