summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-07-07 04:30:27 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-07-07 12:11:33 +0200
commit9a45125ae7810ff1d3f2927538c510fe70148f63 (patch)
treeae5ab701baa38dde2c6c1e77241c92ce2af84dd9 /src
parentman/systemd.unit: document restart behavior on Upholds= (diff)
downloadsystemd-9a45125ae7810ff1d3f2927538c510fe70148f63.tar.xz
systemd-9a45125ae7810ff1d3f2927538c510fe70148f63.zip
network: split-out address_section_adjust_broadcast()
No functional change, just refactoring.
Diffstat (limited to 'src')
-rw-r--r--src/network/networkd-address.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c
index 57a9ceb229..d393d3374b 100644
--- a/src/network/networkd-address.c
+++ b/src/network/networkd-address.c
@@ -2072,6 +2072,32 @@ int config_parse_address_netlabel(
return 0;
}
+static void address_section_adjust_broadcast(Address *address) {
+ assert(address);
+ assert(address->section);
+
+ if (!in4_addr_is_set(&address->broadcast))
+ return;
+
+ if (address->family == AF_INET6)
+ log_warning("%s: broadcast address is set for an IPv6 address. "
+ "Ignoring Broadcast= setting in the [Address] section from line %u.",
+ address->section->filename, address->section->line);
+ else if (address->prefixlen > 30)
+ log_warning("%s: broadcast address is set for an IPv4 address with prefix length larger than 30. "
+ "Ignoring Broadcast= setting in the [Address] section from line %u.",
+ address->section->filename, address->section->line);
+ else if (in4_addr_is_set(&address->in_addr_peer.in))
+ log_warning("%s: broadcast address is set for an IPv4 address with peer address. "
+ "Ignoring Broadcast= setting in the [Address] section from line %u.",
+ address->section->filename, address->section->line);
+ else
+ /* Otherwise, keep the specified broadcast address. */
+ return;
+
+ address->broadcast.s_addr = 0;
+}
+
static int address_section_verify(Address *address) {
if (section_is_invalid(address->section))
return -EINVAL;
@@ -2087,16 +2113,7 @@ static int address_section_verify(Address *address) {
assert(IN_SET(address->family, AF_INET, AF_INET6));
- if (in4_addr_is_set(&address->broadcast) &&
- (address->family == AF_INET6 || address->prefixlen > 30 ||
- in_addr_is_set(address->family, &address->in_addr_peer))) {
- log_warning("%s: broadcast address is set for an IPv6 address, "
- "an IPv4 address with peer address, or with prefix length larger than 30. "
- "Ignoring Broadcast= setting in the [Address] section from line %u.",
- address->section->filename, address->section->line);
-
- address->broadcast.s_addr = 0;
- }
+ address_section_adjust_broadcast(address);
if (address->family == AF_INET6 && address->label) {
log_warning("%s: address label is set for IPv6 address in the [Address] section from line %u. "