diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-09-29 17:50:30 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-10-06 19:36:29 +0200 |
commit | 50a3682f1ea89d83c3d614375bcb8ffe22d76e57 (patch) | |
tree | 29ad7202e7053c02469afe75c70f9aa6faf14473 /src | |
parent | network: make routing_policy_rule_new() static (diff) | |
download | systemd-50a3682f1ea89d83c3d614375bcb8ffe22d76e57.tar.xz systemd-50a3682f1ea89d83c3d614375bcb8ffe22d76e57.zip |
network: introduce network_verify_routing_policy_rules()
Diffstat (limited to 'src')
-rw-r--r-- | src/network/networkd-network.c | 5 | ||||
-rw-r--r-- | src/network/networkd-routing-policy-rule.c | 12 | ||||
-rw-r--r-- | src/network/networkd-routing-policy-rule.h | 3 |
3 files changed, 14 insertions, 6 deletions
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 78ccd9311d..c642e86fda 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 386aa5789b..9dbced6c0c 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 8510dec0fc..9b4f979f7b 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); |