summaryrefslogtreecommitdiffstats
path: root/src/network/networkd-state-file.c
diff options
context:
space:
mode:
authorRonan Pigott <ronan@rjp.ie>2024-11-05 00:12:00 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-11-05 21:01:55 +0100
commit57feaaece38a9e8e6a362a8b50ff94e4edca61ea (patch)
tree2b735d9077ccf6ec67513c7398052acd732f13b8 /src/network/networkd-state-file.c
parenttree-wide: time-out → timeout (diff)
downloadsystemd-57feaaece38a9e8e6a362a8b50ff94e4edca61ea.tar.xz
systemd-57feaaece38a9e8e6a362a8b50ff94e4edca61ea.zip
network: handle ENODATA better with DNR
It is normal for DHCP leases not to have DNR options. We need to be less verbose and more forgiving in these cases. Also, if either DHCP does not have DNR options, make sure to still consider any DHCPv6/RA options. Fixes: c7c9e3c7c016 (network: adjust log message about DNR)
Diffstat (limited to '')
-rw-r--r--src/network/networkd-state-file.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/network/networkd-state-file.c b/src/network/networkd-state-file.c
index 0c9e530128..da917dd897 100644
--- a/src/network/networkd-state-file.c
+++ b/src/network/networkd-state-file.c
@@ -600,14 +600,16 @@ static void serialize_resolvers(
int r;
r = sd_dhcp_lease_get_dnr(lease, &resolvers);
- if (r < 0)
- return (void) log_debug_errno(r, "Failed to get DNR from DHCP lease, ignoring: %m");
+ if (r < 0 && r != -ENODATA)
+ log_warning_errno(r, "Failed to get DNR from DHCP lease, ignoring: %m");
- r = dns_resolvers_to_dot_strv(resolvers, r, &names);
- if (r < 0)
- return (void) log_warning_errno(r, "Failed to get DoT servers from DHCP DNR, ignoring: %m");
- if (r > 0)
- fputstrv(f, names, NULL, space);
+ if (r > 0) {
+ r = dns_resolvers_to_dot_strv(resolvers, r, &names);
+ if (r < 0)
+ return (void) log_warning_errno(r, "Failed to get DoT servers from DHCP DNR, ignoring: %m");
+ if (r > 0)
+ fputstrv(f, names, NULL, space);
+ }
}
if (lease6 && conditional6) {
@@ -616,14 +618,16 @@ static void serialize_resolvers(
int r;
r = sd_dhcp6_lease_get_dnr(lease6, &resolvers);
- if (r < 0)
- return (void) log_debug_errno(r, "Failed to get DNR from DHCPv6 lease, ignoring: %m");
+ if (r < 0 && r != -ENODATA)
+ log_warning_errno(r, "Failed to get DNR from DHCPv6 lease, ignoring: %m");
- r = dns_resolvers_to_dot_strv(resolvers, r, &names);
- if (r < 0)
- return (void) log_warning_errno(r, "Failed to get DoT servers from DHCPv6 DNR, ignoring: %m");
- if (r > 0)
- fputstrv(f, names, NULL, space);
+ if (r > 0) {
+ r = dns_resolvers_to_dot_strv(resolvers, r, &names);
+ if (r < 0)
+ return (void) log_warning_errno(r, "Failed to get DoT servers from DHCPv6 DNR, ignoring: %m");
+ if (r > 0)
+ fputstrv(f, names, NULL, space);
+ }
}
if (lvalue)