]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: introduce network_verify_prefix() and network_verify_route_prefix()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 29 Sep 2020 21:01:09 +0000 (06:01 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 6 Oct 2020 17:44:42 +0000 (02:44 +0900)
src/network/networkd-network.c
src/network/networkd-radv.c
src/network/networkd-radv.h

index a89a8259a28f63071c7a8cb9d76fc79540bfd9a2..f77d1bae89c257295c0b1b7677e0a64d378cc007 100644 (file)
@@ -154,9 +154,7 @@ static int network_resolve_stacked_netdevs(Network *network) {
 }
 
 int network_verify(Network *network) {
-        RoutePrefix *route_prefix;
         Address *address, *address_next;
-        Prefix *prefix;
         Route *route, *route_next;
         TrafficControl *tc;
         SRIOV *sr_iov;
@@ -308,15 +306,8 @@ int network_verify(Network *network) {
         network_verify_mdb_entries(network);
         network_verify_neighbors(network);
         network_verify_address_labels(network);
-
-        HASHMAP_FOREACH(prefix, network->prefixes_by_section)
-                if (section_is_invalid(prefix->section))
-                        prefix_free(prefix);
-
-        HASHMAP_FOREACH(route_prefix, network->route_prefixes_by_section)
-                if (section_is_invalid(route_prefix->section))
-                        route_prefix_free(route_prefix);
-
+        network_verify_prefixes(network);
+        network_verify_route_prefixes(network);
         network_verify_routing_policy_rules(network);
 
         bool has_root = false, has_clsact = false;
index f5e1926afb7153c4a16385eff9fb552086266397..9762b3a5e7b9821b792df0147daf9c037dae3b3c 100644 (file)
@@ -162,6 +162,26 @@ static int route_prefix_new_static(Network *network, const char *filename,
         return 0;
 }
 
+void network_verify_prefixes(Network *network) {
+        Prefix *prefix;
+
+        assert(network);
+
+        HASHMAP_FOREACH(prefix, network->prefixes_by_section)
+                if (section_is_invalid(prefix->section))
+                        prefix_free(prefix);
+}
+
+void network_verify_route_prefixes(Network *network) {
+        RoutePrefix *prefix;
+
+        assert(network);
+
+        HASHMAP_FOREACH(prefix, network->route_prefixes_by_section)
+                if (section_is_invalid(prefix->section))
+                        route_prefix_free(prefix);
+}
+
 int config_parse_prefix(const char *unit,
                         const char *filename,
                         unsigned line,
index 6fe1c947bab11d9646a1b57bfb0aa2ad4a21dfdc..d549be5f8e68697156da4fbb17150e1ee9f846d4 100644 (file)
@@ -41,6 +41,9 @@ struct RoutePrefix {
 Prefix *prefix_free(Prefix *prefix);
 RoutePrefix *route_prefix_free(RoutePrefix *prefix);
 
+void network_verify_prefixes(Network *network);
+void network_verify_route_prefixes(Network *network);
+
 int radv_emit_dns(Link *link);
 int radv_configure(Link *link);
 int radv_add_prefix(Link *link, const struct in6_addr *prefix, uint8_t prefix_len,