diff options
author | Ronan Pigott <ronan@rjp.ie> | 2024-11-05 00:12:00 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-11-05 21:01:55 +0100 |
commit | 57feaaece38a9e8e6a362a8b50ff94e4edca61ea (patch) | |
tree | 2b735d9077ccf6ec67513c7398052acd732f13b8 /src/network/networkd-json.c | |
parent | tree-wide: time-out → timeout (diff) | |
download | systemd-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/networkd-json.c')
-rw-r--r-- | src/network/networkd-json.c | 44 |
1 files changed, 20 insertions, 24 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)) { |