]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/routing-policy-rule: use address family of existing rule when judging if...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 21 Aug 2024 19:11:52 +0000 (04:11 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 21 Aug 2024 19:11:52 +0000 (04:11 +0900)
Otherwise, the other RoutingPolicyRule object may not have a valid
address family yet, and the existing rule may be wrongly handled as
that it is not requested by any interface, and it may be removed.

Follow-up for 727235006a7e8904f8493d32376cffa6969c5fa9.
Fixes #34068.

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

index 44d85d000fe07b7cdfd0c2344d82d06b2e1080c8..ea3cb458680b59747f5efe8bdfb61290cefa9d8e 100644 (file)
@@ -351,11 +351,13 @@ static bool routing_policy_rule_equal(const RoutingPolicyRule *a, const RoutingP
         return routing_policy_rule_compare_func_full(a, b, /* all = */ false) == 0;
 }
 
-static bool routing_policy_rule_can_update(const RoutingPolicyRule *existing, const RoutingPolicyRule *requesting, int family) {
+static bool routing_policy_rule_can_update(const RoutingPolicyRule *existing, const RoutingPolicyRule *requesting) {
         assert(existing);
+        assert(IN_SET(existing->family, AF_INET, AF_INET6));
         assert(requesting);
+        assert(IN_SET(requesting->family, AF_INET, AF_INET6) || requesting->address_family == ADDRESS_FAMILY_YES);
 
-        if (!routing_policy_rule_equal(existing, requesting, family, existing->priority))
+        if (!routing_policy_rule_equal(existing, requesting, existing->family, existing->priority))
                 return false;
 
         /* These flags cannot be updated. */
@@ -791,7 +793,7 @@ static void manager_unmark_routing_policy_rule(Manager *m, const RoutingPolicyRu
         if (routing_policy_rule_get(m, rule, family, &existing) < 0)
                 return;
 
-        if (!routing_policy_rule_can_update(existing, rule, rule->family))
+        if (!routing_policy_rule_can_update(existing, rule))
                 return;
 
         routing_policy_rule_unmark(existing);