summaryrefslogtreecommitdiffstats
path: root/src/network/networkd-dhcp6.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-11-01 02:35:43 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-11-01 10:22:55 +0100
commitc30f9aafedcb6d515631341a30997b3e5123c0a8 (patch)
tree54a00c23c9684fd31f6506d9d649ced6b199fd03 /src/network/networkd-dhcp6.c
parentsd-dhcp6-client: introduce sd_dhcp6_lease_get_server_address() (diff)
downloadsystemd-c30f9aafedcb6d515631341a30997b3e5123c0a8.tar.xz
systemd-c30f9aafedcb6d515631341a30997b3e5123c0a8.zip
network: save server address to DHCPv6 addresses
The server address will be used in later commits.
Diffstat (limited to 'src/network/networkd-dhcp6.c')
-rw-r--r--src/network/networkd-dhcp6.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c
index 3cc457a02d..170cf7d57d 100644
--- a/src/network/networkd-dhcp6.c
+++ b/src/network/networkd-dhcp6.c
@@ -1129,6 +1129,7 @@ simple_log:
static int dhcp6_request_address(
Link *link,
+ const struct in6_addr *server_address,
const struct in6_addr *ip6_addr,
usec_t lifetime_preferred_usec,
usec_t lifetime_valid_usec) {
@@ -1142,6 +1143,7 @@ static int dhcp6_request_address(
return log_oom();
addr->source = NETWORK_CONFIG_SOURCE_DHCP6;
+ addr->provider.in6 = *server_address;
addr->family = AF_INET6;
addr->in_addr.in6 = *ip6_addr;
addr->flags = IFA_F_NOPREFIXROUTE;
@@ -1169,6 +1171,7 @@ static int dhcp6_request_address(
}
static int dhcp6_address_acquired(Link *link) {
+ struct in6_addr server_address;
usec_t timestamp_usec;
int r;
@@ -1179,6 +1182,10 @@ static int dhcp6_address_acquired(Link *link) {
if (!link->network->dhcp6_use_address)
return 0;
+ r = sd_dhcp6_lease_get_server_address(link->dhcp6_lease, &server_address);
+ if (r < 0)
+ return log_link_warning_errno(link, r, "Failed to get server address of DHCPv6 lease: %m");
+
r = sd_dhcp6_lease_get_timestamp(link->dhcp6_lease, clock_boottime_or_monotonic(), &timestamp_usec);
if (r < 0)
return log_link_warning_errno(link, r, "Failed to get timestamp of DHCPv6 lease: %m");
@@ -1191,7 +1198,7 @@ static int dhcp6_address_acquired(Link *link) {
if (r < 0)
break;
- r = dhcp6_request_address(link, &ip6_addr,
+ r = dhcp6_request_address(link, &server_address, &ip6_addr,
usec_add(lifetime_preferred_sec * USEC_PER_SEC, timestamp_usec),
usec_add(lifetime_valid_sec * USEC_PER_SEC, timestamp_usec));
if (r < 0)