diff --git a/src/network/networkd-neighbor.c b/src/network/networkd-neighbor.c index 5eed80bc8a4..47839df13c1 100644 --- a/src/network/networkd-neighbor.c +++ b/src/network/networkd-neighbor.c @@ -116,11 +116,6 @@ int neighbor_configure(Neighbor *neighbor, Link *link, link_netlink_message_hand assert(link->manager); assert(link->manager->rtnl); - if (neighbor->family == AF_UNSPEC) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Neighbor without Address= configured"); - if (neighbor->lladdr_type < 0) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Neighbor without LinkLayerAddress= configured"); - r = sd_rtnl_message_new_neigh(link->manager->rtnl, &req, RTM_NEWNEIGH, link->ifindex, neighbor->family); if (r < 0) @@ -156,6 +151,25 @@ int neighbor_configure(Neighbor *neighbor, Link *link, link_netlink_message_hand return 0; } +int neighbor_section_verify(Neighbor *neighbor) { + if (section_is_invalid(neighbor->section)) + return -EINVAL; + + if (neighbor->family == AF_UNSPEC) + return log_warning_errno(SYNTHETIC_ERRNO(EINVAL), + "%s: Neighbor section without Address= configured. " + "Ignoring [Neighbor] section from line %u.", + neighbor->section->filename, neighbor->section->line); + + if (neighbor->lladdr_type < 0) + return log_warning_errno(SYNTHETIC_ERRNO(EINVAL), + "%s: Neighbor section without LinkLayerAddress= configured. " + "Ignoring [Neighbor] section from line %u.", + neighbor->section->filename, neighbor->section->line); + + return 0; +} + 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 59cd82ac11f..1405ac25e2f 100644 --- a/src/network/networkd-neighbor.h +++ b/src/network/networkd-neighbor.h @@ -44,6 +44,8 @@ DEFINE_NETWORK_SECTION_FUNCTIONS(Neighbor, neighbor_free); int neighbor_configure(Neighbor *neighbor, Link *link, link_netlink_message_handler_t callback); +int neighbor_section_verify(Neighbor *neighbor); + CONFIG_PARSER_PROTOTYPE(config_parse_neighbor_address); CONFIG_PARSER_PROTOTYPE(config_parse_neighbor_hwaddr); CONFIG_PARSER_PROTOTYPE(config_parse_neighbor_lladdr); diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 097938057bb..9d3c383378e 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -269,7 +269,7 @@ int network_verify(Network *network) { fdb_entry_free(fdb); LIST_FOREACH_SAFE(neighbors, neighbor, neighbor_next, network->neighbors) - if (section_is_invalid(neighbor->section)) + if (neighbor_section_verify(neighbor) < 0) neighbor_free(neighbor); LIST_FOREACH_SAFE(labels, label, label_next, network->address_labels)