summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-07-10 20:08:31 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-07-11 15:22:29 +0200
commit044d4b4067052427033d35cc3fc5a0fa23cb4b71 (patch)
tree1a20e9c669c0a574eca5ad9b098dfea99c7a1ecc
parentnetwork: rename Neighbor.MACAddress= to Neighbor.LinkLayerAddress= (diff)
downloadsystemd-044d4b4067052427033d35cc3fc5a0fa23cb4b71.tar.xz
systemd-044d4b4067052427033d35cc3fc5a0fa23cb4b71.zip
network: drop invalid [Neighbor] section earlier
-rw-r--r--src/network/networkd-neighbor.c24
-rw-r--r--src/network/networkd-neighbor.h2
-rw-r--r--src/network/networkd-network.c2
3 files changed, 22 insertions, 6 deletions
diff --git a/src/network/networkd-neighbor.c b/src/network/networkd-neighbor.c
index 5eed80bc8a..47839df13c 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 59cd82ac11..1405ac25e2 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 097938057b..9d3c383378 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)