From: Yu Watanabe Date: Thu, 29 Oct 2020 02:41:01 +0000 (+0900) Subject: network: introduce routing_policy_rule_equal() X-Git-Tag: v248-rc1~513^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=40424f1ad97db59958e40a395986a5e248da6f05;p=thirdparty%2Fsystemd.git network: introduce routing_policy_rule_equal() --- diff --git a/src/network/networkd-routing-policy-rule.c b/src/network/networkd-routing-policy-rule.c index 0b7ee79f6ff..411d44b073a 100644 --- a/src/network/networkd-routing-policy-rule.c +++ b/src/network/networkd-routing-policy-rule.c @@ -264,6 +264,16 @@ static int routing_policy_rule_compare_func(const RoutingPolicyRule *a, const Ro } } +static bool routing_policy_rule_equal(const RoutingPolicyRule *rule1, const RoutingPolicyRule *rule2) { + if (rule1 == rule2) + return true; + + if (!rule1 || !rule2) + return false; + + return routing_policy_rule_compare_func(rule1, rule2) == 0; +} + DEFINE_PRIVATE_HASH_OPS_WITH_KEY_DESTRUCTOR( routing_policy_rule_hash_ops, RoutingPolicyRule, @@ -605,7 +615,7 @@ static bool manager_links_have_routing_policy_rule(Manager *m, RoutingPolicyRule continue; HASHMAP_FOREACH(link_rule, link->network->rules_by_section) - if (routing_policy_rule_compare_func(link_rule, rule) == 0) + if (routing_policy_rule_equal(link_rule, rule)) return true; }