]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: save server address to DHCPv6 addresses 21200/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 1 Nov 2021 01:35:43 +0000 (10:35 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 1 Nov 2021 09:22:55 +0000 (18:22 +0900)
The server address will be used in later commits.

src/network/networkd-dhcp6.c

index 3cc457a02d5d5c7296fa86602ea365c350d43800..170cf7d57dbd7ef7b911eabae05e3d310a7ccd68 100644 (file)
@@ -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)