chiark / gitweb /
sd-rtnl: make string returned by sd_rtnl_message_read_string() const
[elogind.git] / src / network / networkd-link.c
index ccf818115b3192313628c204ceabfcbf7783fc08..7a0f30bdf51b68837097760acbca61ecdf06d85a 100644 (file)
@@ -24,6 +24,7 @@
 #include <unistd.h>
 
 #include "networkd.h"
+#include "networkd-netdev.h"
 #include "libudev-private.h"
 #include "udev-util.h"
 #include "util.h"
@@ -41,7 +42,7 @@ static bool ipv4ll_is_bound(sd_ipv4ll *ll);
 static int link_new(Manager *manager, sd_rtnl_message *message, Link **ret) {
         _cleanup_link_unref_ Link *link = NULL;
         uint16_t type;
-        char *ifname;
+        const char *ifname;
         int r, ifindex;
 
         assert(manager);
@@ -400,20 +401,18 @@ static int route_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
 
 static int link_set_dhcp_routes(Link *link) {
         struct sd_dhcp_route *static_routes;
-        size_t static_routes_size;
-        int r;
-        unsigned i;
+        int r, n, i;
 
         assert(link);
 
-        r = sd_dhcp_lease_get_routes(link->dhcp_lease, &static_routes, &static_routes_size);
-        if (r < 0) {
-                if (r != -ENOENT)
-                        log_warning_link(link, "DHCP error: could not get routes: %s", strerror(-r));
-                return r;
+        n = sd_dhcp_lease_get_routes(link->dhcp_lease, &static_routes);
+        if (n < 0) {
+                if (n != -ENOENT)
+                        log_warning_link(link, "DHCP error: could not get routes: %s", strerror(-n));
+                return n;
         }
 
-        for (i = 0; i < static_routes_size; i++) {
+        for (i = 0; i < n; i++) {
                 _cleanup_route_free_ Route *route = NULL;
 
                 r = route_new_dynamic(&route);
@@ -954,7 +953,6 @@ static int dhcp_lease_lost(Link *link) {
         struct in_addr netmask;
         struct in_addr gateway;
         unsigned prefixlen;
-        unsigned i;
         int r;
 
         assert(link);
@@ -964,11 +962,11 @@ static int dhcp_lease_lost(Link *link) {
 
         if (link->network->dhcp_routes) {
                 struct sd_dhcp_route *routes;
-                size_t routes_size;
+                int n, i;
 
-                r = sd_dhcp_lease_get_routes(link->dhcp_lease, &routes, &routes_size);
-                if (r >= 0) {
-                        for (i = 0; i < routes_size; i++) {
+                n = sd_dhcp_lease_get_routes(link->dhcp_lease, &routes);
+                if (n >= 0) {
+                        for (i = 0; i < n; i++) {
                                 _cleanup_route_free_ Route *route = NULL;
 
                                 r = route_new_dynamic(&route);
@@ -1997,6 +1995,10 @@ static int link_configure(Link *link) {
                 if (r < 0)
                         return r;
 
+                r = sd_dhcp_client_set_request_broadcast(link->dhcp_client, link->network->dhcp_broadcast);
+                if (r < 0)
+                        return r;
+
                 if (link->network->dhcp_mtu) {
                         r = sd_dhcp_client_set_request_option(link->dhcp_client, 26);
                         if (r < 0)
@@ -2121,6 +2123,9 @@ int link_initialized(Link *link, struct udev_device *device) {
         if (link->state != LINK_STATE_INITIALIZING)
                 return 0;
 
+        if (link->udev_device)
+                return 0;
+
         log_debug_link(link, "udev initialized link");
 
         link->udev_device = udev_device_ref(device);
@@ -2332,7 +2337,7 @@ int link_add(Manager *m, sd_rtnl_message *message, Link **ret) {
 
 int link_update(Link *link, sd_rtnl_message *m) {
         struct ether_addr mac;
-        char *ifname;
+        const char *ifname;
         int r;
 
         assert(link);
@@ -2501,9 +2506,8 @@ int link_save(Link *link) {
         fprintf(f,
                 "# This is private data. Do not parse.\n"
                 "ADMIN_STATE=%s\n"
-                "OPER_STATE=%s\n"
-                "FLAGS=%u\n",
-                admin_state, oper_state, link->flags);
+                "OPER_STATE=%s\n",
+                admin_state, oper_state);
 
         if (link->network) {
                 serialize_addresses(f, "DNS", link->network->dns);