X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fnetwork%2Fnetworkd-link.c;h=94683a54036b729eecfaca95986051a3a3e7aeb1;hp=ccf818115b3192313628c204ceabfcbf7783fc08;hb=a2ba62c719224a4b47751623ca5e8b0333f49721;hpb=3f2650377631aed3bc26fdbc3a2eef6e33cdf7e7 diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index ccf818115..94683a540 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -24,6 +24,7 @@ #include #include "networkd.h" +#include "networkd-netdev.h" #include "libudev-private.h" #include "udev-util.h" #include "util.h" @@ -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);