diff options
author | Tom Gundersen <teg@jklm.no> | 2015-11-10 15:43:52 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-11-11 15:42:38 +0100 |
commit | 7a695d8e1fda59857c4c23bcb50cd1e0aaf4a854 (patch) | |
tree | 996633b296c8ecd09018c3d1c346d5b721a72562 /src/network/networkd-ndisc.c | |
parent | 9d96e6c3efbe5ef52b2855612d51db52c469beb2 (diff) |
networkd: dhcp6 - split up configure() method
Enabling address acquisition, configuring the client and starting the client are now
split out. This to better handle the client being repeatedly enabled due to router
advertisements.
Diffstat (limited to 'src/network/networkd-ndisc.c')
-rw-r--r-- | src/network/networkd-ndisc.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index dfbc5a866e..bd5a5d675c 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -29,6 +29,7 @@ static void ndisc_router_handler(sd_ndisc *nd, uint8_t flags, const struct in6_addr *gateway, unsigned lifetime, int pref, void *userdata) { Link *link = userdata; + int r; assert(link); assert(link->network); @@ -36,14 +37,19 @@ static void ndisc_router_handler(sd_ndisc *nd, uint8_t flags, const struct in6_a if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER)) return; - if (flags & ND_RA_FLAG_MANAGED) - dhcp6_configure(link, false); - else if (flags & ND_RA_FLAG_OTHER) - dhcp6_configure(link, true); + if (flags & (ND_RA_FLAG_MANAGED | ND_RA_FLAG_OTHER)) { + if (flags & ND_RA_FLAG_MANAGED) + dhcp6_request_address(link); + + r = sd_dhcp6_client_start(link->dhcp6_client); + if (r < 0 && r != -EBUSY) + log_link_warning_errno(link, r, "Starting DHCPv6 client on NDisc request failed: %m"); + } } static void ndisc_handler(sd_ndisc *nd, int event, void *userdata) { Link *link = userdata; + int r; assert(link); @@ -52,7 +58,11 @@ static void ndisc_handler(sd_ndisc *nd, int event, void *userdata) { switch (event) { case SD_NDISC_EVENT_TIMEOUT: - dhcp6_configure(link, false); + dhcp6_request_address(link); + + r = sd_dhcp6_client_start(link->dhcp6_client); + if (r < 0 && r != -EBUSY) + log_link_warning_errno(link, r, "Starting DHCPv6 client after NDisc timeout failed: %m"); break; case SD_NDISC_EVENT_STOP: break; |