summaryrefslogtreecommitdiffstats
path: root/src/network
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
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 'src/network')
-rw-r--r--src/network/networkd-json.c44
-rw-r--r--src/network/networkd-state-file.c32
2 files changed, 38 insertions, 38 deletions
diff --git a/src/network/networkd-json.c b/src/network/networkd-json.c
index 07d52c96c0..fd2b709d9d 100644
--- a/src/network/networkd-json.c
+++ b/src/network/networkd-json.c
@@ -561,18 +561,16 @@ static int dnr_append_json(Link *link, sd_json_variant **v) {
return r;
n_dnr = sd_dhcp_lease_get_dnr(link->dhcp_lease, &dnr);
- if (n_dnr < 0)
- return 0;
-
- FOREACH_ARRAY(res, dnr, n_dnr) {
- r = dnr_append_json_one(link,
- res,
- NETWORK_CONFIG_SOURCE_DHCP4,
- &s,
- &array);
- if (r < 0)
- return r;
- }
+ if (n_dnr > 0)
+ FOREACH_ARRAY(res, dnr, n_dnr) {
+ r = dnr_append_json_one(link,
+ res,
+ NETWORK_CONFIG_SOURCE_DHCP4,
+ &s,
+ &array);
+ if (r < 0)
+ return r;
+ }
}
if (link->dhcp6_lease && link_get_use_dnr(link, NETWORK_CONFIG_SOURCE_DHCP6)) {
@@ -585,18 +583,16 @@ static int dnr_append_json(Link *link, sd_json_variant **v) {
return r;
n_dnr = sd_dhcp6_lease_get_dnr(link->dhcp6_lease, &dnr);
- if (n_dnr < 0)
- return 0;
-
- FOREACH_ARRAY(res, dnr, n_dnr) {
- r = dnr_append_json_one(link,
- res,
- NETWORK_CONFIG_SOURCE_DHCP6,
- &s,
- &array);
- if (r < 0)
- return r;
- }
+ if (n_dnr > 0)
+ FOREACH_ARRAY(res, dnr, n_dnr) {
+ r = dnr_append_json_one(link,
+ res,
+ NETWORK_CONFIG_SOURCE_DHCP6,
+ &s,
+ &array);
+ if (r < 0)
+ return r;
+ }
}
if (link_get_use_dnr(link, NETWORK_CONFIG_SOURCE_NDISC)) {
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)