summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/network')
-rw-r--r--src/network/networkd-dhcp6.c98
-rw-r--r--src/network/networkd-link.c3
-rw-r--r--src/network/networkd-link.h1
3 files changed, 55 insertions, 47 deletions
diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c
index fca73b3154..13105c7865 100644
--- a/src/network/networkd-dhcp6.c
+++ b/src/network/networkd-dhcp6.c
@@ -147,7 +147,9 @@ static void dhcp6_handler(sd_dhcp6_client *client, int event, void *userdata) {
case SD_DHCP6_CLIENT_EVENT_STOP:
case SD_DHCP6_CLIENT_EVENT_RESEND_EXPIRE:
case SD_DHCP6_CLIENT_EVENT_RETRANS_MAX:
- log_link_debug(link, "DHCPv6 event %d", event);
+ log_link_warning(link, "DHCPv6 lease lost");
+
+ link->dhcp6_configured = false;
break;
case SD_DHCP6_CLIENT_EVENT_IP_ACQUIRE:
@@ -165,6 +167,7 @@ static void dhcp6_handler(sd_dhcp6_client *client, int event, void *userdata) {
return;
}
+ link->dhcp6_configured = true;
break;
default:
@@ -176,6 +179,8 @@ static void dhcp6_handler(sd_dhcp6_client *client, int event, void *userdata) {
event);
return;
}
+
+ link_client_handler(link);
}
static int dhcp6_configure(Link *link, int event) {
@@ -183,91 +188,90 @@ static int dhcp6_configure(Link *link, int event) {
bool information_request;
assert_return(link, -EINVAL);
+ assert_return(IN_SET(event, SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_TIMEOUT,
+ SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_OTHER,
+ SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_MANAGED), -EINVAL);
- if (link->dhcp6_client) {
- if (event != SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_MANAGED)
- return 0;
+ link->dhcp6_configured = false;
+ if (link->dhcp6_client) {
r = sd_dhcp6_client_get_information_request(link->dhcp6_client,
&information_request);
if (r < 0) {
log_link_warning(link, "Could not get DHCPv6 Information request setting: %s",
- strerror(-r));
- link->dhcp6_client =
- sd_dhcp6_client_unref(link->dhcp6_client);
- return r;
+ strerror(-r));
+ goto error;
}
- if (!information_request)
- return r;
+ if (information_request && event != SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_OTHER) {
+ r = sd_dhcp6_client_stop(link->dhcp6_client);
+ if (r < 0) {
+ log_link_warning(link, "Could not stop DHCPv6 while setting Managed mode %s",
+ strerror(-r));
+ goto error;
+ }
+
+ r = sd_dhcp6_client_set_information_request(link->dhcp6_client,
+ false);
+ if (r < 0) {
+ log_link_warning(link, "Could not unset DHCPv6 Information request: %s",
+ strerror(-r));
+ goto error;
+ }
- r = sd_dhcp6_client_set_information_request(link->dhcp6_client,
- false);
- if (r < 0) {
- log_link_warning(link, "Could not unset DHCPv6 Information request: %s",
- strerror(-r));
- link->dhcp6_client =
- sd_dhcp6_client_unref(link->dhcp6_client);
- return r;
}
r = sd_dhcp6_client_start(link->dhcp6_client);
- if (r < 0) {
- log_link_warning(link, "Could not restart DHCPv6 after enabling Information request: %s",
- strerror(-r));
- link->dhcp6_client =
- sd_dhcp6_client_unref(link->dhcp6_client);
- return r;
+ if (r < 0 && r != -EALREADY) {
+ log_link_warning(link, "Could not restart DHCPv6: %s",
+ strerror(-r));
+ goto error;
}
+ if (r == -EALREADY)
+ link->dhcp6_configured = true;
+
return r;
}
r = sd_dhcp6_client_new(&link->dhcp6_client);
if (r < 0)
- return r;
+ goto error;
r = sd_dhcp6_client_attach_event(link->dhcp6_client, NULL, 0);
- if (r < 0) {
- link->dhcp6_client = sd_dhcp6_client_unref(link->dhcp6_client);
- return r;
- }
+ if (r < 0)
+ goto error;
r = sd_dhcp6_client_set_mac(link->dhcp6_client,
(const uint8_t *) &link->mac,
sizeof (link->mac), ARPHRD_ETHER);
- if (r < 0) {
- link->dhcp6_client = sd_dhcp6_client_unref(link->dhcp6_client);
- return r;
- }
+ if (r < 0)
+ goto error;
r = sd_dhcp6_client_set_index(link->dhcp6_client, link->ifindex);
- if (r < 0) {
- link->dhcp6_client = sd_dhcp6_client_unref(link->dhcp6_client);
- return r;
- }
+ if (r < 0)
+ goto error;
r = sd_dhcp6_client_set_callback(link->dhcp6_client, dhcp6_handler,
link);
- if (r < 0) {
- link->dhcp6_client = sd_dhcp6_client_unref(link->dhcp6_client);
- return r;
- }
+ if (r < 0)
+ goto error;
if (event == SD_ICMP6_ND_EVENT_ROUTER_ADVERTISMENT_OTHER) {
r = sd_dhcp6_client_set_information_request(link->dhcp6_client,
true);
- if (r < 0) {
- link->dhcp6_client =
- sd_dhcp6_client_unref(link->dhcp6_client);
- return r;
- }
+ if (r < 0)
+ goto error;
}
r = sd_dhcp6_client_start(link->dhcp6_client);
if (r < 0)
- link->dhcp6_client = sd_dhcp6_client_unref(link->dhcp6_client);
+ goto error;
+
+ return r;
+ error:
+ link->dhcp6_client = sd_dhcp6_client_unref(link->dhcp6_client);
return r;
}
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 05a1358eca..5dd14b1104 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -504,6 +504,9 @@ void link_client_handler(Link *link) {
if (link_dhcp4_enabled(link) && !link->dhcp4_configured)
return;
+ if (link_dhcp6_enabled(link) && !link->dhcp6_configured)
+ return;
+
if (link->state != LINK_STATE_CONFIGURED)
link_enter_configured(link);
diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h
index f588faf209..7b219c6854 100644
--- a/src/network/networkd-link.h
+++ b/src/network/networkd-link.h
@@ -91,6 +91,7 @@ struct Link {
uint16_t original_mtu;
unsigned dhcp4_messages;
bool dhcp4_configured;
+ bool dhcp6_configured;
sd_ipv4ll *ipv4ll;
bool ipv4ll_address;