]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-network: make sd_network_link_get_dns() or friends return -ENODATA 24805/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 24 Sep 2022 00:31:00 +0000 (09:31 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 27 Sep 2022 01:42:31 +0000 (10:42 +0900)
To make them consistent with other functions.

src/libsystemd/sd-network/sd-network.c
src/resolve/resolved-link.c
src/timesync/timesyncd-manager.c

index 4fd4c2502b6db7ec5ebe76cebcf41c44a43e1404..3d6b07f39f038db7405334700d615f8f6b0c4f54 100644 (file)
@@ -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;
 
index cd960e25b1d5a3ca0e8040d3614418e5d3eaa4cb..35b31a5317ed2e947fd151647625f65da35757d6 100644 (file)
@@ -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;
 
index 49eb2283185f510368f9747a89d3e431b22eda13..e9fa00aacab8c180ef0fe220ef6241e51af6f948 100644 (file)
@@ -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;
         }