summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2020-09-29 17:43:06 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2020-10-06 19:44:42 +0200
commit78ada14f257991635d2cba68e1232cda0f4617e2 (patch)
tree5e384f62a7dc3c6a3b218860460d137f1b78eba3 /src
parentnetwork: introduce neighbor_drop_{,foreign_}neighbors() (diff)
downloadsystemd-78ada14f257991635d2cba68e1232cda0f4617e2.tar.xz
systemd-78ada14f257991635d2cba68e1232cda0f4617e2.zip
network: introduce network_verify_neighbors()
Diffstat (limited to 'src')
-rw-r--r--src/network/networkd-neighbor.c13
-rw-r--r--src/network/networkd-neighbor.h3
-rw-r--r--src/network/networkd-network.c5
3 files changed, 15 insertions, 6 deletions
diff --git a/src/network/networkd-neighbor.c b/src/network/networkd-neighbor.c
index 5135ed6422..908fc1c11c 100644
--- a/src/network/networkd-neighbor.c
+++ b/src/network/networkd-neighbor.c
@@ -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,
diff --git a/src/network/networkd-neighbor.h b/src/network/networkd-neighbor.h
index a0e3fbd47a..0c3dfc8303 100644
--- a/src/network/networkd-neighbor.h
+++ b/src/network/networkd-neighbor.h
@@ -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);
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index f0fd3ad3e9..0591b23e09 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -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))