diff options
-rw-r--r-- | src/network/networkd-address.c | 18 | ||||
-rw-r--r-- | src/network/networkd-dhcp-prefix-delegation.c | 12 | ||||
-rw-r--r-- | src/network/networkd-dhcp4.c | 5 | ||||
-rw-r--r-- | src/network/networkd-ndisc.c | 9 | ||||
-rw-r--r-- | src/network/networkd-route.c | 5 |
5 files changed, 31 insertions, 18 deletions
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index 8e8d5f7781..7131b0e04c 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -212,13 +212,14 @@ void address_set_broadcast(Address *a, Link *link) { a->broadcast.s_addr = a->in_addr.in.s_addr | htobe32(UINT32_C(0xffffffff) >> a->prefixlen); } -static struct ifa_cacheinfo *address_set_cinfo(const Address *a, struct ifa_cacheinfo *cinfo) { +static struct ifa_cacheinfo *address_set_cinfo(Manager *m, const Address *a, struct ifa_cacheinfo *cinfo) { usec_t now_usec; + assert(m); assert(a); assert(cinfo); - now_usec = now(CLOCK_BOOTTIME); + assert_se(sd_event_now(m->event, CLOCK_BOOTTIME, &now_usec) >= 0); *cinfo = (struct ifa_cacheinfo) { .ifa_valid = MIN(usec_sub_unsigned(a->lifetime_valid_usec, now_usec) / USEC_PER_SEC, UINT32_MAX), @@ -228,13 +229,14 @@ static struct ifa_cacheinfo *address_set_cinfo(const Address *a, struct ifa_cach return cinfo; } -static void address_set_lifetime(Address *a, const struct ifa_cacheinfo *cinfo) { +static void address_set_lifetime(Manager *m, Address *a, const struct ifa_cacheinfo *cinfo) { usec_t now_usec; + assert(m); assert(a); assert(cinfo); - now_usec = now(CLOCK_BOOTTIME); + assert_se(sd_event_now(m->event, CLOCK_BOOTTIME, &now_usec) >= 0); if (cinfo->ifa_valid == UINT32_MAX) a->lifetime_valid_usec = USEC_INFINITY; @@ -1078,7 +1080,7 @@ static int address_configure(const Address *address, Link *link, Request *req) { } r = sd_netlink_message_append_cache_info(m, IFA_CACHEINFO, - address_set_cinfo(address, &(struct ifa_cacheinfo) {})); + address_set_cinfo(link->manager, address, &(struct ifa_cacheinfo) {})); if (r < 0) return r; @@ -1455,18 +1457,18 @@ int manager_rtnl_process_address(sd_netlink *rtnl, sd_netlink_message *message, /* update flags and etc. */ address->flags = tmp->flags; address->scope = tmp->scope; - address_set_lifetime(address, &cinfo); + address_set_lifetime(m, address, &cinfo); address_enter_configured(address); log_address_debug(address, "Received updated", link); } else { - address_set_lifetime(tmp, &cinfo); + address_set_lifetime(m, tmp, &cinfo); address_enter_configured(tmp); log_address_debug(tmp, "Received new", link); r = address_add(link, tmp); if (r < 0) { log_link_warning_errno(link, r, "Failed to remember foreign address %s, ignoring: %m", - IN_ADDR_PREFIX_TO_STRING(tmp->family, &tmp->in_addr, tmp->prefixlen)); + IN_ADDR_PREFIX_TO_STRING(tmp->family, &tmp->in_addr, tmp->prefixlen)); return 0; } diff --git a/src/network/networkd-dhcp-prefix-delegation.c b/src/network/networkd-dhcp-prefix-delegation.c index 5c923c258c..89ff59abe0 100644 --- a/src/network/networkd-dhcp-prefix-delegation.c +++ b/src/network/networkd-dhcp-prefix-delegation.c @@ -854,11 +854,12 @@ static int dhcp4_pd_assign_subnet_prefix(Link *link, Link *uplink) { const struct in_addr *br_addresses; struct in_addr ipv4address; uint32_t lifetime_sec; - usec_t lifetime_usec; + usec_t lifetime_usec, now_usec; int r; assert(link); assert(uplink); + assert(uplink->manager); assert(uplink->dhcp_lease); r = sd_dhcp_lease_get_address(uplink->dhcp_lease, &ipv4address); @@ -869,7 +870,8 @@ static int dhcp4_pd_assign_subnet_prefix(Link *link, Link *uplink) { if (r < 0) return log_link_warning_errno(uplink, r, "Failed to get lifetime of DHCPv4 lease: %m"); - lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now(CLOCK_BOOTTIME)); + assert_se(sd_event_now(uplink->manager->event, CLOCK_BOOTTIME, &now_usec) >= 0); + lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now_usec); r = sd_dhcp_lease_get_6rd(uplink->dhcp_lease, &ipv4masklen, &sixrd_prefixlen, &sixrd_prefix, &br_addresses, NULL); if (r < 0) @@ -926,11 +928,12 @@ int dhcp4_pd_prefix_acquired(Link *uplink) { union in_addr_union server_address; const struct in_addr *br_addresses; uint32_t lifetime_sec; - usec_t lifetime_usec; + usec_t lifetime_usec, now_usec; Link *link; int r; assert(uplink); + assert(uplink->manager); assert(uplink->dhcp_lease); r = sd_dhcp_lease_get_address(uplink->dhcp_lease, &ipv4address); @@ -941,7 +944,8 @@ int dhcp4_pd_prefix_acquired(Link *uplink) { if (r < 0) return log_link_warning_errno(uplink, r, "Failed to get lifetime of DHCPv4 lease: %m"); - lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now(CLOCK_BOOTTIME)); + assert_se(sd_event_now(uplink->manager->event, CLOCK_BOOTTIME, &now_usec) >= 0); + lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now_usec); r = sd_dhcp_lease_get_server_identifier(uplink->dhcp_lease, &server_address.in); if (r < 0) diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index 5770b48767..86d167e628 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -797,6 +797,7 @@ static int dhcp4_request_address(Link *link, bool announce) { int r; assert(link); + assert(link->manager); assert(link->network); assert(link->dhcp_lease); @@ -814,12 +815,14 @@ static int dhcp4_request_address(Link *link, bool announce) { if (!FLAGS_SET(link->network->keep_configuration, KEEP_CONFIGURATION_DHCP)) { uint32_t lifetime_sec; + usec_t now_usec; r = sd_dhcp_lease_get_lifetime(link->dhcp_lease, &lifetime_sec); if (r < 0) return log_link_warning_errno(link, r, "DHCP error: no lifetime: %m"); - lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now(CLOCK_BOOTTIME)); + assert_se(sd_event_now(link->manager->event, CLOCK_BOOTTIME, &now_usec) >= 0); + lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now_usec); } else lifetime_usec = USEC_INFINITY; diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index f66745a4ff..b76b9608f3 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -1145,20 +1145,21 @@ int link_request_ndisc(Link *link) { void ndisc_vacuum(Link *link) { NDiscRDNSS *r; NDiscDNSSL *d; - usec_t time_now; + usec_t now_usec; assert(link); + assert(link->manager); /* Removes all RDNSS and DNSSL entries whose validity time has passed */ - time_now = now(CLOCK_BOOTTIME); + assert_se(sd_event_now(link->manager->event, CLOCK_BOOTTIME, &now_usec) >= 0); SET_FOREACH(r, link->ndisc_rdnss) - if (r->lifetime_usec < time_now) + if (r->lifetime_usec < now_usec) free(set_remove(link->ndisc_rdnss, r)); SET_FOREACH(d, link->ndisc_dnssl) - if (d->lifetime_usec < time_now) + if (d->lifetime_usec < now_usec) free(set_remove(link->ndisc_dnssl, d)); } diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 2708f9d79d..adc4660cfd 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -1180,8 +1180,11 @@ static int route_configure(const Route *route, Link *link, Request *req) { return r; if (route->lifetime_usec != USEC_INFINITY) { + usec_t now_usec; + + assert_se(sd_event_now(link->manager->event, CLOCK_BOOTTIME, &now_usec) >= 0); r = sd_netlink_message_append_u32(m, RTA_EXPIRES, - MIN(DIV_ROUND_UP(usec_sub_unsigned(route->lifetime_usec, now(CLOCK_BOOTTIME)), USEC_PER_SEC), UINT32_MAX)); + MIN(DIV_ROUND_UP(usec_sub_unsigned(route->lifetime_usec, now_usec), USEC_PER_SEC), UINT32_MAX)); if (r < 0) return r; } |