network: introduce network_verify_nexthops()

This commit is contained in:
Yu Watanabe 2020-09-30 00:58:01 +09:00
parent f96f4ebc85
commit 0992f9fb0e
3 changed files with 14 additions and 6 deletions

View File

@ -153,7 +153,6 @@ int network_verify(Network *network) {
RoutePrefix *route_prefix, *route_prefix_next;
Neighbor *neighbor, *neighbor_next;
AddressLabel *label, *label_next;
NextHop *nexthop;
Address *address, *address_next;
Prefix *prefix, *prefix_next;
Route *route, *route_next;
@ -299,9 +298,7 @@ int network_verify(Network *network) {
if (route_section_verify(route, network) < 0)
route_free(route);
HASHMAP_FOREACH(nexthop, network->nexthops_by_section)
if (nexthop_section_verify(nexthop) < 0)
nexthop_free(nexthop);
network_verify_nexthops(network);
LIST_FOREACH_SAFE(static_fdb_entries, fdb, fdb_next, network->static_fdb_entries)
if (section_is_invalid(fdb->section))

View File

@ -439,7 +439,7 @@ int manager_rtnl_process_nexthop(sd_netlink *rtnl, sd_netlink_message *message,
return 1;
}
int nexthop_section_verify(NextHop *nh) {
static int nexthop_section_verify(NextHop *nh) {
if (section_is_invalid(nh->section))
return -EINVAL;
@ -449,6 +449,16 @@ int nexthop_section_verify(NextHop *nh) {
return 0;
}
void network_verify_nexthops(Network *network) {
NextHop *nh;
assert(network);
HASHMAP_FOREACH(nh, network->nexthops_by_section)
if (nexthop_section_verify(nh) < 0)
nexthop_free(nh);
}
int config_parse_nexthop_id(
const char *unit,
const char *filename,

View File

@ -30,7 +30,8 @@ typedef struct NextHop {
} NextHop;
NextHop *nexthop_free(NextHop *nexthop);
int nexthop_section_verify(NextHop *nexthop);
void network_verify_nexthops(Network *network);
int link_set_nexthop(Link *link);