]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: remove routing policy rule from foreign rule database when it is removed
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 22 Feb 2019 04:27:44 +0000 (13:27 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 27 Feb 2019 01:58:09 +0000 (10:58 +0900)
Previously, When the first link configures rules, it removes all saved
rules, which were configured by networkd previously, in the foreign rule
database, but the rules themselves are still in the database.
Thus, when the second or later link configures rules, it errnously
treats the rules already exist.
This is the root of issue #11280.

This removes rules from the foreign database when they are removed.

Fixes #11280.

src/network/networkd-routing-policy-rule.c

index dd15574817787b020e1b8eebc9da7090bb2fd6e6..3941245733fc393e744d7ac395dee8e8a357d793 100644 (file)
@@ -1244,15 +1244,18 @@ void routing_policy_rule_purge(Manager *m, Link *link) {
 
         SET_FOREACH(rule, m->rules_saved, i) {
                 existing = set_get(m->rules_foreign, rule);
-                if (existing) {
+                if (!existing)
+                        continue; /* Saved rule does not exist anymore. */
 
-                        r = routing_policy_rule_remove(rule, link, NULL);
-                        if (r < 0) {
-                                log_warning_errno(r, "Could not remove routing policy rules: %m");
-                                continue;
-                        }
-
-                        link->routing_policy_rule_remove_messages++;
+                r = routing_policy_rule_remove(existing, link, NULL);
+                if (r < 0) {
+                        log_warning_errno(r, "Could not remove routing policy rules: %m");
+                        continue;
                 }
+
+                link->routing_policy_rule_remove_messages++;
+
+                assert_se(set_remove(m->rules_foreign, existing) == existing);
+                routing_policy_rule_free(existing);
         }
 }