summaryrefslogtreecommitdiffstats
path: root/src/network/networkd-dhcp6.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:40 +0000
commitfc53809803cd2bc2434e312b19a18fa36776da12 (patch)
treeb4b43bd6538f51965ce32856e9c053d0f90919c8 /src/network/networkd-dhcp6.c
parentAdding upstream version 255.5. (diff)
downloadsystemd-fc53809803cd2bc2434e312b19a18fa36776da12.tar.xz
systemd-fc53809803cd2bc2434e312b19a18fa36776da12.zip
Adding upstream version 256.upstream/256
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/network/networkd-dhcp6.c')
-rw-r--r--src/network/networkd-dhcp6.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c
index f499d03..852987b 100644
--- a/src/network/networkd-dhcp6.c
+++ b/src/network/networkd-dhcp6.c
@@ -14,6 +14,7 @@
#include "networkd-dhcp6.h"
#include "networkd-link.h"
#include "networkd-manager.h"
+#include "networkd-ntp.h"
#include "networkd-queue.h"
#include "networkd-route.h"
#include "networkd-state-file.h"
@@ -48,24 +49,21 @@ static DHCP6ClientStartMode link_get_dhcp6_client_start_mode(Link *link) {
static int dhcp6_remove(Link *link, bool only_marked) {
Address *address;
Route *route;
- int k, r = 0;
+ int ret = 0;
assert(link);
+ assert(link->manager);
if (!only_marked)
link->dhcp6_configured = false;
- SET_FOREACH(route, link->routes) {
+ SET_FOREACH(route, link->manager->routes) {
if (route->source != NETWORK_CONFIG_SOURCE_DHCP6)
continue;
if (only_marked && !route_is_marked(route))
continue;
- k = route_remove(route);
- if (k < 0)
- r = k;
-
- route_cancel_request(route, link);
+ RET_GATHER(ret, route_remove_and_cancel(route, link->manager));
}
SET_FOREACH(address, link->addresses) {
@@ -74,12 +72,10 @@ static int dhcp6_remove(Link *link, bool only_marked) {
if (only_marked && !address_is_marked(address))
continue;
- k = address_remove_and_drop(address);
- if (k < 0)
- r = k;
+ RET_GATHER(ret, address_remove_and_cancel(address, link));
}
- return r;
+ return ret;
}
static int dhcp6_address_ready_callback(Address *address) {
@@ -164,8 +160,7 @@ static int verify_dhcp6_address(Link *link, const Address *address) {
} else
log_level = LOG_DEBUG;
- if (address->prefixlen == existing->prefixlen)
- /* Currently, only conflict in prefix length is reported. */
+ if (address_can_update(existing, address))
goto simple_log;
if (existing->source == NETWORK_CONFIG_SOURCE_NDISC)
@@ -197,7 +192,7 @@ static int dhcp6_request_address(
usec_t lifetime_preferred_usec,
usec_t lifetime_valid_usec) {
- _cleanup_(address_freep) Address *addr = NULL;
+ _cleanup_(address_unrefp) Address *addr = NULL;
Address *existing;
int r;
@@ -298,7 +293,7 @@ static int dhcp6_lease_ip_acquired(sd_dhcp6_client *client, Link *link) {
int r;
link_mark_addresses(link, NETWORK_CONFIG_SOURCE_DHCP6);
- link_mark_routes(link, NETWORK_CONFIG_SOURCE_DHCP6);
+ manager_mark_routes(link->manager, NULL, NETWORK_CONFIG_SOURCE_DHCP6);
r = sd_dhcp6_client_get_lease(client, &lease);
if (r < 0)
@@ -358,6 +353,9 @@ static int dhcp6_lease_lost(Link *link) {
assert(link);
assert(link->manager);
+ if (!link->dhcp6_lease)
+ return 0;
+
log_link_info(link, "DHCPv6 lease lost");
if (sd_dhcp6_lease_has_pd_prefix(link->dhcp6_lease))
@@ -636,13 +634,13 @@ static int dhcp6_configure(Link *link) {
return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to set MUD URL: %m");
}
- if (link->network->dhcp6_use_dns) {
+ if (link_get_use_dns(link, NETWORK_CONFIG_SOURCE_DHCP6)) {
r = sd_dhcp6_client_set_request_option(client, SD_DHCP6_OPTION_DNS_SERVER);
if (r < 0)
return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to request DNS servers: %m");
}
- if (link->network->dhcp6_use_domains > 0) {
+ if (link_get_use_domains(link, NETWORK_CONFIG_SOURCE_DHCP6) > 0) {
r = sd_dhcp6_client_set_request_option(client, SD_DHCP6_OPTION_DOMAIN);
if (r < 0)
return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to request domains: %m");
@@ -654,7 +652,7 @@ static int dhcp6_configure(Link *link) {
return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to request captive portal: %m");
}
- if (link->network->dhcp6_use_ntp) {
+ if (link_get_use_ntp(link, NETWORK_CONFIG_SOURCE_DHCP6)) {
r = sd_dhcp6_client_set_request_option(client, SD_DHCP6_OPTION_NTP_SERVER);
if (r < 0)
return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to request NTP servers: %m");
@@ -805,7 +803,7 @@ int link_request_dhcp6_client(Link *link) {
assert(link);
- if (!link_dhcp6_enabled(link) && !link_ipv6_accept_ra_enabled(link))
+ if (!link_dhcp6_enabled(link) && !link_ndisc_enabled(link))
return 0;
if (link->dhcp6_client)
@@ -833,7 +831,7 @@ int link_serialize_dhcp6_client(Link *link, FILE *f) {
if (r >= 0)
fprintf(f, "DHCP6_CLIENT_IAID=0x%x\n", iaid);
- r = sd_dhcp6_client_duid_as_string(link->dhcp6_client, &duid);
+ r = sd_dhcp6_client_get_duid_as_string(link->dhcp6_client, &duid);
if (r >= 0)
fprintf(f, "DHCP6_CLIENT_DUID=%s\n", duid);