chiark / gitweb /
sd-rtnl: link - allow setting the change mask
[elogind.git] / src / network / networkd-link.c
index 7f692d1f9b9323ef9697e7215540d7d321df139b..2fa77f15ffb961665744b56e83fa3d562276482c 100644 (file)
@@ -325,11 +325,15 @@ static int set_hostname(sd_bus *bus, const char *hostname) {
         _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
         int r = 0;
 
-        assert(bus);
         assert(hostname);
 
         log_debug("Setting transient hostname: '%s'", hostname);
 
+        if (!bus) { /* TODO: replace by assert when we can rely on kdbus */
+                log_info("Not connected to system bus, ignoring transient hostname.");
+                return 0;
+        }
+
         r = sd_bus_message_new_method_call(
                         bus,
                         "org.freedesktop.hostname1",
@@ -584,9 +588,13 @@ static int link_acquire_conf(Link *link) {
         assert(link->manager->event);
 
         if (!link->dhcp) {
-                link->dhcp = sd_dhcp_client_new(link->manager->event);
-                if (!link->dhcp)
-                        return -ENOMEM;
+                r = sd_dhcp_client_new(&link->dhcp);
+                if (r < 0)
+                        return r;
+
+                r = sd_dhcp_client_attach_event(link->dhcp, NULL, 0);
+                if (r < 0)
+                        return r;
 
                 r = sd_dhcp_client_set_index(link->dhcp, link->ifindex);
                 if (r < 0)
@@ -632,7 +640,7 @@ static int link_update_flags(Link *link, unsigned flags) {
 
         if ((link->flags & IFF_UP) != (flags & IFF_UP))
                 log_info_link(link,
-                              "power %s", flags & IFF_UP ? "on": "off");
+                              "link is %s", flags & IFF_UP ? "up": "down");
 
         if ((link->flags & IFF_LOWER_UP) != (flags & IFF_LOWER_UP)) {
                 if (flags & IFF_LOWER_UP) {
@@ -705,7 +713,7 @@ static int link_up(Link *link) {
                 return r;
         }
 
-        r = sd_rtnl_message_link_set_flags(req, IFF_UP);
+        r = sd_rtnl_message_link_set_flags(req, IFF_UP, IFF_UP);
         if (r < 0) {
                 log_error_link(link, "Could not set link flags: %s", strerror(-r));
                 return r;