]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: introduce network_verify_neighbors()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 29 Sep 2020 15:43:06 +0000 (00:43 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 6 Oct 2020 17:44:42 +0000 (02:44 +0900)
src/network/networkd-neighbor.c
src/network/networkd-neighbor.h
src/network/networkd-network.c

index 5135ed64226afd8b8fdc1918d66af6fb715dee1c..908fc1c11c2c2953d86f20028e78b4437ef39941 100644 (file)
@@ -572,7 +572,7 @@ int manager_rtnl_process_neighbor(sd_netlink *rtnl, sd_netlink_message *message,
         return 1;
 }
 
-int neighbor_section_verify(Neighbor *neighbor) {
+static int neighbor_section_verify(Neighbor *neighbor) {
         if (section_is_invalid(neighbor->section))
                 return -EINVAL;
 
@@ -591,6 +591,17 @@ int neighbor_section_verify(Neighbor *neighbor) {
         return 0;
 }
 
+void network_verify_neighbors(Network *network) {
+        Neighbor *neighbor;
+
+        assert(network);
+
+        HASHMAP_FOREACH(neighbor, network->neighbors_by_section)
+                if (neighbor_section_verify(neighbor) < 0)
+                        neighbor_free(neighbor);
+}
+
+
 int config_parse_neighbor_address(
                 const char *unit,
                 const char *filename,
index a0e3fbd47a938befac2145aa132111cd30faac50..0c3dfc830310cc5ff1ab932f3d84ec687114fecd 100644 (file)
@@ -31,7 +31,8 @@ typedef struct Neighbor {
 } Neighbor;
 
 void neighbor_free(Neighbor *neighbor);
-int neighbor_section_verify(Neighbor *neighbor);
+
+void network_verify_neighbors(Network *network);
 
 int link_set_neighbors(Link *link);
 int link_drop_neighbors(Link *link);
index f0fd3ad3e910e431fc9ffd06ad5ee960c668adb0..0591b23e0926e5cbb940c39d5650bd714a597004 100644 (file)
@@ -152,7 +152,6 @@ static int network_resolve_stacked_netdevs(Network *network) {
 
 int network_verify(Network *network) {
         RoutePrefix *route_prefix, *route_prefix_next;
-        Neighbor *neighbor;
         AddressLabel *label, *label_next;
         Address *address, *address_next;
         Prefix *prefix, *prefix_next;
@@ -309,9 +308,7 @@ int network_verify(Network *network) {
                 if (mdb_entry_verify(mdb) < 0)
                         mdb_entry_free(mdb);
 
-        HASHMAP_FOREACH(neighbor, network->neighbors_by_section)
-                if (neighbor_section_verify(neighbor) < 0)
-                        neighbor_free(neighbor);
+        network_verify_neighbors(network);
 
         LIST_FOREACH_SAFE(labels, label, label_next, network->address_labels)
                 if (section_is_invalid(label->section))