return mfree(address);
}
+static bool address_lifetime_is_valid(const Address *a) {
+ assert(a);
+
+ return
+ a->lifetime_valid_usec == USEC_INFINITY ||
+ a->lifetime_valid_usec > now(CLOCK_BOOTTIME);
+}
+
bool address_is_ready(const Address *a) {
assert(a);
if (!FLAGS_SET(a->state, NETWORK_CONFIG_STATE_CONFIGURED))
return false;
- return true;
+ return address_lifetime_is_valid(a);
}
bool link_check_addresses_ready(Link *link, NetworkConfigSource source) {
if (manager_get_address(manager, family, address, 0, &a) < 0)
return false;
- return check_ready ? address_is_ready(a) : address_exists(a);
+ return check_ready ? address_is_ready(a) : (address_exists(a) && address_lifetime_is_valid(a));
}
const char* format_lifetime(char *buf, size_t l, usec_t lifetime_usec) {
return cached;
}
+static bool route_lifetime_is_valid(const Route *route) {
+ assert(route);
+
+ return
+ route->lifetime_usec == USEC_INFINITY ||
+ route->lifetime_usec > now(CLOCK_BOOTTIME);
+}
+
static Route *link_find_default_gateway(Link *link, int family, Route *gw) {
Route *route;
SET_FOREACH(route, link->routes) {
if (!route_exists(route))
continue;
+ if (!route_lifetime_is_valid(route))
+ continue;
if (route->family != family)
continue;
if (!in_addr_is_set(route->family, &route->dst) && route->dst_prefixlen == 0)
if (!route_exists(route))
continue;
+ if (!route_lifetime_is_valid(route))
+ continue;
+
if (route->type != RTN_UNICAST)
continue;