network: introduce network_verify_routing_policy_rules()

This commit is contained in:
Yu Watanabe
2020-10-07 02:36:29 +09:00
parent f1828a222a
commit 50a3682f1e
3 changed files with 14 additions and 6 deletions
+1 -4
View File
@@ -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)
+11 -1
View File
@@ -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;
+2 -1
View File
@@ -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);