summaryrefslogtreecommitdiffstats
path: root/src/network/networkd-dhcp-prefix-delegation.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/networkd-dhcp-prefix-delegation.c')
-rw-r--r--src/network/networkd-dhcp-prefix-delegation.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/network/networkd-dhcp-prefix-delegation.c b/src/network/networkd-dhcp-prefix-delegation.c
index 89ff59abe0..62f0192bcb 100644
--- a/src/network/networkd-dhcp-prefix-delegation.c
+++ b/src/network/networkd-dhcp-prefix-delegation.c
@@ -871,7 +871,7 @@ static int dhcp4_pd_assign_subnet_prefix(Link *link, Link *uplink) {
return log_link_warning_errno(uplink, r, "Failed to get lifetime of DHCPv4 lease: %m");
assert_se(sd_event_now(uplink->manager->event, CLOCK_BOOTTIME, &now_usec) >= 0);
- lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now_usec);
+ lifetime_usec = sec_to_usec(lifetime_sec, now_usec);
r = sd_dhcp_lease_get_6rd(uplink->dhcp_lease, &ipv4masklen, &sixrd_prefixlen, &sixrd_prefix, &br_addresses, NULL);
if (r < 0)
@@ -945,7 +945,7 @@ int dhcp4_pd_prefix_acquired(Link *uplink) {
return log_link_warning_errno(uplink, r, "Failed to get lifetime of DHCPv4 lease: %m");
assert_se(sd_event_now(uplink->manager->event, CLOCK_BOOTTIME, &now_usec) >= 0);
- lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now_usec);
+ lifetime_usec = sec_to_usec(lifetime_sec, now_usec);
r = sd_dhcp_lease_get_server_identifier(uplink->dhcp_lease, &server_address.in);
if (r < 0)
@@ -1036,7 +1036,6 @@ static int dhcp6_pd_assign_subnet_prefixes(Link *link, Link *uplink) {
for (sd_dhcp6_lease_reset_pd_prefix_iter(uplink->dhcp6_lease);;) {
uint32_t lifetime_preferred_sec, lifetime_valid_sec;
- usec_t lifetime_preferred_usec, lifetime_valid_usec;
struct in6_addr pd_prefix;
uint8_t pd_prefix_len;
@@ -1053,11 +1052,9 @@ static int dhcp6_pd_assign_subnet_prefixes(Link *link, Link *uplink) {
if (r < 0)
return r;
- lifetime_preferred_usec = usec_add(lifetime_preferred_sec * USEC_PER_SEC, timestamp_usec);
- lifetime_valid_usec = usec_add(lifetime_valid_sec * USEC_PER_SEC, timestamp_usec);
-
r = dhcp_pd_assign_subnet_prefix(link, &pd_prefix, pd_prefix_len,
- lifetime_preferred_usec, lifetime_valid_usec,
+ sec_to_usec(lifetime_preferred_sec, timestamp_usec),
+ sec_to_usec(lifetime_valid_sec, timestamp_usec),
/* is_uplink = */ link == uplink);
if (r < 0)
return r;
@@ -1086,7 +1083,6 @@ int dhcp6_pd_prefix_acquired(Link *uplink) {
/* First, logs acquired prefixes and request unreachable routes. */
for (sd_dhcp6_lease_reset_pd_prefix_iter(uplink->dhcp6_lease);;) {
uint32_t lifetime_preferred_sec, lifetime_valid_sec;
- usec_t lifetime_valid_usec;
struct in6_addr pd_prefix;
uint8_t pd_prefix_len;
@@ -1100,13 +1096,13 @@ int dhcp6_pd_prefix_acquired(Link *uplink) {
if (r < 0)
return log_link_error_errno(uplink, r, "Failed to mask DHCPv6 delegated prefix: %m");
- lifetime_valid_usec = usec_add(lifetime_valid_sec * USEC_PER_SEC, timestamp_usec);
-
r = dhcp_pd_prefix_add(uplink, &pd_prefix, pd_prefix_len);
if (r < 0)
return r;
- r = dhcp6_request_unreachable_route(uplink, &pd_prefix, pd_prefix_len, lifetime_valid_usec, &server_address);
+ r = dhcp6_request_unreachable_route(uplink, &pd_prefix, pd_prefix_len,
+ sec_to_usec(lifetime_valid_sec, timestamp_usec),
+ &server_address);
if (r < 0)
return r;
}