diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-24 02:31:00 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-27 03:42:31 +0200 |
commit | e05dd7718d0b32e039c9e0f7bf3875079d1a359d (patch) | |
tree | 31dd3087ce69e79f563d6d47343b827bf1241f11 /src | |
parent | sd-network: drop fallback values (diff) | |
download | systemd-e05dd7718d0b32e039c9e0f7bf3875079d1a359d.tar.xz systemd-e05dd7718d0b32e039c9e0f7bf3875079d1a359d.zip |
sd-network: make sd_network_link_get_dns() or friends return -ENODATA
To make them consistent with other functions.
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd/sd-network/sd-network.c | 18 | ||||
-rw-r--r-- | src/resolve/resolved-link.c | 2 | ||||
-rw-r--r-- | src/timesync/timesyncd-manager.c | 2 |
3 files changed, 6 insertions, 16 deletions
diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c index 4fd4c2502b..3d6b07f39f 100644 --- a/src/libsystemd/sd-network/sd-network.c +++ b/src/libsystemd/sd-network/sd-network.c @@ -68,10 +68,8 @@ static int network_get_strv(const char *key, char ***ret) { r = parse_env_file(NULL, "/run/systemd/netif/state", key, &s); if (r < 0) return r; - if (isempty(s)) { - *ret = NULL; - return 0; - } + if (isempty(s)) + return -ENODATA; a = strv_split(s, NULL); if (!a) @@ -132,7 +130,6 @@ static int network_link_get_boolean(int ifindex, const char *key) { } static int network_link_get_strv(int ifindex, const char *key, char ***ret) { - char path[STRLEN("/run/systemd/netif/links/") + DECIMAL_STR_MAX(ifindex)]; _cleanup_strv_free_ char **a = NULL; _cleanup_free_ char *s = NULL; int r; @@ -140,14 +137,9 @@ static int network_link_get_strv(int ifindex, const char *key, char ***ret) { assert_return(ifindex > 0, -EINVAL); assert_return(ret, -EINVAL); - xsprintf(path, "/run/systemd/netif/links/%i", ifindex); - r = parse_env_file(NULL, path, key, &s); + r = network_link_get_string(ifindex, key, &s); if (r < 0) return r; - if (isempty(s)) { - *ret = NULL; - return 0; - } a = strv_split(s, NULL); if (!a) @@ -261,7 +253,6 @@ int sd_network_link_get_dns_default_route(int ifindex) { } static int network_link_get_ifindexes(int ifindex, const char *key, int **ret) { - char path[STRLEN("/run/systemd/netif/links/") + DECIMAL_STR_MAX(ifindex)]; _cleanup_free_ int *ifis = NULL; _cleanup_free_ char *s = NULL; size_t c = 0; @@ -270,8 +261,7 @@ static int network_link_get_ifindexes(int ifindex, const char *key, int **ret) { assert_return(ifindex > 0, -EINVAL); assert_return(ret, -EINVAL); - xsprintf(path, "/run/systemd/netif/links/%i", ifindex); - r = parse_env_file(NULL, path, key, &s); + r = network_link_get_string(ifindex, key, &s); if (r < 0) return r; diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c index cd960e25b1..35b31a5317 100644 --- a/src/resolve/resolved-link.c +++ b/src/resolve/resolved-link.c @@ -469,7 +469,7 @@ static int link_update_dnssec_negative_trust_anchors(Link *l) { r = sd_network_link_get_dnssec_negative_trust_anchors(l->ifindex, &ntas); if (r == -ENODATA) - return r; + return 0; if (r < 0) return r; diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c index 49eb228318..e9fa00aaca 100644 --- a/src/timesync/timesyncd-manager.c +++ b/src/timesync/timesyncd-manager.c @@ -972,7 +972,7 @@ static int manager_network_read_link_servers(Manager *m) { if (r < 0) { if (r == -ENOMEM) log_oom(); - else + else if (r != -ENODATA) log_debug_errno(r, "Failed to get link NTP servers: %m"); goto clear; } |