From 8d6eedd8a31db65420ab83f63643fdf095941bc8 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 19 Sep 2024 04:03:11 +0900 Subject: [PATCH] network/neighbor: use log_section_warning_errno() --- src/network/networkd-neighbor.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/network/networkd-neighbor.c b/src/network/networkd-neighbor.c index 9a03e12448..87af5e9e62 100644 --- a/src/network/networkd-neighbor.c +++ b/src/network/networkd-neighbor.c @@ -660,28 +660,28 @@ int manager_rtnl_process_neighbor(sd_netlink *rtnl, sd_netlink_message *message, return 1; } +#define log_neighbor_section(neighbor, fmt, ...) \ + ({ \ + const Neighbor *_neighbor = (neighbor); \ + log_section_warning_errno( \ + _neighbor ? _neighbor->section : NULL, \ + SYNTHETIC_ERRNO(EINVAL), \ + fmt " Ignoring [Neighbor] section.", \ + ##__VA_ARGS__); \ + }) + static int neighbor_section_verify(Neighbor *neighbor) { if (section_is_invalid(neighbor->section)) return -EINVAL; if (neighbor->dst_addr.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); + return log_neighbor_section(neighbor, "Neighbor section without Address= configured."); if (neighbor->dst_addr.family == AF_INET6 && !socket_ipv6_is_supported()) - return log_warning_errno(SYNTHETIC_ERRNO(EINVAL), - "%s: Neighbor section with an IPv6 destination address configured, " - "but the kernel does not support IPv6. " - "Ignoring [Neighbor] section from line %u.", - neighbor->section->filename, neighbor->section->line); + return log_neighbor_section(neighbor, "Neighbor section with an IPv6 destination address configured, but the kernel does not support IPv6."); if (neighbor->ll_addr.length == 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 log_neighbor_section(neighbor, "Neighbor section without LinkLayerAddress= configured."); return 0; } -- 2.25.1