]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: drop invalid [Neighbor] section earlier
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 10 Jul 2019 18:08:31 +0000 (03:08 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 11 Jul 2019 13:22:29 +0000 (22:22 +0900)
src/network/networkd-neighbor.c
src/network/networkd-neighbor.h
src/network/networkd-network.c

index 5eed80bc8a47a9d30ee218e3e197b877af9d4942..47839df13c1d328b0b72ea1c3bf3dc46b7f5feb5 100644 (file)
@@ -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,
index 59cd82ac11f2fb4391e3e43f8a52ae5186a61bbf..1405ac25e2f8ee151546fc3de327df8805dfcdb1 100644 (file)
@@ -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);
index 097938057bb210d9a8d7be1634010e6b6b258998..9d3c383378e6d59494c6770cedc3a3e6c8b3fe58 100644 (file)
@@ -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)