From: Yu Watanabe Date: Tue, 29 Sep 2020 15:50:30 +0000 (+0900) Subject: network: introduce network_verify_routing_policy_rules() X-Git-Tag: v247-rc1~117^2~124 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=50a3682f1ea89d83c3d614375bcb8ffe22d76e57;p=thirdparty%2Fsystemd.git network: introduce network_verify_routing_policy_rules() --- diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 78ccd9311d9..c642e86fda3 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -150,7 +150,6 @@ static int network_resolve_stacked_netdevs(Network *network) { int network_verify(Network *network) { RoutePrefix *route_prefix, *route_prefix_next; - RoutingPolicyRule *rule; Neighbor *neighbor, *neighbor_next; AddressLabel *label, *label_next; NextHop *nexthop, *nextnop_next; @@ -327,9 +326,7 @@ int network_verify(Network *network) { if (section_is_invalid(route_prefix->section)) route_prefix_free(route_prefix); - HASHMAP_FOREACH(rule, network->rules_by_section) - if (routing_policy_rule_section_verify(rule) < 0) - routing_policy_rule_free(rule); + network_verify_routing_policy_rules(network); bool has_root = false, has_clsact = false; ORDERED_HASHMAP_FOREACH(tc, network->tc_by_section) diff --git a/src/network/networkd-routing-policy-rule.c b/src/network/networkd-routing-policy-rule.c index 386aa5789b0..9dbced6c0c1 100644 --- a/src/network/networkd-routing-policy-rule.c +++ b/src/network/networkd-routing-policy-rule.c @@ -1460,7 +1460,7 @@ int config_parse_routing_policy_rule_suppress_prefixlen( return 0; } -int routing_policy_rule_section_verify(RoutingPolicyRule *rule) { +static int routing_policy_rule_section_verify(RoutingPolicyRule *rule) { if (section_is_invalid(rule->section)) return -EINVAL; @@ -1477,6 +1477,16 @@ int routing_policy_rule_section_verify(RoutingPolicyRule *rule) { return 0; } +void network_verify_routing_policy_rules(Network *network) { + RoutingPolicyRule *rule; + + assert(network); + + HASHMAP_FOREACH(rule, network->rules_by_section) + if (routing_policy_rule_section_verify(rule) < 0) + routing_policy_rule_free(rule); +} + int routing_policy_serialize_rules(Set *rules, FILE *f) { RoutingPolicyRule *rule; int r; diff --git a/src/network/networkd-routing-policy-rule.h b/src/network/networkd-routing-policy-rule.h index 8510dec0fc2..9b4f979f7b1 100644 --- a/src/network/networkd-routing-policy-rule.h +++ b/src/network/networkd-routing-policy-rule.h @@ -50,7 +50,8 @@ typedef struct RoutingPolicyRule { } RoutingPolicyRule; RoutingPolicyRule *routing_policy_rule_free(RoutingPolicyRule *rule); -int routing_policy_rule_section_verify(RoutingPolicyRule *rule); + +void network_verify_routing_policy_rules(Network *network); int link_set_routing_policy_rules(Link *link);