1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 02:21:44 +03:00

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; RoutePrefix *route_prefix, *route_prefix_next;
Neighbor *neighbor, *neighbor_next; Neighbor *neighbor, *neighbor_next;
AddressLabel *label, *label_next; AddressLabel *label, *label_next;
NextHop *nexthop;
Address *address, *address_next; Address *address, *address_next;
Prefix *prefix, *prefix_next; Prefix *prefix, *prefix_next;
Route *route, *route_next; Route *route, *route_next;
@ -299,9 +298,7 @@ int network_verify(Network *network) {
if (route_section_verify(route, network) < 0) if (route_section_verify(route, network) < 0)
route_free(route); route_free(route);
HASHMAP_FOREACH(nexthop, network->nexthops_by_section) network_verify_nexthops(network);
if (nexthop_section_verify(nexthop) < 0)
nexthop_free(nexthop);
LIST_FOREACH_SAFE(static_fdb_entries, fdb, fdb_next, network->static_fdb_entries) LIST_FOREACH_SAFE(static_fdb_entries, fdb, fdb_next, network->static_fdb_entries)
if (section_is_invalid(fdb->section)) 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; return 1;
} }
int nexthop_section_verify(NextHop *nh) { static int nexthop_section_verify(NextHop *nh) {
if (section_is_invalid(nh->section)) if (section_is_invalid(nh->section))
return -EINVAL; return -EINVAL;
@ -449,6 +449,16 @@ int nexthop_section_verify(NextHop *nh) {
return 0; 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( int config_parse_nexthop_id(
const char *unit, const char *unit,
const char *filename, const char *filename,

View File

@ -30,7 +30,8 @@ typedef struct NextHop {
} NextHop; } NextHop;
NextHop *nexthop_free(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); int link_set_nexthop(Link *link);