diff options
author | Tom Gundersen <teg@jklm.no> | 2014-03-20 19:57:19 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-03-20 20:18:15 +0100 |
commit | eb34d4af3fd2ddfaa4bdb591a1549d203e2d8ac8 (patch) | |
tree | 5c25c58f4e30122da20112e3de651a581d6fdb90 | |
parent | c49b33aca6fd6a66e2bc43dad4a12701b7df8472 (diff) |
networkd: link - create dhcp and ipv4ll eagerly
Make sure the client objects exist for the lifetime of the Link.
-rw-r--r-- | src/network/networkd-link.c | 92 |
1 files changed, 44 insertions, 48 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index e60ba9d61b..a7ba46692c 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -883,27 +883,7 @@ static int link_acquire_conf(Link *link) { assert(link->manager->event); if (link->network->ipv4ll) { - if (!link->ipv4ll) { - r = sd_ipv4ll_new(&link->ipv4ll); - if (r < 0) - return r; - - r = sd_ipv4ll_attach_event(link->ipv4ll, NULL, 0); - if (r < 0) - return r; - - r = sd_ipv4ll_set_index(link->ipv4ll, link->ifindex); - if (r < 0) - return r; - - r = sd_ipv4ll_set_mac(link->ipv4ll, &link->mac); - if (r < 0) - return r; - - r = sd_ipv4ll_set_callback(link->ipv4ll, ipv4ll_handler, link); - if (r < 0) - return r; - } + assert(link->ipv4ll); log_debug_link(link, "acquiring IPv4 link-local address"); @@ -913,33 +893,7 @@ static int link_acquire_conf(Link *link) { } if (link->network->dhcp) { - if (!link->dhcp_client) { - r = sd_dhcp_client_new(&link->dhcp_client); - if (r < 0) - return r; - - r = sd_dhcp_client_attach_event(link->dhcp_client, NULL, 0); - if (r < 0) - return r; - - r = sd_dhcp_client_set_index(link->dhcp_client, link->ifindex); - if (r < 0) - return r; - - r = sd_dhcp_client_set_mac(link->dhcp_client, &link->mac); - if (r < 0) - return r; - - r = sd_dhcp_client_set_callback(link->dhcp_client, dhcp_handler, link); - if (r < 0) - return r; - - if (link->network->dhcp_mtu) { - r = sd_dhcp_client_set_request_option(link->dhcp_client, 26); - if (r < 0) - return r; - } - } + assert(link->dhcp_client); log_debug_link(link, "acquiring DHCPv4 lease"); @@ -1303,6 +1257,48 @@ int link_add(Manager *m, struct udev_device *device, Link **ret) { if (r < 0) return r; + if (link->network->ipv4ll) { + r = sd_ipv4ll_new(&link->ipv4ll); + if (r < 0) + return r; + + r = sd_ipv4ll_attach_event(link->ipv4ll, NULL, 0); + if (r < 0) + return r; + + r = sd_ipv4ll_set_index(link->ipv4ll, link->ifindex); + if (r < 0) + return r; + + r = sd_ipv4ll_set_callback(link->ipv4ll, ipv4ll_handler, link); + if (r < 0) + return r; + } + + if (link->network->dhcp) { + r = sd_dhcp_client_new(&link->dhcp_client); + if (r < 0) + return r; + + r = sd_dhcp_client_attach_event(link->dhcp_client, NULL, 0); + if (r < 0) + return r; + + r = sd_dhcp_client_set_index(link->dhcp_client, link->ifindex); + if (r < 0) + return r; + + r = sd_dhcp_client_set_callback(link->dhcp_client, dhcp_handler, link); + if (r < 0) + return r; + + if (link->network->dhcp_mtu) { + r = sd_dhcp_client_set_request_option(link->dhcp_client, 26); + if (r < 0) + return r; + } + } + r = link_configure(link); if (r < 0) return r; |