[systemd-commits] 4 commits - src/libsystemd src/network

Lennart Poettering lennart at kemper.freedesktop.org
Fri Aug 15 06:43:55 PDT 2014


 src/libsystemd/sd-network/sd-network.c |    7 ++++---
 src/network/networkctl.c               |    6 +++++-
 src/network/networkd-link.c            |   24 ++++++++++++------------
 src/network/networkd-network.c         |   12 ++++++------
 4 files changed, 27 insertions(+), 22 deletions(-)

New commits:
commit d5314fff96221c1b32e4d7c21eba9798dab58764
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Aug 15 15:42:56 2014 +0200

    networkd: always write out locally configured settings first, dhcp-acquired ones later
    
    This is primarily important for the domains list, as we really should
    prefer the locally configured domain over the dhcp supplied ones when we
    use it as a search list.

diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 76e6427..a37561a 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1726,6 +1726,10 @@ int link_save(Link *link) {
 
                 fputs("DNS=", f);
 
+                STRV_FOREACH(address, link->network->dns)
+                        fprintf(f, "%s%s", *address,
+                                (address + 1 ? " " : ""));
+
                 if (link->network->dhcp_dns &&
                     link->dhcp_lease) {
                         const struct in_addr *addresses;
@@ -1738,14 +1742,14 @@ int link_save(Link *link) {
                         }
                 }
 
-                STRV_FOREACH(address, link->network->dns)
-                        fprintf(f, "%s%s", *address,
-                                (address + 1 ? " " : ""));
-
                 fputs("\n", f);
 
                 fprintf(f, "NTP=");
 
+                STRV_FOREACH(address, link->network->ntp)
+                        fprintf(f, "%s%s", *address,
+                                (address + 1 ? " " : ""));
+
                 if (link->network->dhcp_ntp &&
                     link->dhcp_lease) {
                         const struct in_addr *addresses;
@@ -1758,14 +1762,14 @@ int link_save(Link *link) {
                         }
                 }
 
-                STRV_FOREACH(address, link->network->ntp)
-                        fprintf(f, "%s%s", *address,
-                                (address + 1 ? " " : ""));
-
                 fputs("\n", f);
 
                 fprintf(f, "DOMAINS=");
 
+                STRV_FOREACH(domain, link->network->domains)
+                        fprintf(f, "%s%s", *domain,
+                                (domain + 1 ? " " : ""));
+
                 if (link->network->dhcp_domains &&
                     link->dhcp_lease) {
                         const char *domainname;
@@ -1778,10 +1782,6 @@ int link_save(Link *link) {
                         }
                 }
 
-                STRV_FOREACH(domain, link->network->domains)
-                        fprintf(f, "%s%s", *domain,
-                                (domain + 1 ? " " : ""));
-
                 fputs("\n", f);
 
                 fprintf(f, "WILDCARD_DOMAIN=%s\n",

commit f15b6e5a8b6e550c6df7f6ccc216d5c4cbe6a604
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Aug 15 15:36:17 2014 +0200

    networkd: remove "*" from domains list
    
    Also, simplify things a bit and make sure we don't forget looking at one
    of the entries.

diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index f3b2c68..6f0d1a1 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -362,16 +362,16 @@ int config_parse_domains(const char *unit,
                 return r;
 
         strv_uniq(*domains);
-
-        if (strv_isempty(*domains))
-                network->wildcard_domain = false;
-        else if (strv_find(*domains, "*"))
-                network->wildcard_domain = true;
+        network->wildcard_domain = !!strv_find(*domains, "*");
 
         STRV_FOREACH(domain, *domains)
-                if (is_localhost(*domain) || !hostname_is_valid(*domain))
+                if (is_localhost(*domain) || !hostname_is_valid(*domain) || streq(*domain, "*")) {
                         strv_remove(*domains, *domain);
 
+                        /* We removed one entry, make sure we don't skip the next one */
+                        domain--;
+                }
+
         return 0;
 }
 

commit 1405434b6986d3c3d6ccaaa2e472bad843cbbfa1
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Aug 15 15:34:56 2014 +0200

    networkctl: two OOM fixes

diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index bf95aa2..8f2c1b3 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -371,7 +371,11 @@ static int link_status_one(sd_rtnl *rtnl, struct udev *udev, const char *name) {
                 char *wildcard;
 
                 wildcard = strdup("*");
-                strv_push(&domains, wildcard);
+                if (!wildcard)
+                        return log_oom();
+
+                if (strv_consume(&domains, wildcard) < 0)
+                        return log_oom();
         }
 
         sprintf(devid, "n%i", ifindex);

commit 31d2e1961aa05f1204090792e2acc27103de5bfd
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Aug 15 15:34:33 2014 +0200

    sd-nework: be more careful with error codes, return ENODATA if you lack information

diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c
index e30fc3c..5d28af0 100644
--- a/src/libsystemd/sd-network/sd-network.c
+++ b/src/libsystemd/sd-network/sd-network.c
@@ -220,11 +220,12 @@ _public_ int sd_network_link_get_wildcard_domain(int ifindex) {
                 return -ENOMEM;
 
         r = parse_env_file(p, NEWLINE, "WILDCARD_DOMAIN", &s, NULL);
+        if (r == -ENOENT)
+                return -ENODATA;
         if (r < 0)
                 return r;
-
-        if (!s)
-                return -EIO;
+        if (isempty(s))
+                return -ENODATA;
 
         return parse_boolean(s);
 }



More information about the systemd-commits mailing list