]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: introduce network_verify_routing_policy_rules()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 29 Sep 2020 15:50:30 +0000 (00:50 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 6 Oct 2020 17:36:29 +0000 (02:36 +0900)
src/network/networkd-network.c
src/network/networkd-routing-policy-rule.c
src/network/networkd-routing-policy-rule.h

index 78ccd9311d90694514f8783c01cd89931afc9f23..c642e86fda3359a35af5e418e65a8ba536ef1d18 100644 (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)
index 386aa5789b0a38e1780952ffcd14729431a720b3..9dbced6c0c129c02cf790cf87f74bc8f7d74e5af 100644 (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;
index 8510dec0fc2b5a0b3466014a1f52e2389c800d1e..9b4f979f7b1422f7cf003f3b7d7302d58b1f6b29 100644 (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);