[systemd-commits] 2 commits - src/libsystemd-dhcp src/network

Tom Gundersen tomegun at kemper.freedesktop.org
Wed Feb 12 17:09:03 CET 2014


 src/libsystemd-dhcp/sd-dhcp-client.c |    2 +-
 src/network/networkd-manager.c       |   27 +++++++++++++++++++++------
 2 files changed, 22 insertions(+), 7 deletions(-)

New commits:
commit c6f7b693fedfd822febc219868fc810c32d458c5
Author: Tom Gundersen <teg at jklm.no>
Date:   Wed Feb 12 16:59:52 2014 +0100

    sd-dhcp: make sure client->secs > 0
    
    Some DHCP servers will not work correctly if secs == 0, so round up
    to at least 1.

diff --git a/src/libsystemd-dhcp/sd-dhcp-client.c b/src/libsystemd-dhcp/sd-dhcp-client.c
index 4f41b4c..3b4db1d 100644
--- a/src/libsystemd-dhcp/sd-dhcp-client.c
+++ b/src/libsystemd-dhcp/sd-dhcp-client.c
@@ -338,7 +338,7 @@ static int client_send_request(sd_dhcp_client *client, uint16_t secs) {
 
 static uint16_t client_update_secs(sd_dhcp_client *client, usec_t time_now)
 {
-        client->secs = (time_now - client->start_time) / USEC_PER_SEC;
+        client->secs = ((time_now - client->start_time) / USEC_PER_SEC) ? : 1;
 
         return client->secs;
 }

commit 60ad0c85e58ea8f546677c1d2e425551f7b96179
Author: Tom Gundersen <teg at jklm.no>
Date:   Wed Feb 12 16:40:24 2014 +0100

    networkd: work inside containers
    
    Udev does not run in containers, so instead of relying on it to tell us when a
    network device is ready to be used by networkd, we simply assume that any
    device was fully initialized before being added to the container.

diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index fb3360d..54e83e3 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -27,6 +27,7 @@
 #include "udev-util.h"
 #include "rtnl-util.h"
 #include "mkdir.h"
+#include "virt.h"
 
 const char* const network_dirs[] = {
         "/etc/systemd/network",
@@ -63,9 +64,18 @@ int manager_new(Manager **ret) {
         if (!m->udev)
                 return -ENOMEM;
 
-        m->udev_monitor = udev_monitor_new_from_netlink(m->udev, "udev");
-        if (!m->udev_monitor)
-                return -ENOMEM;
+        /* udev does not initialize devices inside containers,
+         * so we rely on them being already initialized before
+         * entering the container */
+        if (detect_container(NULL) > 0) {
+                m->udev_monitor = udev_monitor_new_from_netlink(m->udev, "kernel");
+                if (!m->udev_monitor)
+                        return -ENOMEM;
+        } else {
+                m->udev_monitor = udev_monitor_new_from_netlink(m->udev, "udev");
+                if (!m->udev_monitor)
+                        return -ENOMEM;
+        }
 
         m->links = hashmap_new(uint64_hash_func, uint64_compare_func);
         if (!m->links)
@@ -179,9 +189,14 @@ int manager_udev_enumerate_links(Manager *m) {
         if (r < 0)
                 return r;
 
-        r = udev_enumerate_add_match_is_initialized(e);
-        if (r < 0)
-                return r;
+        /* udev does not initialize devices inside containers,
+         * so we rely on them being already initialized before
+         * entering the container */
+        if (detect_container(NULL) <= 0) {
+                r = udev_enumerate_add_match_is_initialized(e);
+                if (r < 0)
+                        return r;
+        }
 
         r = udev_enumerate_scan_devices(e);
         if (r < 0)



More information about the systemd-commits mailing list