summaryrefslogtreecommitdiff
path: root/src/network/networkd-link.c
diff options
context:
space:
mode:
authorTom Yan <tom.ty89@gmail.com>2016-06-01 14:54:46 +0800
committerTom Yan <tom.ty89@gmail.com>2016-06-01 14:54:46 +0800
commit720bec40e94a65d7a63a0091773b2bab2934ee41 (patch)
treecbe9b2feba5ca74afd85aedcf3e4d3abe1dfc952 /src/network/networkd-link.c
parente33a06a1eb7406ece8e35f6346ba0ea208c11cf1 (diff)
networkd-dhcp6: generalize DHCPv6 client (re)starting
dhcp6_request_address() was merely a function to switch the DHCPv6 client from "stateless" mode to "stateful" mode. It was also a one-way switch. Also, to (re)start the client, we would need to repeat separate function calls. In this patch, dhcp6_request_address() is made a general starter/manager of the DHCPv6 client. It now takes an extra parameter so we will be specifying which mode the DHCPv6 client should be started in. Also it will keep track of the current mode and compare with the newly requested mode, and only restart the client in case there is a difference between them. This also makes sure that the DHCPv6 client will be (re)started accordingly as per the Router Advertisement flags.
Diffstat (limited to 'src/network/networkd-link.c')
-rw-r--r--src/network/networkd-link.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 9ac0b47d77..ba4147f875 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1444,15 +1444,12 @@ static int link_acquire_ipv6_conf(Link *link) {
assert(link->dhcp6_client);
assert(in_addr_is_link_local(AF_INET6, (const union in_addr_union*)&link->ipv6ll_address) > 0);
- log_link_debug(link, "Acquiring DHCPv6 lease");
-
- r = sd_dhcp6_client_set_local_address(link->dhcp6_client, &link->ipv6ll_address);
- if (r < 0 && r != -EBUSY)
- return log_link_warning_errno(link, r, "Could not set IPv6LL address in DHCP client: %m");
-
- r = sd_dhcp6_client_start(link->dhcp6_client);
+ /* start DHCPv6 client in stateless mode */
+ r = dhcp6_request_address(link, true);
if (r < 0 && r != -EBUSY)
return log_link_warning_errno(link, r, "Could not acquire DHCPv6 lease: %m");
+ else
+ log_link_debug(link, "Acquiring DHCPv6 lease");
}
if (link_ipv6_accept_ra_enabled(link)) {